@mparticle/web-rokt-kit 1.0.0 → 1.2.0
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/dist/Rokt-Kit.common.js +60 -3
- package/dist/Rokt-Kit.iife.js +60 -3
- package/package.json +3 -1
package/dist/Rokt-Kit.common.js
CHANGED
|
@@ -28,6 +28,7 @@ var constructor = function () {
|
|
|
28
28
|
self.name = name;
|
|
29
29
|
self.moduleId = moduleId;
|
|
30
30
|
self.isInitialized = false;
|
|
31
|
+
|
|
31
32
|
self.launcher = null;
|
|
32
33
|
self.filters = {};
|
|
33
34
|
self.filteredUser = {};
|
|
@@ -43,6 +44,7 @@ var constructor = function () {
|
|
|
43
44
|
var accountId = settings.accountId;
|
|
44
45
|
var sandboxMode = window.mParticle.getEnvironment() === 'development';
|
|
45
46
|
self.userAttributes = filteredUserAttributes;
|
|
47
|
+
self.onboardingExpProvider = settings.onboardingExpProvider;
|
|
46
48
|
|
|
47
49
|
if (testMode) {
|
|
48
50
|
attachLauncher(accountId, sandboxMode);
|
|
@@ -120,9 +122,18 @@ var constructor = function () {
|
|
|
120
122
|
|
|
121
123
|
self.userAttributes = filteredAttributes;
|
|
122
124
|
|
|
123
|
-
var
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
var optimizelyAttributes =
|
|
126
|
+
self.onboardingExpProvider === 'Optimizely'
|
|
127
|
+
? fetchOptimizely()
|
|
128
|
+
: {};
|
|
129
|
+
|
|
130
|
+
var selectPlacementsAttributes = mergeObjects(
|
|
131
|
+
filteredAttributes,
|
|
132
|
+
optimizelyAttributes,
|
|
133
|
+
{
|
|
134
|
+
mpid: mpid,
|
|
135
|
+
}
|
|
136
|
+
);
|
|
126
137
|
|
|
127
138
|
var selectPlacementsOptions = mergeObjects(options, {
|
|
128
139
|
attributes: selectPlacementsAttributes,
|
|
@@ -148,6 +159,12 @@ var constructor = function () {
|
|
|
148
159
|
window.Rokt.createLauncher({
|
|
149
160
|
accountId: accountId,
|
|
150
161
|
sandbox: sandboxMode,
|
|
162
|
+
integrationName:
|
|
163
|
+
'mParticle_' +
|
|
164
|
+
'wsdkv_' +
|
|
165
|
+
window.mParticle.getVersion() +
|
|
166
|
+
'_kitv_' +
|
|
167
|
+
"1.2.0",
|
|
151
168
|
})
|
|
152
169
|
.then(function (launcher) {
|
|
153
170
|
// Assign the launcher to a global variable for later access
|
|
@@ -185,6 +202,46 @@ var constructor = function () {
|
|
|
185
202
|
this.selectPlacements = selectPlacements;
|
|
186
203
|
|
|
187
204
|
// mParticle Kit Callback Methods
|
|
205
|
+
function fetchOptimizely() {
|
|
206
|
+
var forwarders = window.mParticle
|
|
207
|
+
._getActiveForwarders()
|
|
208
|
+
.filter(function (forwarder) {
|
|
209
|
+
return forwarder.name === 'Optimizely';
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
try {
|
|
213
|
+
if (forwarders.length > 0 && window.optimizely) {
|
|
214
|
+
// Get the state object
|
|
215
|
+
var optimizelyState = window.optimizely.get('state');
|
|
216
|
+
if (
|
|
217
|
+
!optimizelyState ||
|
|
218
|
+
!optimizelyState.getActiveExperimentIds
|
|
219
|
+
) {
|
|
220
|
+
return {};
|
|
221
|
+
}
|
|
222
|
+
// Get active experiment IDs
|
|
223
|
+
var activeExperimentIds =
|
|
224
|
+
optimizelyState.getActiveExperimentIds();
|
|
225
|
+
// Get variations for each active experiment
|
|
226
|
+
var activeExperiments = activeExperimentIds.reduce(function (
|
|
227
|
+
acc,
|
|
228
|
+
expId
|
|
229
|
+
) {
|
|
230
|
+
acc[
|
|
231
|
+
'rokt.custom.optimizely.experiment.' +
|
|
232
|
+
expId +
|
|
233
|
+
'.variationId'
|
|
234
|
+
] = optimizelyState.getVariationMap()[expId].id;
|
|
235
|
+
return acc;
|
|
236
|
+
},
|
|
237
|
+
{});
|
|
238
|
+
return activeExperiments;
|
|
239
|
+
}
|
|
240
|
+
} catch (error) {
|
|
241
|
+
console.error('Error fetching Optimizely attributes:', error);
|
|
242
|
+
}
|
|
243
|
+
return {};
|
|
244
|
+
}
|
|
188
245
|
this.init = initForwarder;
|
|
189
246
|
this.setUserAttribute = setUserAttribute;
|
|
190
247
|
this.onUserIdentified = onUserIdentified;
|
package/dist/Rokt-Kit.iife.js
CHANGED
|
@@ -27,6 +27,7 @@ var RoktKit = (function (exports) {
|
|
|
27
27
|
self.name = name;
|
|
28
28
|
self.moduleId = moduleId;
|
|
29
29
|
self.isInitialized = false;
|
|
30
|
+
|
|
30
31
|
self.launcher = null;
|
|
31
32
|
self.filters = {};
|
|
32
33
|
self.filteredUser = {};
|
|
@@ -42,6 +43,7 @@ var RoktKit = (function (exports) {
|
|
|
42
43
|
var accountId = settings.accountId;
|
|
43
44
|
var sandboxMode = window.mParticle.getEnvironment() === 'development';
|
|
44
45
|
self.userAttributes = filteredUserAttributes;
|
|
46
|
+
self.onboardingExpProvider = settings.onboardingExpProvider;
|
|
45
47
|
|
|
46
48
|
if (testMode) {
|
|
47
49
|
attachLauncher(accountId, sandboxMode);
|
|
@@ -119,9 +121,18 @@ var RoktKit = (function (exports) {
|
|
|
119
121
|
|
|
120
122
|
self.userAttributes = filteredAttributes;
|
|
121
123
|
|
|
122
|
-
var
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
var optimizelyAttributes =
|
|
125
|
+
self.onboardingExpProvider === 'Optimizely'
|
|
126
|
+
? fetchOptimizely()
|
|
127
|
+
: {};
|
|
128
|
+
|
|
129
|
+
var selectPlacementsAttributes = mergeObjects(
|
|
130
|
+
filteredAttributes,
|
|
131
|
+
optimizelyAttributes,
|
|
132
|
+
{
|
|
133
|
+
mpid: mpid,
|
|
134
|
+
}
|
|
135
|
+
);
|
|
125
136
|
|
|
126
137
|
var selectPlacementsOptions = mergeObjects(options, {
|
|
127
138
|
attributes: selectPlacementsAttributes,
|
|
@@ -147,6 +158,12 @@ var RoktKit = (function (exports) {
|
|
|
147
158
|
window.Rokt.createLauncher({
|
|
148
159
|
accountId: accountId,
|
|
149
160
|
sandbox: sandboxMode,
|
|
161
|
+
integrationName:
|
|
162
|
+
'mParticle_' +
|
|
163
|
+
'wsdkv_' +
|
|
164
|
+
window.mParticle.getVersion() +
|
|
165
|
+
'_kitv_' +
|
|
166
|
+
"1.2.0",
|
|
150
167
|
})
|
|
151
168
|
.then(function (launcher) {
|
|
152
169
|
// Assign the launcher to a global variable for later access
|
|
@@ -184,6 +201,46 @@ var RoktKit = (function (exports) {
|
|
|
184
201
|
this.selectPlacements = selectPlacements;
|
|
185
202
|
|
|
186
203
|
// mParticle Kit Callback Methods
|
|
204
|
+
function fetchOptimizely() {
|
|
205
|
+
var forwarders = window.mParticle
|
|
206
|
+
._getActiveForwarders()
|
|
207
|
+
.filter(function (forwarder) {
|
|
208
|
+
return forwarder.name === 'Optimizely';
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
try {
|
|
212
|
+
if (forwarders.length > 0 && window.optimizely) {
|
|
213
|
+
// Get the state object
|
|
214
|
+
var optimizelyState = window.optimizely.get('state');
|
|
215
|
+
if (
|
|
216
|
+
!optimizelyState ||
|
|
217
|
+
!optimizelyState.getActiveExperimentIds
|
|
218
|
+
) {
|
|
219
|
+
return {};
|
|
220
|
+
}
|
|
221
|
+
// Get active experiment IDs
|
|
222
|
+
var activeExperimentIds =
|
|
223
|
+
optimizelyState.getActiveExperimentIds();
|
|
224
|
+
// Get variations for each active experiment
|
|
225
|
+
var activeExperiments = activeExperimentIds.reduce(function (
|
|
226
|
+
acc,
|
|
227
|
+
expId
|
|
228
|
+
) {
|
|
229
|
+
acc[
|
|
230
|
+
'rokt.custom.optimizely.experiment.' +
|
|
231
|
+
expId +
|
|
232
|
+
'.variationId'
|
|
233
|
+
] = optimizelyState.getVariationMap()[expId].id;
|
|
234
|
+
return acc;
|
|
235
|
+
},
|
|
236
|
+
{});
|
|
237
|
+
return activeExperiments;
|
|
238
|
+
}
|
|
239
|
+
} catch (error) {
|
|
240
|
+
console.error('Error fetching Optimizely attributes:', error);
|
|
241
|
+
}
|
|
242
|
+
return {};
|
|
243
|
+
}
|
|
187
244
|
this.init = initForwarder;
|
|
188
245
|
this.setUserAttribute = setUserAttribute;
|
|
189
246
|
this.onUserIdentified = onUserIdentified;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mparticle/web-rokt-kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "mParticle integration kit for Rokt",
|
|
5
5
|
"main": "dist/Rokt-Kit.common.js",
|
|
6
6
|
"files": [
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
25
26
|
"@semantic-release/changelog": "^5.0.1",
|
|
26
27
|
"@semantic-release/exec": "^5.0.0",
|
|
27
28
|
"@semantic-release/git": "^9.0.0",
|
|
@@ -39,6 +40,7 @@
|
|
|
39
40
|
"rollup": "^1.15.6",
|
|
40
41
|
"rollup-plugin-commonjs": "^10.0.0",
|
|
41
42
|
"rollup-plugin-node-resolve": "^5.0.3",
|
|
43
|
+
"rollup-plugin-replace": "^2.2.0",
|
|
42
44
|
"shelljs": "0.8.3",
|
|
43
45
|
"should": "13.2.3",
|
|
44
46
|
"watchify": "^3.11.0"
|