@mparticle/web-double-click-kit 2.1.1 → 2.1.3
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 -42
- package/package.json +1 -1
|
@@ -50,12 +50,6 @@ ConsentHandler.prototype.getUserConsentState = function () {
|
|
|
50
50
|
return userConsentState;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
ConsentHandler.prototype.getEventConsentState = function (eventConsentState) {
|
|
54
|
-
return eventConsentState && eventConsentState.getGDPRConsentState
|
|
55
|
-
? eventConsentState.getGDPRConsentState()
|
|
56
|
-
: {};
|
|
57
|
-
};
|
|
58
|
-
|
|
59
53
|
ConsentHandler.prototype.getConsentSettings = function () {
|
|
60
54
|
var consentSettings = {};
|
|
61
55
|
|
|
@@ -94,7 +88,10 @@ ConsentHandler.prototype.generateConsentStatePayloadFromMappings = function (
|
|
|
94
88
|
|
|
95
89
|
for (var i = 0; i <= mappings.length - 1; i++) {
|
|
96
90
|
var mappingEntry = mappings[i];
|
|
97
|
-
|
|
91
|
+
// Although consent purposes can be inputted into the UI in any casing
|
|
92
|
+
// the SDK will automatically lowercase them to prevent pseudo-duplicate
|
|
93
|
+
// consent purposes, so we call `toLowerCase` on the consentMapping purposes here
|
|
94
|
+
var mpMappedConsentName = mappingEntry.map.toLowerCase();
|
|
98
95
|
var googleMappedConsentName = mappingEntry.value;
|
|
99
96
|
|
|
100
97
|
if (
|
|
@@ -167,6 +164,42 @@ Common.prototype.sendGtagConsent = function (type, payload) {
|
|
|
167
164
|
gtag('consent', type, payload);
|
|
168
165
|
};
|
|
169
166
|
|
|
167
|
+
Common.prototype.getEventConsentState = function (eventConsentState) {
|
|
168
|
+
return eventConsentState && eventConsentState.getGDPRConsentState
|
|
169
|
+
? eventConsentState.getGDPRConsentState()
|
|
170
|
+
: {};
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
Common.prototype.maybeSendConsentUpdateToGoogle = function (consentState) {
|
|
174
|
+
// If consent payload is empty,
|
|
175
|
+
// we never sent an initial default consent state
|
|
176
|
+
// so we shouldn't send an update.
|
|
177
|
+
if (
|
|
178
|
+
this.consentPayloadAsString &&
|
|
179
|
+
this.consentMappings &&
|
|
180
|
+
!this.isEmpty(consentState)
|
|
181
|
+
) {
|
|
182
|
+
var updatedConsentPayload =
|
|
183
|
+
this.consentHandler.generateConsentStatePayloadFromMappings(
|
|
184
|
+
consentState,
|
|
185
|
+
this.consentMappings
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
var eventConsentAsString = JSON.stringify(updatedConsentPayload);
|
|
189
|
+
|
|
190
|
+
if (eventConsentAsString !== this.consentPayloadAsString) {
|
|
191
|
+
this.sendGtagConsent('update', updatedConsentPayload);
|
|
192
|
+
this.consentPayloadAsString = eventConsentAsString;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
Common.prototype.sendDefaultConsentPayloadToGoogle = function (consentPayload) {
|
|
198
|
+
this.consentPayloadAsString = JSON.stringify(consentPayload);
|
|
199
|
+
|
|
200
|
+
this.sendGtagConsent('default', consentPayload);
|
|
201
|
+
};
|
|
202
|
+
|
|
170
203
|
Common.prototype.cloneObject = function (obj) {
|
|
171
204
|
return JSON.parse(JSON.stringify(obj));
|
|
172
205
|
};
|
|
@@ -279,34 +312,11 @@ function EventHandler(common) {
|
|
|
279
312
|
this.common = common || {};
|
|
280
313
|
}
|
|
281
314
|
|
|
282
|
-
EventHandler.prototype.maybeSendConsentUpdateToGoogle = function (event) {
|
|
283
|
-
// If consent payload is empty,
|
|
284
|
-
// we never sent an initial default consent state
|
|
285
|
-
// so we shouldn't send an update.
|
|
286
|
-
if (this.common.consentPayloadAsString && this.common.consentMappings) {
|
|
287
|
-
var eventConsentState = this.common.consentHandler.getEventConsentState(
|
|
288
|
-
event.ConsentState
|
|
289
|
-
);
|
|
290
|
-
|
|
291
|
-
if (!this.common.isEmpty(eventConsentState)) {
|
|
292
|
-
var updatedConsentPayload =
|
|
293
|
-
this.common.consentHandler.generateConsentStatePayloadFromMappings(
|
|
294
|
-
eventConsentState,
|
|
295
|
-
this.common.consentMappings
|
|
296
|
-
);
|
|
297
|
-
|
|
298
|
-
var eventConsentAsString = JSON.stringify(updatedConsentPayload);
|
|
299
|
-
|
|
300
|
-
if (eventConsentAsString !== this.common.consentPayloadAsString) {
|
|
301
|
-
this.common.sendGtagConsent('update', updatedConsentPayload);
|
|
302
|
-
this.common.consentPayloadAsString = eventConsentAsString;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
};
|
|
307
|
-
|
|
308
315
|
EventHandler.prototype.logEvent = function (event) {
|
|
309
|
-
this.
|
|
316
|
+
var eventConsentState = this.common.getEventConsentState(
|
|
317
|
+
event.ConsentState
|
|
318
|
+
);
|
|
319
|
+
this.common.maybeSendConsentUpdateToGoogle(eventConsentState);
|
|
310
320
|
|
|
311
321
|
var gtagProperties = {};
|
|
312
322
|
this.common.setCustomVariables(event, gtagProperties);
|
|
@@ -450,20 +460,28 @@ var initialization = {
|
|
|
450
460
|
|
|
451
461
|
common.consentPayloadDefaults =
|
|
452
462
|
common.consentHandler.getConsentSettings();
|
|
453
|
-
var
|
|
454
|
-
|
|
463
|
+
var defaultConsentPayload = common.cloneObject(
|
|
464
|
+
common.consentPayloadDefaults
|
|
465
|
+
);
|
|
466
|
+
var updatedConsentState = common.consentHandler.getUserConsentState();
|
|
467
|
+
var updatedDefaultConsentPayload =
|
|
455
468
|
common.consentHandler.generateConsentStatePayloadFromMappings(
|
|
456
|
-
|
|
469
|
+
updatedConsentState,
|
|
457
470
|
common.consentMappings
|
|
458
471
|
);
|
|
459
|
-
|
|
472
|
+
|
|
473
|
+
// If a default consent payload exists (as selected in the mParticle UI), set it as the default
|
|
460
474
|
if (!common.isEmpty(defaultConsentPayload)) {
|
|
461
|
-
common.
|
|
462
|
-
|
|
475
|
+
common.sendDefaultConsentPayloadToGoogle(defaultConsentPayload);
|
|
476
|
+
// If a default consent payload does not exist, but the user currently has updated their consent,
|
|
477
|
+
// send that as the default because a default must be sent
|
|
478
|
+
} else if (!common.isEmpty(updatedDefaultConsentPayload)) {
|
|
479
|
+
common.sendDefaultConsentPayloadToGoogle(
|
|
480
|
+
updatedDefaultConsentPayload
|
|
463
481
|
);
|
|
464
|
-
|
|
465
|
-
common.sendGtagConsent('default', defaultConsentPayload);
|
|
466
482
|
}
|
|
483
|
+
|
|
484
|
+
common.maybeSendConsentUpdateToGoogle(updatedConsentState);
|
|
467
485
|
},
|
|
468
486
|
};
|
|
469
487
|
|
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.1.3",
|
|
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",
|