@mparticle/web-optimizely-kit 2.1.1 → 2.1.4
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.
- package/CHANGELOG.md +18 -0
- package/README.md +32 -3
- package/dist/OptimizelyKit.common.js +37 -18
- package/package.json +2 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
## Releases
|
|
2
|
+
|
|
3
|
+
--
|
|
4
|
+
|
|
5
|
+
#### 2.1.4 - 2022-03-31
|
|
6
|
+
* fix - update datafile loading callback
|
|
7
|
+
|
|
8
|
+
#### 2.1.3 - 202108-09
|
|
9
|
+
* fix - correct casing for customerid
|
|
10
|
+
|
|
11
|
+
#### 2.1.2 - 2020-09-02
|
|
12
|
+
* fix - remove other instances of settings.useFullStack
|
|
13
|
+
|
|
14
|
+
#### 2.1.1 - 2020-09-01
|
|
15
|
+
* fix - turn useFullStack into a boolean on common module
|
|
16
|
+
|
|
17
|
+
#### 2.1.0 - 2020-08-26
|
|
18
|
+
* feat - implement Optimizely Full Stack
|
package/README.md
CHANGED
|
@@ -1,9 +1,38 @@
|
|
|
1
|
-
# integration-optimizely
|
|
2
|
-
|
|
1
|
+
# integration-optimizely
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This integration contains code that maps to both [Optimizely Web](https://docs.developers.optimizely.com/web/docs/introduction/) and [Optimizely Full Stack](https://docs.developers.optimizely.com/full-stack/docs/javascript-sdk). Depending on your use case, the kit is flexible enough so that you can either use 1 of these products in isolation or both at the same time. To use both concurrently, simply add 2 Optimizely connections in the [mParticle UI](https://app.mparticle.com), and check `Use Full Stack` in one of them.
|
|
6
|
+
|
|
7
|
+
## Documentation
|
|
8
|
+
|
|
9
|
+
Please view the [Optimizely Integration docs](https://docs.mparticle.com/integrations/optimizely/event/) for full set up instructions.
|
|
10
|
+
|
|
11
|
+
### Development Notes
|
|
12
|
+
|
|
13
|
+
Normally, mParticle kit code maps mParticle events to a single product/SDK. However, as mentioned above, this mParticle Optimizely kit enables mapping an mParticle event to 2 Optimizely products/SDKs. As such, all mapping code must follow 2 different code paths. In each module under `src/`, you'll find that code is split between products with code that looks something like the following:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
if (window.optimizely && !common.useFullStack`) {
|
|
17
|
+
// Perform mapping for Optimizely Web
|
|
18
|
+
// window.optimizely checks for existence of Optimizely Web's API
|
|
19
|
+
// common.useFullStack is an explicit check for if the connection is for Full Stack
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// OR
|
|
23
|
+
|
|
24
|
+
if (window.optimizelyClientInstance && this.common.useFullStack) {
|
|
25
|
+
// Perform mapping for Optimizely Full Stack
|
|
26
|
+
// window.optimizelyClientInstance checks for existence of Optimizely Full Stack's API
|
|
27
|
+
// common.useFullStack is an explicit check for if the connection is for Full Stack
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
When updating this kit, be sure to follow the correct code paths where appropriate.
|
|
3
32
|
|
|
4
33
|
# License
|
|
5
34
|
|
|
6
|
-
Copyright
|
|
35
|
+
Copyright 2020 mParticle, Inc.
|
|
7
36
|
|
|
8
37
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
38
|
you may not use this file except in compliance with the License.
|
|
@@ -35,8 +35,10 @@ var helpers = {
|
|
|
35
35
|
var userIdentities = identities['userIdentities'];
|
|
36
36
|
var userId;
|
|
37
37
|
switch(userIdField) {
|
|
38
|
+
// The server returns `customerId` as part of the `userIdField` setting
|
|
39
|
+
// but the API for identity requies it to be cased as `customerid`
|
|
38
40
|
case 'customerId':
|
|
39
|
-
userId = userIdentities['
|
|
41
|
+
userId = userIdentities['customerid'];
|
|
40
42
|
break;
|
|
41
43
|
case 'email':
|
|
42
44
|
userId = userIdentities['email'];
|
|
@@ -338,14 +340,18 @@ IdentityHandler.prototype.onSetUserIdentity = function(
|
|
|
338
340
|
|
|
339
341
|
var identityHandler = IdentityHandler;
|
|
340
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
|
+
|
|
341
347
|
var initialization = {
|
|
342
348
|
name: 'Optimizely',
|
|
343
349
|
moduleId: 54,
|
|
344
350
|
initForwarder: function(settings, testMode, userAttributes, userIdentities, processEvent, eventQueue, isInitialized, common, appVersion, appName, customFlags, clientId) {
|
|
345
|
-
common.useFullStack = settings.useFullStack;
|
|
351
|
+
common.useFullStack = settings.useFullStack === 'True';
|
|
346
352
|
|
|
347
353
|
if (!testMode) {
|
|
348
|
-
if (!window.optimizely && !
|
|
354
|
+
if (!window.optimizely && !common.useFullStack) {
|
|
349
355
|
var optimizelyScript = document.createElement('script');
|
|
350
356
|
optimizelyScript.type = 'text/javascript';
|
|
351
357
|
optimizelyScript.async = true;
|
|
@@ -366,7 +372,7 @@ var initialization = {
|
|
|
366
372
|
loadWebXEventsAndPages();
|
|
367
373
|
}
|
|
368
374
|
|
|
369
|
-
if (!window.optimizelyClientInstance &&
|
|
375
|
+
if (!window.optimizelyClientInstance && common.useFullStack) {
|
|
370
376
|
common.userIdField = settings.userIdField;
|
|
371
377
|
common.userAttributes = userAttributes;
|
|
372
378
|
var errorHandler = function() {};
|
|
@@ -386,17 +392,25 @@ var initialization = {
|
|
|
386
392
|
});
|
|
387
393
|
};
|
|
388
394
|
|
|
389
|
-
helpers_1.loadScript(
|
|
390
|
-
|
|
395
|
+
helpers_1.loadScript(optimizelyFsSdkUrl,
|
|
396
|
+
function() {
|
|
397
|
+
helpers_1.loadScript(
|
|
398
|
+
dataFilePrefix +
|
|
399
|
+
settings.projectId +
|
|
400
|
+
dataFileURLending,
|
|
401
|
+
instantiateFSClient
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
);
|
|
391
405
|
|
|
392
406
|
} else {
|
|
393
407
|
loadFullStackEvents();
|
|
394
408
|
}
|
|
395
409
|
} else {
|
|
396
|
-
if (!
|
|
410
|
+
if (!common.useFullStack) {
|
|
397
411
|
loadWebXEventsAndPages();
|
|
398
412
|
}
|
|
399
|
-
if (
|
|
413
|
+
if (common.useFullStack) {
|
|
400
414
|
common.userIdField = settings.userIdField;
|
|
401
415
|
common.userAttributes = userAttributes;
|
|
402
416
|
loadFullStackEvents();
|
|
@@ -553,7 +567,10 @@ var constructor = function() {
|
|
|
553
567
|
) {
|
|
554
568
|
forwarderSettings = settings;
|
|
555
569
|
|
|
556
|
-
if (
|
|
570
|
+
if (
|
|
571
|
+
typeof window !== 'undefined' &&
|
|
572
|
+
window.mParticle.isTestEnvironment
|
|
573
|
+
) {
|
|
557
574
|
reportingService = function() {};
|
|
558
575
|
} else {
|
|
559
576
|
reportingService = service;
|
|
@@ -969,14 +986,14 @@ function isObject(val) {
|
|
|
969
986
|
|
|
970
987
|
function register(config) {
|
|
971
988
|
if (!config) {
|
|
972
|
-
|
|
989
|
+
console.log(
|
|
973
990
|
'You must pass a config object to register the kit ' + name
|
|
974
991
|
);
|
|
975
992
|
return;
|
|
976
993
|
}
|
|
977
994
|
|
|
978
995
|
if (!isObject(config)) {
|
|
979
|
-
|
|
996
|
+
console.log(
|
|
980
997
|
"'config' must be an object. You passed in a " + typeof config
|
|
981
998
|
);
|
|
982
999
|
return;
|
|
@@ -992,17 +1009,19 @@ function register(config) {
|
|
|
992
1009
|
constructor: constructor,
|
|
993
1010
|
};
|
|
994
1011
|
}
|
|
995
|
-
|
|
1012
|
+
console.log(
|
|
996
1013
|
'Successfully registered ' + name + ' to your mParticle configuration'
|
|
997
1014
|
);
|
|
998
1015
|
}
|
|
999
1016
|
|
|
1000
|
-
if (
|
|
1001
|
-
window.mParticle.addForwarder
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1017
|
+
if (typeof window !== 'undefined') {
|
|
1018
|
+
if (window && window.mParticle && window.mParticle.addForwarder) {
|
|
1019
|
+
window.mParticle.addForwarder({
|
|
1020
|
+
name: name,
|
|
1021
|
+
constructor: constructor,
|
|
1022
|
+
getId: getId,
|
|
1023
|
+
});
|
|
1024
|
+
}
|
|
1006
1025
|
}
|
|
1007
1026
|
|
|
1008
1027
|
var webKitWrapper = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mparticle/web-optimizely-kit",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
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",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"watch": "ENVIRONMENT=production rollup --config rollup.config.js -w"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@mparticle/web-kit-wrapper": "^1.0.
|
|
19
|
+
"@mparticle/web-kit-wrapper": "^1.0.5",
|
|
20
20
|
"chai": "^4.2.0",
|
|
21
21
|
"karma": "^3.1.1",
|
|
22
22
|
"karma-chai": "^0.1.0",
|