-
Notifications
You must be signed in to change notification settings - Fork 55
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -56,6 +56,12 @@ export interface IRoktManagerOptions { | |||||||||||||||||||||||
| sandbox?: boolean; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| export interface IRoktExperimentAllocation { | ||||||||||||||||||||||||
| userId: string; | ||||||||||||||||||||||||
| experimentId: string; | ||||||||||||||||||||||||
| bucketId: string; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // The purpose of this class is to create a link between the Core mParticle SDK and the | ||||||||||||||||||||||||
| // Rokt Web SDK via a Web Kit. | ||||||||||||||||||||||||
| // The Rokt Manager should load before the Web Kit and stubs out many of the | ||||||||||||||||||||||||
|
|
@@ -72,9 +78,12 @@ export default class RoktManager { | |||||||||||||||||||||||
| private currentUser: IMParticleUser | null = null; | ||||||||||||||||||||||||
| private filteredUser: IMParticleUser | null = null; | ||||||||||||||||||||||||
| private messageQueue: IRoktMessage[] = []; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| private sandbox: boolean | null = null; | ||||||||||||||||||||||||
| private placementAttributesMapping: Dictionary<string>[] = []; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| private experimentAllocation: IRoktExperimentAllocation | null = null; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||
| * Initializes the RoktManager with configuration settings and user data. | ||||||||||||||||||||||||
| * | ||||||||||||||||||||||||
|
|
@@ -112,6 +121,7 @@ export default class RoktManager { | |||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public selectPlacements(options: IRoktSelectPlacementsOptions): Promise<IRoktSelection> { | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (!this.isReady()) { | ||||||||||||||||||||||||
| this.queueMessage({ | ||||||||||||||||||||||||
| methodName: 'selectPlacements', | ||||||||||||||||||||||||
|
|
@@ -127,6 +137,12 @@ export default class RoktManager { | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| this.setUserAttributes(mappedAttributes); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (this.experimentAllocation) { | ||||||||||||||||||||||||
| mappedAttributes['rokt.partnerexperiment.experimentid'] = this.experimentAllocation.experimentId; | ||||||||||||||||||||||||
| mappedAttributes['rokt.partnerexperiment.bucketid'] = this.experimentAllocation.bucketId; | ||||||||||||||||||||||||
| mappedAttributes['rokt.partnerexperiment.userid'] = this.experimentAllocation.userId; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const enrichedAttributes = { | ||||||||||||||||||||||||
| ...mappedAttributes, | ||||||||||||||||||||||||
| ...(sandboxValue !== null ? { sandbox: sandboxValue } : {}), | ||||||||||||||||||||||||
|
|
@@ -176,6 +192,15 @@ export default class RoktManager { | |||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
| /** | |
| * 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. | |
| */ |
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.
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.