@mparticle/web-google-tag-manager-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/GoogleTagManager-Kit.common.js +128 -107
- package/package.json +46 -42
|
@@ -23,13 +23,16 @@ var googleConsentProperties = [
|
|
|
23
23
|
'ad_user_data',
|
|
24
24
|
'ad_personalization',
|
|
25
25
|
'analytics_storage',
|
|
26
|
+
'functionality_storage',
|
|
27
|
+
'personalization_storage',
|
|
28
|
+
'security_storage',
|
|
26
29
|
];
|
|
27
30
|
|
|
28
31
|
function ConsentHandler(common) {
|
|
29
32
|
this.common = common || {};
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
ConsentHandler.prototype.getUserConsentState = function
|
|
35
|
+
ConsentHandler.prototype.getUserConsentState = function() {
|
|
33
36
|
var userConsentState = {};
|
|
34
37
|
|
|
35
38
|
if (mParticle.Identity && mParticle.Identity.getCurrentUser) {
|
|
@@ -39,8 +42,7 @@ ConsentHandler.prototype.getUserConsentState = function () {
|
|
|
39
42
|
return {};
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
var consentState =
|
|
43
|
-
mParticle.Identity.getCurrentUser().getConsentState();
|
|
45
|
+
var consentState = mParticle.Identity.getCurrentUser().getConsentState();
|
|
44
46
|
|
|
45
47
|
if (consentState && consentState.getGDPRConsentState) {
|
|
46
48
|
userConsentState = consentState.getGDPRConsentState();
|
|
@@ -50,7 +52,7 @@ ConsentHandler.prototype.getUserConsentState = function () {
|
|
|
50
52
|
return userConsentState;
|
|
51
53
|
};
|
|
52
54
|
|
|
53
|
-
ConsentHandler.prototype.getConsentSettings = function
|
|
55
|
+
ConsentHandler.prototype.getConsentSettings = function() {
|
|
54
56
|
var consentSettings = {};
|
|
55
57
|
|
|
56
58
|
var googleToMpConsentSettingsMapping = {
|
|
@@ -58,11 +60,14 @@ ConsentHandler.prototype.getConsentSettings = function () {
|
|
|
58
60
|
ad_personalization: 'defaultAdPersonalizationConsentWeb',
|
|
59
61
|
ad_storage: 'defaultAdStorageConsentWeb',
|
|
60
62
|
analytics_storage: 'defaultAnalyticsStorageConsentWeb',
|
|
63
|
+
functionality_storage: 'defaultFunctionalityStorageConsentWeb',
|
|
64
|
+
personalization_storage: 'defaultPersonalizationStorageConsentWeb',
|
|
65
|
+
security_storage: 'defaultSecurityStorageConsentWeb',
|
|
61
66
|
};
|
|
62
67
|
|
|
63
68
|
var settings = this.common.settings;
|
|
64
69
|
|
|
65
|
-
Object.keys(googleToMpConsentSettingsMapping).forEach(function
|
|
70
|
+
Object.keys(googleToMpConsentSettingsMapping).forEach(function(
|
|
66
71
|
googleConsentKey
|
|
67
72
|
) {
|
|
68
73
|
var mpConsentSettingKey =
|
|
@@ -78,7 +83,7 @@ ConsentHandler.prototype.getConsentSettings = function () {
|
|
|
78
83
|
return consentSettings;
|
|
79
84
|
};
|
|
80
85
|
|
|
81
|
-
ConsentHandler.prototype.generateConsentStatePayloadFromMappings = function
|
|
86
|
+
ConsentHandler.prototype.generateConsentStatePayloadFromMappings = function(
|
|
82
87
|
consentState,
|
|
83
88
|
mappings
|
|
84
89
|
) {
|
|
@@ -185,7 +190,7 @@ Common.prototype.buildConsentObject = function(event) {
|
|
|
185
190
|
}
|
|
186
191
|
|
|
187
192
|
return {
|
|
188
|
-
gdpr: gdpr
|
|
193
|
+
gdpr: gdpr,
|
|
189
194
|
};
|
|
190
195
|
};
|
|
191
196
|
|
|
@@ -202,13 +207,13 @@ Common.prototype.send = function(_attributes) {
|
|
|
202
207
|
mpid: this.buildMPID(event, user),
|
|
203
208
|
consent_state: this.buildConsentObject(event),
|
|
204
209
|
attributes: this.buildUserAttributes(event, user),
|
|
205
|
-
identities: this.buildUserIdentities(event, user)
|
|
210
|
+
identities: this.buildUserIdentities(event, user),
|
|
206
211
|
};
|
|
207
212
|
|
|
208
213
|
var mpEvent = {
|
|
209
214
|
name: eventName,
|
|
210
215
|
type: attributes.eventType || 'custom_event',
|
|
211
|
-
attributes: event.EventAttributes || {}
|
|
216
|
+
attributes: event.EventAttributes || {},
|
|
212
217
|
};
|
|
213
218
|
|
|
214
219
|
payload.event = eventName;
|
|
@@ -217,7 +222,7 @@ Common.prototype.send = function(_attributes) {
|
|
|
217
222
|
device_application_stamp:
|
|
218
223
|
event.DeviceId || mParticle.getDeviceId() || '',
|
|
219
224
|
user: mpUser,
|
|
220
|
-
event: mpEvent
|
|
225
|
+
event: mpEvent,
|
|
221
226
|
};
|
|
222
227
|
|
|
223
228
|
payload.mp_data = mpData;
|
|
@@ -233,7 +238,7 @@ Common.prototype.send = function(_attributes) {
|
|
|
233
238
|
window[this.customDataLayerName].push(payload);
|
|
234
239
|
};
|
|
235
240
|
|
|
236
|
-
Common.prototype.sendConsent = function
|
|
241
|
+
Common.prototype.sendConsent = function(type, payload) {
|
|
237
242
|
// Google Tag Manager doesn't directly use the gtag function
|
|
238
243
|
// but recommends pushing directly into the dataLayer
|
|
239
244
|
// https://developers.google.com/tag-manager/devguide
|
|
@@ -245,26 +250,25 @@ Common.prototype.sendConsent = function (type, payload) {
|
|
|
245
250
|
customDataLayer('consent', type, payload);
|
|
246
251
|
};
|
|
247
252
|
|
|
248
|
-
Common.prototype.getEventConsentState = function
|
|
253
|
+
Common.prototype.getEventConsentState = function(eventConsentState) {
|
|
249
254
|
return eventConsentState && eventConsentState.getGDPRConsentState
|
|
250
255
|
? eventConsentState.getGDPRConsentState()
|
|
251
256
|
: {};
|
|
252
257
|
};
|
|
253
258
|
|
|
254
|
-
Common.prototype.maybeSendConsentUpdateToGoogle = function
|
|
259
|
+
Common.prototype.maybeSendConsentUpdateToGoogle = function(consentState) {
|
|
255
260
|
// If consent payload is empty,
|
|
256
261
|
// we never sent an initial default consent state
|
|
257
262
|
// so we shouldn't send an update.
|
|
258
263
|
if (
|
|
259
|
-
this.consentPayloadAsString &&
|
|
260
|
-
this.consentMappings &&
|
|
264
|
+
this.consentPayloadAsString &&
|
|
265
|
+
this.consentMappings &&
|
|
261
266
|
!this.isEmpty(consentState)
|
|
262
267
|
) {
|
|
263
|
-
var updatedConsentPayload =
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
);
|
|
268
|
+
var updatedConsentPayload = this.consentHandler.generateConsentStatePayloadFromMappings(
|
|
269
|
+
consentState,
|
|
270
|
+
this.consentMappings
|
|
271
|
+
);
|
|
268
272
|
|
|
269
273
|
var eventConsentAsString = JSON.stringify(updatedConsentPayload);
|
|
270
274
|
|
|
@@ -275,15 +279,13 @@ Common.prototype.maybeSendConsentUpdateToGoogle = function (consentState) {
|
|
|
275
279
|
}
|
|
276
280
|
};
|
|
277
281
|
|
|
278
|
-
Common.prototype.sendDefaultConsentPayloadToGoogle = function
|
|
279
|
-
this.consentPayloadAsString = JSON.stringify(
|
|
280
|
-
consentPayload
|
|
281
|
-
);
|
|
282
|
+
Common.prototype.sendDefaultConsentPayloadToGoogle = function(consentPayload) {
|
|
283
|
+
this.consentPayloadAsString = JSON.stringify(consentPayload);
|
|
282
284
|
|
|
283
285
|
this.sendConsent('default', consentPayload);
|
|
284
286
|
};
|
|
285
287
|
|
|
286
|
-
Common.prototype.cloneObject = function
|
|
288
|
+
Common.prototype.cloneObject = function(obj) {
|
|
287
289
|
return JSON.parse(JSON.stringify(obj));
|
|
288
290
|
};
|
|
289
291
|
|
|
@@ -302,12 +304,12 @@ var ProductActionTypes = {
|
|
|
302
304
|
Purchase: 16,
|
|
303
305
|
Refund: 17,
|
|
304
306
|
RemoveFromCart: 11,
|
|
305
|
-
ViewDetail: 15
|
|
307
|
+
ViewDetail: 15,
|
|
306
308
|
};
|
|
307
309
|
|
|
308
310
|
var PromotionType = {
|
|
309
311
|
PromotionClick: 19,
|
|
310
|
-
PromotionView: 18
|
|
312
|
+
PromotionView: 18,
|
|
311
313
|
};
|
|
312
314
|
|
|
313
315
|
function CommerceHandler(common) {
|
|
@@ -321,10 +323,12 @@ CommerceHandler.prototype.buildAddToCart = function(event) {
|
|
|
321
323
|
ecommerce: {
|
|
322
324
|
currencyCode: event.CurrencyCode || 'USD',
|
|
323
325
|
add: {
|
|
324
|
-
products: buildProductsList(
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
326
|
+
products: buildProductsList(
|
|
327
|
+
event.ProductAction.ProductList
|
|
328
|
+
),
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
},
|
|
328
332
|
};
|
|
329
333
|
};
|
|
330
334
|
CommerceHandler.prototype.buildCheckout = function(event) {
|
|
@@ -336,12 +340,14 @@ CommerceHandler.prototype.buildCheckout = function(event) {
|
|
|
336
340
|
checkout: {
|
|
337
341
|
actionField: {
|
|
338
342
|
step: event.ProductAction.CheckoutStep,
|
|
339
|
-
option: event.ProductAction.CheckoutOptions
|
|
343
|
+
option: event.ProductAction.CheckoutOptions,
|
|
340
344
|
},
|
|
341
|
-
products: buildProductsList(
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
+
products: buildProductsList(
|
|
346
|
+
event.ProductAction.ProductList
|
|
347
|
+
),
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
},
|
|
345
351
|
};
|
|
346
352
|
};
|
|
347
353
|
CommerceHandler.prototype.buildCheckoutOption = function(event) {
|
|
@@ -353,12 +359,14 @@ CommerceHandler.prototype.buildCheckoutOption = function(event) {
|
|
|
353
359
|
checkout_option: {
|
|
354
360
|
actionField: {
|
|
355
361
|
step: event.ProductAction.CheckoutStep,
|
|
356
|
-
option: event.ProductAction.CheckoutOptions
|
|
362
|
+
option: event.ProductAction.CheckoutOptions,
|
|
357
363
|
},
|
|
358
|
-
products: buildProductsList(
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
364
|
+
products: buildProductsList(
|
|
365
|
+
event.ProductAction.ProductList
|
|
366
|
+
),
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
},
|
|
362
370
|
};
|
|
363
371
|
};
|
|
364
372
|
CommerceHandler.prototype.buildRemoveFromCart = function(event) {
|
|
@@ -369,10 +377,12 @@ CommerceHandler.prototype.buildRemoveFromCart = function(event) {
|
|
|
369
377
|
ecommerce: {
|
|
370
378
|
currencyCode: event.CurrencyCode || 'USD',
|
|
371
379
|
remove: {
|
|
372
|
-
products: buildProductsList(
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
380
|
+
products: buildProductsList(
|
|
381
|
+
event.ProductAction.ProductList
|
|
382
|
+
),
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
},
|
|
376
386
|
};
|
|
377
387
|
};
|
|
378
388
|
CommerceHandler.prototype.buildImpression = function(event, impression) {
|
|
@@ -382,9 +392,9 @@ CommerceHandler.prototype.buildImpression = function(event, impression) {
|
|
|
382
392
|
eventPayload: {
|
|
383
393
|
ecommerce: {
|
|
384
394
|
currencyCode: event.CurrencyCode || 'USD',
|
|
385
|
-
impressions: buildProductsList(impression.ProductList)
|
|
386
|
-
}
|
|
387
|
-
}
|
|
395
|
+
impressions: buildProductsList(impression.ProductList),
|
|
396
|
+
},
|
|
397
|
+
},
|
|
388
398
|
};
|
|
389
399
|
};
|
|
390
400
|
CommerceHandler.prototype.buildProductClick = function(event) {
|
|
@@ -401,10 +411,12 @@ CommerceHandler.prototype.buildProductClick = function(event) {
|
|
|
401
411
|
ecommerce: {
|
|
402
412
|
click: {
|
|
403
413
|
actionField: actionField,
|
|
404
|
-
products: buildProductsList(
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
414
|
+
products: buildProductsList(
|
|
415
|
+
event.ProductAction.ProductList
|
|
416
|
+
),
|
|
417
|
+
},
|
|
418
|
+
},
|
|
419
|
+
},
|
|
408
420
|
};
|
|
409
421
|
};
|
|
410
422
|
CommerceHandler.prototype.buildProductViewDetail = function(event) {
|
|
@@ -421,10 +433,12 @@ CommerceHandler.prototype.buildProductViewDetail = function(event) {
|
|
|
421
433
|
ecommerce: {
|
|
422
434
|
detail: {
|
|
423
435
|
actionField: actionField,
|
|
424
|
-
products: buildProductsList(
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
436
|
+
products: buildProductsList(
|
|
437
|
+
event.ProductAction.ProductList
|
|
438
|
+
),
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
},
|
|
428
442
|
};
|
|
429
443
|
};
|
|
430
444
|
CommerceHandler.prototype.buildPromoClick = function(event) {
|
|
@@ -436,10 +450,10 @@ CommerceHandler.prototype.buildPromoClick = function(event) {
|
|
|
436
450
|
promoClick: {
|
|
437
451
|
promotions: buildPromoList(
|
|
438
452
|
event.PromotionAction.PromotionList
|
|
439
|
-
)
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
}
|
|
453
|
+
),
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
},
|
|
443
457
|
};
|
|
444
458
|
};
|
|
445
459
|
CommerceHandler.prototype.buildPromoView = function(event) {
|
|
@@ -451,10 +465,10 @@ CommerceHandler.prototype.buildPromoView = function(event) {
|
|
|
451
465
|
promoView: {
|
|
452
466
|
promotions: buildPromoList(
|
|
453
467
|
event.PromotionAction.PromotionList
|
|
454
|
-
)
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
}
|
|
468
|
+
),
|
|
469
|
+
},
|
|
470
|
+
},
|
|
471
|
+
},
|
|
458
472
|
};
|
|
459
473
|
};
|
|
460
474
|
CommerceHandler.prototype.buildPurchase = function(event) {
|
|
@@ -471,12 +485,12 @@ CommerceHandler.prototype.buildPurchase = function(event) {
|
|
|
471
485
|
revenue: productAction.TotalAmount || '',
|
|
472
486
|
tax: productAction.TaxAmount || '',
|
|
473
487
|
shipping: productAction.ShippingAmount || '',
|
|
474
|
-
coupon: productAction.CouponCode || ''
|
|
488
|
+
coupon: productAction.CouponCode || '',
|
|
475
489
|
},
|
|
476
|
-
products: buildProductsList(productAction.ProductList)
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
}
|
|
490
|
+
products: buildProductsList(productAction.ProductList),
|
|
491
|
+
},
|
|
492
|
+
},
|
|
493
|
+
},
|
|
480
494
|
};
|
|
481
495
|
};
|
|
482
496
|
CommerceHandler.prototype.buildRefund = function(event) {
|
|
@@ -489,12 +503,14 @@ CommerceHandler.prototype.buildRefund = function(event) {
|
|
|
489
503
|
ecommerce: {
|
|
490
504
|
refund: {
|
|
491
505
|
actionField: {
|
|
492
|
-
id: event.ProductAction.TransactionId || ''
|
|
506
|
+
id: event.ProductAction.TransactionId || '',
|
|
493
507
|
},
|
|
494
|
-
products: buildProductsList(
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
508
|
+
products: buildProductsList(
|
|
509
|
+
event.ProductAction.ProductList
|
|
510
|
+
),
|
|
511
|
+
},
|
|
512
|
+
},
|
|
513
|
+
},
|
|
498
514
|
};
|
|
499
515
|
};
|
|
500
516
|
CommerceHandler.prototype.logCommerceEvent = function(event) {
|
|
@@ -556,12 +572,16 @@ CommerceHandler.prototype.logCommerceEvent = function(event) {
|
|
|
556
572
|
|
|
557
573
|
// Utility function
|
|
558
574
|
function toUnderscore(string) {
|
|
559
|
-
return string
|
|
575
|
+
return string
|
|
576
|
+
.split(/(?=[A-Z])/)
|
|
577
|
+
.join('_')
|
|
578
|
+
.toLowerCase();
|
|
560
579
|
}
|
|
580
|
+
|
|
561
581
|
function parseProduct(_product) {
|
|
562
582
|
var product = {};
|
|
563
583
|
|
|
564
|
-
for(var key in _product) {
|
|
584
|
+
for (var key in _product) {
|
|
565
585
|
if (key === 'Sku') {
|
|
566
586
|
product.id = _product.Sku;
|
|
567
587
|
} else {
|
|
@@ -608,7 +628,7 @@ function EventHandler(common) {
|
|
|
608
628
|
this.common = common || {};
|
|
609
629
|
}
|
|
610
630
|
|
|
611
|
-
EventHandler.prototype.logEvent = function
|
|
631
|
+
EventHandler.prototype.logEvent = function(event) {
|
|
612
632
|
var eventConsentState = this.common.getEventConsentState(
|
|
613
633
|
event.ConsentState
|
|
614
634
|
);
|
|
@@ -622,14 +642,14 @@ EventHandler.prototype.logEvent = function (event) {
|
|
|
622
642
|
|
|
623
643
|
EventHandler.prototype.logError = function() {};
|
|
624
644
|
|
|
625
|
-
EventHandler.prototype.logPageView = function
|
|
645
|
+
EventHandler.prototype.logPageView = function(event) {
|
|
626
646
|
var eventConsentState = this.common.getEventConsentState(
|
|
627
647
|
event.ConsentState
|
|
628
648
|
);
|
|
629
649
|
this.common.maybeSendConsentUpdateToGoogle(eventConsentState);
|
|
630
650
|
this.common.send({
|
|
631
651
|
event: event,
|
|
632
|
-
eventType: 'screen_view'
|
|
652
|
+
eventType: 'screen_view',
|
|
633
653
|
});
|
|
634
654
|
|
|
635
655
|
return true;
|
|
@@ -663,7 +683,7 @@ function IdentityHandler(common) {
|
|
|
663
683
|
IdentityHandler.prototype.onUserIdentified = function(mParticleUser) {
|
|
664
684
|
this.common.send({
|
|
665
685
|
event: {
|
|
666
|
-
EventName: 'User Identified'
|
|
686
|
+
EventName: 'User Identified',
|
|
667
687
|
},
|
|
668
688
|
user: mParticleUser,
|
|
669
689
|
});
|
|
@@ -674,7 +694,7 @@ IdentityHandler.prototype.onIdentifyComplete = function(
|
|
|
674
694
|
) {
|
|
675
695
|
this.common.send({
|
|
676
696
|
event: {
|
|
677
|
-
EventName: 'Identify Complete'
|
|
697
|
+
EventName: 'Identify Complete',
|
|
678
698
|
},
|
|
679
699
|
user: mParticleUser,
|
|
680
700
|
});
|
|
@@ -686,7 +706,7 @@ IdentityHandler.prototype.onLoginComplete = function(
|
|
|
686
706
|
) {
|
|
687
707
|
this.common.send({
|
|
688
708
|
event: {
|
|
689
|
-
EventName: 'Login Complete'
|
|
709
|
+
EventName: 'Login Complete',
|
|
690
710
|
},
|
|
691
711
|
user: mParticleUser,
|
|
692
712
|
});
|
|
@@ -697,7 +717,7 @@ IdentityHandler.prototype.onLogoutComplete = function(
|
|
|
697
717
|
) {
|
|
698
718
|
this.common.send({
|
|
699
719
|
event: {
|
|
700
|
-
EventName: 'Logout Complete'
|
|
720
|
+
EventName: 'Logout Complete',
|
|
701
721
|
},
|
|
702
722
|
user: mParticleUser,
|
|
703
723
|
});
|
|
@@ -708,7 +728,7 @@ IdentityHandler.prototype.onModifyComplete = function(
|
|
|
708
728
|
) {
|
|
709
729
|
this.common.send({
|
|
710
730
|
event: {
|
|
711
|
-
EventName: 'Modify Complete'
|
|
731
|
+
EventName: 'Modify Complete',
|
|
712
732
|
},
|
|
713
733
|
user: mParticleUser,
|
|
714
734
|
});
|
|
@@ -796,24 +816,26 @@ var initialization = {
|
|
|
796
816
|
);
|
|
797
817
|
}
|
|
798
818
|
|
|
799
|
-
common.consentPayloadDefaults =
|
|
800
|
-
common.consentHandler.getConsentSettings();
|
|
819
|
+
common.consentPayloadDefaults = common.consentHandler.getConsentSettings();
|
|
801
820
|
|
|
802
|
-
var defaultConsentPayload = common.cloneObject(
|
|
821
|
+
var defaultConsentPayload = common.cloneObject(
|
|
822
|
+
common.consentPayloadDefaults
|
|
823
|
+
);
|
|
803
824
|
var updatedConsentState = common.consentHandler.getUserConsentState();
|
|
804
|
-
var updatedDefaultConsentPayload =
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
);
|
|
825
|
+
var updatedDefaultConsentPayload = common.consentHandler.generateConsentStatePayloadFromMappings(
|
|
826
|
+
updatedConsentState,
|
|
827
|
+
common.consentMappings
|
|
828
|
+
);
|
|
809
829
|
|
|
810
830
|
// If a default consent payload exists (as selected in the mParticle UI), set it as the default
|
|
811
831
|
if (!common.isEmpty(defaultConsentPayload)) {
|
|
812
832
|
common.sendDefaultConsentPayloadToGoogle(defaultConsentPayload);
|
|
813
|
-
|
|
814
|
-
|
|
833
|
+
// If a default consent payload does not exist, but the user currently has updated their consent,
|
|
834
|
+
// send that as the default because a default must be sent
|
|
815
835
|
} else if (!common.isEmpty(updatedDefaultConsentPayload)) {
|
|
816
|
-
common.sendDefaultConsentPayloadToGoogle(
|
|
836
|
+
common.sendDefaultConsentPayloadToGoogle(
|
|
837
|
+
updatedDefaultConsentPayload
|
|
838
|
+
);
|
|
817
839
|
}
|
|
818
840
|
|
|
819
841
|
common.maybeSendConsentUpdateToGoogle(updatedConsentState);
|
|
@@ -904,8 +926,7 @@ function sanitizeDataLayerName(_dataLayerName) {
|
|
|
904
926
|
|
|
905
927
|
function sanitizePreviewUrl(_previewUrl) {
|
|
906
928
|
var previewUrl = _previewUrl || '';
|
|
907
|
-
var regex =
|
|
908
|
-
/^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/gm;
|
|
929
|
+
var regex = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/gm;
|
|
909
930
|
return previewUrl.trim().match(regex) ? previewUrl.trim() : '';
|
|
910
931
|
}
|
|
911
932
|
|
|
@@ -917,7 +938,7 @@ var initialization_1 = initialization;
|
|
|
917
938
|
|
|
918
939
|
var sessionHandler = {
|
|
919
940
|
onSessionStart: function(event) {},
|
|
920
|
-
onSessionEnd: function(event) {}
|
|
941
|
+
onSessionEnd: function(event) {},
|
|
921
942
|
};
|
|
922
943
|
|
|
923
944
|
var sessionHandler_1 = sessionHandler;
|
|
@@ -940,11 +961,11 @@ UserAttributeHandler.prototype.onRemoveUserAttribute = function(
|
|
|
940
961
|
) {
|
|
941
962
|
this.common.send({
|
|
942
963
|
event: {
|
|
943
|
-
EventName: 'Remove User Attribute'
|
|
964
|
+
EventName: 'Remove User Attribute',
|
|
944
965
|
},
|
|
945
966
|
options: {
|
|
946
|
-
key: key
|
|
947
|
-
}
|
|
967
|
+
key: key,
|
|
968
|
+
},
|
|
948
969
|
});
|
|
949
970
|
};
|
|
950
971
|
UserAttributeHandler.prototype.onSetUserAttribute = function(
|
|
@@ -954,12 +975,12 @@ UserAttributeHandler.prototype.onSetUserAttribute = function(
|
|
|
954
975
|
) {
|
|
955
976
|
this.common.send({
|
|
956
977
|
event: {
|
|
957
|
-
EventName: 'Set User Attribute'
|
|
978
|
+
EventName: 'Set User Attribute',
|
|
958
979
|
},
|
|
959
980
|
options: {
|
|
960
981
|
key: key,
|
|
961
|
-
value: value
|
|
962
|
-
}
|
|
982
|
+
value: value,
|
|
983
|
+
},
|
|
963
984
|
});
|
|
964
985
|
};
|
|
965
986
|
UserAttributeHandler.prototype.onConsentStateUpdated = function(
|
|
@@ -969,12 +990,12 @@ UserAttributeHandler.prototype.onConsentStateUpdated = function(
|
|
|
969
990
|
) {
|
|
970
991
|
this.common.send({
|
|
971
992
|
event: {
|
|
972
|
-
EventName: 'Consent State Update'
|
|
993
|
+
EventName: 'Consent State Update',
|
|
973
994
|
},
|
|
974
995
|
options: {
|
|
975
996
|
old_state: oldState,
|
|
976
|
-
new_state: newState
|
|
977
|
-
}
|
|
997
|
+
new_state: newState,
|
|
998
|
+
},
|
|
978
999
|
});
|
|
979
1000
|
};
|
|
980
1001
|
|
package/package.json
CHANGED
|
@@ -1,44 +1,48 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
2
|
+
"name": "@mparticle/web-google-tag-manager-kit",
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/mParticle/mparticle-web-sdk",
|
|
7
|
+
"directory": "kits/google-tag-manager"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/GoogleTagManager-Kit.common.js",
|
|
10
|
+
"browser": "dist/GoogleTagManager-Kit.common.js",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist/GoogleTagManager-Kit.common.js"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "npm run build && npm run test:karma",
|
|
16
|
+
"test:karma": "node test/test-karma.js",
|
|
17
|
+
"build": "ENVIRONMENT=production rollup --config rollup.config.js",
|
|
18
|
+
"watch": "ENVIRONMENT=production rollup --config rollup.config.js -w",
|
|
19
|
+
"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"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@mparticle/web-sdk": "^3.0.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@mparticle/web-kit-wrapper": "^1.0.5",
|
|
26
|
+
"@semantic-release/changelog": "^5.0.1",
|
|
27
|
+
"@semantic-release/exec": "^5.0.0",
|
|
28
|
+
"@semantic-release/git": "^9.0.0",
|
|
29
|
+
"chai": "^4.3.4",
|
|
30
|
+
"karma": "^5.1.0",
|
|
31
|
+
"karma-chai": "^0.1.0",
|
|
32
|
+
"karma-chrome-launcher": "^2.2.0",
|
|
33
|
+
"karma-edge-launcher": "^0.4.2",
|
|
34
|
+
"karma-firefox-launcher": "^1.1.0",
|
|
35
|
+
"karma-ie-launcher": "^1.0.0",
|
|
36
|
+
"karma-junit-reporter": "^1.2.0",
|
|
37
|
+
"karma-mocha": "^1.3.0",
|
|
38
|
+
"karma-safari-launcher": "^1.0.0",
|
|
39
|
+
"mocha": "^5.2.0",
|
|
40
|
+
"mparticle-sdk-javascript": "github:mparticle/mparticle-sdk-javascript",
|
|
41
|
+
"rollup": "^1.15.6",
|
|
42
|
+
"rollup-plugin-commonjs": "^10.0.0",
|
|
43
|
+
"rollup-plugin-node-resolve": "^5.0.3",
|
|
44
|
+
"shelljs": "0.8.3",
|
|
45
|
+
"should": "13.2.3",
|
|
46
|
+
"watchify": "^3.11.0"
|
|
47
|
+
}
|
|
44
48
|
}
|