@prenta/sections-react 0.21.1 → 0.21.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/CHANGELOG.md +14 -0
- package/dist/PrentaFormHtml.d.ts +5 -0
- package/dist/PrentaFormHtml.d.ts.map +1 -1
- package/dist/PrentaFormHtml.js +8 -2
- package/dist/PrentaFormHtml.js.map +1 -1
- package/dist/attribution-core.d.ts +32 -0
- package/dist/attribution-core.d.ts.map +1 -0
- package/dist/attribution-core.js +109 -0
- package/dist/attribution-core.js.map +1 -0
- package/dist/attribution.d.ts +3 -23
- package/dist/attribution.d.ts.map +1 -1
- package/dist/attribution.js +8 -57
- package/dist/attribution.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @actuate-media/sections-react
|
|
2
2
|
|
|
3
|
+
## 0.21.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 71d5d0a: Zero-JS forms now post attribution (#1237). Forms rendered from a prefetched schema (`PrentaFormHtml`, the scaffolded Next catch-all's default) sent no attribution, so every entry was stored as Direct with no click ID.
|
|
8
|
+
|
|
9
|
+
- `renderPublicFormHtml` always renders a hidden `__pageUrl` input and, when attribution recording is on, an empty `__attribution` input plus the site's attribution windows in `data-prenta-attribution`. With recording off, neither is rendered.
|
|
10
|
+
- New `enhanceAttributionForms(root?)` in `@prenta/sections-react` (no React needed). It records the page view, respecting the consent rule, and on submit fills `__attribution` with the v2 payload and `__pageUrl` with the current URL. Without JS the form still posts, without attribution.
|
|
11
|
+
- `PrentaFormHtml` mounts the new `FormAttributionEnhancer` client component, so Next pages need no change. Pages that do not hydrate (Astro) call `enhanceAttributionForms()` from a `<script>`.
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [71d5d0a]
|
|
14
|
+
- Updated dependencies [fbab09f]
|
|
15
|
+
- @prenta/core@8.22.2
|
|
16
|
+
|
|
3
17
|
## 0.21.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/PrentaFormHtml.d.ts
CHANGED
|
@@ -14,6 +14,11 @@ export interface PrentaFormHtmlProps {
|
|
|
14
14
|
/**
|
|
15
15
|
* Zero-JS public form renderer with WebMCP declarative annotations.
|
|
16
16
|
* Server-safe — use in React Server Components, Astro, or any SSR context.
|
|
17
|
+
*
|
|
18
|
+
* Attribution: the form carries hidden `__attribution` / `__pageUrl` inputs.
|
|
19
|
+
* Where React hydrates (Next), {@link FormAttributionEnhancer} fills them on
|
|
20
|
+
* submit. Pages that do not hydrate (Astro) call `enhanceAttributionForms()`
|
|
21
|
+
* from a `<script>`.
|
|
17
22
|
*/
|
|
18
23
|
export declare function PrentaFormHtml({ form, action, className, submitLabel, pageUrl, webmcp, }: PrentaFormHtmlProps): ReactNode;
|
|
19
24
|
//# sourceMappingURL=PrentaFormHtml.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrentaFormHtml.d.ts","sourceRoot":"","sources":["../src/PrentaFormHtml.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"PrentaFormHtml.d.ts","sourceRoot":"","sources":["../src/PrentaFormHtml.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAG9C,MAAM,WAAW,mBAAmB;IAClC,6EAA6E;IAC7E,IAAI,EAAE,UAAU,CAAA;IAChB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,MAAM,EACN,SAAS,EACT,WAAW,EACX,OAAO,EACP,MAAM,GACP,EAAE,mBAAmB,GAAG,SAAS,CAejC"}
|
package/dist/PrentaFormHtml.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { renderPublicFormHtml } from '@prenta/core/forms/public-html';
|
|
3
|
+
import { FormAttributionEnhancer } from './attribution.js';
|
|
3
4
|
/**
|
|
4
5
|
* Zero-JS public form renderer with WebMCP declarative annotations.
|
|
5
6
|
* Server-safe — use in React Server Components, Astro, or any SSR context.
|
|
7
|
+
*
|
|
8
|
+
* Attribution: the form carries hidden `__attribution` / `__pageUrl` inputs.
|
|
9
|
+
* Where React hydrates (Next), {@link FormAttributionEnhancer} fills them on
|
|
10
|
+
* submit. Pages that do not hydrate (Astro) call `enhanceAttributionForms()`
|
|
11
|
+
* from a `<script>`.
|
|
6
12
|
*/
|
|
7
13
|
export function PrentaFormHtml({ form, action, className, submitLabel, pageUrl, webmcp, }) {
|
|
8
14
|
const html = renderPublicFormHtml(form, {
|
|
@@ -13,6 +19,6 @@ export function PrentaFormHtml({ form, action, className, submitLabel, pageUrl,
|
|
|
13
19
|
webmcp,
|
|
14
20
|
renderStartedAt: Date.now(),
|
|
15
21
|
});
|
|
16
|
-
return _jsx("div", { dangerouslySetInnerHTML: { __html: html } });
|
|
22
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { dangerouslySetInnerHTML: { __html: html } }), _jsx(FormAttributionEnhancer, {})] }));
|
|
17
23
|
}
|
|
18
24
|
//# sourceMappingURL=PrentaFormHtml.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrentaFormHtml.js","sourceRoot":"","sources":["../src/PrentaFormHtml.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"PrentaFormHtml.js","sourceRoot":"","sources":["../src/PrentaFormHtml.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AAErE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAc1D;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,EAC7B,IAAI,EACJ,MAAM,EACN,SAAS,EACT,WAAW,EACX,OAAO,EACP,MAAM,GACc;IACpB,MAAM,IAAI,GAAG,oBAAoB,CAAC,IAAI,EAAE;QACtC,MAAM;QACN,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,eAAe,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,aAAa;QACxE,WAAW;QACX,OAAO;QACP,MAAM;QACN,eAAe,EAAE,IAAI,CAAC,GAAG,EAAE;KAC5B,CAAC,CAAA;IACF,OAAO,CACL,8BACE,cAAK,uBAAuB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAI,EAClD,KAAC,uBAAuB,KAAG,IAC1B,CACJ,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface AttributionCaptureOptions {
|
|
2
|
+
record?: boolean;
|
|
3
|
+
requireConsent?: boolean;
|
|
4
|
+
firstTouchDays?: number;
|
|
5
|
+
lastTouchHours?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Whether attribution may be captured under the site's consent state.
|
|
9
|
+
*
|
|
10
|
+
* - Plugin not installed → the site has no consent framework; resolve `true`.
|
|
11
|
+
* - Analytics already granted → resolve `true` immediately.
|
|
12
|
+
* - No decision yet → wait for the visitor's banner choice.
|
|
13
|
+
*
|
|
14
|
+
* Kept for callers that have not opted into `requireConsent`. The settings-aware
|
|
15
|
+
* path is {@link captureAttributionIfAllowed}.
|
|
16
|
+
*/
|
|
17
|
+
export declare function attributionConsentAllowed(): Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* Capture the current page as an attribution touch when the site settings and
|
|
20
|
+
* consent decision allow it. Resolves `false` without writing storage when
|
|
21
|
+
* recording is off or consent was not given.
|
|
22
|
+
*/
|
|
23
|
+
export declare function captureAttributionIfAllowed(options?: AttributionCaptureOptions): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Progressive enhancement for zero-JS forms rendered by `PrentaFormHtml` /
|
|
26
|
+
* `renderPublicFormHtml`. For every `form[data-prenta-attribution]` under
|
|
27
|
+
* `root`, records the page view (consent-aware) and, on submit, fills the
|
|
28
|
+
* hidden `__attribution` and `__pageUrl` inputs. Without JS the form still
|
|
29
|
+
* posts, just without attribution. Safe to call more than once.
|
|
30
|
+
*/
|
|
31
|
+
export declare function enhanceAttributionForms(root?: ParentNode): void;
|
|
32
|
+
//# sourceMappingURL=attribution-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribution-core.d.ts","sourceRoot":"","sources":["../src/attribution-core.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,yBAAyB;IACxC,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED;;;;;;;;;GASG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,OAAO,CAAC,CASlE;AAcD;;;;GAIG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,OAAO,CAAC,CAYlB;AAcD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,CAoB/D"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework-neutral attribution helpers (no React). Used by the React
|
|
3
|
+
* components in `attribution.ts` and by the zero-JS form enhancer, so a
|
|
4
|
+
* non-React page (an Astro `<script>`) can call them too.
|
|
5
|
+
*/
|
|
6
|
+
import { captureAttribution, getAttributionForSubmission } from '@prenta/core/forms/attribution';
|
|
7
|
+
import { shouldRecordAttribution } from '@prenta/core/forms/attribution-settings';
|
|
8
|
+
/**
|
|
9
|
+
* Whether attribution may be captured under the site's consent state.
|
|
10
|
+
*
|
|
11
|
+
* - Plugin not installed → the site has no consent framework; resolve `true`.
|
|
12
|
+
* - Analytics already granted → resolve `true` immediately.
|
|
13
|
+
* - No decision yet → wait for the visitor's banner choice.
|
|
14
|
+
*
|
|
15
|
+
* Kept for callers that have not opted into `requireConsent`. The settings-aware
|
|
16
|
+
* path is {@link captureAttributionIfAllowed}.
|
|
17
|
+
*/
|
|
18
|
+
export async function attributionConsentAllowed() {
|
|
19
|
+
try {
|
|
20
|
+
const consent = await import('@prenta/plugin-consent');
|
|
21
|
+
const existing = consent.readConsentState();
|
|
22
|
+
if (existing)
|
|
23
|
+
return consent.hasAnalyticsConsent(existing);
|
|
24
|
+
return consent.hasAnalyticsConsent(await consent.waitForConsentState());
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function consentGranted(requireConsent) {
|
|
31
|
+
if (!requireConsent)
|
|
32
|
+
return true;
|
|
33
|
+
try {
|
|
34
|
+
const consent = await import('@prenta/plugin-consent');
|
|
35
|
+
const existing = consent.readConsentState();
|
|
36
|
+
if (existing)
|
|
37
|
+
return consent.hasAnalyticsConsent(existing);
|
|
38
|
+
return consent.hasAnalyticsConsent(await consent.waitForConsentState());
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Capture the current page as an attribution touch when the site settings and
|
|
46
|
+
* consent decision allow it. Resolves `false` without writing storage when
|
|
47
|
+
* recording is off or consent was not given.
|
|
48
|
+
*/
|
|
49
|
+
export async function captureAttributionIfAllowed(options) {
|
|
50
|
+
if (typeof window === 'undefined')
|
|
51
|
+
return false;
|
|
52
|
+
const record = options?.record !== false;
|
|
53
|
+
const requireConsent = options?.requireConsent === true;
|
|
54
|
+
const granted = await consentGranted(requireConsent);
|
|
55
|
+
if (!shouldRecordAttribution({ record, requireConsent, consentGranted: granted }))
|
|
56
|
+
return false;
|
|
57
|
+
captureAttribution({
|
|
58
|
+
record,
|
|
59
|
+
firstTouchDays: options?.firstTouchDays,
|
|
60
|
+
lastTouchHours: options?.lastTouchHours,
|
|
61
|
+
});
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
function parseOptions(raw) {
|
|
65
|
+
if (!raw)
|
|
66
|
+
return undefined;
|
|
67
|
+
try {
|
|
68
|
+
const parsed = JSON.parse(raw);
|
|
69
|
+
return parsed && typeof parsed === 'object' ? parsed : undefined;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const BOUND_FLAG = 'prentaAttributionBound';
|
|
76
|
+
/**
|
|
77
|
+
* Progressive enhancement for zero-JS forms rendered by `PrentaFormHtml` /
|
|
78
|
+
* `renderPublicFormHtml`. For every `form[data-prenta-attribution]` under
|
|
79
|
+
* `root`, records the page view (consent-aware) and, on submit, fills the
|
|
80
|
+
* hidden `__attribution` and `__pageUrl` inputs. Without JS the form still
|
|
81
|
+
* posts, just without attribution. Safe to call more than once.
|
|
82
|
+
*/
|
|
83
|
+
export function enhanceAttributionForms(root) {
|
|
84
|
+
if (typeof window === 'undefined' || typeof document === 'undefined')
|
|
85
|
+
return;
|
|
86
|
+
const scope = root ?? document;
|
|
87
|
+
const forms = scope.querySelectorAll('form[data-prenta-attribution]');
|
|
88
|
+
for (const form of Array.from(forms)) {
|
|
89
|
+
if (form.dataset[BOUND_FLAG])
|
|
90
|
+
continue;
|
|
91
|
+
form.dataset[BOUND_FLAG] = '1';
|
|
92
|
+
const options = parseOptions(form.dataset.prentaAttribution);
|
|
93
|
+
let allowed = false;
|
|
94
|
+
void captureAttributionIfAllowed(options).then((ok) => {
|
|
95
|
+
allowed = ok;
|
|
96
|
+
});
|
|
97
|
+
form.addEventListener('submit', () => {
|
|
98
|
+
const page = form.querySelector('input[name="__pageUrl"]');
|
|
99
|
+
if (page && !page.value)
|
|
100
|
+
page.value = window.location.href;
|
|
101
|
+
if (!allowed)
|
|
102
|
+
return;
|
|
103
|
+
const field = form.querySelector('input[name="__attribution"]');
|
|
104
|
+
if (field)
|
|
105
|
+
field.value = JSON.stringify(getAttributionForSubmission(options));
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=attribution-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribution-core.js","sourceRoot":"","sources":["../src/attribution-core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAA;AAChG,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAA;AASjF;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB;IAC7C,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAA;QACtD,MAAM,QAAQ,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAA;QAC3C,IAAI,QAAQ;YAAE,OAAO,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAA;QAC1D,OAAO,OAAO,CAAC,mBAAmB,CAAC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AAM,CAAC,QAAQ,CAAC,IAAI,CAAA;YAC1D,IAAI,CAAC,OAAO;gBAAE,OAAM;YACpB,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAmB,6BAA6B,CAAC,CAAA;YACjF,IAAI,KAAK;gBAAE,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,2BAA2B,CAAC,OAAO,CAAC,CAAC,CAAA;QAC/E,CAAC,CAAC,CAAA;IACJ,CAAC;AACH,CAAC"}
|
package/dist/attribution.d.ts
CHANGED
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
firstTouchDays?: number;
|
|
5
|
-
lastTouchHours?: number;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Whether attribution may be captured under the site's consent state.
|
|
9
|
-
*
|
|
10
|
-
* - Plugin not installed → the site has no consent framework; resolve `true`.
|
|
11
|
-
* - Analytics already granted → resolve `true` immediately.
|
|
12
|
-
* - No decision yet → wait for the visitor's banner choice.
|
|
13
|
-
*
|
|
14
|
-
* Kept for callers that have not opted into `requireConsent`. The settings-aware
|
|
15
|
-
* path is {@link captureAttributionIfAllowed}.
|
|
16
|
-
*/
|
|
17
|
-
export declare function attributionConsentAllowed(): Promise<boolean>;
|
|
18
|
-
/**
|
|
19
|
-
* Capture the current page as an attribution touch when the site settings and
|
|
20
|
-
* consent decision allow it. Resolves `false` without writing storage when
|
|
21
|
-
* recording is off or consent was not given.
|
|
22
|
-
*/
|
|
23
|
-
export declare function captureAttributionIfAllowed(options?: AttributionCaptureOptions): Promise<boolean>;
|
|
1
|
+
export { attributionConsentAllowed, captureAttributionIfAllowed, enhanceAttributionForms, type AttributionCaptureOptions, } from './attribution-core.js';
|
|
2
|
+
/** Mounts the zero-JS form enhancer once the page hydrates. Renders nothing. */
|
|
3
|
+
export declare function FormAttributionEnhancer(): null;
|
|
24
4
|
/**
|
|
25
5
|
* Site-wide attribution tracker. Mount once in the public site layout so
|
|
26
6
|
* UTMs, ad click IDs, and referrers are recorded on the landing page.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attribution.d.ts","sourceRoot":"","sources":["../src/attribution.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"attribution.d.ts","sourceRoot":"","sources":["../src/attribution.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,uBAAuB,EACvB,KAAK,yBAAyB,GAC/B,MAAM,uBAAuB,CAAA;AAE9B,gFAAgF;AAChF,wBAAgB,uBAAuB,IAAI,IAAI,CAK9C;AAMD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,OAAY,EAAE,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,IAAI,CAsBpF"}
|
package/dist/attribution.js
CHANGED
|
@@ -8,63 +8,14 @@
|
|
|
8
8
|
* capture nothing when consent is required and the plugin is not installed.
|
|
9
9
|
*/
|
|
10
10
|
import { useEffect } from 'react';
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
* Kept for callers that have not opted into `requireConsent`. The settings-aware
|
|
21
|
-
* path is {@link captureAttributionIfAllowed}.
|
|
22
|
-
*/
|
|
23
|
-
export async function attributionConsentAllowed() {
|
|
24
|
-
try {
|
|
25
|
-
const consent = await import('@prenta/plugin-consent');
|
|
26
|
-
const existing = consent.readConsentState();
|
|
27
|
-
if (existing)
|
|
28
|
-
return consent.hasAnalyticsConsent(existing);
|
|
29
|
-
return consent.hasAnalyticsConsent(await consent.waitForConsentState());
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
async function consentGranted(requireConsent) {
|
|
36
|
-
if (!requireConsent)
|
|
37
|
-
return true;
|
|
38
|
-
try {
|
|
39
|
-
const consent = await import('@prenta/plugin-consent');
|
|
40
|
-
const existing = consent.readConsentState();
|
|
41
|
-
if (existing)
|
|
42
|
-
return consent.hasAnalyticsConsent(existing);
|
|
43
|
-
return consent.hasAnalyticsConsent(await consent.waitForConsentState());
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Capture the current page as an attribution touch when the site settings and
|
|
51
|
-
* consent decision allow it. Resolves `false` without writing storage when
|
|
52
|
-
* recording is off or consent was not given.
|
|
53
|
-
*/
|
|
54
|
-
export async function captureAttributionIfAllowed(options) {
|
|
55
|
-
if (typeof window === 'undefined')
|
|
56
|
-
return false;
|
|
57
|
-
const record = options?.record !== false;
|
|
58
|
-
const requireConsent = options?.requireConsent === true;
|
|
59
|
-
const granted = await consentGranted(requireConsent);
|
|
60
|
-
if (!shouldRecordAttribution({ record, requireConsent, consentGranted: granted }))
|
|
61
|
-
return false;
|
|
62
|
-
captureAttribution({
|
|
63
|
-
record,
|
|
64
|
-
firstTouchDays: options?.firstTouchDays,
|
|
65
|
-
lastTouchHours: options?.lastTouchHours,
|
|
66
|
-
});
|
|
67
|
-
return true;
|
|
11
|
+
import { captureAttributionIfAllowed, enhanceAttributionForms, } from './attribution-core.js';
|
|
12
|
+
export { attributionConsentAllowed, captureAttributionIfAllowed, enhanceAttributionForms, } from './attribution-core.js';
|
|
13
|
+
/** Mounts the zero-JS form enhancer once the page hydrates. Renders nothing. */
|
|
14
|
+
export function FormAttributionEnhancer() {
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
enhanceAttributionForms(document);
|
|
17
|
+
}, []);
|
|
18
|
+
return null;
|
|
68
19
|
}
|
|
69
20
|
/**
|
|
70
21
|
* Site-wide attribution tracker. Mount once in the public site layout so
|
package/dist/attribution.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attribution.js","sourceRoot":"","sources":["../src/attribution.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ;;;;;;;GAOG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,
|
|
1
|
+
{"version":3,"file":"attribution.js","sourceRoot":"","sources":["../src/attribution.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ;;;;;;;GAOG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,GAExB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,uBAAuB,GAExB,MAAM,uBAAuB,CAAA;AAE9B,gFAAgF;AAChF,MAAM,UAAU,uBAAuB;IACrC,SAAS,CAAC,GAAG,EAAE;QACb,uBAAuB,CAAC,QAAQ,CAAC,CAAA;IACnC,CAAC,EAAE,EAAE,CAAC,CAAA;IACN,OAAO,IAAI,CAAA;AACb,CAAC;AAMD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAE,OAAO,GAAG,EAAE,KAA2B,EAAE;IAC5E,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAG,KAAK,CAAA;QACrB,KAAK,CAAC,KAAK,IAAI,EAAE;YACf,IAAI,OAA8C,CAAA;YAClD,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,oCAAoC,CAAC,CAAA;gBAC5E,IAAI,QAAQ,CAAC,EAAE,EAAE,CAAC;oBAChB,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CACoB,CAAA;oBACvD,OAAO,GAAG,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAE,IAAkC,CAAA;gBACzF,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,GAAG,SAAS,CAAA;YACrB,CAAC;YACD,IAAI,CAAC,SAAS;gBAAE,MAAM,2BAA2B,CAAC,OAAO,CAAC,CAAA;QAC5D,CAAC,CAAC,EAAE,CAAA;QACJ,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAA;QAClB,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IACb,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export { HeroSection, TextSection, FeatureSection, StatsSection, BadgesSection,
|
|
|
34
34
|
export { WidgetEmbedSection } from './components/WidgetEmbedSection.js';
|
|
35
35
|
export { PrentaForm } from './PrentaForm.js';
|
|
36
36
|
export type { PrentaFormProps } from './PrentaForm.js';
|
|
37
|
-
export { AttributionTracker, attributionConsentAllowed, captureAttributionIfAllowed, } from './attribution.js';
|
|
37
|
+
export { AttributionTracker, FormAttributionEnhancer, attributionConsentAllowed, captureAttributionIfAllowed, enhanceAttributionForms, } from './attribution.js';
|
|
38
38
|
export { PrentaFormHtml } from './PrentaFormHtml.js';
|
|
39
39
|
export type { PrentaFormHtmlProps } from './PrentaFormHtml.js';
|
|
40
40
|
export { webMcpFormAttributes, webMcpFieldAttribute } from './webmcp.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AACpD,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEnE,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,eAAe,CAAA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BAAuB,GACxB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAE9D,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAExE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE7D,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,eAAe,GAChB,MAAM,YAAY,CAAA;AACnB,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAE3F;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAElE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,GAAG,EAAE,MAAM,YAAY,CAAA;AAEpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAC9C,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAE7C,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE/F,YAAY,EACV,aAAa,EACb,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ export { registerSectionRenderer, registerSectionRenderers, unregisterSectionRen
|
|
|
32
32
|
export { HeroSection, TextSection, FeatureSection, StatsSection, BadgesSection, FaqSection, CtaSection, FormSection, ArticleBodySection, QuoteSection, AuthorBioSection, RelatedPostsSection, GallerySection, EmbedSection, } from './components/defaults.js';
|
|
33
33
|
export { WidgetEmbedSection } from './components/WidgetEmbedSection.js';
|
|
34
34
|
export { PrentaForm } from './PrentaForm.js';
|
|
35
|
-
export { AttributionTracker, attributionConsentAllowed, captureAttributionIfAllowed, } from './attribution.js';
|
|
35
|
+
export { AttributionTracker, FormAttributionEnhancer, attributionConsentAllowed, captureAttributionIfAllowed, enhanceAttributionForms, } from './attribution.js';
|
|
36
36
|
export { PrentaFormHtml } from './PrentaFormHtml.js';
|
|
37
37
|
export { webMcpFormAttributes, webMcpFieldAttribute } from './webmcp.js';
|
|
38
38
|
export { SiteNav } from './SiteNav.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAGpD,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,eAAe,CAAA;AAEtB,OAAO,EACL,WAAW,EACX,WAAW,EACX,cAAc,EACd,YAAY,EACZ,aAAa,EACb,UAAU,EACV,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,YAAY,GACb,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,2BAA2B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;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EAAE,YAAY,EAAE,MAAM,YAAY,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prenta/sections-react",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Public React renderer for Prenta CMS page sections — the canonical PageSection[] contract — with a consumer-controlled renderer registry.",
|
|
6
6
|
"repository": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"CHANGELOG.md"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@prenta/core": "8.22.
|
|
38
|
+
"@prenta/core": "8.22.2"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": ">=18.0.0",
|