@getuserfeedback/adapters 0.4.0 → 0.4.2

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,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,sBAAsB,EAAE,CAAC;IAC3C,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACxC,GACD;IACA,IAAI,EAAE,QAAQ,CAAC;IACf,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,cAAc,EAAE,OAAO,CAAC;IACxB,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAClC,eAAe,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAC3C,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACxC,GACD;IACA,IAAI,EAAE,OAAO,CA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B,EAAE,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAEnD,MAAM,MAAM,4BAA4B,GAAG;IAC1C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,kCAAkC,qDACI,CAAC;AA+HpD,wBAAgB,0BAA0B,CACzC,QAAQ,CAAC,EAAE,4BAA4B,GACrC,iBAAiB,EAAE,CA0KrB;AAED,wBAAgB,qBAAqB,CACpC,KAAK,CAAC,EAAE,4BAA4B,GAClC,MAAM,CAiQR;AAED,wBAAgB,mBAAmB,CAClC,KAAK,CAAC,EAAE,4BAA4B,GAClC,qBAAqB,EAAE,CA+CzB;AAED,wBAAgB,oBAAoB,CACnC,KAAK,CAAC,EAAE,4BAA4B,GAClC,eAAe,CASjB;AAED,wBAAgB,qBAAqB,CACpC,KAAK,CAAC,EAAE,4BAA4B,GAClC,gBAAgB,CAOlB;AAED,wBAAgB,wBAAwB,CACvC,KAAK,CAAC,EAAE,4BAA4B,GAClC,mBAAmB,CAErB"}
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,iBAAiB,GAC1B;IACA,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAA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CAAC,EAAE,4BAA4B,GAClC,gBAAgB,CAOlB;AAED,wBAAgB,wBAAwB,CACvC,KAAK,CAAC,EAAE,4BAA4B,GAClC,mBAAmB,CAErB"}
@@ -3,7 +3,7 @@ import { DEFAULT_GTM_SCOPE_MAPPINGS, ESSENTIAL_GTM_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 modern loader, theme, and GTM Consent Mode defaults derived from the public protocol contract.";
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,20 @@ const AUTOMATIC_CONSENT_MODE_CONDITION = [
26
26
  type: "EQUALS",
27
27
  },
28
28
  ];
29
+ const buildAutomaticDefaultScopeMappings = () => DEFAULT_GTM_SCOPE_MAPPINGS.filter((mapping) => isHostConfigurableGtmScope(mapping.scope)).map((mapping) => ({
30
+ scope: mapping.scope,
31
+ mapping: mapping.consentType,
32
+ }));
29
33
  const buildHostConfigurableDefaultScopeMappings = () => [
30
- ...DEFAULT_GTM_SCOPE_MAPPINGS.filter((mapping) => isHostConfigurableGtmScope(mapping.scope)).map((mapping) => ({
31
- scope: mapping.scope,
32
- mapping: mapping.consentType,
33
- })),
34
+ ...buildAutomaticDefaultScopeMappings(),
34
35
  {
35
36
  scope: "analytics.measurement",
36
37
  mapping: "analytics_storage",
37
38
  },
38
39
  ];
39
40
  const buildScopeParameterHelp = () => [
40
- "Essential scopes are fixed by the loader and are not exposed for GTM override.",
41
- `${ESSENTIAL_GTM_SCOPES[0]} and ${ESSENTIAL_GTM_SCOPES[1]} always remain baseline scopes outside the GTM template UI.`,
41
+ "Some required widget storage settings are always enabled and do not appear here.",
42
+ `${ESSENTIAL_GTM_SCOPES[0]} and ${ESSENTIAL_GTM_SCOPES[1]} are always enabled so the widget can load and keep itself secure.`,
42
43
  "",
43
44
  ...GTM_TEMPLATE_SCOPE_OPTIONS.filter((option) => isHostConfigurableGtmScope(option.scope)).map((option) => `${option.label}: ${option.description}`),
44
45
  ].join("\n");
@@ -99,7 +100,7 @@ export function buildGtmTemplateParameters(_options) {
99
100
  name: "apiKey",
100
101
  displayName: "API Key",
101
102
  simpleValueType: true,
102
- help: "Find your API key in getuserfeedback.com under Settings -> Widget.",
103
+ help: "Find your API key in getuserfeedback.com under Settings Widget.",
103
104
  valueValidators: [NON_EMPTY_VALIDATOR],
104
105
  },
105
106
  {
@@ -137,7 +138,7 @@ export function buildGtmTemplateParameters(_options) {
137
138
  ],
138
139
  simpleValueType: true,
139
140
  defaultValue: "host",
140
- help: "Generate protocol-valid `init.opts.colorScheme` using fixed modes, host auto-detect attributes, or a GTM variable.",
141
+ 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
142
  },
