@mparticle/web-optimizely-kit 2.1.3 → 2.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,7 +44,7 @@ var helpers = {
44
44
  userId = userIdentities['email'];
45
45
  break;
46
46
  case 'mpid':
47
- userId = userIdentities['mpid'];
47
+ userId = window.mParticle.Identity.getCurrentUser().getMPID();
48
48
  break;
49
49
  case 'other':
50
50
  userId = userIdentities['other'];
@@ -340,6 +340,10 @@ IdentityHandler.prototype.onSetUserIdentity = function(
340
340
 
341
341
  var identityHandler = IdentityHandler;
342
342
 
343
+ var optimizelyFsSdkUrl = 'https://unpkg.com/@optimizely/optimizely-sdk@3.5.0/dist/optimizely.browser.umd.min.js',
344
+ dataFilePrefix = 'https://cdn.optimizely.com/datafiles/',
345
+ dataFileURLending = '.json/tag.js';
346
+
343
347
  var initialization = {
344
348
  name: 'Optimizely',
345
349
  moduleId: 54,
@@ -388,10 +392,20 @@ var initialization = {
388
392
  });
389
393
  };
390
394
 
391
- helpers_1.loadScript('https://unpkg.com/@optimizely/optimizely-sdk/dist/optimizely.browser.umd.min.js',
392
- helpers_1.loadScript('https://cdn.optimizely.com/datafiles/' + settings.projectId + '.json/tag.js', instantiateFSClient));
395
+ helpers_1.loadScript(optimizelyFsSdkUrl,
396
+ function() {
397
+ helpers_1.loadScript(
398
+ dataFilePrefix +
399
+ settings.projectId +
400
+ dataFileURLending,
401
+ instantiateFSClient
402
+ );
403
+ }
404
+ );
393
405
 
394
406
  } else {
407
+ common.userIdField = settings.userIdField;
408
+ common.userAttributes = userAttributes;
395
409
  loadFullStackEvents();
396
410
  }
397
411
  } else {
@@ -555,7 +569,10 @@ var constructor = function() {
555
569
  ) {
556
570
  forwarderSettings = settings;
557
571
 
558
- if (window.mParticle.isTestEnvironment) {
572
+ if (
573
+ typeof window !== 'undefined' &&
574
+ window.mParticle.isTestEnvironment
575
+ ) {
559
576
  reportingService = function() {};
560
577
  } else {
561
578
  reportingService = service;
@@ -971,14 +988,14 @@ function isObject(val) {
971
988
 
972
989
  function register(config) {
973
990
  if (!config) {
974
- window.console.log(
991
+ console.log(
975
992
  'You must pass a config object to register the kit ' + name
976
993
  );
977
994
  return;
978
995
  }
979
996
 
980
997
  if (!isObject(config)) {
981
- window.console.log(
998
+ console.log(
982
999
  "'config' must be an object. You passed in a " + typeof config
983
1000
  );
984
1001
  return;
@@ -994,17 +1011,19 @@ function register(config) {
994
1011
  constructor: constructor,
995
1012
  };
996
1013
  }
997
- window.console.log(
1014
+ console.log(
998
1015
  'Successfully registered ' + name + ' to your mParticle configuration'
999
1016
  );
1000
1017
  }
1001
1018
 
1002
- if (window && window.mParticle && window.mParticle.addForwarder) {
1003
- window.mParticle.addForwarder({
1004
- name: name,
1005
- constructor: constructor,
1006
- getId: getId,
1007
- });
1019
+ if (typeof window !== 'undefined') {
1020
+ if (window && window.mParticle && window.mParticle.addForwarder) {
1021
+ window.mParticle.addForwarder({
1022
+ name: name,
1023
+ constructor: constructor,
1024
+ getId: getId,
1025
+ });
1026
+ }
1008
1027
  }
1009
1028
 
1010
1029
  var webKitWrapper = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-optimizely-kit",
3
- "version": "2.1.3",
3
+ "version": "2.1.6",
4
4
  "author": "mParticle Developers <developers@mparticle.com> (https://www.mparticle.com)",
5
5
  "description": "mParticle integration sdk for Optimizely",
6
6
  "main": "dist/OptimizelyKit.common.js",