analytics.js-integrations icon indicating copy to clipboard operation
analytics.js-integrations copied to clipboard

feat (Optimizely): Support passing a specific clientInstance to track

Open jamesopti opened this issue 5 years ago • 3 comments

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 avatar May 28 '20 22:05 jamesopti

@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?

Danny-Driscoll avatar May 29 '20 02:05 Danny-Driscoll

@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!

jamesopti avatar May 29 '20 18:05 jamesopti

This looks good form my end. Thanks, @jamesopti!

circAssimilate avatar Jun 01 '20 17:06 circAssimilate