@getuserfeedback/adapters 0.5.0 → 0.5.1

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.
Files changed (2) hide show
  1. package/README.md +48 -43
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -6,25 +6,20 @@
6
6
 
7
7
  The `@getuserfeedback/adapters/gtm` entrypoint is the authoritative source for Google Tag Manager template generation. It owns:
8
8
 
9
- - GTM consent mapping logic
10
- - GTM theme normalization logic
9
+ - GTM color scheme normalization logic
11
10
  - GTM template parameter generation
12
11
  - GTM runtime source generation
13
12
  - GTM permission generation
13
+ - GTM importable `template.tpl` file generation
14
14
  - GTM template defaults, help text, and option labels
15
15
  - the canonical loader script base URL pattern
16
16
 
17
17
  ### Public exports
18
18
 
19
- Core mappings:
19
+ Template inputs and init translation:
20
20
 
21
21
  - `GTM_CONSENT_TYPES`
22
- - `ESSENTIAL_GTM_SCOPES`
23
- - `DEFAULT_GTM_SCOPE_MAPPINGS`
24
- - `GTM_TEMPLATE_SCOPE_OPTIONS`
25
- - `GTM_TEMPLATE_MAPPING_OPTIONS`
26
22
  - `isGtmConsentType(value)`
27
- - `isHostConfigurableGtmScope(scope)`
28
23
  - `normalizeGtmThemeInput(input)`
29
24
  - `resolveDefaultConsentFromGtm(input)`
30
25
  - `buildInitOptionsFromGtmTemplate(input)`
@@ -34,11 +29,7 @@ Types:
34
29
  - `GtmConsentType`
35
30
  - `GtmConsentValue`
36
31
  - `GtmConsentState`
37
- - `GtmScopeMapping`
38
- - `GtmAnalyticsMeasurementMode`
39
32
  - `GtmTemplateInput`
40
- - `GtmTemplateScopeOption`
41
- - `GtmTemplateMappingOption`
42
33
 
43
34
  Template generation:
44
35
 
@@ -49,29 +40,19 @@ Template generation:
49
40
  - `buildGtmTemplateInfo(options?)`
50
41
  - `buildGtmTemplateParts(options?)`
51
42
  - `buildGtmTemplateArtifact(options?)`
43
+ - `buildGtmTemplateFileSource(options?)`
52
44
 
53
- ### Essential scope policy
45
+ ### Consent behavior
54
46
 
55
- `functionality.storage` and `security.storage` are essential baseline scopes.
47
+ The GTM template no longer exposes consent settings in its UI.
56
48
 
57
- - They remain accepted by the protocol for backward compatibility.
58
- - They are not host-configurable in GTM-generated consent UI.
59
- - They are not emitted in GTM-generated host-overridable default consent output.
60
- - Generated help text states that they are fixed by the loader.
49
+ - Default consent is derived automatically from Google Consent Mode state.
50
+ - `analytics.measurement` follows `analytics.storage`.
51
+ - If no GTM consent state is available, the adapter leaves `defaultConsent` unset.
61
52
 
62
- ### Analytics measurement policy
53
+ ### Color scheme behavior
63
54
 
64
- Automatic GTM consent mode exposes an explicit analytics measurement policy:
65
-
66
- - `inherit-analytics-storage`
67
- - `granted`
68
- - `denied`
69
-
70
- Manual GTM consent mode does not apply hidden analytics measurement behavior. It only uses the generated host-configurable scope mappings.
71
-
72
- ### Theme behavior
73
-
74
- Generated GTM theme support accepts:
55
+ Generated GTM color scheme support accepts:
75
56
 
76
57
  - fixed `light`
77
58
  - fixed `dark`
@@ -80,35 +61,56 @@ Generated GTM theme support accepts:
80
61
  - GTM variable-driven values
81
62
  - comma-separated auto-detect attribute lists
82
63
 
83
- The adapter normalizes all theme inputs into protocol-valid `colorScheme`.
64
+ The adapter normalizes all of these into protocol-valid `colorScheme`.
84
65
 
