chore: Refactor to reduce the importance of Config#89
Merged
Conversation
- Change calculateVariant signature to accept options object with visitor, splitRegistry, and splitName - Remove getSplit helper function (inline the logic) - Update visitor.ts to pass splitRegistry explicitly - Update calculateVariant tests to use new signature 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add splitRegistry to Options type - Update getABVariants to use splitRegistry parameter instead of visitor.config.splitRegistry - Update visitor.ts ab() method to pass splitRegistry explicitly - Update abConfiguration tests to pass splitRegistry 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add splitRegistry to Options type - Update validateVariants to accept splitRegistry parameter - Update vary to use splitRegistry parameter instead of visitor.config.splitRegistry - Update visitor.ts vary() method to pass splitRegistry explicitly - Update vary tests to pass splitRegistry 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add config to Options type - Update persistAssignment to accept config parameter - Update sendAssignmentNotification to use config parameter instead of visitor.config - Update visitor.ts _notify() method to pass config explicitly - Update assignmentNotification tests to pass config 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add config to Options type - Update persistAssignmentOverride to use config parameter instead of visitor.config - Update session.ts call site to pass config explicitly - Update assignmentOverride tests to pass config 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Update calculateVariant expectations to use new object parameter syntax - Update sendAssignmentNotification expectations to include config parameter - Update persistAssignmentOverride expectation to include config parameter - Use shorthand property syntax in test expectations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
052ef78 to
d979324
Compare
b11de05 to
e0216b6
Compare
9b017c0 to
f946c44
Compare
samandmoore
approved these changes
Jan 9, 2026
samandmoore
left a comment
Member
There was a problem hiding this comment.
domainlgtm platformlgtm
(reviewed live)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Config
Currently,
Configis a grab bag of a bunch of unrelated things, and we pass it everywhere.In this PR, my primary motivation is to split the config into multiple objects, each of which has responsibility. The
loadConfigfunction does not perform any type coersion. It just parseswindow.TTand returns the raw data.Client
Uses the configured
urlto perform HTTP requests against the API. This object has functions likegetVisitor(). These functions are intended to be pretty low-level and should not contain any business logic.Storage
StorageProviderdefines an interface for storing the visitorId.Currently, the only storage adapter is
createCookieStorage(). This storage adapter accepts a cookie name and domain to store the visitor ID in a cookie.In the future, we could allow clients to configure other storage adapters (e.g. localStorage or AsyncStorage in React Native).
SplitRegistry and Assignments
No real changes here, but we're passing these around instead of passing
Config.Visitor
Previously, we were passing around
Visitorto a bunch of functions, mostly so they could accesslogErrorand thesplitRegistry. The Visitor has a very complex setup, and passing simpler arguments makes testing much easier.Misc
Code consolidation:
mixpanelAnalytics.tsintoanalyticsProvider.tssplit.tsintosplitRegistry.tsapi.tstoclient/request.tsRenames:
getABVariants()→getFalseVariant()(returns just the false variant now, not both)Assignment.fromJsonArray()→Assignment.fromV1Assignment()(handles single item, not array)Test improvements:
visitor.logErrordirectly; now usesvisitor.setErrorLogger()