Skip to content

Commit e895c27

Browse files
chore(build): Generate latest bundle [skip ci]
1 parent fdf9ca9 commit e895c27

2 files changed

Lines changed: 110 additions & 8 deletions

File tree

dist/Rokt-Kit.common.js

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var constructor = function () {
2828
self.name = name;
2929
self.moduleId = moduleId;
3030
self.isInitialized = false;
31+
3132
self.launcher = null;
3233
self.filters = {};
3334
self.filteredUser = {};
@@ -43,6 +44,7 @@ var constructor = function () {
4344
var accountId = settings.accountId;
4445
var sandboxMode = window.mParticle.getEnvironment() === 'development';
4546
self.userAttributes = filteredUserAttributes;
47+
self.onboardingExpProvider = settings.onboardingExpProvider;
4648

4749
if (testMode) {
4850
attachLauncher(accountId, sandboxMode);
@@ -120,9 +122,18 @@ var constructor = function () {
120122

121123
self.userAttributes = filteredAttributes;
122124

123-
var selectPlacementsAttributes = mergeObjects(filteredAttributes, {
124-
mpid: mpid,
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+
);
126137

127138
var selectPlacementsOptions = mergeObjects(options, {
128139
attributes: selectPlacementsAttributes,
@@ -153,7 +164,7 @@ var constructor = function () {
153164
'wsdkv_' +
154165
window.mParticle.getVersion() +
155166
'_kitv_' +
156-
"1.1.0",
167+
"1.2.0",
157168
})
158169
.then(function (launcher) {
159170
// Assign the launcher to a global variable for later access
@@ -191,6 +202,46 @@ var constructor = function () {
191202
this.selectPlacements = selectPlacements;
192203

193204
// 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+
}
194245
this.init = initForwarder;
195246
this.setUserAttribute = setUserAttribute;
196247
this.onUserIdentified = onUserIdentified;

dist/Rokt-Kit.iife.js

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var RoktKit = (function (exports) {
2727
self.name = name;
2828
self.moduleId = moduleId;
2929
self.isInitialized = false;
30+
3031
self.launcher = null;
3132
self.filters = {};
3233
self.filteredUser = {};
@@ -42,6 +43,7 @@ var RoktKit = (function (exports) {
4243
var accountId = settings.accountId;
4344
var sandboxMode = window.mParticle.getEnvironment() === 'development';
4445
self.userAttributes = filteredUserAttributes;
46+
self.onboardingExpProvider = settings.onboardingExpProvider;
4547

4648
if (testMode) {
4749
attachLauncher(accountId, sandboxMode);
@@ -119,9 +121,18 @@ var RoktKit = (function (exports) {
119121

120122
self.userAttributes = filteredAttributes;
121123

122-
var selectPlacementsAttributes = mergeObjects(filteredAttributes, {
123-
mpid: mpid,
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+
);
125136

126137
var selectPlacementsOptions = mergeObjects(options, {
127138
attributes: selectPlacementsAttributes,
@@ -152,7 +163,7 @@ var RoktKit = (function (exports) {
152163
'wsdkv_' +
153164
window.mParticle.getVersion() +
154165
'_kitv_' +
155-
"1.1.0",
166+
"1.2.0",
156167
})
157168
.then(function (launcher) {
158169
// Assign the launcher to a global variable for later access
@@ -190,6 +201,46 @@ var RoktKit = (function (exports) {
190201
this.selectPlacements = selectPlacements;
191202

192203
// 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+
}
193244
this.init = initForwarder;
194245
this.setUserAttribute = setUserAttribute;
195246
this.onUserIdentified = onUserIdentified;

0 commit comments

Comments
 (0)