-
Notifications
You must be signed in to change notification settings - Fork 54
Add experiments allocation function to RoktManager #1029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Add experiments allocation function to RoktManager #1029
Conversation
src/roktManager.ts
Outdated
if (this.experimentAllocation) { | ||
options.attributes['rokt.experimentid'] = this.experimentAllocation.experimentId; | ||
options.attributes['rokt.bucketid'] = this.experimentAllocation.bucketId; | ||
options.attributes['rokt.userid'] = this.experimentAllocation.userId; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should put this in the try/catch block below. The queuing logic should be the first thing in this function because it runs before the rokt web sdk and kit initialize.
33e1016
to
7e2dc18
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds the experiment allocation functionality to the RoktManager, enabling clients to pass experiment allocation data to the Rokt Kit during placement selection.
- Introduces the IRoktExperimentAllocation interface.
- Adds the experimentAllocation property and updates selectPlacements to include experiment allocation attributes if available.
- Implements the setExperimentAllocationData function for setting experiment allocation data.
throw new Error('Error setting extension data: ' + errorMessage); | ||
} | ||
} | ||
|
Copilot
AI
May 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider adding a JSDoc comment above setExperimentAllocationData to clarify its purpose, input parameters, and usage.
/** | |
* Sets the experiment allocation data for a user. | |
* | |
* @param {string} userId - The unique identifier for the user. | |
* @param {string} experimentId - The unique identifier for the experiment. | |
* @param {string} bucketId - The unique identifier for the bucket within the experiment. | |
* | |
* This method stores the provided experiment allocation data in the `experimentAllocation` object. | |
*/ |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another useful suggestion and something we should be doing more often. Not a blocker.
src/roktManager.ts
Outdated
mappedAttributes['rokt.experimentid'] = this.experimentAllocation.experimentId; | ||
mappedAttributes['rokt.bucketid'] = this.experimentAllocation.bucketId; | ||
mappedAttributes['rokt.userid'] = this.experimentAllocation.userId; |
Copilot
AI
May 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider extracting the hard-coded attribute keys ('rokt.experimentid', 'rokt.bucketid', 'rokt.userid') to constants to improve maintainability and reduce potential typos.
mappedAttributes['rokt.experimentid'] = this.experimentAllocation.experimentId; | |
mappedAttributes['rokt.bucketid'] = this.experimentAllocation.bucketId; | |
mappedAttributes['rokt.userid'] = this.experimentAllocation.userId; | |
mappedAttributes[ROKT_EXPERIMENT_ID] = this.experimentAllocation.experimentId; | |
mappedAttributes[ROKT_BUCKET_ID] = this.experimentAllocation.bucketId; | |
mappedAttributes[ROKT_USER_ID] = this.experimentAllocation.userId; |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a useful suggestion but not a blocker.
private placementAttributesMapping: Dictionary<string>[] = []; | ||
|
||
private experimentAllocation: IRoktExperimentAllocation | null = null; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Summary
setExperimentAllocationData
to the RoktManager for clients to save experiment allocation dataTesting Plan
Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)