@hubpav/hwio-web-runtime 0.7.4 → 0.7.5
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/dist/forms-core.d.ts +21 -0
- package/dist/forms-core.js +14 -0
- package/dist/forms.js +14 -10
- package/package.json +1 -1
package/dist/forms-core.d.ts
CHANGED
|
@@ -19,6 +19,27 @@ export declare function hwioBuildSubmitPayload(input: HWioSubmitInput): {
|
|
|
19
19
|
fields: Record<string, string>;
|
|
20
20
|
attribution: Record<string, string> | undefined;
|
|
21
21
|
};
|
|
22
|
+
export interface HWioAttributionInput {
|
|
23
|
+
/** The form opted into enrichment (`data-hs-enrich="true"`). */
|
|
24
|
+
enrich: boolean;
|
|
25
|
+
/** Marketing consent is granted. */
|
|
26
|
+
marketing: boolean;
|
|
27
|
+
/** Statistics consent is granted. */
|
|
28
|
+
statistics: boolean;
|
|
29
|
+
/** The session copy of the first-touch attribution (`hwio_attribution`). */
|
|
30
|
+
stored?: Record<string, string>;
|
|
31
|
+
/** Click ids and UTM parameters in the current page URL. */
|
|
32
|
+
page?: Record<string, string>;
|
|
33
|
+
/** GA4 client id from the `_ga` cookie. */
|
|
34
|
+
gaClientId?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The attribution sent with a submission (owner decision 2026-10-08). Click ids and UTM
|
|
38
|
+
* parameters travel only with marketing consent, whether they come from the current URL or
|
|
39
|
+
* from the stored session copy (the latter on enriched forms only; the URL wins on a clash).
|
|
40
|
+
* The GA4 client id travels only with statistics consent, on enriched forms.
|
|
41
|
+
*/
|
|
42
|
+
export declare function hwioSubmitAttribution(input: HWioAttributionInput): Record<string, string>;
|
|
22
43
|
/** Origin + pathname only: keeps raw query-string click ids out of HubSpot's hs_context. */
|
|
23
44
|
export declare function hwioPageUri(location: {
|
|
24
45
|
origin: string;
|
package/dist/forms-core.js
CHANGED
|
@@ -12,6 +12,20 @@ export function hwioBuildSubmitPayload(input) {
|
|
|
12
12
|
attribution,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* The attribution sent with a submission (owner decision 2026-10-08). Click ids and UTM
|
|
17
|
+
* parameters travel only with marketing consent, whether they come from the current URL or
|
|
18
|
+
* from the stored session copy (the latter on enriched forms only; the URL wins on a clash).
|
|
19
|
+
* The GA4 client id travels only with statistics consent, on enriched forms.
|
|
20
|
+
*/
|
|
21
|
+
export function hwioSubmitAttribution(input) {
|
|
22
|
+
const out = {};
|
|
23
|
+
if (input.marketing)
|
|
24
|
+
Object.assign(out, input.enrich ? input.stored : undefined, input.page);
|
|
25
|
+
if (input.enrich && input.statistics && input.gaClientId)
|
|
26
|
+
out.ga_client_id = input.gaClientId;
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
15
29
|
/** Origin + pathname only: keeps raw query-string click ids out of HubSpot's hs_context. */
|
|
16
30
|
export function hwioPageUri(location) {
|
|
17
31
|
return location.origin + location.pathname;
|
package/dist/forms.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hwioMount } from './mount.js';
|
|
2
2
|
import { hwioGetAttribution, hwioGetPageAttribution } from './attribution.js';
|
|
3
|
-
import { hwioBuildSubmitPayload, hwioFoldMessageContext, hwioFormEventPayload, hwioGaClientId, hwioPageUri } from './forms-core.js';
|
|
3
|
+
import { hwioBuildSubmitPayload, hwioFoldMessageContext, hwioFormEventPayload, hwioGaClientId, hwioPageUri, hwioSubmitAttribution } from './forms-core.js';
|
|
4
4
|
import { hwioEnsureTurnstileToken, hwioResetTurnstile } from './turnstile.js';
|
|
5
5
|
/**
|
|
6
6
|
* Self-describing form contract (attributes stay compatible with the current sites):
|
|
@@ -9,7 +9,8 @@ import { hwioEnsureTurnstileToken, hwioResetTurnstile } from './turnstile.js';
|
|
|
9
9
|
* data-hs-sending-msg data-hs-success-msg data-hs-error-msg data-form-kind data-inquiry-source>
|
|
10
10
|
* inside: [data-hs-status] element, optional .cf-turnstile, optional [data-message-field data-message-label] controls.
|
|
11
11
|
* `data-hs-enrich="true"` sends the HubSpot cookie, the stored attribution and the GA4 client id,
|
|
12
|
-
* each gated on the matching consent category. Click ids in the current URL
|
|
12
|
+
* each gated on the matching consent category. Click ids and UTM parameters in the current URL
|
|
13
|
+
* are sent on every form, but only with marketing consent (owner decision 2026-10-08).
|
|
13
14
|
*/
|
|
14
15
|
async function readHubspotCookie() {
|
|
15
16
|
const store = window.cookieStore;
|
|
@@ -30,14 +31,17 @@ export async function hwioSubmitForm(form, fields) {
|
|
|
30
31
|
const turnstileToken = fields['cf-turnstile-response'];
|
|
31
32
|
delete fields['cf-turnstile-response'];
|
|
32
33
|
const enrich = form.dataset.hsEnrich === 'true';
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
const marketing = window.hwioConsent?.allows('marketing') === true;
|
|
35
|
+
const statistics = window.hwioConsent?.allows('statistics') === true;
|
|
36
|
+
const canEnrich = enrich && marketing;
|
|
37
|
+
const attribution = hwioSubmitAttribution({
|
|
38
|
+
enrich,
|
|
39
|
+
marketing,
|
|
40
|
+
statistics,
|
|
41
|
+
stored: canEnrich ? hwioGetAttribution() : undefined,
|
|
42
|
+
page: marketing ? hwioGetPageAttribution() : undefined,
|
|
43
|
+
gaClientId: enrich && statistics ? hwioGaClientId(document.cookie) : undefined,
|
|
44
|
+
});
|
|
41
45
|
const payload = hwioBuildSubmitPayload({
|
|
42
46
|
formId,
|
|
43
47
|
locale,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubpav/hwio-web-runtime",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"description": "Framework-free browser runtime for the HARDWARIO websites: consent (Consent Mode v2 + GTM), HubSpot forms with Turnstile, attribution, theme, CTA tracking and small behaviours. View-transition safe.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|