85
- ### Generate a GTM template artifact
66
+ ### Identity behavior
67
+
68
+ The generated template supports:
69
+
70
+ - `Intelligent` mode, which reads common data-layer keys for user ID, email, phone, first name, and last name
71
+ - `Custom` mode, which lets GTM explicitly map a main identity and traits
72
+ - `Disabled` mode, which skips identify entirely
73
+
74
+ ### Generate GTM output
86
75
 
87
76
  ```ts
88
- import { buildGtmTemplateArtifact } from "@getuserfeedback/adapters/gtm";
77
+ import {
78
+ buildGtmTemplateArtifact,
79
+ buildGtmTemplateFileSource,
80
+ } from "@getuserfeedback/adapters/gtm";
89
81
 
90
82
  const artifact = buildGtmTemplateArtifact({
91
83
  loaderScriptBaseUrl: "https://cdn.getuserfeedback.com/widget/loader/v1",
92
84
  });
93
85
 
94
- artifact.info;
95
- artifact.parameters;
96
- artifact.runtimeSource;
97
- artifact.permissions;
86
+ const templateFile = buildGtmTemplateFileSource({
87
+ loaderScriptBaseUrl: "https://cdn.getuserfeedback.com/widget/loader/v1",
88
+ });
89
+ ```
90
+
91
+ Use the package script to write a local importable file:
92
+
93
+ ```sh
94
+ bun run generate:gtm-template
98
95
  ```
99
96
 
100
- The returned object is suitable for rendering into GTM `___INFO___`, `___TEMPLATE_PARAMETERS___`, `___SANDBOXED_JS_FOR_WEB_TEMPLATE___`, and `___WEB_PERMISSIONS___` sections.
97
+ For the sandbox-backed GTM smoke:
98
+
99
+ ```sh
100
+ bun run generate:gtm-template:sandbox-hybrid
101
+ ```
102
+
103
+ `buildGtmTemplateArtifact()` returns the rendered GTM sections. `buildGtmTemplateFileSource()` returns a full importable `template.tpl`.
101
104
 
102
105
  ### What the GTM repo should still own
103
106
 
104
107
  After importing the published package, the GTM repo should only own:
105
108
 
106
- - GTM Gallery wrapper file assembly
107
109
  - brand thumbnail and base64 image assets
108
110
  - `metadata.yaml`
109
111
  - publishing and release workflow
110
112
 
111
- It should not rebuild parameters, runtime source, permissions, or GTM-specific init payload translation.
113
+ It should not rebuild parameters, runtime source, permissions, file assembly, or GTM-specific init payload translation.
112
114
 
113
115
  ### Customizing the loader base URL
114
116
 
@@ -118,9 +120,12 @@ Pass `loaderScriptBaseUrl` to:
118
120
  - `buildGtmPermissions`
119
121
  - `buildGtmTemplateParts`
120
122
  - `buildGtmTemplateArtifact`
123
+ - `buildGtmTemplateFileSource`
121
124
 
122
125
  The same base URL is used to derive the runtime loader URL and the `inject_script` permission pattern.
123
126
 
127
+ Pass `runtimeEndpoints` when you need the generated template to point loader bootstrap at non-default `core` and `api` endpoints.
128
+
124
129
  ### Versioning expectations
125
130
 
126
131
  Any change that affects generated GTM output is a public package change and should be versioned accordingly. This includes:
@@ -128,8 +133,8 @@ Any change that affects generated GTM output is a public package change and shou
128
133
  - parameter shape or defaults
129
134
  - runtime behavior
130
135
  - permission generation
131
- - default mappings
132
- - essential-scope exposure
133
- - analytics measurement behavior
136
+ - color scheme normalization
137
+ - identity lookup behavior
138
+ - consent derivation behavior
134
139
 
135
140
  Release notes should call out template-affecting changes explicitly.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getuserfeedback/adapters",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "getuserfeedback integration adapters",
5
5
  "keywords": [
6
6
  "getuserfeedback",
@@ -38,7 +38,7 @@
38
38
  "publish:npm": "node ../../scripts/publish-package.cjs . --expect-dependency @getuserfeedback/protocol:../protocol/package.json"
39
39
  },
40
40
  "dependencies": {
41
- "@getuserfeedback/protocol": "^0.2.2"
41
+ "@getuserfeedback/protocol": "^0.3.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "rimraf": "^6.0.0",