@getuserfeedback/adapters 0.5.0 → 0.5.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.
- package/README.md +50 -43
- package/dist/gtm/template-generation.js +2 -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
|
|
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
|
-
|
|
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,21 @@ Template generation:
|
|
|
49
40
|
- `buildGtmTemplateInfo(options?)`
|
|
50
41
|
- `buildGtmTemplateParts(options?)`
|
|
51
42
|
- `buildGtmTemplateArtifact(options?)`
|
|
43
|
+
- `buildGtmTemplateFileSource(options?)`
|
|
52
44
|
|
|
53
|
-
###
|
|
45
|
+
### Consent behavior
|
|
54
46
|
|
|
55
|
-
|
|
47
|
+
The GTM template no longer exposes consent settings in its UI.
|
|
56
48
|
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
49
|
+
- The template follows GTM Consent Mode directly.
|
|
50
|
+
- getuserfeedback `defaultConsent` scopes are inferred from GTM's standard consent signals only.
|
|
51
|
+
- `analytics.measurement` follows `analytics_storage`.
|
|
52
|
+
- There is no custom consent remapping UI or runtime path.
|
|
53
|
+
- If no GTM consent state is available, the adapter leaves `defaultConsent` unset.
|
|
61
54
|
|
|
62
|
-
###
|
|
55
|
+
### Color scheme behavior
|
|
63
56
|
|
|
64
|
-
|
|
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:
|
|
57
|
+
Generated GTM color scheme support accepts:
|
|
75
58
|
|
|
76
59
|
- fixed `light`
|
|
77
60
|
- fixed `dark`
|
|
@@ -80,35 +63,56 @@ Generated GTM theme support accepts:
|
|
|
80
63
|
- GTM variable-driven values
|
|
81
64
|
- comma-separated auto-detect attribute lists
|
|
82
65
|
|
|
83
|
-
The adapter normalizes all
|
|
66
|
+
The adapter normalizes all of these into protocol-valid `colorScheme`.
|
|
84
67
|
|
|
85
|
-
###
|
|
68
|
+
### Identity behavior
|
|
69
|
+
|
|
70
|
+
The generated template supports:
|
|
71
|
+
|
|
72
|
+
- `Intelligent` mode, which reads common data-layer keys for user ID, email, phone, first name, and last name
|
|
73
|
+
- `Custom` mode, which lets GTM explicitly map a main identity and traits
|
|
74
|
+
- `Disabled` mode, which skips identify entirely
|
|
75
|
+
|
|
76
|
+
### Generate GTM output
|
|
86
77
|
|
|
87
78
|
```ts
|
|
88
|
-
import {
|
|
79
|
+
import {
|
|
80
|
+
buildGtmTemplateArtifact,
|
|
81
|
+
buildGtmTemplateFileSource,
|
|
82
|
+
} from "@getuserfeedback/adapters/gtm";
|
|
89
83
|
|
|
90
84
|
const artifact = buildGtmTemplateArtifact({
|
|
91
85
|
loaderScriptBaseUrl: "https://cdn.getuserfeedback.com/widget/loader/v1",
|
|
92
86
|
});
|
|
93
87
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
88
|
+
const templateFile = buildGtmTemplateFileSource({
|
|
89
|
+
loaderScriptBaseUrl: "https://cdn.getuserfeedback.com/widget/loader/v1",
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Use the package script to write a local importable file:
|
|
94
|
+
|
|
95
|
+
```sh
|
|
96
|
+
bun run generate:gtm-template
|
|
98
97
|
```
|
|
99
98
|
|
|
100
|
-
|
|
99
|
+
For the sandbox-backed GTM smoke:
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
bun run generate:gtm-template:sandbox-hybrid
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`buildGtmTemplateArtifact()` returns the rendered GTM sections. `buildGtmTemplateFileSource()` returns a full importable `template.tpl`.
|
|
101
106
|
|
|
102
107
|
### What the GTM repo should still own
|
|
103
108
|
|
|
104
109
|
After importing the published package, the GTM repo should only own:
|
|
105
110
|
|
|
106
|
-
- GTM Gallery wrapper file assembly
|
|
107
111
|
- brand thumbnail and base64 image assets
|
|
108
112
|
- `metadata.yaml`
|
|
109
113
|
- publishing and release workflow
|
|
110
114
|
|
|
111
|
-
It should not rebuild parameters, runtime source, permissions, or GTM-specific init payload translation.
|
|
115
|
+
It should not rebuild parameters, runtime source, permissions, file assembly, or GTM-specific init payload translation.
|
|
112
116
|
|
|
113
117
|
### Customizing the loader base URL
|
|
114
118
|
|
|
@@ -118,9 +122,12 @@ Pass `loaderScriptBaseUrl` to:
|
|
|
118
122
|
- `buildGtmPermissions`
|
|
119
123
|
- `buildGtmTemplateParts`
|
|
120
124
|
- `buildGtmTemplateArtifact`
|
|
125
|
+
- `buildGtmTemplateFileSource`
|
|
121
126
|
|
|
122
127
|
The same base URL is used to derive the runtime loader URL and the `inject_script` permission pattern.
|
|
123
128
|
|
|
129
|
+
Pass `runtimeEndpoints` when you need the generated template to point loader bootstrap at non-default `core` and `api` endpoints.
|
|
130
|
+
|
|
124
131
|
### Versioning expectations
|
|
125
132
|
|
|
126
133
|
Any change that affects generated GTM output is a public package change and should be versioned accordingly. This includes:
|
|
@@ -128,8 +135,8 @@ Any change that affects generated GTM output is a public package change and shou
|
|
|
128
135
|
- parameter shape or defaults
|
|
129
136
|
- runtime behavior
|
|
130
137
|
- permission generation
|
|
131
|
-
-
|
|
132
|
-
-
|
|
133
|
-
-
|
|
138
|
+
- color scheme normalization
|
|
139
|
+
- identity lookup behavior
|
|
140
|
+
- consent derivation behavior
|
|
134
141
|
|
|
135
142
|
Release notes should call out template-affecting changes explicitly.
|
|
@@ -541,7 +541,7 @@ const getConsentState = function() {
|
|
|
541
541
|
return result;
|
|
542
542
|
};
|
|
543
543
|
|
|
544
|
-
const
|
|
544
|
+
const deriveDefaultConsentFromGtmConsentState = function() {
|
|
545
545
|
const consentState = getConsentState();
|
|
546
546
|
const grantedScopeLookup = {};
|
|
547
547
|
const grantedScopes = [];
|
|
@@ -617,7 +617,7 @@ if (colorScheme !== undefined) {
|
|
|
617
617
|
initOptions.colorScheme = colorScheme;
|
|
618
618
|
}
|
|
619
619
|
|
|
620
|
-
const defaultConsent =
|
|
620
|
+
const defaultConsent = deriveDefaultConsentFromGtmConsentState();
|
|
621
621
|
if (defaultConsent !== undefined) {
|
|
622
622
|
initOptions.defaultConsent = defaultConsent;
|
|
623
623
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getuserfeedback/adapters",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
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.
|
|
41
|
+
"@getuserfeedback/protocol": "^0.3.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"rimraf": "^6.0.0",
|