@mparticle/web-double-click-kit 2.2.0 → 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/DoubleClick-Kit.common.js +60 -46
- package/package.json +7 -3
|
@@ -29,7 +29,7 @@ function ConsentHandler(common) {
|
|
|
29
29
|
this.common = common || {};
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
ConsentHandler.prototype.getUserConsentState = function
|
|
32
|
+
ConsentHandler.prototype.getUserConsentState = function() {
|
|
33
33
|
var userConsentState = {};
|
|
34
34
|
|
|
35
35
|
if (mParticle.Identity && mParticle.Identity.getCurrentUser) {
|
|
@@ -39,8 +39,7 @@ ConsentHandler.prototype.getUserConsentState = function () {
|
|
|
39
39
|
return {};
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
var consentState =
|
|
43
|
-
mParticle.Identity.getCurrentUser().getConsentState();
|
|
42
|
+
var consentState = mParticle.Identity.getCurrentUser().getConsentState();
|
|
44
43
|
|
|
45
44
|
if (consentState && consentState.getGDPRConsentState) {
|
|
46
45
|
userConsentState = consentState.getGDPRConsentState();
|
|
@@ -50,7 +49,7 @@ ConsentHandler.prototype.getUserConsentState = function () {
|
|
|
50
49
|
return userConsentState;
|
|
51
50
|
};
|
|
52
51
|
|
|
53
|
-
ConsentHandler.prototype.getConsentSettings = function
|
|
52
|
+
ConsentHandler.prototype.getConsentSettings = function() {
|
|
54
53
|
var consentSettings = {};
|
|
55
54
|
|
|
56
55
|
var googleToMpConsentSettingsMapping = {
|
|
@@ -62,7 +61,7 @@ ConsentHandler.prototype.getConsentSettings = function () {
|
|
|
62
61
|
|
|
63
62
|
var settings = this.common.settings;
|
|
64
63
|
|
|
65
|
-
Object.keys(googleToMpConsentSettingsMapping).forEach(function
|
|
64
|
+
Object.keys(googleToMpConsentSettingsMapping).forEach(function(
|
|
66
65
|
googleConsentKey
|
|
67
66
|
) {
|
|
68
67
|
var mpConsentSettingKey =
|
|
@@ -78,7 +77,7 @@ ConsentHandler.prototype.getConsentSettings = function () {
|
|
|
78
77
|
return consentSettings;
|
|
79
78
|
};
|
|
80
79
|
|
|
81
|
-
ConsentHandler.prototype.generateConsentStatePayloadFromMappings = function
|
|
80
|
+
ConsentHandler.prototype.generateConsentStatePayloadFromMappings = function(
|
|
82
81
|
consentState,
|
|
83
82
|
mappings
|
|
84
83
|
) {
|
|
@@ -141,7 +140,7 @@ Common.prototype.setCustomFields = function(event, gtagProperties) {
|
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
142
|
if (hasMappings) {
|
|
144
|
-
gtagProperties[
|
|
143
|
+
gtagProperties['dc_custom_params'] = dc_custom_params;
|
|
145
144
|
}
|
|
146
145
|
};
|
|
147
146
|
Common.prototype.setSendTo = function(mapping, customFlags, gtagProperties) {
|
|
@@ -172,20 +171,20 @@ Common.prototype.sendGtag = function(type, properties, isInitialization) {
|
|
|
172
171
|
}
|
|
173
172
|
};
|
|
174
173
|
|
|
175
|
-
Common.prototype.sendGtagConsent = function
|
|
174
|
+
Common.prototype.sendGtagConsent = function(type, payload) {
|
|
176
175
|
function gtag() {
|
|
177
176
|
window.dataLayer.push(arguments);
|
|
178
177
|
}
|
|
179
178
|
gtag('consent', type, payload);
|
|
180
179
|
};
|
|
181
180
|
|
|
182
|
-
Common.prototype.getEventConsentState = function
|
|
181
|
+
Common.prototype.getEventConsentState = function(eventConsentState) {
|
|
183
182
|
return eventConsentState && eventConsentState.getGDPRConsentState
|
|
184
183
|
? eventConsentState.getGDPRConsentState()
|
|
185
184
|
: {};
|
|
186
185
|
};
|
|
187
186
|
|
|
188
|
-
Common.prototype.maybeSendConsentUpdateToGoogle = function
|
|
187
|
+
Common.prototype.maybeSendConsentUpdateToGoogle = function(consentState) {
|
|
189
188
|
// If consent payload is empty,
|
|
190
189
|
// we never sent an initial default consent state
|
|
191
190
|
// so we shouldn't send an update.
|
|
@@ -194,11 +193,10 @@ Common.prototype.maybeSendConsentUpdateToGoogle = function (consentState) {
|
|
|
194
193
|
this.consentMappings &&
|
|
195
194
|
!this.isEmpty(consentState)
|
|
196
195
|
) {
|
|
197
|
-
var updatedConsentPayload =
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
);
|
|
196
|
+
var updatedConsentPayload = this.consentHandler.generateConsentStatePayloadFromMappings(
|
|
197
|
+
consentState,
|
|
198
|
+
this.consentMappings
|
|
199
|
+
);
|
|
202
200
|
|
|
203
201
|
var eventConsentAsString = JSON.stringify(updatedConsentPayload);
|
|
204
202
|
|
|
@@ -209,13 +207,13 @@ Common.prototype.maybeSendConsentUpdateToGoogle = function (consentState) {
|
|
|
209
207
|
}
|
|
210
208
|
};
|
|
211
209
|
|
|
212
|
-
Common.prototype.sendDefaultConsentPayloadToGoogle = function
|
|
210
|
+
Common.prototype.sendDefaultConsentPayloadToGoogle = function(consentPayload) {
|
|
213
211
|
this.consentPayloadAsString = JSON.stringify(consentPayload);
|
|
214
212
|
|
|
215
213
|
this.sendGtagConsent('default', consentPayload);
|
|
216
214
|
};
|
|
217
215
|
|
|
218
|
-
Common.prototype.cloneObject = function
|
|
216
|
+
Common.prototype.cloneObject = function(obj) {
|
|
219
217
|
return JSON.parse(JSON.stringify(obj));
|
|
220
218
|
};
|
|
221
219
|
|
|
@@ -237,14 +235,14 @@ function findValueInMapping(jsHash, mapping) {
|
|
|
237
235
|
}
|
|
238
236
|
|
|
239
237
|
return {
|
|
240
|
-
result: false
|
|
238
|
+
result: false,
|
|
241
239
|
};
|
|
242
240
|
});
|
|
243
241
|
|
|
244
242
|
if (filteredArray && filteredArray.length > 0) {
|
|
245
243
|
return {
|
|
246
244
|
result: true,
|
|
247
|
-
match: filteredArray[0]
|
|
245
|
+
match: filteredArray[0],
|
|
248
246
|
};
|
|
249
247
|
}
|
|
250
248
|
}
|
|
@@ -259,7 +257,7 @@ function calculateJSHash(eventDataType, eventCategory, name) {
|
|
|
259
257
|
|
|
260
258
|
var salesCounterTypes = {
|
|
261
259
|
transactions: 1,
|
|
262
|
-
items_sold: 1
|
|
260
|
+
items_sold: 1,
|
|
263
261
|
};
|
|
264
262
|
var ITEMS_SOLD = 'items_sold';
|
|
265
263
|
|
|
@@ -320,14 +318,14 @@ var commerceHandler = CommerceHandler;
|
|
|
320
318
|
var eventCounterTypes = {
|
|
321
319
|
standard: 1,
|
|
322
320
|
unique: 1,
|
|
323
|
-
per_session: 1
|
|
321
|
+
per_session: 1,
|
|
324
322
|
};
|
|
325
323
|
|
|
326
324
|
function EventHandler(common) {
|
|
327
325
|
this.common = common || {};
|
|
328
326
|
}
|
|
329
327
|
|
|
330
|
-
EventHandler.prototype.logEvent = function
|
|
328
|
+
EventHandler.prototype.logEvent = function(event) {
|
|
331
329
|
var eventConsentState = this.common.getEventConsentState(
|
|
332
330
|
event.ConsentState
|
|
333
331
|
);
|
|
@@ -433,7 +431,16 @@ var identityHandler = IdentityHandler;
|
|
|
433
431
|
var initialization = {
|
|
434
432
|
name: 'DoubleclickDFP',
|
|
435
433
|
moduleId: 41,
|
|
436
|
-
initForwarder: function(
|
|
434
|
+
initForwarder: function(
|
|
435
|
+
settings,
|
|
436
|
+
testMode,
|
|
437
|
+
userAttributes,
|
|
438
|
+
userIdentities,
|
|
439
|
+
processEvent,
|
|
440
|
+
eventQueue,
|
|
441
|
+
isInitialized,
|
|
442
|
+
common
|
|
443
|
+
) {
|
|
437
444
|
common.settings = settings;
|
|
438
445
|
|
|
439
446
|
if (common.settings.consentMappingWeb) {
|
|
@@ -450,13 +457,18 @@ var initialization = {
|
|
|
450
457
|
|
|
451
458
|
window.dataLayer = window.dataLayer || [];
|
|
452
459
|
if (!testMode) {
|
|
453
|
-
var url =
|
|
460
|
+
var url =
|
|
461
|
+
'https://www.googletagmanager.com/gtag/js?id=' +
|
|
462
|
+
settings.advertiserId;
|
|
454
463
|
|
|
455
464
|
var gTagScript = document.createElement('script');
|
|
456
465
|
gTagScript.type = 'text/javascript';
|
|
457
466
|
gTagScript.async = true;
|
|
458
467
|
gTagScript.src = url;
|
|
459
|
-
(
|
|
468
|
+
(
|
|
469
|
+
document.getElementsByTagName('head')[0] ||
|
|
470
|
+
document.getElementsByTagName('body')[0]
|
|
471
|
+
).appendChild(gTagScript);
|
|
460
472
|
gTagScript.onload = function() {
|
|
461
473
|
|
|
462
474
|
initializeGoogleDFP(common, settings);
|
|
@@ -466,7 +478,7 @@ var initialization = {
|
|
|
466
478
|
for (var i = 0; i < eventQueue.length; i++) {
|
|
467
479
|
processEvent(eventQueue[i]);
|
|
468
480
|
}
|
|
469
|
-
|
|
481
|
+
// now that each queued event is processed, we empty the eventQueue
|
|
470
482
|
eventQueue = [];
|
|
471
483
|
}
|
|
472
484
|
};
|
|
@@ -474,29 +486,27 @@ var initialization = {
|
|
|
474
486
|
initializeGoogleDFP(common, settings);
|
|
475
487
|
}
|
|
476
488
|
|
|
477
|
-
common.consentPayloadDefaults =
|
|
478
|
-
common.consentHandler.getConsentSettings();
|
|
489
|
+
common.consentPayloadDefaults = common.consentHandler.getConsentSettings();
|
|
479
490
|
var defaultConsentPayload = common.cloneObject(
|
|
480
491
|
common.consentPayloadDefaults
|
|
481
492
|
);
|
|
482
493
|
var updatedConsentState = common.consentHandler.getUserConsentState();
|
|
483
|
-
var updatedDefaultConsentPayload =
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
494
|
+
var updatedDefaultConsentPayload = common.consentHandler.generateConsentStatePayloadFromMappings(
|
|
495
|
+
updatedConsentState,
|
|
496
|
+
common.consentMappings
|
|
497
|
+
);
|
|
498
|
+
|
|
489
499
|
// If a default consent payload exists (as selected in the mParticle UI), set it as the default
|
|
490
500
|
if (!common.isEmpty(defaultConsentPayload)) {
|
|
491
501
|
common.sendDefaultConsentPayloadToGoogle(defaultConsentPayload);
|
|
492
|
-
|
|
493
|
-
|
|
502
|
+
// If a default consent payload does not exist, but the user currently has updated their consent,
|
|
503
|
+
// send that as the default because a default must be sent
|
|
494
504
|
} else if (!common.isEmpty(updatedDefaultConsentPayload)) {
|
|
495
505
|
common.sendDefaultConsentPayloadToGoogle(
|
|
496
506
|
updatedDefaultConsentPayload
|
|
497
507
|
);
|
|
498
508
|
}
|
|
499
|
-
|
|
509
|
+
|
|
500
510
|
common.maybeSendConsentUpdateToGoogle(updatedConsentState);
|
|
501
511
|
},
|
|
502
512
|
};
|
|
@@ -506,13 +516,13 @@ function initializeGoogleDFP(common, settings, isInitialized) {
|
|
|
506
516
|
|
|
507
517
|
common.customVariablesMappings = parseSettingsString(
|
|
508
518
|
settings.customVariables
|
|
509
|
-
).reduce(function
|
|
519
|
+
).reduce(function(a, b) {
|
|
510
520
|
a[b.map] = b.value;
|
|
511
521
|
return a;
|
|
512
522
|
}, {});
|
|
513
523
|
common.customFieldMappings = parseSettingsString(
|
|
514
524
|
settings.customParams
|
|
515
|
-
).reduce(function
|
|
525
|
+
).reduce(function(a, b) {
|
|
516
526
|
a[b.map] = b.value;
|
|
517
527
|
return a;
|
|
518
528
|
}, {});
|
|
@@ -522,18 +532,22 @@ function initializeGoogleDFP(common, settings, isInitialized) {
|
|
|
522
532
|
}
|
|
523
533
|
|
|
524
534
|
function parseSettingsString(settingsString) {
|
|
525
|
-
|
|
535
|
+
if (!settingsString) {
|
|
536
|
+
return [];
|
|
537
|
+
}
|
|
538
|
+
try {
|
|
539
|
+
return JSON.parse(settingsString.replace(/"/g, '"'));
|
|
540
|
+
} catch (error) {
|
|
541
|
+
console.error('Settings string contains invalid JSON');
|
|
542
|
+
}
|
|
543
|
+
return [];
|
|
526
544
|
}
|
|
527
545
|
|
|
528
546
|
var initialization_1 = initialization;
|
|
529
547
|
|
|
530
548
|
var sessionHandler = {
|
|
531
|
-
onSessionStart: function(event) {
|
|
532
|
-
|
|
533
|
-
},
|
|
534
|
-
onSessionEnd: function(event) {
|
|
535
|
-
|
|
536
|
-
}
|
|
549
|
+
onSessionStart: function(event) {},
|
|
550
|
+
onSessionEnd: function(event) {},
|
|
537
551
|
};
|
|
538
552
|
|
|
539
553
|
var sessionHandler_1 = sessionHandler;
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mparticle/web-double-click-kit",
|
|
3
|
-
"version": "
|
|
4
|
-
"repository":
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/mParticle/mparticle-web-sdk",
|
|
7
|
+
"directory": "kits/doubleclick"
|
|
8
|
+
},
|
|
5
9
|
"main": "dist/DoubleClick-Kit.common.js",
|
|
6
10
|
"browser": "dist/DoubleClick-Kit.common.js",
|
|
7
11
|
"files": [
|
|
@@ -17,7 +21,7 @@
|
|
|
17
21
|
"testEndToEnd": "browserify node_modules/@mparticle/web-kit-wrapper/end-to-end-testapp/index.js -v -o test/end-to-end-testapp/build/compilation.js && open http://localhost:8082/node_modules/@mparticle/web-kit-wrapper/end-to-end-testapp/index.html && node node_modules/@mparticle/web-kit-wrapper/end-to-end-testapp/server"
|
|
18
22
|
},
|
|
19
23
|
"devDependencies": {
|
|
20
|
-
"@mparticle/web-sdk": "^
|
|
24
|
+
"@mparticle/web-sdk": "^3.0.0",
|
|
21
25
|
"@semantic-release/changelog": "^5.0.1",
|
|
22
26
|
"@semantic-release/exec": "^5.0.0",
|
|
23
27
|
"@semantic-release/git": "^9.0.0",
|