@mparticle/web-adobe-client-kit 2.1.2 → 3.1.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/AdobeClientSideKit.common.js +27 -22
- package/dist/AdobeClientSideKit.iife.js +28 -23
- package/package.json +21 -14
- package/src/AdobeClientSideKit.js +0 -693
|
@@ -28,12 +28,12 @@ var MediaEventType = {
|
|
|
28
28
|
SegmentStart: 43,
|
|
29
29
|
SegmentEnd: 44,
|
|
30
30
|
SegmentSkip: 45,
|
|
31
|
-
UpdateQoS: 46
|
|
31
|
+
UpdateQoS: 46,
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
var ContentType = {
|
|
35
35
|
Audio: 'Audio',
|
|
36
|
-
Video: 'Video'
|
|
36
|
+
Video: 'Video',
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
var StreamType = {
|
|
@@ -41,7 +41,7 @@ var StreamType = {
|
|
|
41
41
|
OnDemand: 'OnDemand',
|
|
42
42
|
Linear: 'Linear',
|
|
43
43
|
Podcast: 'Podcast',
|
|
44
|
-
Audiobook: 'Audiobook'
|
|
44
|
+
Audiobook: 'Audiobook',
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
function EventHandler(common) {
|
|
@@ -269,7 +269,7 @@ var getAdobeMetadataKeys = function(attributes, Heartbeat) {
|
|
|
269
269
|
content_mvpd: Heartbeat.VideoMetadataKeys.MVPD,
|
|
270
270
|
content_authorized: Heartbeat.VideoMetadataKeys.AUTHORIZED,
|
|
271
271
|
content_daypart: Heartbeat.VideoMetadataKeys.DAY_PART,
|
|
272
|
-
content_feed: Heartbeat.VideoMetadataKeys.FEED
|
|
272
|
+
content_feed: Heartbeat.VideoMetadataKeys.FEED,
|
|
273
273
|
};
|
|
274
274
|
|
|
275
275
|
var adobeMetadataKeys = {};
|
|
@@ -425,7 +425,7 @@ var Initialization = {
|
|
|
425
425
|
}
|
|
426
426
|
|
|
427
427
|
initHeartbeatCallback();
|
|
428
|
-
}
|
|
428
|
+
},
|
|
429
429
|
};
|
|
430
430
|
|
|
431
431
|
var initialization = Initialization;
|
|
@@ -458,7 +458,7 @@ var MessageType = {
|
|
|
458
458
|
CrashReport: 5,
|
|
459
459
|
OptOut: 6,
|
|
460
460
|
Commerce: 16,
|
|
461
|
-
Media: 20
|
|
461
|
+
Media: 20,
|
|
462
462
|
};
|
|
463
463
|
|
|
464
464
|
function constructor() {
|
|
@@ -542,7 +542,7 @@ function constructor() {
|
|
|
542
542
|
return true;
|
|
543
543
|
} catch (e) {
|
|
544
544
|
return {
|
|
545
|
-
error: 'Error logging event on forwarder ' + name + '; ' + e
|
|
545
|
+
error: 'Error logging event on forwarder ' + name + '; ' + e,
|
|
546
546
|
};
|
|
547
547
|
}
|
|
548
548
|
}
|
|
@@ -556,7 +556,7 @@ if (window.mParticle && window.mParticle.registerHBK) {
|
|
|
556
556
|
}
|
|
557
557
|
|
|
558
558
|
var src = {
|
|
559
|
-
AdobeHbkConstructor: constructor
|
|
559
|
+
AdobeHbkConstructor: constructor,
|
|
560
560
|
};
|
|
561
561
|
var src_1 = src.AdobeHbkConstructor;
|
|
562
562
|
|
|
@@ -653,7 +653,7 @@ var name = 'Adobe',
|
|
|
653
653
|
CrashReport: 5,
|
|
654
654
|
OptOut: 6,
|
|
655
655
|
Commerce: 16,
|
|
656
|
-
Media: 20
|
|
656
|
+
Media: 20,
|
|
657
657
|
},
|
|
658
658
|
//Custom Flag Names
|
|
659
659
|
LINK_NAME = 'Adobe.LinkName',
|
|
@@ -810,14 +810,14 @@ var constructor$1 = function() {
|
|
|
810
810
|
}
|
|
811
811
|
|
|
812
812
|
return {
|
|
813
|
-
result: false
|
|
813
|
+
result: false,
|
|
814
814
|
};
|
|
815
815
|
});
|
|
816
816
|
|
|
817
817
|
if (filteredArray && filteredArray.length > 0) {
|
|
818
818
|
return {
|
|
819
819
|
result: true,
|
|
820
|
-
matches: filteredArray
|
|
820
|
+
matches: filteredArray,
|
|
821
821
|
};
|
|
822
822
|
}
|
|
823
823
|
}
|
|
@@ -826,6 +826,10 @@ var constructor$1 = function() {
|
|
|
826
826
|
|
|
827
827
|
// for each type of event, we run setMappings which sets the eVars, props, hvars, and contextData values
|
|
828
828
|
// after each event is sent to the server (either using t() for pageViews or tl() for non-pageview events), clearVars() is run to wipe out
|
|
829
|
+
function resetVariables() {
|
|
830
|
+
appMeasurement.clearVars();
|
|
831
|
+
appMeasurement.contextData = {};
|
|
832
|
+
}
|
|
829
833
|
// any eVars, props, and hvars
|
|
830
834
|
function processEvent(event) {
|
|
831
835
|
var linkName,
|
|
@@ -950,7 +954,7 @@ var constructor$1 = function() {
|
|
|
950
954
|
appMeasurement.linkTrackVars = linkTrackVars;
|
|
951
955
|
appMeasurement.tl(true, 'o', linkName);
|
|
952
956
|
|
|
953
|
-
|
|
957
|
+
resetVariables();
|
|
954
958
|
|
|
955
959
|
return true;
|
|
956
960
|
}
|
|
@@ -1086,10 +1090,10 @@ var constructor$1 = function() {
|
|
|
1086
1090
|
appMeasurement.pageName =
|
|
1087
1091
|
pageName || event.EventName || window.document.title;
|
|
1088
1092
|
appMeasurement.t();
|
|
1089
|
-
|
|
1093
|
+
resetVariables();
|
|
1090
1094
|
return true;
|
|
1091
1095
|
} catch (e) {
|
|
1092
|
-
|
|
1096
|
+
resetVariables();
|
|
1093
1097
|
return { error: 'logPageView not called, error ' + e };
|
|
1094
1098
|
}
|
|
1095
1099
|
}
|
|
@@ -1118,16 +1122,17 @@ var constructor$1 = function() {
|
|
|
1118
1122
|
appMeasurement.linkTrackVars = linkTrackVars;
|
|
1119
1123
|
|
|
1120
1124
|
appMeasurement.tl(true, 'o', linkName);
|
|
1121
|
-
|
|
1125
|
+
resetVariables();
|
|
1122
1126
|
return true;
|
|
1123
1127
|
} else {
|
|
1124
|
-
|
|
1128
|
+
resetVariables();
|
|
1125
1129
|
window.console.log(
|
|
1126
1130
|
'event name not mapped, aborting event logging'
|
|
1127
1131
|
);
|
|
1132
|
+
return false;
|
|
1128
1133
|
}
|
|
1129
1134
|
} catch (e) {
|
|
1130
|
-
|
|
1135
|
+
resetVariables();
|
|
1131
1136
|
return { error: e };
|
|
1132
1137
|
}
|
|
1133
1138
|
}
|
|
@@ -1226,7 +1231,7 @@ var constructor$1 = function() {
|
|
|
1226
1231
|
if (Object.keys(userIdentities).length) {
|
|
1227
1232
|
for (var identity in userIdentities) {
|
|
1228
1233
|
identitiesToSet[identity] = {
|
|
1229
|
-
id: userIdentities[identity]
|
|
1234
|
+
id: userIdentities[identity],
|
|
1230
1235
|
};
|
|
1231
1236
|
}
|
|
1232
1237
|
} else {
|
|
@@ -1271,7 +1276,7 @@ if (window && window.mParticle && window.mParticle.addForwarder) {
|
|
|
1271
1276
|
window.mParticle.addForwarder({
|
|
1272
1277
|
name: name,
|
|
1273
1278
|
constructor: constructor$1,
|
|
1274
|
-
getId: getId
|
|
1279
|
+
getId: getId,
|
|
1275
1280
|
});
|
|
1276
1281
|
}
|
|
1277
1282
|
|
|
@@ -1292,12 +1297,12 @@ function register(config) {
|
|
|
1292
1297
|
|
|
1293
1298
|
if (isObject(config.kits)) {
|
|
1294
1299
|
config.kits[name] = {
|
|
1295
|
-
constructor: constructor$1
|
|
1300
|
+
constructor: constructor$1,
|
|
1296
1301
|
};
|
|
1297
1302
|
} else {
|
|
1298
1303
|
config.kits = {};
|
|
1299
1304
|
config.kits[name] = {
|
|
1300
|
-
constructor: constructor$1
|
|
1305
|
+
constructor: constructor$1,
|
|
1301
1306
|
};
|
|
1302
1307
|
}
|
|
1303
1308
|
window.console.log(
|
|
@@ -1312,7 +1317,7 @@ function isObject(val) {
|
|
|
1312
1317
|
}
|
|
1313
1318
|
|
|
1314
1319
|
var AdobeClientSideKit_esm = {
|
|
1315
|
-
register: register
|
|
1320
|
+
register: register,
|
|
1316
1321
|
};
|
|
1317
1322
|
|
|
1318
1323
|
module.exports = AdobeClientSideKit_esm;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var mParticleAdobeClient = (function () {
|
|
2
2
|
function Common() {
|
|
3
3
|
this.playheadPosition = 0;
|
|
4
4
|
this.startupTime = 0;
|
|
@@ -29,12 +29,12 @@ var mParticleAdobe = (function () {
|
|
|
29
29
|
SegmentStart: 43,
|
|
30
30
|
SegmentEnd: 44,
|
|
31
31
|
SegmentSkip: 45,
|
|
32
|
-
UpdateQoS: 46
|
|
32
|
+
UpdateQoS: 46,
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
var ContentType = {
|
|
36
36
|
Audio: 'Audio',
|
|
37
|
-
Video: 'Video'
|
|
37
|
+
Video: 'Video',
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
var StreamType = {
|
|
@@ -42,7 +42,7 @@ var mParticleAdobe = (function () {
|
|
|
42
42
|
OnDemand: 'OnDemand',
|
|
43
43
|
Linear: 'Linear',
|
|
44
44
|
Podcast: 'Podcast',
|
|
45
|
-
Audiobook: 'Audiobook'
|
|
45
|
+
Audiobook: 'Audiobook',
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
function EventHandler(common) {
|
|
@@ -270,7 +270,7 @@ var mParticleAdobe = (function () {
|
|
|
270
270
|
content_mvpd: Heartbeat.VideoMetadataKeys.MVPD,
|
|
271
271
|
content_authorized: Heartbeat.VideoMetadataKeys.AUTHORIZED,
|
|
272
272
|
content_daypart: Heartbeat.VideoMetadataKeys.DAY_PART,
|
|
273
|
-
content_feed: Heartbeat.VideoMetadataKeys.FEED
|
|
273
|
+
content_feed: Heartbeat.VideoMetadataKeys.FEED,
|
|
274
274
|
};
|
|
275
275
|
|
|
276
276
|
var adobeMetadataKeys = {};
|
|
@@ -426,7 +426,7 @@ var mParticleAdobe = (function () {
|
|
|
426
426
|
}
|
|
427
427
|
|
|
428
428
|
initHeartbeatCallback();
|
|
429
|
-
}
|
|
429
|
+
},
|
|
430
430
|
};
|
|
431
431
|
|
|
432
432
|
var initialization = Initialization;
|
|
@@ -459,7 +459,7 @@ var mParticleAdobe = (function () {
|
|
|
459
459
|
CrashReport: 5,
|
|
460
460
|
OptOut: 6,
|
|
461
461
|
Commerce: 16,
|
|
462
|
-
Media: 20
|
|
462
|
+
Media: 20,
|
|
463
463
|
};
|
|
464
464
|
|
|
465
465
|
function constructor() {
|
|
@@ -543,7 +543,7 @@ var mParticleAdobe = (function () {
|
|
|
543
543
|
return true;
|
|
544
544
|
} catch (e) {
|
|
545
545
|
return {
|
|
546
|
-
error: 'Error logging event on forwarder ' + name + '; ' + e
|
|
546
|
+
error: 'Error logging event on forwarder ' + name + '; ' + e,
|
|
547
547
|
};
|
|
548
548
|
}
|
|
549
549
|
}
|
|
@@ -557,7 +557,7 @@ var mParticleAdobe = (function () {
|
|
|
557
557
|
}
|
|
558
558
|
|
|
559
559
|
var src = {
|
|
560
|
-
AdobeHbkConstructor: constructor
|
|
560
|
+
AdobeHbkConstructor: constructor,
|
|
561
561
|
};
|
|
562
562
|
var src_1 = src.AdobeHbkConstructor;
|
|
563
563
|
|
|
@@ -654,7 +654,7 @@ var mParticleAdobe = (function () {
|
|
|
654
654
|
CrashReport: 5,
|
|
655
655
|
OptOut: 6,
|
|
656
656
|
Commerce: 16,
|
|
657
|
-
Media: 20
|
|
657
|
+
Media: 20,
|
|
658
658
|
},
|
|
659
659
|
//Custom Flag Names
|
|
660
660
|
LINK_NAME = 'Adobe.LinkName',
|
|
@@ -811,14 +811,14 @@ var mParticleAdobe = (function () {
|
|
|
811
811
|
}
|
|
812
812
|
|
|
813
813
|
return {
|
|
814
|
-
result: false
|
|
814
|
+
result: false,
|
|
815
815
|
};
|
|
816
816
|
});
|
|
817
817
|
|
|
818
818
|
if (filteredArray && filteredArray.length > 0) {
|
|
819
819
|
return {
|
|
820
820
|
result: true,
|
|
821
|
-
matches: filteredArray
|
|
821
|
+
matches: filteredArray,
|
|
822
822
|
};
|
|
823
823
|
}
|
|
824
824
|
}
|
|
@@ -827,6 +827,10 @@ var mParticleAdobe = (function () {
|
|
|
827
827
|
|
|
828
828
|
// for each type of event, we run setMappings which sets the eVars, props, hvars, and contextData values
|
|
829
829
|
// after each event is sent to the server (either using t() for pageViews or tl() for non-pageview events), clearVars() is run to wipe out
|
|
830
|
+
function resetVariables() {
|
|
831
|
+
appMeasurement.clearVars();
|
|
832
|
+
appMeasurement.contextData = {};
|
|
833
|
+
}
|
|
830
834
|
// any eVars, props, and hvars
|
|
831
835
|
function processEvent(event) {
|
|
832
836
|
var linkName,
|
|
@@ -951,7 +955,7 @@ var mParticleAdobe = (function () {
|
|
|
951
955
|
appMeasurement.linkTrackVars = linkTrackVars;
|
|
952
956
|
appMeasurement.tl(true, 'o', linkName);
|
|
953
957
|
|
|
954
|
-
|
|
958
|
+
resetVariables();
|
|
955
959
|
|
|
956
960
|
return true;
|
|
957
961
|
}
|
|
@@ -1087,10 +1091,10 @@ var mParticleAdobe = (function () {
|
|
|
1087
1091
|
appMeasurement.pageName =
|
|
1088
1092
|
pageName || event.EventName || window.document.title;
|
|
1089
1093
|
appMeasurement.t();
|
|
1090
|
-
|
|
1094
|
+
resetVariables();
|
|
1091
1095
|
return true;
|
|
1092
1096
|
} catch (e) {
|
|
1093
|
-
|
|
1097
|
+
resetVariables();
|
|
1094
1098
|
return { error: 'logPageView not called, error ' + e };
|
|
1095
1099
|
}
|
|
1096
1100
|
}
|
|
@@ -1119,16 +1123,17 @@ var mParticleAdobe = (function () {
|
|
|
1119
1123
|
appMeasurement.linkTrackVars = linkTrackVars;
|
|
1120
1124
|
|
|
1121
1125
|
appMeasurement.tl(true, 'o', linkName);
|
|
1122
|
-
|
|
1126
|
+
resetVariables();
|
|
1123
1127
|
return true;
|
|
1124
1128
|
} else {
|
|
1125
|
-
|
|
1129
|
+
resetVariables();
|
|
1126
1130
|
window.console.log(
|
|
1127
1131
|
'event name not mapped, aborting event logging'
|
|
1128
1132
|
);
|
|
1133
|
+
return false;
|
|
1129
1134
|
}
|
|
1130
1135
|
} catch (e) {
|
|
1131
|
-
|
|
1136
|
+
resetVariables();
|
|
1132
1137
|
return { error: e };
|
|
1133
1138
|
}
|
|
1134
1139
|
}
|
|
@@ -1227,7 +1232,7 @@ var mParticleAdobe = (function () {
|
|
|
1227
1232
|
if (Object.keys(userIdentities).length) {
|
|
1228
1233
|
for (var identity in userIdentities) {
|
|
1229
1234
|
identitiesToSet[identity] = {
|
|
1230
|
-
id: userIdentities[identity]
|
|
1235
|
+
id: userIdentities[identity],
|
|
1231
1236
|
};
|
|
1232
1237
|
}
|
|
1233
1238
|
} else {
|
|
@@ -1272,7 +1277,7 @@ var mParticleAdobe = (function () {
|
|
|
1272
1277
|
window.mParticle.addForwarder({
|
|
1273
1278
|
name: name,
|
|
1274
1279
|
constructor: constructor$1,
|
|
1275
|
-
getId: getId
|
|
1280
|
+
getId: getId,
|
|
1276
1281
|
});
|
|
1277
1282
|
}
|
|
1278
1283
|
|
|
@@ -1293,12 +1298,12 @@ var mParticleAdobe = (function () {
|
|
|
1293
1298
|
|
|
1294
1299
|
if (isObject(config.kits)) {
|
|
1295
1300
|
config.kits[name] = {
|
|
1296
|
-
constructor: constructor$1
|
|
1301
|
+
constructor: constructor$1,
|
|
1297
1302
|
};
|
|
1298
1303
|
} else {
|
|
1299
1304
|
config.kits = {};
|
|
1300
1305
|
config.kits[name] = {
|
|
1301
|
-
constructor: constructor$1
|
|
1306
|
+
constructor: constructor$1,
|
|
1302
1307
|
};
|
|
1303
1308
|
}
|
|
1304
1309
|
window.console.log(
|
|
@@ -1313,7 +1318,7 @@ var mParticleAdobe = (function () {
|
|
|
1313
1318
|
}
|
|
1314
1319
|
|
|
1315
1320
|
var AdobeClientSideKit_esm = {
|
|
1316
|
-
register: register
|
|
1321
|
+
register: register,
|
|
1317
1322
|
};
|
|
1318
1323
|
|
|
1319
1324
|
return AdobeClientSideKit_esm;
|
package/package.json
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
"name": "@mparticle/web-adobe-client-kit",
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"description": "mParticle integration sdk for Adobe (client side)",
|
|
5
|
+
"main": "dist/AdobeClientSideKit.common.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/AdobeClientSideKit.common.js",
|
|
8
|
+
"dist/AdobeClientSideKit.iife.js"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
|
+
},
|
|
13
|
+
"author": "mParticle Developers <developers@mparticle.com> (https://www.mparticle.com)",
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/mParticle/mparticle-web-sdk",
|
|
21
|
+
"directory": "kits/adobe/packages/AdobeClient"
|
|
22
|
+
}
|
|
16
23
|
}
|
|
@@ -1,693 +0,0 @@
|
|
|
1
|
-
// START OF ADOBE MPARTICLE JS INTEGRATION
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-undef */
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
// Copyright 2018 mParticle, Inc.
|
|
7
|
-
//
|
|
8
|
-
// Licensed under the Apache License, Version 2.0 (the 'License');
|
|
9
|
-
// you may not use this file except in compliance with the License.
|
|
10
|
-
// You may obtain a copy of the License at
|
|
11
|
-
//
|
|
12
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
//
|
|
14
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
15
|
-
// distributed under the License is distributed on an 'AS IS' BASIS,
|
|
16
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
-
// See the License for the specific language governing permissions and
|
|
18
|
-
// limitations under the License.
|
|
19
|
-
|
|
20
|
-
import { AdobeHbkConstructor } from '../../../HeartbeatKit/dist/AdobeHBKit.esm.js';
|
|
21
|
-
|
|
22
|
-
var name = 'Adobe',
|
|
23
|
-
ADOBEMODULENUMBER = 124,
|
|
24
|
-
MARKETINGCLOUDIDKEY = 'mid',
|
|
25
|
-
MessageType = {
|
|
26
|
-
SessionStart: 1,
|
|
27
|
-
SessionEnd: 2,
|
|
28
|
-
PageView: 3,
|
|
29
|
-
PageEvent: 4,
|
|
30
|
-
CrashReport: 5,
|
|
31
|
-
OptOut: 6,
|
|
32
|
-
Commerce: 16,
|
|
33
|
-
Media: 20
|
|
34
|
-
},
|
|
35
|
-
//Custom Flag Names
|
|
36
|
-
LINK_NAME = 'Adobe.LinkName',
|
|
37
|
-
PAGE_NAME = 'Adobe.PageName';
|
|
38
|
-
|
|
39
|
-
var constructor = function() {
|
|
40
|
-
var self = this,
|
|
41
|
-
//one or more instances of AppMeasurement returned from s_gi()
|
|
42
|
-
appMeasurement,
|
|
43
|
-
settings,
|
|
44
|
-
timestampOption,
|
|
45
|
-
isAdobeClientKitInitialized = false,
|
|
46
|
-
reportingService,
|
|
47
|
-
contextVariableMapping,
|
|
48
|
-
productIncrementorMapping,
|
|
49
|
-
productMerchandisingMapping,
|
|
50
|
-
propsMapping,
|
|
51
|
-
eVarsMapping,
|
|
52
|
-
hiersMapping,
|
|
53
|
-
eventsMapping;
|
|
54
|
-
|
|
55
|
-
(self.adobeMediaSDK = new AdobeHbkConstructor()), (self.name = name);
|
|
56
|
-
|
|
57
|
-
function initForwarder(forwarderSettings, service, testMode) {
|
|
58
|
-
settings = forwarderSettings;
|
|
59
|
-
reportingService = service;
|
|
60
|
-
try {
|
|
61
|
-
loadMappings();
|
|
62
|
-
timestampOption =
|
|
63
|
-
settings.timestampOption === 'optional' ||
|
|
64
|
-
settings.timestampOption === 'required';
|
|
65
|
-
finishAdobeInitialization();
|
|
66
|
-
if (settings.mediaTrackingServer) {
|
|
67
|
-
self.adobeMediaSDK.init(forwarderSettings, service, testMode);
|
|
68
|
-
}
|
|
69
|
-
isAdobeClientKitInitialized = true;
|
|
70
|
-
|
|
71
|
-
return 'ClientSDK successfully loaded';
|
|
72
|
-
} catch (e) {
|
|
73
|
-
return 'Failed to initialize: ' + e;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function loadMappings() {
|
|
78
|
-
eVarsMapping = settings.evars
|
|
79
|
-
? JSON.parse(settings.evars.replace(/"/g, '"'))
|
|
80
|
-
: [];
|
|
81
|
-
propsMapping = settings.props
|
|
82
|
-
? JSON.parse(settings.props.replace(/"/g, '"'))
|
|
83
|
-
: [];
|
|
84
|
-
productIncrementorMapping = settings.productIncrementor
|
|
85
|
-
? JSON.parse(settings.productIncrementor.replace(/"/g, '"'))
|
|
86
|
-
: [];
|
|
87
|
-
productMerchandisingMapping = settings.productMerchandising
|
|
88
|
-
? JSON.parse(settings.productMerchandising.replace(/"/g, '"'))
|
|
89
|
-
: [];
|
|
90
|
-
hiersMapping = settings.hvars
|
|
91
|
-
? JSON.parse(settings.hvars.replace(/"/g, '"'))
|
|
92
|
-
: [];
|
|
93
|
-
eventsMapping = settings.events
|
|
94
|
-
? JSON.parse(settings.events.replace(/"/g, '"'))
|
|
95
|
-
: [];
|
|
96
|
-
contextVariableMapping = settings.contextVariables
|
|
97
|
-
? JSON.parse(settings.contextVariables.replace(/"/g, '"'))
|
|
98
|
-
: [];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function finishAdobeInitialization() {
|
|
102
|
-
var visitorOptions = {};
|
|
103
|
-
if (settings.audienceManagerServer) {
|
|
104
|
-
visitorOptions.audienceManagerServer =
|
|
105
|
-
settings.audienceManagerServer;
|
|
106
|
-
}
|
|
107
|
-
try {
|
|
108
|
-
appMeasurement = s_gi(settings.reportSuiteIDs);
|
|
109
|
-
if (settings.setGlobalObject === 'True') {
|
|
110
|
-
window.s = appMeasurement;
|
|
111
|
-
}
|
|
112
|
-
appMeasurement.visitor = Visitor.getInstance(
|
|
113
|
-
settings.organizationID,
|
|
114
|
-
visitorOptions
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
appMeasurement.trackingServer = settings.trackingServer;
|
|
118
|
-
|
|
119
|
-
appMeasurement.trackDownloadLinks = true;
|
|
120
|
-
appMeasurement.trackExternalLinks =
|
|
121
|
-
settings.trackExternalLinks === 'True';
|
|
122
|
-
appMeasurement.trackInlineStats = true;
|
|
123
|
-
appMeasurement.linkDownloadFileTypes =
|
|
124
|
-
'exe,zip,wav,mp3,mov,mpg,avi,wmv,pdf,doc,docx,xls,xlsx,ppt,pptx';
|
|
125
|
-
appMeasurement.linkInternalFilters = 'javascript:';
|
|
126
|
-
appMeasurement.linkLeaveQueryString = false;
|
|
127
|
-
appMeasurement.linkTrackVars = 'None';
|
|
128
|
-
appMeasurement.linkTrackEvents = 'None';
|
|
129
|
-
appMeasurement.visitorNamespace = '';
|
|
130
|
-
|
|
131
|
-
// On first load, adobe will call the callback correctly if no MCID exists
|
|
132
|
-
// On subsequent loads, it does not, so we need to manually call setMCIDOnIntegrationAttributes
|
|
133
|
-
var mcID = Visitor.getInstance(
|
|
134
|
-
settings.organizationID,
|
|
135
|
-
visitorOptions
|
|
136
|
-
).getMarketingCloudVisitorID(setMarketingCloudId);
|
|
137
|
-
if (mcID && mcID.length > 0) {
|
|
138
|
-
setMCIDOnIntegrationAttributes(mcID);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return true;
|
|
142
|
-
} catch (e) {
|
|
143
|
-
return 'error initializing adobe: ' + e;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function setMarketingCloudId(mcid) {
|
|
148
|
-
setMCIDOnIntegrationAttributes(mcid);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function setMCIDOnIntegrationAttributes(mcid) {
|
|
152
|
-
var adobeIntegrationAttributes = {};
|
|
153
|
-
adobeIntegrationAttributes[MARKETINGCLOUDIDKEY] = mcid;
|
|
154
|
-
mParticle.setIntegrationAttribute(
|
|
155
|
-
ADOBEMODULENUMBER,
|
|
156
|
-
adobeIntegrationAttributes
|
|
157
|
-
);
|
|
158
|
-
mParticle._setIntegrationDelay(ADOBEMODULENUMBER, false);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Get the mapped value for custom events
|
|
162
|
-
function getEventMappingValue(event) {
|
|
163
|
-
var jsHash = calculateJSHash(
|
|
164
|
-
event.EventDataType,
|
|
165
|
-
event.EventCategory,
|
|
166
|
-
event.EventName
|
|
167
|
-
);
|
|
168
|
-
return findValueInMapping(jsHash, eventsMapping);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function calculateJSHash(eventDataType, eventCategory, name) {
|
|
172
|
-
var preHash =
|
|
173
|
-
'' + eventDataType + ('' + eventCategory) + '' + (name || '');
|
|
174
|
-
|
|
175
|
-
return mParticle.generateHash(preHash);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function findValueInMapping(jsHash, mapping) {
|
|
179
|
-
if (mapping) {
|
|
180
|
-
var filteredArray = mapping.filter(function(mappingEntry) {
|
|
181
|
-
if (
|
|
182
|
-
mappingEntry.jsmap &&
|
|
183
|
-
mappingEntry.maptype &&
|
|
184
|
-
mappingEntry.value
|
|
185
|
-
) {
|
|
186
|
-
return mappingEntry.jsmap === jsHash.toString();
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return {
|
|
190
|
-
result: false
|
|
191
|
-
};
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
if (filteredArray && filteredArray.length > 0) {
|
|
195
|
-
return {
|
|
196
|
-
result: true,
|
|
197
|
-
matches: filteredArray
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return null;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// for each type of event, we run setMappings which sets the eVars, props, hvars, and contextData values
|
|
205
|
-
// after each event is sent to the server (either using t() for pageViews or tl() for non-pageview events), clearVars() is run to wipe out
|
|
206
|
-
// any eVars, props, and hvars
|
|
207
|
-
function processEvent(event) {
|
|
208
|
-
var linkName,
|
|
209
|
-
pageName,
|
|
210
|
-
reportEvent = false,
|
|
211
|
-
linkTrackVars = [];
|
|
212
|
-
|
|
213
|
-
appMeasurement.timestamp = timestampOption
|
|
214
|
-
? Math.floor(new Date().getTime() / 1000)
|
|
215
|
-
: null;
|
|
216
|
-
appMeasurement.events = '';
|
|
217
|
-
if (event.CustomFlags && event.CustomFlags.hasOwnProperty(LINK_NAME)) {
|
|
218
|
-
linkName = event.CustomFlags[LINK_NAME];
|
|
219
|
-
}
|
|
220
|
-
if (event.CustomFlags && event.CustomFlags.hasOwnProperty(PAGE_NAME)) {
|
|
221
|
-
pageName = event.CustomFlags[PAGE_NAME];
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (isAdobeClientKitInitialized) {
|
|
225
|
-
try {
|
|
226
|
-
// First determine if an eventName is mapped, if so, log it as an event as opposed to a pageview or commerceview
|
|
227
|
-
// ex. If a pageview is mapped to an event, we logEvent instead of logging it as a pageview
|
|
228
|
-
var eventMapping = getEventMappingValue(event);
|
|
229
|
-
|
|
230
|
-
if (
|
|
231
|
-
eventMapping &&
|
|
232
|
-
eventMapping.result &&
|
|
233
|
-
eventMapping.matches
|
|
234
|
-
) {
|
|
235
|
-
setMappings(event, true, linkTrackVars);
|
|
236
|
-
reportEvent = logEvent(
|
|
237
|
-
event,
|
|
238
|
-
linkTrackVars,
|
|
239
|
-
eventMapping.matches,
|
|
240
|
-
linkName,
|
|
241
|
-
pageName
|
|
242
|
-
);
|
|
243
|
-
} else if (event.EventDataType === MessageType.PageView) {
|
|
244
|
-
setMappings(event, false);
|
|
245
|
-
reportEvent = logPageView(event, pageName);
|
|
246
|
-
} else if (event.EventDataType === MessageType.Commerce) {
|
|
247
|
-
setMappings(event, true, linkTrackVars);
|
|
248
|
-
reportEvent = processCommerceTransaction(
|
|
249
|
-
event,
|
|
250
|
-
linkTrackVars,
|
|
251
|
-
linkName,
|
|
252
|
-
pageName
|
|
253
|
-
);
|
|
254
|
-
} else if (event.EventDataType === MessageType.Media) {
|
|
255
|
-
self.adobeMediaSDK.process(event);
|
|
256
|
-
} else {
|
|
257
|
-
return 'event name not mapped, aborting event logging';
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (
|
|
261
|
-
reportEvent === true &&
|
|
262
|
-
reportingService &&
|
|
263
|
-
event.EventDataType
|
|
264
|
-
) {
|
|
265
|
-
reportingService(self, event);
|
|
266
|
-
return 'Successfully sent to ' + name;
|
|
267
|
-
}
|
|
268
|
-
} catch (e) {
|
|
269
|
-
return 'Failed to send to: ' + name + ' ' + e;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
return 'Cannot send to forwarder ' + name + ', not initialized.';
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
function setMappings(event, includeTrackVars, linkTrackVars) {
|
|
277
|
-
if (includeTrackVars) {
|
|
278
|
-
setEvars(event, linkTrackVars);
|
|
279
|
-
setProps(event, linkTrackVars);
|
|
280
|
-
setHiers(event, linkTrackVars);
|
|
281
|
-
setContextData(event, linkTrackVars);
|
|
282
|
-
} else {
|
|
283
|
-
setEvars(event);
|
|
284
|
-
setProps(event);
|
|
285
|
-
setHiers(event);
|
|
286
|
-
setContextData(event);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function processCommerceTransaction(
|
|
291
|
-
event,
|
|
292
|
-
linkTrackVars,
|
|
293
|
-
linkName,
|
|
294
|
-
pageName
|
|
295
|
-
) {
|
|
296
|
-
if (
|
|
297
|
-
event.EventCategory === mParticle.CommerceEventType.ProductPurchase
|
|
298
|
-
) {
|
|
299
|
-
appMeasurement.events = 'purchase';
|
|
300
|
-
appMeasurement.purchaseID = event.ProductAction.TransactionId;
|
|
301
|
-
appMeasurement.transactionID = event.ProductAction.TransactionId;
|
|
302
|
-
linkTrackVars.push('purchaseID', 'transactionID');
|
|
303
|
-
} else if (
|
|
304
|
-
event.EventCategory ===
|
|
305
|
-
mParticle.CommerceEventType.ProductViewDetail
|
|
306
|
-
) {
|
|
307
|
-
appMeasurement.events = 'prodView';
|
|
308
|
-
} else if (
|
|
309
|
-
event.EventCategory === mParticle.CommerceEventType.ProductAddToCart
|
|
310
|
-
) {
|
|
311
|
-
appMeasurement.events = 'scAdd';
|
|
312
|
-
} else if (
|
|
313
|
-
event.EventCategory ===
|
|
314
|
-
mParticle.CommerceEventType.ProductRemoveFromCart
|
|
315
|
-
) {
|
|
316
|
-
appMeasurement.events = 'scRemove';
|
|
317
|
-
} else if (
|
|
318
|
-
event.EventCategory === mParticle.CommerceEventType.ProductCheckout
|
|
319
|
-
) {
|
|
320
|
-
appMeasurement.events = 'scCheckout';
|
|
321
|
-
}
|
|
322
|
-
appMeasurement.linkTrackEvents = appMeasurement.events || null;
|
|
323
|
-
processProductsAndSetEvents(event, linkTrackVars);
|
|
324
|
-
|
|
325
|
-
linkTrackVars.push('products', 'events');
|
|
326
|
-
setPageName(linkTrackVars, appMeasurement, pageName);
|
|
327
|
-
appMeasurement.linkTrackVars = linkTrackVars;
|
|
328
|
-
appMeasurement.tl(true, 'o', linkName);
|
|
329
|
-
|
|
330
|
-
appMeasurement.clearVars();
|
|
331
|
-
|
|
332
|
-
return true;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
function processProductsAndSetEvents(event) {
|
|
336
|
-
try {
|
|
337
|
-
var productDetails,
|
|
338
|
-
incrementor,
|
|
339
|
-
merchandising,
|
|
340
|
-
productBuilder,
|
|
341
|
-
product,
|
|
342
|
-
allProducts = [];
|
|
343
|
-
|
|
344
|
-
var expandedEvents = mParticle.eCommerce.expandCommerceEvent(event);
|
|
345
|
-
expandedEvents.forEach(function(expandedEvt) {
|
|
346
|
-
productBuilder = [];
|
|
347
|
-
productDetails = [];
|
|
348
|
-
incrementor = [];
|
|
349
|
-
merchandising = [];
|
|
350
|
-
|
|
351
|
-
if (expandedEvt.EventName === 'eCommerce - purchase - Total') {
|
|
352
|
-
for (var eventAttributeKey in expandedEvt.EventAttributes) {
|
|
353
|
-
if (
|
|
354
|
-
expandedEvt.EventAttributes.hasOwnProperty(
|
|
355
|
-
eventAttributeKey
|
|
356
|
-
)
|
|
357
|
-
) {
|
|
358
|
-
var jsHash = calculateJSHash(
|
|
359
|
-
event.EventDataType,
|
|
360
|
-
event.EventCategory,
|
|
361
|
-
eventAttributeKey
|
|
362
|
-
);
|
|
363
|
-
var mapping = findValueInMapping(
|
|
364
|
-
jsHash,
|
|
365
|
-
eventsMapping
|
|
366
|
-
);
|
|
367
|
-
if (mapping && mapping.result && mapping.matches) {
|
|
368
|
-
mapping.matches.forEach(function(mapping) {
|
|
369
|
-
if (mapping.value) {
|
|
370
|
-
if (
|
|
371
|
-
appMeasurement.events.indexOf(
|
|
372
|
-
mapping.value
|
|
373
|
-
) < 0
|
|
374
|
-
) {
|
|
375
|
-
appMeasurement.events +=
|
|
376
|
-
',' +
|
|
377
|
-
mapping.value +
|
|
378
|
-
'=' +
|
|
379
|
-
expandedEvt.EventAttributes[
|
|
380
|
-
eventAttributeKey
|
|
381
|
-
];
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
} else {
|
|
389
|
-
var productAttributes = expandedEvt.EventAttributes;
|
|
390
|
-
productDetails.push(
|
|
391
|
-
productAttributes.Category || '',
|
|
392
|
-
productAttributes.Name,
|
|
393
|
-
productAttributes.Id,
|
|
394
|
-
productAttributes.Quantity || 1,
|
|
395
|
-
productAttributes['Item Price'] || 0
|
|
396
|
-
);
|
|
397
|
-
for (var productAttributeKey in expandedEvt.EventAttributes) {
|
|
398
|
-
if (
|
|
399
|
-
expandedEvt.EventAttributes.hasOwnProperty(
|
|
400
|
-
productAttributeKey
|
|
401
|
-
)
|
|
402
|
-
) {
|
|
403
|
-
productIncrementorMapping.forEach(function(
|
|
404
|
-
productIncrementorMap
|
|
405
|
-
) {
|
|
406
|
-
if (
|
|
407
|
-
productIncrementorMap.map ===
|
|
408
|
-
productAttributeKey
|
|
409
|
-
) {
|
|
410
|
-
incrementor.push(
|
|
411
|
-
productIncrementorMap.value +
|
|
412
|
-
'=' +
|
|
413
|
-
productAttributes[
|
|
414
|
-
productAttributeKey
|
|
415
|
-
]
|
|
416
|
-
);
|
|
417
|
-
if (
|
|
418
|
-
appMeasurement.events.indexOf(
|
|
419
|
-
productIncrementorMap.value
|
|
420
|
-
) < 0
|
|
421
|
-
) {
|
|
422
|
-
appMeasurement.events +=
|
|
423
|
-
',' + productIncrementorMap.value;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
productMerchandisingMapping.forEach(function(
|
|
428
|
-
productMerchandisingMap
|
|
429
|
-
) {
|
|
430
|
-
if (
|
|
431
|
-
productMerchandisingMap.map ===
|
|
432
|
-
productAttributeKey
|
|
433
|
-
) {
|
|
434
|
-
merchandising.push(
|
|
435
|
-
productMerchandisingMap.value +
|
|
436
|
-
'=' +
|
|
437
|
-
productAttributes[
|
|
438
|
-
productAttributeKey
|
|
439
|
-
]
|
|
440
|
-
);
|
|
441
|
-
}
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
productBuilder.push(
|
|
446
|
-
productDetails.join(';'),
|
|
447
|
-
incrementor.join('|'),
|
|
448
|
-
merchandising.join('|')
|
|
449
|
-
);
|
|
450
|
-
product = productBuilder.join(';');
|
|
451
|
-
allProducts.push(product);
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
appMeasurement.products = allProducts.join(',');
|
|
456
|
-
} catch (e) {
|
|
457
|
-
window.console.log(e);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
function logPageView(event, pageName) {
|
|
462
|
-
try {
|
|
463
|
-
appMeasurement.pageName =
|
|
464
|
-
pageName || event.EventName || window.document.title;
|
|
465
|
-
appMeasurement.t();
|
|
466
|
-
appMeasurement.clearVars();
|
|
467
|
-
return true;
|
|
468
|
-
} catch (e) {
|
|
469
|
-
appMeasurement.clearVars();
|
|
470
|
-
return { error: 'logPageView not called, error ' + e };
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
function logEvent(
|
|
475
|
-
event,
|
|
476
|
-
linkTrackVars,
|
|
477
|
-
mappingMatches,
|
|
478
|
-
linkName,
|
|
479
|
-
pageName
|
|
480
|
-
) {
|
|
481
|
-
try {
|
|
482
|
-
if (mappingMatches) {
|
|
483
|
-
mappingMatches.forEach(function(match) {
|
|
484
|
-
if (appMeasurement.events.length === 0) {
|
|
485
|
-
appMeasurement.events += match.value;
|
|
486
|
-
} else {
|
|
487
|
-
appMeasurement.events += ',' + match.value;
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
|
-
appMeasurement.linkTrackEvents = appMeasurement.events;
|
|
491
|
-
|
|
492
|
-
linkTrackVars.push('events');
|
|
493
|
-
setPageName(linkTrackVars, appMeasurement, pageName);
|
|
494
|
-
|
|
495
|
-
appMeasurement.linkTrackVars = linkTrackVars;
|
|
496
|
-
|
|
497
|
-
appMeasurement.tl(true, 'o', linkName);
|
|
498
|
-
appMeasurement.clearVars();
|
|
499
|
-
return true;
|
|
500
|
-
} else {
|
|
501
|
-
appMeasurement.clearVars();
|
|
502
|
-
window.console.log(
|
|
503
|
-
'event name not mapped, aborting event logging'
|
|
504
|
-
);
|
|
505
|
-
}
|
|
506
|
-
} catch (e) {
|
|
507
|
-
appMeasurement.clearVars();
|
|
508
|
-
return { error: e };
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
// .map is the attribute passed through, .value is the eVar value
|
|
513
|
-
function setEvars(event, linkTrackVars) {
|
|
514
|
-
var eventAttributes = event.EventAttributes;
|
|
515
|
-
for (var eventAttributeKey in eventAttributes) {
|
|
516
|
-
if (eventAttributes.hasOwnProperty(eventAttributeKey)) {
|
|
517
|
-
eVarsMapping.forEach(function(eVarMap) {
|
|
518
|
-
if (eVarMap.map === eventAttributeKey) {
|
|
519
|
-
appMeasurement[eVarMap.value] =
|
|
520
|
-
eventAttributes[eventAttributeKey];
|
|
521
|
-
if (linkTrackVars) {
|
|
522
|
-
linkTrackVars.push(eVarMap.value);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
if (event.EventName === eVarMap.map) {
|
|
526
|
-
appMeasurement[eVarMap.value] = event.EventName;
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
// .map is the attribute passed through, .value is the prop value
|
|
534
|
-
function setProps(event, linkTrackVars) {
|
|
535
|
-
var eventAttributes = event.EventAttributes;
|
|
536
|
-
for (var eventAttributeKey in eventAttributes) {
|
|
537
|
-
if (eventAttributes.hasOwnProperty(eventAttributeKey)) {
|
|
538
|
-
propsMapping.forEach(function(propMap) {
|
|
539
|
-
if (propMap.map === eventAttributeKey) {
|
|
540
|
-
appMeasurement[propMap.value] =
|
|
541
|
-
eventAttributes[eventAttributeKey];
|
|
542
|
-
if (linkTrackVars) {
|
|
543
|
-
linkTrackVars.push(propMap.value);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
// .map is the attribute passed through, .value is the hier value
|
|
552
|
-
function setHiers(event, linkTrackVars) {
|
|
553
|
-
var eventAttributes = event.EventAttributes;
|
|
554
|
-
for (var eventAttributeKey in eventAttributes) {
|
|
555
|
-
if (eventAttributes.hasOwnProperty(eventAttributeKey)) {
|
|
556
|
-
var jsHash = calculateJSHash(
|
|
557
|
-
event.EventDataType,
|
|
558
|
-
event.EventCategory,
|
|
559
|
-
eventAttributeKey
|
|
560
|
-
);
|
|
561
|
-
var mapping = findValueInMapping(jsHash, hiersMapping);
|
|
562
|
-
if (mapping && mapping.result && mapping.matches) {
|
|
563
|
-
mapping.matches.forEach(function(mapping) {
|
|
564
|
-
if (mapping.value) {
|
|
565
|
-
appMeasurement[mapping.value] =
|
|
566
|
-
eventAttributes[eventAttributeKey];
|
|
567
|
-
if (linkTrackVars) {
|
|
568
|
-
linkTrackVars.push(mapping.value);
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
// .map is the attribute passed through, .value is the contextData value
|
|
578
|
-
function setContextData(event, linkTrackVars) {
|
|
579
|
-
var eventAttributes = event.EventAttributes;
|
|
580
|
-
for (var eventAttributeKey in eventAttributes) {
|
|
581
|
-
if (eventAttributes.hasOwnProperty(eventAttributeKey)) {
|
|
582
|
-
contextVariableMapping.forEach(function(contextVariableMap) {
|
|
583
|
-
if (contextVariableMap.map === eventAttributeKey) {
|
|
584
|
-
appMeasurement.contextData[contextVariableMap.value] =
|
|
585
|
-
eventAttributes[eventAttributeKey];
|
|
586
|
-
if (linkTrackVars) {
|
|
587
|
-
linkTrackVars.push(
|
|
588
|
-
'contextData.' + contextVariableMap.value
|
|
589
|
-
);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
function onUserIdentified(mpUserObject) {
|
|
598
|
-
if (isAdobeClientKitInitialized) {
|
|
599
|
-
var userIdentities = mpUserObject.getUserIdentities()
|
|
600
|
-
.userIdentities;
|
|
601
|
-
|
|
602
|
-
var identitiesToSet = {};
|
|
603
|
-
if (Object.keys(userIdentities).length) {
|
|
604
|
-
for (var identity in userIdentities) {
|
|
605
|
-
identitiesToSet[identity] = {
|
|
606
|
-
id: userIdentities[identity]
|
|
607
|
-
};
|
|
608
|
-
}
|
|
609
|
-
} else {
|
|
610
|
-
// no user identities means there was a logout, so set all current customer ids to null
|
|
611
|
-
var currentAdobeCustomerIds = appMeasurement.visitor.getCustomerIDs();
|
|
612
|
-
for (var currentIdentityKey in currentAdobeCustomerIds) {
|
|
613
|
-
identitiesToSet[currentIdentityKey] = null;
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
try {
|
|
618
|
-
appMeasurement.visitor.setCustomerIDs(identitiesToSet);
|
|
619
|
-
} catch (e) {
|
|
620
|
-
return 'Error calling setCustomerIDs on adobe';
|
|
621
|
-
}
|
|
622
|
-
} else {
|
|
623
|
-
return (
|
|
624
|
-
'Cannot call setUserIdentity on forwarder ' +
|
|
625
|
-
name +
|
|
626
|
-
', not initialized'
|
|
627
|
-
);
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
function setPageName(linkTrackVars, appMeasurement, pageName) {
|
|
632
|
-
if (settings.enablePageName === 'True') {
|
|
633
|
-
appMeasurement.pageName = pageName || window.document.title;
|
|
634
|
-
linkTrackVars.push('pageName');
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
this.init = initForwarder;
|
|
639
|
-
this.onUserIdentified = onUserIdentified;
|
|
640
|
-
this.process = processEvent;
|
|
641
|
-
};
|
|
642
|
-
|
|
643
|
-
function getId() {
|
|
644
|
-
return moduleId;
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
if (window && window.mParticle && window.mParticle.addForwarder) {
|
|
648
|
-
window.mParticle.addForwarder({
|
|
649
|
-
name: name,
|
|
650
|
-
constructor: constructor,
|
|
651
|
-
getId: getId
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
function register(config) {
|
|
656
|
-
if (!config) {
|
|
657
|
-
window.console.log(
|
|
658
|
-
'You must pass a config object to register the kit ' + name
|
|
659
|
-
);
|
|
660
|
-
return;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
if (!isObject(config)) {
|
|
664
|
-
window.console.log(
|
|
665
|
-
'`config` must be an object. You passed in a ' + typeof config
|
|
666
|
-
);
|
|
667
|
-
return;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
if (isObject(config.kits)) {
|
|
671
|
-
config.kits[name] = {
|
|
672
|
-
constructor: constructor
|
|
673
|
-
};
|
|
674
|
-
} else {
|
|
675
|
-
config.kits = {};
|
|
676
|
-
config.kits[name] = {
|
|
677
|
-
constructor: constructor
|
|
678
|
-
};
|
|
679
|
-
}
|
|
680
|
-
window.console.log(
|
|
681
|
-
'Successfully registered ' + name + ' to your mParticle configuration'
|
|
682
|
-
);
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
function isObject(val) {
|
|
686
|
-
return (
|
|
687
|
-
val != null && typeof val === 'object' && Array.isArray(val) === false
|
|
688
|
-
);
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
export default {
|
|
692
|
-
register: register
|
|
693
|
-
};
|