142
143
  {
143
144
  type: "SELECT",
@@ -146,7 +147,7 @@ export function buildGtmTemplateParameters(_options) {
146
147
  macrosInSelect: true,
147
148
  selectItems: [],
148
149
  simpleValueType: true,
149
- help: "Variable must resolve to `light`, `dark`, `system`, `auto`, or a comma-separated attribute list.",
150
+ help: "Use a GTM variable that resolves to `light`, `dark`, `system`, `auto`, or a comma-separated list of attribute names.",
150
151
  enablingConditions: [
151
152
  {
152
153
  paramName: "themeMode",
@@ -162,7 +163,7 @@ export function buildGtmTemplateParameters(_options) {
162
163
  displayName: "Host Theme Attributes",
163
164
  simpleValueType: true,
164
165
  defaultValue: DEFAULT_AUTO_DETECT_COLOR_SCHEME_ATTRS.join(","),
165
- help: "Comma-separated attributes to inspect on `<html>` or `<body>` when syncing the widget to host theme state.",
166
+ help: "Comma-separated attributes to inspect on `<html>` or `<body>` when matching the widget theme to your site.",
166
167
  enablingConditions: [
167
168
  {
168
169
  paramName: "themeMode",
@@ -187,12 +188,12 @@ export function buildGtmTemplateParameters(_options) {
187
188
  {
188
189
  value: "automatic",
189
190
  displayValue: "Automatic (Use GTM Consent Mode)",
190
- help: "Read GTM consent mode via `isConsentGranted`, translate granted consent types into widget `defaultConsent`, and apply the explicit analytics measurement policy.",
191
+ 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
192
  },
192
193
  {
193
194
  value: "manual",
194
195
  displayValue: "Manual (Map Public Scopes)",
195
- help: "Override host-configurable widget consent scopes with explicit GTM consent mappings. Essential scopes remain fixed by the loader and are never configurable here.",
196
+ 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
197
  },
197
198
  ],
198
199
  simpleValueType: true,
@@ -219,7 +220,12 @@ export function buildGtmTemplateParameters(_options) {
219
220
  ],
220
221
  simpleValueType: true,
221
222
  defaultValue: "inherit-analytics-storage",
222
- help: "Controls whether `analytics.measurement` follows GTM `analytics_storage` or is forced on/off in automatic mode.",
223
+ help: [
224
+ "Analytics measurement is separate from analytics storage so you can control event measurement independently.",
225
+ "Inherit analytics_storage: `analytics.measurement` matches GTM `analytics_storage`.",
226
+ "Always granted: `analytics.measurement` is always enabled.",
227
+ "Always denied: `analytics.measurement` is always disabled.",
228
+ ].join("\n"),
223
229
  enablingConditions: [...AUTOMATIC_CONSENT_MODE_CONDITION],
224
230
  },
225
231
  {
@@ -259,6 +265,7 @@ export function buildGtmTemplateParameters(_options) {
259
265
  }
260
266
  export function buildGtmRuntimeSource(input) {
261
267
  const loaderScriptBaseUrl = trimTrailingSlash(input?.loaderScriptBaseUrl ?? DEFAULT_GTM_LOADER_SCRIPT_BASE_URL);
268
+ const automaticDefaultScopeMappings = buildAutomaticDefaultScopeMappings();
262
269
  const defaultTemplateScopeMappings = buildHostConfigurableDefaultScopeMappings();
263
270
  return `
264
271
  const log = require("logToConsole");
@@ -266,9 +273,11 @@ const injectScript = require("injectScript");
266
273
  const queryPermission = require("queryPermission");
267
274
  const createQueue = require("createQueue");
268
275
  const isConsentGranted = require("isConsentGranted");
276
+ const encodeUriComponent = require("encodeUriComponent");
269
277
 
270
278
  const loaderScriptBaseUrl = ${JSON.stringify(loaderScriptBaseUrl)};
271
279
  const gtmConsentTypes = ${JSON.stringify(GTM_CONSENT_TYPES)};
280
+ const automaticDefaultScopeMappings = ${JSON.stringify(automaticDefaultScopeMappings)};
272
281
  const defaultScopeMappings = ${JSON.stringify(defaultTemplateScopeMappings)};
273
282
  const hostConfigurableScopes = ${JSON.stringify(defaultTemplateScopeMappings.map((row) => row.scope))};
274
283
  const defaultAutoDetectColorSchemeAttrs = ${JSON.stringify(DEFAULT_AUTO_DETECT_COLOR_SCHEME_ATTRS)};
@@ -380,8 +389,16 @@ const isHostConfigurableScope = function(scope) {
380
389
  return false;
381
390
  };
382
391
 
392
+ const isListLike = function(value) {
393
+ return (
394
+ !!value &&
395
+ typeof value.length === "number" &&
396
+ typeof value.map === "function"
397
+ );
398
+ };
399
+
383
400
  const getManualScopeMappings = function(templateData) {
384
- const rawRows = Array.isArray(templateData.scopeMappings)
401
+ const rawRows = isListLike(templateData.scopeMappings)
385
402
  ? templateData.scopeMappings
386
403
  : [];
387
404
  const rows = rawRows.length > 0 ? rawRows : defaultScopeMappings;
@@ -431,8 +448,8 @@ const buildDefaultConsent = function(templateData) {
431
448
  }
432
449
  }
433
450
  } else {
434
- for (let index = 0; index < defaultScopeMappings.length; index += 1) {
435
- const mapping = defaultScopeMappings[index];
451
+ for (let index = 0; index < automaticDefaultScopeMappings.length; index += 1) {
452
+ const mapping = automaticDefaultScopeMappings[index];
436
453
  if (consentState[mapping.mapping] === "granted") {
437
454
  grantedScopes.push(mapping.scope);
438
455
  }
@@ -472,8 +489,13 @@ if (!apiKey) {
472
489
  return;
473
490
  }
474
491
 
475
- const widgetUrl =
476
- loaderScriptBaseUrl + "/" + encodeURIComponent(apiKey) + "/loader.js";
492
+ const encodedApiKey = encodeUriComponent(apiKey);
493
+ if (!encodedApiKey) {
494
+ onFailure();
495
+ return;
496
+ }
497
+
498
+ const widgetUrl = loaderScriptBaseUrl + "/" + encodedApiKey + "/loader.js";
477
499
  const queuePush = createQueue(queueKey);
478
500
  const initOptions = {
479
501
  apiKey: apiKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getuserfeedback/adapters",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
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.0"
38
+ "@getuserfeedback/protocol": "^0.2.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "rimraf": "^6.0.0",