@getuserfeedback/adapters 0.4.3 → 0.4.5
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-generation.d.ts","sourceRoot":"","sources":["../../src/gtm/template-generation.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,kBAAkB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACpC,IAAI,EAAE,WAAW,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE,kBAAkB,EAAE,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAC1B;IACA,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,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BAAqB,CACpC,KAAK,CAAC,EAAE,4BAA4B,GAClC,gBAAgB,CAOlB;AAED,wBAAgB,wBAAwB,CACvC,KAAK,CAAC,EAAE,4BAA4B,GAClC,mBAAmB,CAErB"}
|
|
@@ -26,18 +26,48 @@ const AUTOMATIC_CONSENT_MODE_CONDITION = [
|
|
|
26
26
|
type: "EQUALS",
|
|
27
27
|
},
|
|
28
28
|
];
|
|
29
|
-
const
|
|
29
|
+
const IDENTIFY_ADVANCED_MODE_CONDITION = [
|
|
30
30
|
{
|
|
31
31
|
paramName: "identifyMode",
|
|
32
|
-
paramValue: "
|
|
32
|
+
paramValue: "advanced",
|
|
33
33
|
type: "EQUALS",
|
|
34
34
|
},
|
|
35
35
|
];
|
|
36
|
-
const
|
|
36
|
+
const INTELLIGENT_IDENTIFY_USER_ID_KEYS = [
|
|
37
|
+
"userId",
|
|
38
|
+
"user.userId",
|
|
39
|
+
"user.id",
|
|
40
|
+
"traits.userId",
|
|
41
|
+
"traits.id",
|
|
42
|
+
"context.userId",
|
|
43
|
+
"context.user.id",
|
|
44
|
+
];
|
|
45
|
+
const INTELLIGENT_IDENTIFY_EMAIL_KEYS = [
|
|
46
|
+
"email",
|
|
47
|
+
"user.email",
|
|
48
|
+
"traits.email",
|
|
49
|
+
"context.email",
|
|
50
|
+
"context.user.email",
|
|
51
|
+
];
|
|
52
|
+
const INTELLIGENT_IDENTIFY_PHONE_KEYS = [
|
|
53
|
+
"phone",
|
|
54
|
+
"user.phone",
|
|
55
|
+
"traits.phone",
|
|
56
|
+
"context.phone",
|
|
57
|
+
"context.user.phone",
|
|
58
|
+
];
|
|
59
|
+
const ADVANCED_PRIMARY_IDENTITY_SELECT_ITEMS = [
|
|
37
60
|
{
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
61
|
+
displayValue: "User ID",
|
|
62
|
+
value: "userId",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
displayValue: "Phone",
|
|
66
|
+
value: "phone",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
displayValue: "Email",
|
|
70
|
+
value: "email",
|
|
41
71
|
},
|
|
42
72
|
];
|
|
43
73
|
const buildAutomaticDefaultScopeMappings = () => DEFAULT_GTM_SCOPE_MAPPINGS.filter((mapping) => isHostConfigurableGtmScope(mapping.scope)).map((mapping) => ({
|
|
@@ -278,59 +308,51 @@ export function buildGtmTemplateParameters(_options) {
|
|
|
278
308
|
{
|
|
279
309
|
type: "GROUP",
|
|
280
310
|
name: "identifyGroup",
|
|
281
|
-
displayName: "
|
|
311
|
+
displayName: "User Identity",
|
|
282
312
|
groupStyle: "ZIPPY_CLOSED",
|
|
283
313
|
subParams: [
|
|
284
314
|
{
|
|
285
315
|
type: "RADIO",
|
|
286
316
|
name: "identifyMode",
|
|
287
|
-
displayName: "
|
|
317
|
+
displayName: "Identification mode",
|
|
288
318
|
simpleValueType: true,
|
|
289
|
-
defaultValue: "
|
|
319
|
+
defaultValue: "intelligent",
|
|
290
320
|
radioItems: [
|
|
321
|
+
{
|
|
322
|
+
value: "intelligent",
|
|
323
|
+
displayValue: "Intelligent",
|
|
324
|
+
help: "Automatically read common data layer keys for user ID, email, and phone. User ID is sent as `identify(userId)` and email or phone stay as raw traits.",
|
|
325
|
+
},
|
|
291
326
|
{
|
|
292
327
|
value: "disabled",
|
|
293
328
|
displayValue: "Disabled",
|
|
294
329
|
help: "Do not send identify data from this GTM tag.",
|
|
295
330
|
},
|
|
296
|
-
{
|
|
297
|
-
value: "simple",
|
|
298
|
-
displayValue: "Simple",
|
|
299
|
-
help: "Send a stable user ID and common traits like email or phone from GTM variables.",
|
|
300
|
-
},
|
|
301
331
|
{
|
|
302
332
|
value: "advanced",
|
|
303
333
|
displayValue: "Advanced",
|
|
304
|
-
help: "
|
|
334
|
+
help: "Choose how GTM encodes the primary identity and add any extra traits you want to send from GTM variables.",
|
|
305
335
|
},
|
|
306
336
|
],
|
|
307
337
|
},
|
|
308
338
|
{
|
|
309
|
-
type: "
|
|
310
|
-
name: "
|
|
311
|
-
displayName: "
|
|
312
|
-
simpleValueType: true,
|
|
313
|
-
help: "Use a GTM variable that resolves to the signed-in user's stable ID. If GTM is loaded through Segment, this is often a data layer variable for `userId`.",
|
|
314
|
-
enablingConditions: [
|
|
315
|
-
...IDENTIFY_SIMPLE_MODE_CONDITION,
|
|
316
|
-
...IDENTIFY_ADVANCED_MODE_CONDITION,
|
|
317
|
-
],
|
|
318
|
-
},
|
|
319
|
-
{
|
|
320
|
-
type: "TEXT",
|
|
321
|
-
name: "identifyEmail",
|
|
322
|
-
displayName: "Email",
|
|
339
|
+
type: "SELECT",
|
|
340
|
+
name: "identifyPrimaryIdentityType",
|
|
341
|
+
displayName: "Primary identity",
|
|
323
342
|
simpleValueType: true,
|
|
324
|
-
|
|
325
|
-
|
|
343
|
+
macrosInSelect: false,
|
|
344
|
+
defaultValue: "userId",
|
|
345
|
+
selectItems: [...ADVANCED_PRIMARY_IDENTITY_SELECT_ITEMS],
|
|
346
|
+
help: "Choose whether GTM should encode the primary identity as `identify(userId)` or as a raw identity trait like `email` or `phone`.",
|
|
347
|
+
enablingConditions: [...IDENTIFY_ADVANCED_MODE_CONDITION],
|
|
326
348
|
},
|
|
327
349
|
{
|
|
328
350
|
type: "TEXT",
|
|
329
|
-
name: "
|
|
330
|
-
displayName: "
|
|
351
|
+
name: "identifyPrimaryIdentityValue",
|
|
352
|
+
displayName: "Primary identity value",
|
|
331
353
|
simpleValueType: true,
|
|
332
|
-
help: "
|
|
333
|
-
enablingConditions: [...
|
|
354
|
+
help: "Use a GTM variable that resolves to the selected primary identity value.",
|
|
355
|
+
enablingConditions: [...IDENTIFY_ADVANCED_MODE_CONDITION],
|
|
334
356
|
},
|
|
335
357
|
{
|
|
336
358
|
type: "SIMPLE_TABLE",
|
|
@@ -367,6 +389,7 @@ const queryPermission = require("queryPermission");
|
|
|
367
389
|
const createQueue = require("createQueue");
|
|
368
390
|
const isConsentGranted = require("isConsentGranted");
|
|
369
391
|
const encodeUriComponent = require("encodeUriComponent");
|
|
392
|
+
const copyFromDataLayer = require("copyFromDataLayer");
|
|
370
393
|
|
|
371
394
|
const loaderScriptBaseUrl = ${JSON.stringify(loaderScriptBaseUrl)};
|
|
372
395
|
const gtmConsentTypes = ${JSON.stringify(GTM_CONSENT_TYPES)};
|
|
@@ -375,6 +398,9 @@ const defaultScopeMappings = ${JSON.stringify(defaultTemplateScopeMappings)};
|
|
|
375
398
|
const hostConfigurableScopes = ${JSON.stringify(defaultTemplateScopeMappings.map((row) => row.scope))};
|
|
376
399
|
const defaultAutoDetectColorSchemeAttrs = ${JSON.stringify(DEFAULT_AUTO_DETECT_COLOR_SCHEME_ATTRS)};
|
|
377
400
|
const queueKey = ${JSON.stringify(GTM_QUEUE_KEY)};
|
|
401
|
+
const intelligentIdentifyUserIdKeys = ${JSON.stringify(INTELLIGENT_IDENTIFY_USER_ID_KEYS)};
|
|
402
|
+
const intelligentIdentifyEmailKeys = ${JSON.stringify(INTELLIGENT_IDENTIFY_EMAIL_KEYS)};
|
|
403
|
+
const intelligentIdentifyPhoneKeys = ${JSON.stringify(INTELLIGENT_IDENTIFY_PHONE_KEYS)};
|
|
378
404
|
|
|
379
405
|
const trimString = function(value) {
|
|
380
406
|
return typeof value === "string" ? value.trim() : "";
|
|
@@ -422,12 +448,29 @@ const normalizeThemeInput = function(inputValue) {
|
|
|
422
448
|
return undefined;
|
|
423
449
|
};
|
|
424
450
|
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
451
|
+
const getSimpleTableRows = function(value) {
|
|
452
|
+
const maxSimpleTableRowCount = 1000;
|
|
453
|
+
const length = value && typeof value === "object" ? value.length : undefined;
|
|
454
|
+
if (
|
|
455
|
+
!value ||
|
|
456
|
+
typeof value !== "object" ||
|
|
457
|
+
typeof length !== "number" ||
|
|
458
|
+
length <= 0 ||
|
|
459
|
+
length > maxSimpleTableRowCount ||
|
|
460
|
+
length % 1 !== 0
|
|
461
|
+
) {
|
|
462
|
+
return [];
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
const rows = [];
|
|
466
|
+
for (let index = 0; index < length; index += 1) {
|
|
467
|
+
const row = value[index];
|
|
468
|
+
if (!row || typeof row !== "object") {
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
rows.push(row);
|
|
472
|
+
}
|
|
473
|
+
return rows;
|
|
431
474
|
};
|
|
432
475
|
|
|
433
476
|
const normalizeTraitValue = function(value) {
|
|
@@ -441,6 +484,15 @@ const normalizeTraitValue = function(value) {
|
|
|
441
484
|
return value;
|
|
442
485
|
};
|
|
443
486
|
|
|
487
|
+
const normalizeUserIdValue = function(value) {
|
|
488
|
+
if (typeof value !== "string") {
|
|
489
|
+
return undefined;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
const trimmedValue = value.trim();
|
|
493
|
+
return trimmedValue ? trimmedValue : undefined;
|
|
494
|
+
};
|
|
495
|
+
|
|
444
496
|
const addTrait = function(result, name, value) {
|
|
445
497
|
const traitName = trimString(name);
|
|
446
498
|
const traitValue = normalizeTraitValue(value);
|
|
@@ -450,18 +502,33 @@ const addTrait = function(result, name, value) {
|
|
|
450
502
|
result[traitName] = traitValue;
|
|
451
503
|
};
|
|
452
504
|
|
|
453
|
-
const
|
|
505
|
+
const getIntelligentIdentifyValue = function(keys) {
|
|
506
|
+
for (let index = 0; index < keys.length; index += 1) {
|
|
507
|
+
const key = keys[index];
|
|
508
|
+
if (!queryPermission("read_data_layer", key)) {
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
const value = copyFromDataLayer(key);
|
|
513
|
+
const normalizedValue = normalizeTraitValue(value);
|
|
514
|
+
if (normalizedValue !== undefined) {
|
|
515
|
+
return normalizedValue;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
return undefined;
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
const getIntelligentIdentifyTraits = function() {
|
|
454
523
|
const traits = {};
|
|
455
|
-
addTrait(traits, "email",
|
|
456
|
-
addTrait(traits, "phone",
|
|
524
|
+
addTrait(traits, "email", getIntelligentIdentifyValue(intelligentIdentifyEmailKeys));
|
|
525
|
+
addTrait(traits, "phone", getIntelligentIdentifyValue(intelligentIdentifyPhoneKeys));
|
|
457
526
|
return traits;
|
|
458
527
|
};
|
|
459
528
|
|
|
460
529
|
const getAdvancedIdentifyTraits = function(templateData) {
|
|
461
530
|
const traits = {};
|
|
462
|
-
const rows =
|
|
463
|
-
? templateData.identifyTraits
|
|
464
|
-
: [];
|
|
531
|
+
const rows = getSimpleTableRows(templateData.identifyTraits);
|
|
465
532
|
for (let index = 0; index < rows.length; index += 1) {
|
|
466
533
|
const row = rows[index];
|
|
467
534
|
if (!row || typeof row !== "object") {
|
|
@@ -479,19 +546,7 @@ const hasOwnKeys = function(value) {
|
|
|
479
546
|
return false;
|
|
480
547
|
};
|
|
481
548
|
|
|
482
|
-
const
|
|
483
|
-
if (
|
|
484
|
-
templateData.identifyMode !== "simple" &&
|
|
485
|
-
templateData.identifyMode !== "advanced"
|
|
486
|
-
) {
|
|
487
|
-
return undefined;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
const userId = trimString(templateData.identifyUserId);
|
|
491
|
-
const traits =
|
|
492
|
-
templateData.identifyMode === "advanced"
|
|
493
|
-
? getAdvancedIdentifyTraits(templateData)
|
|
494
|
-
: getSimpleIdentifyTraits(templateData);
|
|
549
|
+
const getIdentifyCommandFromUserIdAndTraits = function(userId, traits) {
|
|
495
550
|
const hasTraits = hasOwnKeys(traits);
|
|
496
551
|
|
|
497
552
|
if (userId && hasTraits) {
|
|
@@ -516,6 +571,51 @@ const getIdentifyCommand = function(templateData) {
|
|
|
516
571
|
return undefined;
|
|
517
572
|
};
|
|
518
573
|
|
|
574
|
+
const getIntelligentIdentifyCommand = function() {
|
|
575
|
+
const userId = normalizeUserIdValue(
|
|
576
|
+
getIntelligentIdentifyValue(intelligentIdentifyUserIdKeys),
|
|
577
|
+
);
|
|
578
|
+
const traits = getIntelligentIdentifyTraits();
|
|
579
|
+
return getIdentifyCommandFromUserIdAndTraits(userId, traits);
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
const getAdvancedIdentifyCommand = function(templateData) {
|
|
583
|
+
const traits = getAdvancedIdentifyTraits(templateData);
|
|
584
|
+
const primaryIdentityType = trimString(templateData.identifyPrimaryIdentityType);
|
|
585
|
+
const primaryIdentityValue = normalizeTraitValue(
|
|
586
|
+
templateData.identifyPrimaryIdentityValue,
|
|
587
|
+
);
|
|
588
|
+
|
|
589
|
+
if (primaryIdentityType === "userId") {
|
|
590
|
+
const userId = normalizeUserIdValue(primaryIdentityValue);
|
|
591
|
+
return getIdentifyCommandFromUserIdAndTraits(userId, traits);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
if (
|
|
595
|
+
primaryIdentityType === "email" ||
|
|
596
|
+
primaryIdentityType === "phone"
|
|
597
|
+
) {
|
|
598
|
+
addTrait(traits, primaryIdentityType, primaryIdentityValue);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
return hasOwnKeys(traits)
|
|
602
|
+
? {
|
|
603
|
+
kind: "identify",
|
|
604
|
+
traits: traits,
|
|
605
|
+
}
|
|
606
|
+
: undefined;
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
const getIdentifyCommand = function(templateData) {
|
|
610
|
+
if (templateData.identifyMode === "intelligent") {
|
|
611
|
+
return getIntelligentIdentifyCommand();
|
|
612
|
+
}
|
|
613
|
+
if (templateData.identifyMode === "advanced") {
|
|
614
|
+
return getAdvancedIdentifyCommand(templateData);
|
|
615
|
+
}
|
|
616
|
+
return undefined;
|
|
617
|
+
};
|
|
618
|
+
|
|
519
619
|
const getThemeInput = function(templateData) {
|
|
520
620
|
if (templateData.themeMode === "variable") {
|
|
521
621
|
return templateData.themeModeVariable;
|
|
@@ -577,31 +677,28 @@ const isHostConfigurableScope = function(scope) {
|
|
|
577
677
|
};
|
|
578
678
|
|
|
579
679
|
const getManualScopeMappings = function(templateData) {
|
|
580
|
-
const rawRows =
|
|
581
|
-
? templateData.scopeMappings
|
|
582
|
-
: [];
|
|
680
|
+
const rawRows = getSimpleTableRows(templateData.scopeMappings);
|
|
583
681
|
const rows = rawRows.length > 0 ? rawRows : defaultScopeMappings;
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
})
|
|
602
|
-
.filter(function(row) {
|
|
603
|
-
return row !== undefined;
|
|
682
|
+
const mappings = [];
|
|
683
|
+
for (let index = 0; index < rows.length; index += 1) {
|
|
684
|
+
const row = rows[index];
|
|
685
|
+
if (!row || typeof row !== "object") {
|
|
686
|
+
continue;
|
|
687
|
+
}
|
|
688
|
+
const scope = trimString(row.scope);
|
|
689
|
+
const consentType = trimString(row.mapping);
|
|
690
|
+
if (!scope || !consentType) {
|
|
691
|
+
continue;
|
|
692
|
+
}
|
|
693
|
+
if (!isHostConfigurableScope(scope) || !isKnownConsentType(consentType)) {
|
|
694
|
+
continue;
|
|
695
|
+
}
|
|
696
|
+
mappings.push({
|
|
697
|
+
scope: scope,
|
|
698
|
+
consentType: consentType,
|
|
604
699
|
});
|
|
700
|
+
}
|
|
701
|
+
return mappings;
|
|
605
702
|
};
|
|
606
703
|
|
|
607
704
|
const getAnalyticsMeasurementMode = function(templateData) {
|
|
@@ -752,6 +849,16 @@ export function buildGtmPermissions(input) {
|
|
|
752
849
|
]))),
|
|
753
850
|
},
|
|
754
851
|
]),
|
|
852
|
+
buildPermission("read_data_layer", [
|
|
853
|
+
{
|
|
854
|
+
key: "keyPatterns",
|
|
855
|
+
value: listValue([
|
|
856
|
+
...INTELLIGENT_IDENTIFY_USER_ID_KEYS,
|
|
857
|
+
...INTELLIGENT_IDENTIFY_EMAIL_KEYS,
|
|
858
|
+
...INTELLIGENT_IDENTIFY_PHONE_KEYS,
|
|
859
|
+
].map((key) => stringValue(key))),
|
|
860
|
+
},
|
|
861
|
+
]),
|
|
755
862
|
];
|
|
756
863
|
}
|
|
757
864
|
export function buildGtmTemplateInfo(input) {
|