@getuserfeedback/adapters 0.4.1 → 0.4.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.
|
@@ -10,6 +10,21 @@ export type TemplateCondition = {
|
|
|
10
10
|
export type TemplateValueValidator = {
|
|
11
11
|
type: "NON_EMPTY";
|
|
12
12
|
};
|
|
13
|
+
export type TemplateSimpleTableTextColumn = {
|
|
14
|
+
defaultValue?: string;
|
|
15
|
+
displayName: string;
|
|
16
|
+
name: string;
|
|
17
|
+
type: "TEXT";
|
|
18
|
+
};
|
|
19
|
+
export type TemplateSimpleTableSelectColumn = {
|
|
20
|
+
defaultValue?: string;
|
|
21
|
+
displayName: string;
|
|
22
|
+
name: string;
|
|
23
|
+
type: "SELECT";
|
|
24
|
+
isUnique?: boolean;
|
|
25
|
+
macrosInSelect?: boolean;
|
|
26
|
+
selectItems: TemplateSelectItem[];
|
|
27
|
+
};
|
|
13
28
|
export type TemplateParameter = {
|
|
14
29
|
type: "TEXT";
|
|
15
30
|
name: string;
|
|
@@ -46,15 +61,7 @@ export type TemplateParameter = {
|
|
|
46
61
|
help?: string;
|
|
47
62
|
defaultValue?: Array<Record<string, string>>;
|
|
48
63
|
newRowButtonText: string;
|
|
49
|
-
simpleTableColumns: Array<
|
|
50
|
-
defaultValue?: string;
|
|
51
|
-
displayName: string;
|
|
52
|
-
name: string;
|
|
53
|
-
type: "SELECT";
|
|
54
|
-
isUnique?: boolean;
|
|
55
|
-
macrosInSelect?: boolean;
|
|
56
|
-
selectItems: TemplateSelectItem[];
|
|
57
|
-
}>;
|
|
64
|
+
simpleTableColumns: Array<TemplateSimpleTableTextColumn | TemplateSimpleTableSelectColumn>;
|
|
58
65
|
valueValidators?: TemplateValueValidator[];
|
|
59
66
|
enablingConditions?: TemplateCondition[];
|
|
60
67
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-generation.d.ts","sourceRoot":"","sources":["../../src/gtm/template-generation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TM_SCOPES, GTM_CONSENT_TYPES, GT
|
|
|
3
3
|
export const DEFAULT_GTM_LOADER_SCRIPT_BASE_URL = "https://cdn.getuserfeedback.com/widget/loader/v1";
|
|
4
4
|
const GTM_TEMPLATE_VERSION = 1;
|
|
5
5
|
const GTM_TEMPLATE_DEFAULT_DISPLAY_NAME = "getuserfeedback Widget";
|
|
6
|
-
const GTM_TEMPLATE_DEFAULT_DESCRIPTION = "Load the getuserfeedback widget with
|
|
6
|
+
const GTM_TEMPLATE_DEFAULT_DESCRIPTION = "Load the getuserfeedback widget with Google Tag Manager, including theme settings and consent defaults.";
|
|
7
7
|
const GTM_TEMPLATE_CATEGORIES = [
|
|
8
8
|
"SURVEY",
|
|
9
9
|
"PERSONALIZATION",
|
|
@@ -26,19 +26,34 @@ const AUTOMATIC_CONSENT_MODE_CONDITION = [
|
|
|
26
26
|
type: "EQUALS",
|
|
27
27
|
},
|
|
28
28
|
];
|
|
29
|
+
const IDENTIFY_SIMPLE_MODE_CONDITION = [
|
|
30
|
+
{
|
|
31
|
+
paramName: "identifyMode",
|
|
32
|
+
paramValue: "simple",
|
|
33
|
+
type: "EQUALS",
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
const IDENTIFY_ADVANCED_MODE_CONDITION = [
|
|
37
|
+
{
|
|
38
|
+
paramName: "identifyMode",
|
|
39
|
+
paramValue: "advanced",
|
|
40
|
+
type: "EQUALS",
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
const buildAutomaticDefaultScopeMappings = () => DEFAULT_GTM_SCOPE_MAPPINGS.filter((mapping) => isHostConfigurableGtmScope(mapping.scope)).map((mapping) => ({
|
|
44
|
+
scope: mapping.scope,
|
|
45
|
+
mapping: mapping.consentType,
|
|
46
|
+
}));
|
|
29
47
|
const buildHostConfigurableDefaultScopeMappings = () => [
|
|
30
|
-
...
|
|
31
|
-
scope: mapping.scope,
|
|
32
|
-
mapping: mapping.consentType,
|
|
33
|
-
})),
|
|
48
|
+
...buildAutomaticDefaultScopeMappings(),
|
|
34
49
|
{
|
|
35
50
|
scope: "analytics.measurement",
|
|
36
51
|
mapping: "analytics_storage",
|
|
37
52
|
},
|
|
38
53
|
];
|
|
39
54
|
const buildScopeParameterHelp = () => [
|
|
40
|
-
"
|
|
41
|
-
`${ESSENTIAL_GTM_SCOPES[0]} and ${ESSENTIAL_GTM_SCOPES[1]} always
|
|
55
|
+
"Some required widget storage settings are always enabled and do not appear here.",
|
|
56
|
+
`${ESSENTIAL_GTM_SCOPES[0]} and ${ESSENTIAL_GTM_SCOPES[1]} are always enabled so the widget can load and keep itself secure.`,
|
|
42
57
|
"",
|
|
43
58
|
...GTM_TEMPLATE_SCOPE_OPTIONS.filter((option) => isHostConfigurableGtmScope(option.scope)).map((option) => `${option.label}: ${option.description}`),
|
|
44
59
|
].join("\n");
|
|
@@ -99,7 +114,7 @@ export function buildGtmTemplateParameters(_options) {
|
|
|
99
114
|
name: "apiKey",
|
|
100
115
|
displayName: "API Key",
|
|
101
116
|
simpleValueType: true,
|
|
102
|
-
help: "Find your API key in getuserfeedback.com under Settings
|
|
117
|
+
help: "Find your API key in getuserfeedback.com under Settings → Widget.",
|
|
103
118
|
valueValidators: [NON_EMPTY_VALIDATOR],
|
|
104
119
|
},
|
|
105
120
|
{
|
|
@@ -137,7 +152,7 @@ export function buildGtmTemplateParameters(_options) {
|
|
|
137
152
|
],
|
|
138
153
|
simpleValueType: true,
|
|
139
154
|
defaultValue: "host",
|
|
140
|
-
help: "
|
|
155
|
+
help: "Choose how the widget theme is set: use a fixed mode, follow your site's theme attributes, or read the value from a GTM variable.",
|
|
141
156
|
},
|
|
142
157
|
{
|
|
143
158
|
type: "SELECT",
|
|
@@ -146,7 +161,7 @@ export function buildGtmTemplateParameters(_options) {
|
|
|
146
161
|
macrosInSelect: true,
|
|
147
162
|
selectItems: [],
|
|
148
163
|
simpleValueType: true,
|
|
149
|
-
help: "
|
|
164
|
+
help: "Use a GTM variable that resolves to `light`, `dark`, `system`, `auto`, or a comma-separated list of attribute names.",
|
|
150
165
|
enablingConditions: [
|
|
151
166
|
{
|
|
152
167
|
paramName: "themeMode",
|
|
@@ -162,7 +177,7 @@ export function buildGtmTemplateParameters(_options) {
|
|
|
162
177
|
displayName: "Host Theme Attributes",
|
|
163
178
|
simpleValueType: true,
|
|
164
179
|
defaultValue: DEFAULT_AUTO_DETECT_COLOR_SCHEME_ATTRS.join(","),
|
|
165
|
-
help: "Comma-separated attributes to inspect on `<html>` or `<body>` when
|
|
180
|
+
help: "Comma-separated attributes to inspect on `<html>` or `<body>` when matching the widget theme to your site.",
|
|
166
181
|
enablingConditions: [
|
|
167
182
|
{
|
|
168
183
|
paramName: "themeMode",
|
|
@@ -187,12 +202,12 @@ export function buildGtmTemplateParameters(_options) {
|
|
|
187
202
|
{
|
|
188
203
|
value: "automatic",
|
|
189
204
|
displayValue: "Automatic (Use GTM Consent Mode)",
|
|
190
|
-
help: "
|
|
205
|
+
help: "Use GTM consent checks to set the widget's initial consent state. This also lets you decide whether analytics measurement should follow analytics storage or use its own fixed setting.",
|
|
191
206
|
},
|
|
192
207
|
{
|
|
193
208
|
value: "manual",
|
|
194
209
|
displayValue: "Manual (Map Public Scopes)",
|
|
195
|
-
help: "
|
|
210
|
+
help: "Choose which widget consent settings are granted for each GTM consent type. Required widget storage settings stay enabled and are not configurable here.",
|
|
196
211
|
},
|
|
197
212
|
],
|
|
198
213
|
simpleValueType: true,
|
|
@@ -219,7 +234,12 @@ export function buildGtmTemplateParameters(_options) {
|
|
|
219
234
|
],
|
|
220
235
|
simpleValueType: true,
|
|
221
236
|
defaultValue: "inherit-analytics-storage",
|
|
222
|
-
help:
|
|
237
|
+
help: [
|
|
238
|
+
"Analytics measurement is separate from analytics storage so you can control event measurement independently.",
|
|
239
|
+
"Inherit analytics_storage: `analytics.measurement` matches GTM `analytics_storage`.",
|
|
240
|
+
"Always granted: `analytics.measurement` is always enabled.",
|
|
241
|
+
"Always denied: `analytics.measurement` is always disabled.",
|
|
242
|
+
].join("\n"),
|
|
223
243
|
enablingConditions: [...AUTOMATIC_CONSENT_MODE_CONDITION],
|
|
224
244
|
},
|
|
225
245
|
{
|
|
@@ -255,10 +275,90 @@ export function buildGtmTemplateParameters(_options) {
|
|
|
255
275
|
},
|
|
256
276
|
],
|
|
257
277
|
},
|
|
278
|
+
{
|
|
279
|
+
type: "GROUP",
|
|
280
|
+
name: "identifyGroup",
|
|
281
|
+
displayName: "Identify Settings",
|
|
282
|
+
groupStyle: "ZIPPY_CLOSED",
|
|
283
|
+
subParams: [
|
|
284
|
+
{
|
|
285
|
+
type: "RADIO",
|
|
286
|
+
name: "identifyMode",
|
|
287
|
+
displayName: "Identify Mode",
|
|
288
|
+
simpleValueType: true,
|
|
289
|
+
defaultValue: "disabled",
|
|
290
|
+
radioItems: [
|
|
291
|
+
{
|
|
292
|
+
value: "disabled",
|
|
293
|
+
displayValue: "Disabled",
|
|
294
|
+
help: "Do not send identify data from this GTM tag.",
|
|
295
|
+
},
|
|
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
|
+
{
|
|
302
|
+
value: "advanced",
|
|
303
|
+
displayValue: "Advanced",
|
|
304
|
+
help: "Map any traits you want from GTM variables, including email, phone, name, or plan.",
|
|
305
|
+
},
|
|
306
|
+
],
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
type: "TEXT",
|
|
310
|
+
name: "identifyUserId",
|
|
311
|
+
displayName: "User ID",
|
|
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",
|
|
323
|
+
simpleValueType: true,
|
|
324
|
+
help: "Optional. Sends `email` as an identify trait when available.",
|
|
325
|
+
enablingConditions: [...IDENTIFY_SIMPLE_MODE_CONDITION],
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
type: "TEXT",
|
|
329
|
+
name: "identifyPhone",
|
|
330
|
+
displayName: "Phone",
|
|
331
|
+
simpleValueType: true,
|
|
332
|
+
help: "Optional. Sends `phone` as an identify trait when available.",
|
|
333
|
+
enablingConditions: [...IDENTIFY_SIMPLE_MODE_CONDITION],
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
type: "SIMPLE_TABLE",
|
|
337
|
+
name: "identifyTraits",
|
|
338
|
+
displayName: "Traits",
|
|
339
|
+
help: "Add any traits you want to send from GTM variables. Common examples are `email`, `phone`, `name`, and `plan`. Empty rows are ignored.",
|
|
340
|
+
newRowButtonText: "Add Trait",
|
|
341
|
+
simpleTableColumns: [
|
|
342
|
+
{
|
|
343
|
+
displayName: "Trait Name",
|
|
344
|
+
name: "name",
|
|
345
|
+
type: "TEXT",
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
displayName: "Trait Value",
|
|
349
|
+
name: "value",
|
|
350
|
+
type: "TEXT",
|
|
351
|
+
},
|
|
352
|
+
],
|
|
353
|
+
enablingConditions: [...IDENTIFY_ADVANCED_MODE_CONDITION],
|
|
354
|
+
},
|
|
355
|
+
],
|
|
356
|
+
},
|
|
258
357
|
];
|
|
259
358
|
}
|
|
260
359
|
export function buildGtmRuntimeSource(input) {
|
|
261
360
|
const loaderScriptBaseUrl = trimTrailingSlash(input?.loaderScriptBaseUrl ?? DEFAULT_GTM_LOADER_SCRIPT_BASE_URL);
|
|
361
|
+
const automaticDefaultScopeMappings = buildAutomaticDefaultScopeMappings();
|
|
262
362
|
const defaultTemplateScopeMappings = buildHostConfigurableDefaultScopeMappings();
|
|
263
363
|
return `
|
|
264
364
|
const log = require("logToConsole");
|
|
@@ -270,6 +370,7 @@ const encodeUriComponent = require("encodeUriComponent");
|
|
|
270
370
|
|
|
271
371
|
const loaderScriptBaseUrl = ${JSON.stringify(loaderScriptBaseUrl)};
|
|
272
372
|
const gtmConsentTypes = ${JSON.stringify(GTM_CONSENT_TYPES)};
|
|
373
|
+
const automaticDefaultScopeMappings = ${JSON.stringify(automaticDefaultScopeMappings)};
|
|
273
374
|
const defaultScopeMappings = ${JSON.stringify(defaultTemplateScopeMappings)};
|
|
274
375
|
const hostConfigurableScopes = ${JSON.stringify(defaultTemplateScopeMappings.map((row) => row.scope))};
|
|
275
376
|
const defaultAutoDetectColorSchemeAttrs = ${JSON.stringify(DEFAULT_AUTO_DETECT_COLOR_SCHEME_ATTRS)};
|
|
@@ -321,6 +422,100 @@ const normalizeThemeInput = function(inputValue) {
|
|
|
321
422
|
return undefined;
|
|
322
423
|
};
|
|
323
424
|
|
|
425
|
+
const isListLike = function(value) {
|
|
426
|
+
return (
|
|
427
|
+
!!value &&
|
|
428
|
+
typeof value.length === "number" &&
|
|
429
|
+
typeof value.map === "function"
|
|
430
|
+
);
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
const normalizeTraitValue = function(value) {
|
|
434
|
+
if (value === undefined || value === null) {
|
|
435
|
+
return undefined;
|
|
436
|
+
}
|
|
437
|
+
if (typeof value === "string") {
|
|
438
|
+
const trimmedValue = value.trim();
|
|
439
|
+
return trimmedValue ? trimmedValue : undefined;
|
|
440
|
+
}
|
|
441
|
+
return value;
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
const addTrait = function(result, name, value) {
|
|
445
|
+
const traitName = trimString(name);
|
|
446
|
+
const traitValue = normalizeTraitValue(value);
|
|
447
|
+
if (!traitName || traitValue === undefined) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
result[traitName] = traitValue;
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
const getSimpleIdentifyTraits = function(templateData) {
|
|
454
|
+
const traits = {};
|
|
455
|
+
addTrait(traits, "email", templateData.identifyEmail);
|
|
456
|
+
addTrait(traits, "phone", templateData.identifyPhone);
|
|
457
|
+
return traits;
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
const getAdvancedIdentifyTraits = function(templateData) {
|
|
461
|
+
const traits = {};
|
|
462
|
+
const rows = isListLike(templateData.identifyTraits)
|
|
463
|
+
? templateData.identifyTraits
|
|
464
|
+
: [];
|
|
465
|
+
for (let index = 0; index < rows.length; index += 1) {
|
|
466
|
+
const row = rows[index];
|
|
467
|
+
if (!row || typeof row !== "object") {
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
addTrait(traits, row.name, row.value);
|
|
471
|
+
}
|
|
472
|
+
return traits;
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
const hasOwnKeys = function(value) {
|
|
476
|
+
for (const key in value) {
|
|
477
|
+
return !!key;
|
|
478
|
+
}
|
|
479
|
+
return false;
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
const getIdentifyCommand = function(templateData) {
|
|
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);
|
|
495
|
+
const hasTraits = hasOwnKeys(traits);
|
|
496
|
+
|
|
497
|
+
if (userId && hasTraits) {
|
|
498
|
+
return {
|
|
499
|
+
kind: "identify",
|
|
500
|
+
userId: userId,
|
|
501
|
+
traits: traits,
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
if (userId) {
|
|
505
|
+
return {
|
|
506
|
+
kind: "identify",
|
|
507
|
+
userId: userId,
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
if (hasTraits) {
|
|
511
|
+
return {
|
|
512
|
+
kind: "identify",
|
|
513
|
+
traits: traits,
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
return undefined;
|
|
517
|
+
};
|
|
518
|
+
|
|
324
519
|
const getThemeInput = function(templateData) {
|
|
325
520
|
if (templateData.themeMode === "variable") {
|
|
326
521
|
return templateData.themeModeVariable;
|
|
@@ -381,14 +576,6 @@ const isHostConfigurableScope = function(scope) {
|
|
|
381
576
|
return false;
|
|
382
577
|
};
|
|
383
578
|
|
|
384
|
-
const isListLike = function(value) {
|
|
385
|
-
return (
|
|
386
|
-
!!value &&
|
|
387
|
-
typeof value.length === "number" &&
|
|
388
|
-
typeof value.map === "function"
|
|
389
|
-
);
|
|
390
|
-
};
|
|
391
|
-
|
|
392
579
|
const getManualScopeMappings = function(templateData) {
|
|
393
580
|
const rawRows = isListLike(templateData.scopeMappings)
|
|
394
581
|
? templateData.scopeMappings
|
|
@@ -440,8 +627,8 @@ const buildDefaultConsent = function(templateData) {
|
|
|
440
627
|
}
|
|
441
628
|
}
|
|
442
629
|
} else {
|
|
443
|
-
for (let index = 0; index <
|
|
444
|
-
const mapping =
|
|
630
|
+
for (let index = 0; index < automaticDefaultScopeMappings.length; index += 1) {
|
|
631
|
+
const mapping = automaticDefaultScopeMappings[index];
|
|
445
632
|
if (consentState[mapping.mapping] === "granted") {
|
|
446
633
|
grantedScopes.push(mapping.scope);
|
|
447
634
|
}
|
|
@@ -512,6 +699,11 @@ queuePush({
|
|
|
512
699
|
opts: initOptions,
|
|
513
700
|
});
|
|
514
701
|
|
|
702
|
+
const identifyCommand = getIdentifyCommand(data);
|
|
703
|
+
if (identifyCommand !== undefined) {
|
|
704
|
+
queuePush(identifyCommand);
|
|
705
|
+
}
|
|
706
|
+
|
|
515
707
|
log("Loading getuserfeedback loader:", widgetUrl);
|
|
516
708
|
|
|
517
709
|
if (queryPermission("inject_script", widgetUrl)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getuserfeedback/adapters",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "getuserfeedback integration adapters",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"getuserfeedback",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"publish:npm": "node ../../scripts/publish-package.cjs . --expect-dependency @getuserfeedback/protocol:../protocol/package.json"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@getuserfeedback/protocol": "^0.2.
|
|
38
|
+
"@getuserfeedback/protocol": "^0.2.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"rimraf": "^6.0.0",
|