@mparticle/web-double-click-kit 2.1.3 → 2.2.1
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.
|
@@ -120,6 +120,7 @@ function Common() {
|
|
|
120
120
|
|
|
121
121
|
Common.prototype.eventMapping = {};
|
|
122
122
|
Common.prototype.customVariablesMappings = {};
|
|
123
|
+
Common.prototype.customFieldMappings = {};
|
|
123
124
|
Common.prototype.settings = {};
|
|
124
125
|
Common.prototype.setCustomVariables = function(event, gtagProperties) {
|
|
125
126
|
for (var attribute in event.EventAttributes) {
|
|
@@ -129,6 +130,20 @@ Common.prototype.setCustomVariables = function(event, gtagProperties) {
|
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
};
|
|
133
|
+
Common.prototype.setCustomFields = function(event, gtagProperties) {
|
|
134
|
+
var dc_custom_params = {};
|
|
135
|
+
var hasMappings = false;
|
|
136
|
+
for (var attribute in event.EventAttributes) {
|
|
137
|
+
if (this.customFieldMappings[attribute]) {
|
|
138
|
+
dc_custom_params[this.customFieldMappings[attribute]] =
|
|
139
|
+
event.EventAttributes[attribute];
|
|
140
|
+
hasMappings = true;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (hasMappings) {
|
|
144
|
+
gtagProperties["dc_custom_params"] = dc_custom_params;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
132
147
|
Common.prototype.setSendTo = function(mapping, customFlags, gtagProperties) {
|
|
133
148
|
var tags = mapping.value.split(';');
|
|
134
149
|
var groupTag = tags[0];
|
|
@@ -320,6 +335,7 @@ EventHandler.prototype.logEvent = function (event) {
|
|
|
320
335
|
|
|
321
336
|
var gtagProperties = {};
|
|
322
337
|
this.common.setCustomVariables(event, gtagProperties);
|
|
338
|
+
this.common.setCustomFields(event, gtagProperties);
|
|
323
339
|
var eventMapping = this.common.getEventMapping(event);
|
|
324
340
|
|
|
325
341
|
if (!eventMapping) {
|
|
@@ -494,13 +510,27 @@ function initializeGoogleDFP(common, settings, isInitialized) {
|
|
|
494
510
|
a[b.map] = b.value;
|
|
495
511
|
return a;
|
|
496
512
|
}, {});
|
|
513
|
+
common.customFieldMappings = parseSettingsString(
|
|
514
|
+
settings.customParams
|
|
515
|
+
).reduce(function (a, b) {
|
|
516
|
+
a[b.map] = b.value;
|
|
517
|
+
return a;
|
|
518
|
+
}, {});
|
|
497
519
|
common.sendGtag('js', new Date(), true);
|
|
498
520
|
common.sendGtag('allow_custom_scripts', true, true);
|
|
499
521
|
common.sendGtag('config', settings.advertiserId, true);
|
|
500
522
|
}
|
|
501
523
|
|
|
502
524
|
function parseSettingsString(settingsString) {
|
|
503
|
-
|
|
525
|
+
if (!settingsString) {
|
|
526
|
+
return [];
|
|
527
|
+
}
|
|
528
|
+
try {
|
|
529
|
+
return JSON.parse(settingsString.replace(/"/g, '"'));
|
|
530
|
+
} catch (error) {
|
|
531
|
+
console.error('Settings string contains invalid JSON');
|
|
532
|
+
}
|
|
533
|
+
return [];
|
|
504
534
|
}
|
|
505
535
|
|
|
506
536
|
var initialization_1 = initialization;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mparticle/web-double-click-kit",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"repository": "https://github.com/mparticle-integrations/mparticle-javascript-integration-doubleclick",
|
|
5
5
|
"main": "dist/DoubleClick-Kit.common.js",
|
|
6
6
|
"browser": "dist/DoubleClick-Kit.common.js",
|