analytics.js-integrations
analytics.js-integrations copied to clipboard
feat (Optimizely): Support passing a specific clientInstance to track
What does this PR do?
Adds an additional parameter to users of this integration, enabling them to specify which instance the JS SDK to use as part of a track call.
This provides an alternative to step #4 on the Optimizely Full Stack Javascript-SDK setup instructions. Instead of specifying a single window.optimizelyClientInstance, one can be passed as part of the track call (see example below).
Example Usage:
// Instantiate an Optimizely client
var FullStackClientInstance = optimizely.createInstance({ datafile });
...
analytics.track('my_event', {}, {
Optimizely: {
FullStackClientInstance,
}
})
Are there breaking changes in this PR?
No - Without this option, the code still uses window.optimizelyClientInstance
Any background context you want to provide?
Heavy users of our product may instantiate multiple client instances in the same global scope of the browser (window). Today, this integration only supports a single client instance.
With this PR, all callers of .track can specify which client instance they want to use for tracking.
Is there parity with the server-side/android/iOS integration components (if applicable)? N/A
Does this require a new integration setting? If so, please explain how the new setting works No
Links to helpful docs and other external resources
@jamesopti only thing I might change is adding something to clarify that the option is specific to the Full Stack client instance in the name. We're not introducing it here, but generally the ambiguity between web and full stack functionality is already tough to parse and keep track of. i.e. FSclientInstance potentially?
@jamesopti only thing I might change is adding something to clarify that the option is specific to the Full Stack client instance in the name. We're not introducing it here, but generally the ambiguity between web and full stack functionality is already tough to parse and keep track of. i.e. FSclientInstance potentially?
I think thats good feedback. Updated!
This looks good form my end. Thanks, @jamesopti!