Skip to content

Commit d8cd3e0

Browse files
refactor: Remove unused ROKT_EXTENSIONS and simplify extension extraction logic
1 parent 120febf commit d8cd3e0

2 files changed

Lines changed: 33 additions & 51 deletions

File tree

src/Rokt-Kit.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@
1616
var name = 'Rokt';
1717
var moduleId = 181;
1818

19-
var ROKT_EXTENSIONS = {
20-
'Coupon on Signup Extension Detection': 'cos-extension-detection',
21-
'Experiment Monitoring': 'experiment-monitoring',
22-
'Sponsored Payments Apple Pay': 'sponsored-payments-apple-pay',
23-
'Realtime Conversion Promotion': 'realtime-conversion-promotion',
24-
};
25-
2619
var constructor = function () {
2720
var self = this;
2821

@@ -411,11 +404,7 @@ function extractRoktExtensions(settingsString) {
411404

412405
var roktExtensions = [];
413406
for (var i = 0; i < settings.length; i++) {
414-
var extensionName = settings[i].value;
415-
var mappedExtension = ROKT_EXTENSIONS[extensionName];
416-
if (mappedExtension) {
417-
roktExtensions.push(mappedExtension);
418-
}
407+
roktExtensions.push(settings[i].value);
419408
}
420409

421410
return roktExtensions;

test/src/tests.js

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,37 +1209,39 @@ describe('Rokt Forwarder', () => {
12091209

12101210
it('should return base URL when no extensions are provided', () => {
12111211
const url =
1212-
window.mParticle.forwarder.testHelpers.generateLauncherScript(
1213-
[]
1214-
);
1212+
window.mParticle.forwarder.testHelpers.generateLauncherScript();
12151213
url.should.equal(baseUrl);
12161214
});
12171215

12181216
it('should return base URL when extensions is null or undefined', () => {
12191217
window.mParticle.forwarder.testHelpers
1220-
.generateLauncherScript(null)
1218+
.generateLauncherScript(undefined, null)
12211219
.should.equal(baseUrl);
12221220

12231221
window.mParticle.forwarder.testHelpers
1224-
.generateLauncherScript(undefined)
1222+
.generateLauncherScript(undefined, undefined)
12251223
.should.equal(baseUrl);
12261224
});
12271225

12281226
it('should correctly append a single extension', () => {
12291227
const url =
1230-
window.mParticle.forwarder.testHelpers.generateLauncherScript([
1231-
'cos-extension-detection',
1232-
]);
1228+
window.mParticle.forwarder.testHelpers.generateLauncherScript(
1229+
undefined,
1230+
['cos-extension-detection']
1231+
);
12331232
url.should.equal(baseUrl + '?extensions=cos-extension-detection');
12341233
});
12351234

12361235
it('should correctly append multiple extensions', () => {
12371236
const url =
1238-
window.mParticle.forwarder.testHelpers.generateLauncherScript([
1239-
'cos-extension-detection',
1240-
'experiment-monitoring',
1241-
'sponsored-payments-apple-pay',
1242-
]);
1237+
window.mParticle.forwarder.testHelpers.generateLauncherScript(
1238+
undefined,
1239+
[
1240+
'cos-extension-detection',
1241+
'experiment-monitoring',
1242+
'sponsored-payments-apple-pay',
1243+
]
1244+
);
12431245
url.should.equal(
12441246
baseUrl +
12451247
'?extensions=cos-extension-detection,' +
@@ -1250,40 +1252,31 @@ describe('Rokt Forwarder', () => {
12501252
});
12511253

12521254
describe('#roktExtensions', () => {
1253-
beforeEach(() => {
1255+
beforeEach(async () => {
12541256
window.Rokt = new MockRoktForwarder();
12551257
window.mParticle.Rokt = window.Rokt;
1258+
1259+
await window.mParticle.forwarder.init(
1260+
{
1261+
accountId: '123456',
1262+
},
1263+
reportService.cb,
1264+
true
1265+
);
12561266
});
12571267

12581268
describe('extractRoktExtensions', () => {
12591269
it('should correctly map known extension names to their query parameters', async () => {
1260-
window.mParticle.forwarder.testHelpers
1261-
.extractRoktExtensions(
1262-
'[{&quot;value&quot;:&quot;Coupon on Signup Extension Detection&quot;},' +
1263-
'{&quot;value&quot;:&quot;Experiment Monitoring&quot;},' +
1264-
'{&quot;value&quot;:&quot;Sponsored Payments Apple Pay&quot;},' +
1265-
'{&quot;value&quot;:&quot;Realtime Conversion Promotion&quot;}]'
1266-
)
1267-
.should.deepEqual([
1268-
'cos-extension-detection',
1269-
'experiment-monitoring',
1270-
'sponsored-payments-apple-pay',
1271-
'realtime-conversion-promotion',
1272-
]);
1273-
});
1270+
const settingsString =
1271+
'[{&quot;jsmap&quot;:null,&quot;map&quot;:null,&quot;maptype&quot;:&quot;StaticList&quot;,&quot;value&quot;:&quot;cos-extension-detection&quot;},{&quot;jsmap&quot;:null,&quot;map&quot;:null,&quot;maptype&quot;:&quot;StaticList&quot;,&quot;value&quot;:&quot;experiment-monitoring&quot;}]';
1272+
const expectedExtensions = [
1273+
'cos-extension-detection',
1274+
'experiment-monitoring',
1275+
];
12741276

1275-
it('should ignore unknown or invalid extensions', async () => {
12761277
window.mParticle.forwarder.testHelpers
1277-
.extractRoktExtensions(
1278-
'[{&quot;value&quot;:&quot;Unknown Extension&quot;},' +
1279-
'{&quot;value&quot;:&quot;Experiment Monitoring&quot;},' +
1280-
'{&quot;invalid_key&quot;:&quot;Invalid Format&quot;},' +
1281-
'{&quot;value&quot;:&quot;Sponsored Payments Apple Pay&quot;}]'
1282-
)
1283-
.should.deepEqual([
1284-
'experiment-monitoring',
1285-
'sponsored-payments-apple-pay',
1286-
]);
1278+
.extractRoktExtensions(settingsString)
1279+
.should.deepEqual(expectedExtensions);
12871280
});
12881281
});
12891282
});

0 commit comments

Comments
 (0)