flowgrid-sdk 1.7.1 → 1.7.3
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 +94 -129
- package/dist/browser.d.ts +3 -0
- package/dist/browser.js +39 -0
- package/dist/browser.js.map +1 -1
- package/dist/flowgrid.min.js +1 -1
- package/dist/flowgrid.min.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/consent/declarativeBanner.d.ts +73 -0
- package/dist/lib/consent/declarativeBanner.js +260 -0
- package/dist/lib/consent/declarativeBanner.js.map +1 -0
- package/dist/lib/consent/index.d.ts +2 -0
- package/dist/lib/consent/index.js +3 -1
- package/dist/lib/consent/index.js.map +1 -1
- package/dist/lib/consent/manager.js +6 -1
- package/dist/lib/consent/manager.js.map +1 -1
- package/dist/lib/consent/types.d.ts +31 -1
- package/dist/lib/features/core/activation.d.ts +10 -0
- package/dist/lib/features/core/activation.js +19 -0
- package/dist/lib/features/core/activation.js.map +1 -1
- package/dist/lib/features/core/declarativeExperiments.d.ts +4 -0
- package/dist/lib/features/core/declarativeExperiments.js +23 -1
- package/dist/lib/features/core/declarativeExperiments.js.map +1 -1
- package/dist/lib/flowgrid.d.ts +40 -1
- package/dist/lib/flowgrid.js +31 -4
- package/dist/lib/flowgrid.js.map +1 -1
- package/dist/lib/helpers/consent.d.ts +53 -2
- package/dist/lib/helpers/consent.js +339 -8
- package/dist/lib/helpers/consent.js.map +1 -1
- package/dist/lib/helpers/index.d.ts +2 -2
- package/dist/lib/helpers/index.js +2 -1
- package/dist/lib/helpers/index.js.map +1 -1
- package/dist/lib/tracking/core/activation.d.ts +2 -0
- package/dist/lib/tracking/core/activation.js +4 -0
- package/dist/lib/tracking/core/activation.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export { getCookie, getVisitorId, getSessionId, getWebId, getUTM, getUTMHistory,
|
|
|
46
46
|
export type { FlowGridUTM, FlowGridUTMHistoryEntry, } from "./lib/utils/storage";
|
|
47
47
|
export { IdentityManager } from "./lib/utils/identity";
|
|
48
48
|
export type { IdentityConfig, ServerCookieReader, } from "./lib/utils/identity";
|
|
49
|
-
export { ConsentManager } from "./lib/consent";
|
|
50
|
-
export type { ConsentConfig, ConsentPreferences, ConsentCategory as ConsentCategoryType, ConsentChangeEvent, CookieBannerConfig, CookieBannerTheme, } from "./lib/consent";
|
|
51
|
-
export { getOrCreateAnonId, getOrCreateCartId, resetCartId, setupConsent, attachConsentBanner, } from "./lib/helpers";
|
|
52
|
-
export type { ConsentBannerOptions, ConsentBannerHandle, } from "./lib/helpers";
|
|
49
|
+
export { ConsentManager, wireDeclarativeBanners } from "./lib/consent";
|
|
50
|
+
export type { ConsentConfig, ConsentPreferences, ConsentCategory as ConsentCategoryType, ConsentChangeEvent, CookieBannerConfig, CookieBannerTheme, WireDeclarativeBannersOptions, DeclarativeBannersHandle, } from "./lib/consent";
|
|
51
|
+
export { getOrCreateAnonId, getOrCreateCartId, resetCartId, setupConsent, attachConsentBanner, renderConsentBanner, } from "./lib/helpers";
|
|
52
|
+
export type { ConsentBannerOptions, ConsentBannerHandle, RenderConsentBannerOptions, } from "./lib/helpers";
|
package/dist/index.js
CHANGED
|
@@ -31,8 +31,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
31
31
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
32
|
};
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.
|
|
35
|
-
exports.attachConsentBanner = exports.setupConsent = void 0;
|
|
34
|
+
exports.getOrCreateCartId = exports.getOrCreateAnonId = exports.wireDeclarativeBanners = exports.ConsentManager = exports.IdentityManager = exports.getUTMHistory = exports.getUTM = exports.getWebId = exports.getSessionId = exports.getVisitorId = exports.getCookie = exports.Forecasting = exports.SecurityAnalytics = exports.AlertsAnalytics = exports.PathAnalytics = exports.AcquisitionAnalytics = exports.SupportAnalytics = exports.MultiPathFunnels = exports.Monetization = exports.ChurnAnalytics = exports.Cohorts = exports.Engagement = exports.FlowGridTransport = exports.Subscriptions = exports.SearchAnalytics = exports.CustomerLTV = exports.WishlistTracking = exports.Promotions = exports.Refunds = exports.Purchases = exports.Checkout = exports.CartTracking = exports.Products = exports.SessionReplay = exports.Performance = exports.PerformanceTracking = exports.Heatmaps = exports.Attribution = exports.Retention = exports.Funnels = exports.Identify = exports.Events = exports.Sessions = exports.PageViews = exports.Experiment = exports.TrackPrompt = exports.TrackFeature = exports.Activation = exports.default = exports.FlowGrid = void 0;
|
|
35
|
+
exports.renderConsentBanner = exports.attachConsentBanner = exports.setupConsent = exports.resetCartId = void 0;
|
|
36
36
|
// ============================================================================
|
|
37
37
|
// UNIFIED SDK CLASS
|
|
38
38
|
// ============================================================================
|
|
@@ -116,6 +116,7 @@ Object.defineProperty(exports, "IdentityManager", { enumerable: true, get: funct
|
|
|
116
116
|
// ============================================================================
|
|
117
117
|
var consent_1 = require("./lib/consent");
|
|
118
118
|
Object.defineProperty(exports, "ConsentManager", { enumerable: true, get: function () { return consent_1.ConsentManager; } });
|
|
119
|
+
Object.defineProperty(exports, "wireDeclarativeBanners", { enumerable: true, get: function () { return consent_1.wireDeclarativeBanners; } });
|
|
119
120
|
// ============================================================================
|
|
120
121
|
// DROP-IN HELPERS
|
|
121
122
|
//
|
|
@@ -128,4 +129,5 @@ Object.defineProperty(exports, "getOrCreateCartId", { enumerable: true, get: fun
|
|
|
128
129
|
Object.defineProperty(exports, "resetCartId", { enumerable: true, get: function () { return helpers_1.resetCartId; } });
|
|
129
130
|
Object.defineProperty(exports, "setupConsent", { enumerable: true, get: function () { return helpers_1.setupConsent; } });
|
|
130
131
|
Object.defineProperty(exports, "attachConsentBanner", { enumerable: true, get: function () { return helpers_1.attachConsentBanner; } });
|
|
132
|
+
Object.defineProperty(exports, "renderConsentBanner", { enumerable: true, get: function () { return helpers_1.renderConsentBanner; } });
|
|
131
133
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;;;;;AAEH,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E,2CAA0C;AAAjC,oGAAA,QAAQ,OAAA;AACjB,2CAAyC;AAAhC,oHAAA,OAAO,OAAA;AAGhB,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,4CAK6B;AAJ3B,kGAAA,UAAU,OAAA;AACV,oGAAA,YAAY,OAAA;AACZ,mGAAA,WAAW,OAAA;AACX,kGAAA,UAAU,OAAA;AA8BZ,+EAA+E;AAC/E,4BAA4B;AAC5B,+EAA+E;AAE/E,sDAYkC;AAXhC,sGAAA,SAAS,OAAA;AACT,qGAAA,QAAQ,OAAA;AACR,mGAAA,MAAM,OAAA;AACN,qGAAA,QAAQ,OAAA;AACR,oGAAA,OAAO,OAAA;AACP,sGAAA,SAAS,OAAA;AACT,wGAAA,WAAW,OAAA;AACX,qGAAA,QAAQ,OAAA;AACR,gHAAA,mBAAmB,OAAA;AACnB,wGAAA,mBAAmB,OAAe;AAClC,0GAAA,aAAa,OAAA;AAiEf,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E,sDAWkC;AAVhC,qGAAA,QAAQ,OAAA;AACR,yGAAA,YAAY,OAAA;AACZ,qGAAA,QAAQ,OAAA;AACR,sGAAA,SAAS,OAAA;AACT,oGAAA,OAAO,OAAA;AACP,uGAAA,UAAU,OAAA;AACV,6GAAA,gBAAgB,OAAA;AAChB,wGAAA,WAAW,OAAA;AACX,4GAAA,eAAe,OAAA;AACf,0GAAA,aAAa,OAAA;AAqDf,+EAA+E;AAC/E,8BAA8B;AAC9B,+E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AA+E;AAE/E,iDAAuD;AAA9C,2GAAA,eAAe,OAAA;AAOxB,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E,yCAAuE;AAA9D,yGAAA,cAAc,OAAA;AAAE,iHAAA,sBAAsB,OAAA;AAa/C,+EAA+E;AAC/E,kBAAkB;AAClB,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,+EAA+E;AAE/E,yCAOuB;AANrB,4GAAA,iBAAiB,OAAA;AACjB,4GAAA,iBAAiB,OAAA;AACjB,sGAAA,WAAW,OAAA;AACX,uGAAA,YAAY,OAAA;AACZ,8GAAA,mBAAmB,OAAA;AACnB,8GAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Declarative, attribute-driven cookie-consent banner (no-code).
|
|
3
|
+
* @module consent/declarativeBanner
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* The no-code front door to the FlowGrid consent stack. A customer drops a
|
|
7
|
+
* single element on the page:
|
|
8
|
+
*
|
|
9
|
+
* ```html
|
|
10
|
+
* <div data-cookie-ccbanner></div>
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* …and this layer initialises a fully styled, GDPR/CCPA-friendly consent banner.
|
|
14
|
+
* It defaults to opt-out (nothing is blocked — FlowGrid collects data unless the
|
|
15
|
+
* visitor declines); set `data-cc-mode="opt-in"` to block analytics, marketing and
|
|
16
|
+
* session-replay tracking until the visitor accepts — with zero JavaScript. It
|
|
17
|
+
* contains **no consent logic of its
|
|
18
|
+
* own**: it reads config off the page and delegates to the shipped engine
|
|
19
|
+
* ({@link renderConsentBanner} for the default styled banner, or
|
|
20
|
+
* {@link attachConsentBanner} when the customer supplied their own inner markup),
|
|
21
|
+
* mirroring how `declarativeExperiments.ts` wires `data-fg-*` experiments.
|
|
22
|
+
*
|
|
23
|
+
* @attributes
|
|
24
|
+
* data-cookie-ccbanner Marker. Presence = initialise a banner here.
|
|
25
|
+
* data-cc-mode "opt-out" (default) | "opt-in".
|
|
26
|
+
* data-cc-title / -description Copy overrides.
|
|
27
|
+
* data-cc-accept-label / ... Button label overrides.
|
|
28
|
+
* data-cc-privacy-url Adds a "Learn more" privacy link.
|
|
29
|
+
* data-cc-position / -primary / Theme: position, colours, radius, font, z.
|
|
30
|
+
* -bg / -text / -radius / -font / -z
|
|
31
|
+
* data-cc-categories Comma list of visible toggles (analytics,marketing).
|
|
32
|
+
* data-cc-cookie-name / -days / Cookie persistence overrides.
|
|
33
|
+
* -domain
|
|
34
|
+
* data-cc-respect-dnt="false" Ignore DNT/GPC (defaults to honouring it).
|
|
35
|
+
* data-cc-theme Named preset bundle: flowgrid | light | dark.
|
|
36
|
+
* data-cc-unstyled Drop default CSS (Tier 2 BYO-CSS).
|
|
37
|
+
* data-cc-manage-selector CSS selector whose clicks re-open the banner.
|
|
38
|
+
* data-cc-manual Skip auto-init for this element.
|
|
39
|
+
*
|
|
40
|
+
* Robust to dynamically-injected DOM: a MutationObserver re-scans on changes, so
|
|
41
|
+
* page builders and SPA route changes keep working with zero extra calls. Init
|
|
42
|
+
* is idempotent per element via a `data-cc-wired` marker.
|
|
43
|
+
*/
|
|
44
|
+
import type { RenderConsentBannerOptions } from "../helpers/consent";
|
|
45
|
+
/** Options for {@link wireDeclarativeBanners}. */
|
|
46
|
+
export interface WireDeclarativeBannersOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Global defaults, normally read from `window.FlowGridConfig.consentBanner`.
|
|
49
|
+
* Per-element `data-cc-*` attributes override these.
|
|
50
|
+
*/
|
|
51
|
+
globalConfig?: RenderConsentBannerOptions;
|
|
52
|
+
}
|
|
53
|
+
/** Handle returned by {@link wireDeclarativeBanners}. */
|
|
54
|
+
export interface DeclarativeBannersHandle {
|
|
55
|
+
/** Re-scan the DOM for new `[data-cookie-ccbanner]` markers. Idempotent. */
|
|
56
|
+
rescan: () => void;
|
|
57
|
+
/** Stop the MutationObserver and tear down every wired banner. */
|
|
58
|
+
disconnect: () => void;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Scan the document for `[data-cookie-ccbanner]` markers and initialise a
|
|
62
|
+
* consent banner for each: the default styled banner via {@link renderConsentBanner}
|
|
63
|
+
* when the element is empty, or the customer's own markup via
|
|
64
|
+
* {@link attachConsentBanner} when it has children. Watches for late-mounted
|
|
65
|
+
* markers via a MutationObserver. Each element is marked `data-cc-wired` so
|
|
66
|
+
* re-scans never double-init.
|
|
67
|
+
*
|
|
68
|
+
* SSR-safe: a no-op (returns inert handle) when there's no `document`.
|
|
69
|
+
*
|
|
70
|
+
* @param options - Optional global defaults to layer beneath `data-cc-*`.
|
|
71
|
+
* @returns A {@link DeclarativeBannersHandle} for manual rescans / teardown.
|
|
72
|
+
*/
|
|
73
|
+
export declare function wireDeclarativeBanners(options?: WireDeclarativeBannersOptions): DeclarativeBannersHandle;
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Declarative, attribute-driven cookie-consent banner (no-code).
|
|
4
|
+
* @module consent/declarativeBanner
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* The no-code front door to the FlowGrid consent stack. A customer drops a
|
|
8
|
+
* single element on the page:
|
|
9
|
+
*
|
|
10
|
+
* ```html
|
|
11
|
+
* <div data-cookie-ccbanner></div>
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* …and this layer initialises a fully styled, GDPR/CCPA-friendly consent banner.
|
|
15
|
+
* It defaults to opt-out (nothing is blocked — FlowGrid collects data unless the
|
|
16
|
+
* visitor declines); set `data-cc-mode="opt-in"` to block analytics, marketing and
|
|
17
|
+
* session-replay tracking until the visitor accepts — with zero JavaScript. It
|
|
18
|
+
* contains **no consent logic of its
|
|
19
|
+
* own**: it reads config off the page and delegates to the shipped engine
|
|
20
|
+
* ({@link renderConsentBanner} for the default styled banner, or
|
|
21
|
+
* {@link attachConsentBanner} when the customer supplied their own inner markup),
|
|
22
|
+
* mirroring how `declarativeExperiments.ts` wires `data-fg-*` experiments.
|
|
23
|
+
*
|
|
24
|
+
* @attributes
|
|
25
|
+
* data-cookie-ccbanner Marker. Presence = initialise a banner here.
|
|
26
|
+
* data-cc-mode "opt-out" (default) | "opt-in".
|
|
27
|
+
* data-cc-title / -description Copy overrides.
|
|
28
|
+
* data-cc-accept-label / ... Button label overrides.
|
|
29
|
+
* data-cc-privacy-url Adds a "Learn more" privacy link.
|
|
30
|
+
* data-cc-position / -primary / Theme: position, colours, radius, font, z.
|
|
31
|
+
* -bg / -text / -radius / -font / -z
|
|
32
|
+
* data-cc-categories Comma list of visible toggles (analytics,marketing).
|
|
33
|
+
* data-cc-cookie-name / -days / Cookie persistence overrides.
|
|
34
|
+
* -domain
|
|
35
|
+
* data-cc-respect-dnt="false" Ignore DNT/GPC (defaults to honouring it).
|
|
36
|
+
* data-cc-theme Named preset bundle: flowgrid | light | dark.
|
|
37
|
+
* data-cc-unstyled Drop default CSS (Tier 2 BYO-CSS).
|
|
38
|
+
* data-cc-manage-selector CSS selector whose clicks re-open the banner.
|
|
39
|
+
* data-cc-manual Skip auto-init for this element.
|
|
40
|
+
*
|
|
41
|
+
* Robust to dynamically-injected DOM: a MutationObserver re-scans on changes, so
|
|
42
|
+
* page builders and SPA route changes keep working with zero extra calls. Init
|
|
43
|
+
* is idempotent per element via a `data-cc-wired` marker.
|
|
44
|
+
*/
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.wireDeclarativeBanners = wireDeclarativeBanners;
|
|
47
|
+
const consent_1 = require("../helpers/consent");
|
|
48
|
+
const MARKER_ATTR = "data-cookie-ccbanner";
|
|
49
|
+
const WIRED_ATTR = "data-cc-wired";
|
|
50
|
+
const MANUAL_ATTR = "data-cc-manual";
|
|
51
|
+
/**
|
|
52
|
+
* Named theme presets reachable from `data-cc-theme` / `theme: "<name>"`.
|
|
53
|
+
* Explicit `data-cc-*` colour attributes still override the preset.
|
|
54
|
+
*/
|
|
55
|
+
const THEME_PRESETS = {
|
|
56
|
+
flowgrid: { primaryColor: "#4F46E5", backgroundColor: "#FFFFFF", textColor: "#1F2937" },
|
|
57
|
+
light: { primaryColor: "#4F46E5", backgroundColor: "#FFFFFF", textColor: "#1F2937" },
|
|
58
|
+
dark: { primaryColor: "#818CF8", backgroundColor: "#111827", textColor: "#F9FAFB" },
|
|
59
|
+
};
|
|
60
|
+
/** Parse a numeric attribute, returning `undefined` when absent or invalid. */
|
|
61
|
+
function num(raw) {
|
|
62
|
+
if (raw == null || raw.trim() === "")
|
|
63
|
+
return undefined;
|
|
64
|
+
const n = Number(raw);
|
|
65
|
+
return Number.isFinite(n) ? n : undefined;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Read `data-cc-*` attributes off an element into a partial banner config.
|
|
69
|
+
* Only present attributes are emitted, so this object can be layered over
|
|
70
|
+
* `window.FlowGridConfig.consentBanner` without clobbering it with defaults.
|
|
71
|
+
*/
|
|
72
|
+
function parseElementConfig(el) {
|
|
73
|
+
const attr = (name) => el.getAttribute(name);
|
|
74
|
+
const cfg = {};
|
|
75
|
+
const theme = {};
|
|
76
|
+
// Named preset first so explicit colour attributes below override it.
|
|
77
|
+
const preset = attr("data-cc-theme");
|
|
78
|
+
if (preset && THEME_PRESETS[preset])
|
|
79
|
+
Object.assign(theme, THEME_PRESETS[preset]);
|
|
80
|
+
const mode = attr("data-cc-mode");
|
|
81
|
+
if (mode === "opt-in" || mode === "opt-out")
|
|
82
|
+
cfg.mode = mode;
|
|
83
|
+
const title = attr("data-cc-title");
|
|
84
|
+
if (title != null)
|
|
85
|
+
cfg.title = title;
|
|
86
|
+
const description = attr("data-cc-description");
|
|
87
|
+
if (description != null)
|
|
88
|
+
cfg.description = description;
|
|
89
|
+
const acceptLabel = attr("data-cc-accept-label");
|
|
90
|
+
if (acceptLabel != null)
|
|
91
|
+
cfg.acceptAllLabel = acceptLabel;
|
|
92
|
+
const rejectLabel = attr("data-cc-reject-label");
|
|
93
|
+
if (rejectLabel != null)
|
|
94
|
+
cfg.rejectAllLabel = rejectLabel;
|
|
95
|
+
const customizeLabel = attr("data-cc-customize-label");
|
|
96
|
+
if (customizeLabel != null)
|
|
97
|
+
cfg.customizeLabel = customizeLabel;
|
|
98
|
+
const saveLabel = attr("data-cc-save-label");
|
|
99
|
+
if (saveLabel != null)
|
|
100
|
+
cfg.saveLabel = saveLabel;
|
|
101
|
+
const privacyUrl = attr("data-cc-privacy-url");
|
|
102
|
+
if (privacyUrl != null)
|
|
103
|
+
cfg.privacyPolicyUrl = privacyUrl;
|
|
104
|
+
// Theme appearance
|
|
105
|
+
const position = attr("data-cc-position");
|
|
106
|
+
if (position)
|
|
107
|
+
theme.position = position;
|
|
108
|
+
const primary = attr("data-cc-primary");
|
|
109
|
+
if (primary != null)
|
|
110
|
+
theme.primaryColor = primary;
|
|
111
|
+
const bg = attr("data-cc-bg");
|
|
112
|
+
if (bg != null)
|
|
113
|
+
theme.backgroundColor = bg;
|
|
114
|
+
const text = attr("data-cc-text");
|
|
115
|
+
if (text != null)
|
|
116
|
+
theme.textColor = text;
|
|
117
|
+
const radius = attr("data-cc-radius");
|
|
118
|
+
if (radius != null)
|
|
119
|
+
theme.borderRadius = radius;
|
|
120
|
+
const font = attr("data-cc-font");
|
|
121
|
+
if (font != null)
|
|
122
|
+
theme.fontFamily = font;
|
|
123
|
+
const z = num(attr("data-cc-z"));
|
|
124
|
+
if (z !== undefined)
|
|
125
|
+
theme.zIndex = z;
|
|
126
|
+
if (Object.keys(theme).length > 0)
|
|
127
|
+
cfg.theme = theme;
|
|
128
|
+
// Categories (comma list of visible non-essential toggles).
|
|
129
|
+
const categories = attr("data-cc-categories");
|
|
130
|
+
if (categories != null) {
|
|
131
|
+
cfg.categories = categories
|
|
132
|
+
.split(",")
|
|
133
|
+
.map((s) => s.trim())
|
|
134
|
+
.filter((s) => s.length > 0);
|
|
135
|
+
}
|
|
136
|
+
// Cookie persistence (ConsentConfig fields).
|
|
137
|
+
const cookieName = attr("data-cc-cookie-name");
|
|
138
|
+
if (cookieName != null)
|
|
139
|
+
cfg.cookieName = cookieName;
|
|
140
|
+
const cookieDays = num(attr("data-cc-cookie-days"));
|
|
141
|
+
if (cookieDays !== undefined)
|
|
142
|
+
cfg.cookieDays = cookieDays;
|
|
143
|
+
const cookieDomain = attr("data-cc-cookie-domain");
|
|
144
|
+
if (cookieDomain != null)
|
|
145
|
+
cfg.cookieDomain = cookieDomain;
|
|
146
|
+
const respectDNT = attr("data-cc-respect-dnt");
|
|
147
|
+
if (respectDNT != null)
|
|
148
|
+
cfg.respectDNT = respectDNT !== "false";
|
|
149
|
+
if (el.hasAttribute("data-cc-unstyled"))
|
|
150
|
+
cfg.unstyled = true;
|
|
151
|
+
const manageSelector = attr("data-cc-manage-selector");
|
|
152
|
+
if (manageSelector != null)
|
|
153
|
+
cfg.manageSelector = manageSelector;
|
|
154
|
+
return cfg;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Merge global config (`window.FlowGridConfig.consentBanner`) with the
|
|
158
|
+
* per-element `data-cc-*` config. Precedence (low → high, per the plan):
|
|
159
|
+
* 1. global object
|
|
160
|
+
* 2. element attributes
|
|
161
|
+
* `theme` is merged field-by-field so an element can tweak one colour without
|
|
162
|
+
* dropping the rest of the global theme.
|
|
163
|
+
*/
|
|
164
|
+
function mergeConfig(global, element) {
|
|
165
|
+
if (!global)
|
|
166
|
+
return element;
|
|
167
|
+
return {
|
|
168
|
+
...global,
|
|
169
|
+
...element,
|
|
170
|
+
theme: global.theme || element.theme ? { ...global.theme, ...element.theme } : undefined,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/** Whether an element already contains author markup (Tier 3 BYO-markup). */
|
|
174
|
+
function hasChildMarkup(el) {
|
|
175
|
+
return el.children.length > 0;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Scan the document for `[data-cookie-ccbanner]` markers and initialise a
|
|
179
|
+
* consent banner for each: the default styled banner via {@link renderConsentBanner}
|
|
180
|
+
* when the element is empty, or the customer's own markup via
|
|
181
|
+
* {@link attachConsentBanner} when it has children. Watches for late-mounted
|
|
182
|
+
* markers via a MutationObserver. Each element is marked `data-cc-wired` so
|
|
183
|
+
* re-scans never double-init.
|
|
184
|
+
*
|
|
185
|
+
* SSR-safe: a no-op (returns inert handle) when there's no `document`.
|
|
186
|
+
*
|
|
187
|
+
* @param options - Optional global defaults to layer beneath `data-cc-*`.
|
|
188
|
+
* @returns A {@link DeclarativeBannersHandle} for manual rescans / teardown.
|
|
189
|
+
*/
|
|
190
|
+
function wireDeclarativeBanners(options) {
|
|
191
|
+
if (typeof document === "undefined") {
|
|
192
|
+
return { rescan: () => { }, disconnect: () => { } };
|
|
193
|
+
}
|
|
194
|
+
const globalConfig = options?.globalConfig;
|
|
195
|
+
const handles = [];
|
|
196
|
+
const wireElement = (el) => {
|
|
197
|
+
if (el.hasAttribute(WIRED_ATTR) || el.hasAttribute(MANUAL_ATTR))
|
|
198
|
+
return;
|
|
199
|
+
el.setAttribute(WIRED_ATTR, "");
|
|
200
|
+
const config = mergeConfig(globalConfig, parseElementConfig(el));
|
|
201
|
+
let handle = null;
|
|
202
|
+
try {
|
|
203
|
+
if (hasChildMarkup(el)) {
|
|
204
|
+
// Tier 3 — bind the customer's own buttons by data-role, never inject DOM.
|
|
205
|
+
handle = (0, consent_1.attachConsentBanner)({ ...config, container: el });
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
// Tiers 1 & 2 — render the default styled banner (the marker is just an
|
|
209
|
+
// anchor; the banner is position:fixed so DOM placement doesn't matter).
|
|
210
|
+
handle = (0, consent_1.renderConsentBanner)(config);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
/* never throw from auto-init — leave the page untouched on failure */
|
|
215
|
+
}
|
|
216
|
+
if (handle)
|
|
217
|
+
handles.push(handle);
|
|
218
|
+
};
|
|
219
|
+
const scan = (root = document) => {
|
|
220
|
+
const sel = `[${MARKER_ATTR}]:not([${WIRED_ATTR}])`;
|
|
221
|
+
// The root node itself may be a marker (e.g. a single injected element).
|
|
222
|
+
if (root instanceof Element && root.matches(sel))
|
|
223
|
+
wireElement(root);
|
|
224
|
+
root.querySelectorAll(sel).forEach(wireElement);
|
|
225
|
+
};
|
|
226
|
+
scan();
|
|
227
|
+
// Re-scan when the DOM changes (page builders, SPA navigation, lazy content).
|
|
228
|
+
const observer = typeof MutationObserver !== "undefined"
|
|
229
|
+
? new MutationObserver((mutations) => {
|
|
230
|
+
for (const m of mutations) {
|
|
231
|
+
m.addedNodes.forEach((node) => {
|
|
232
|
+
if (node.nodeType === 1)
|
|
233
|
+
scan(node);
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
})
|
|
237
|
+
: null;
|
|
238
|
+
observer?.observe(document.documentElement, { childList: true, subtree: true });
|
|
239
|
+
return {
|
|
240
|
+
rescan: () => scan(),
|
|
241
|
+
disconnect: () => {
|
|
242
|
+
try {
|
|
243
|
+
observer?.disconnect();
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
/* ignore */
|
|
247
|
+
}
|
|
248
|
+
for (const h of handles) {
|
|
249
|
+
try {
|
|
250
|
+
h.destroy();
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
/* ignore */
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
handles.length = 0;
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=declarativeBanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declarativeBanner.js","sourceRoot":"","sources":["../../../src/lib/consent/declarativeBanner.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;;AA6JH,wDAsEC;AAjOD,gDAA8E;AAI9E,MAAM,WAAW,GAAG,sB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|
* @see {@link ConsentManager} for the core API.
|
|
30
30
|
*/
|
|
31
31
|
export { ConsentManager } from './manager';
|
|
32
|
+
export { wireDeclarativeBanners } from './declarativeBanner';
|
|
33
|
+
export type { WireDeclarativeBannersOptions, DeclarativeBannersHandle, } from './declarativeBanner';
|
|
32
34
|
export type { ConsentCategory, ConsentPreferences, ConsentConfig, ConsentChangeEvent, CookieBannerConfig, CookieBannerTheme, } from './types';
|
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
* @see {@link ConsentManager} for the core API.
|
|
31
31
|
*/
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.ConsentManager = void 0;
|
|
33
|
+
exports.wireDeclarativeBanners = exports.ConsentManager = void 0;
|
|
34
34
|
var manager_1 = require("./manager");
|
|
35
35
|
Object.defineProperty(exports, "ConsentManager", { enumerable: true, get: function () { return manager_1.ConsentManager; } });
|
|
36
|
+
var declarativeBanner_1 = require("./declarativeBanner");
|
|
37
|
+
Object.defineProperty(exports, "wireDeclarativeBanners", { enumerable: true, get: function () { return declarativeBanner_1.wireDeclarativeBanners; } });
|
|
36
38
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/consent/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;AAEH,qCAA2C;AAAlC,yGAAA,cAAc,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/consent/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;AAEH,qCAA2C;AAAlC,yGAAA,cAAc,OAAA;AAEvB,yDAA6D;AAApD,2HAAA,sBAAsB,OAAA"}
|
|
@@ -118,7 +118,12 @@ class ConsentManager {
|
|
|
118
118
|
cookieDays: config?.cookieDays ?? DEFAULT_COOKIE_DAYS,
|
|
119
119
|
cookieDomain: config?.cookieDomain,
|
|
120
120
|
respectDNT: config?.respectDNT ?? true,
|
|
121
|
-
|
|
121
|
+
// Permissive by default: FlowGrid collects data unless the customer
|
|
122
|
+
// explicitly opts into a consent gate (`requireExplicitConsent: true` or
|
|
123
|
+
// the banner's `mode: 'opt-in'`). Implementing consent is the customer's
|
|
124
|
+
// responsibility — the SDK does not block essential or analytics data,
|
|
125
|
+
// including session replay, out of the box.
|
|
126
|
+
requireExplicitConsent: config?.requireExplicitConsent ?? false,
|
|
122
127
|
onChange: config?.onChange,
|
|
123
128
|
defaultPreferences: {
|
|
124
129
|
...DEFAULT_PREFERENCES,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../src/lib/consent/manager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;;;AAOH,+EAA+E;AAC/E,WAAW;AACX,+EAA+E;AAE/E,MAAM,mBAAmB,GAAG,YAAY,CAAC;AACzC,MAAM,4BAA4B,GAAG,qBAAqB,CAAC;AAC3D,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC,MAAM,mBAAmB,GAAuB;IAC9C,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,WAAW,EAAE,IAAI;CAClB,CAAC;AAEF,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAa,cAAc;IAQzB;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,GAAG;YACZ,UAAU,EAAE,MAAM,EAAE,UAAU,IAAI,mBAAmB;YACrD,UAAU,EAAE,MAAM,EAAE,UAAU,IAAI,mBAAmB;YACrD,YAAY,EAAE,MAAM,EAAE,YAAY;YAClC,UAAU,EAAE,MAAM,EAAE,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,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;QACnG,QAAQ,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,KAAK,qBAAqB,MAAM,iBAAiB,MAAM,GAAG,MAAM,EAAE,CAAC;QAElH,mDAAmD;QACnD,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;QACtE,QAAQ,CAAC,MAAM,GAAG,GAAG,4BAA4B,IAAI,eAAe,qBAAqB,MAAM,iBAAiB,MAAM,GAAG,MAAM,EAAE,CAAC;IACpI,CAAC;IAEO,YAAY;QAClB,IAAI,OAAO,QAAQ,KAAK,WAAW;YAAE,OAAO;QAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtF,QAAQ,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,uBAAuB,MAAM,EAAE,CAAC;QAC3E,QAAQ,CAAC,MAAM,GAAG,GAAG,4BAA4B,uBAAuB,MAAM,EAAE,CAAC;IACnF,CAAC;CACF;AArQD,wCAqQC"}
|
|
@@ -69,7 +69,12 @@ export interface ConsentConfig {
|
|
|
69
69
|
onChange?: (preferences: ConsentPreferences) => void;
|
|
70
70
|
/** Respect `navigator.doNotTrack` / `globalPrivacyControl`. Defaults to `true`. */
|
|
71
71
|
respectDNT?: boolean;
|
|
72
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* Auto-block analytics/marketing (and session-replay chunks) until the visitor
|
|
74
|
+
* explicitly consents. Defaults to `false` — FlowGrid is permissive by default
|
|
75
|
+
* and it's up to the customer to opt into a consent gate. Set `true` for a
|
|
76
|
+
* GDPR-style opt-in flow.
|
|
77
|
+
*/
|
|
73
78
|
requireExplicitConsent?: boolean;
|
|
74
79
|
}
|
|
75
80
|
/**
|
|
@@ -122,6 +127,31 @@ export interface CookieBannerTheme {
|
|
|
122
127
|
* framework-agnostic.
|
|
123
128
|
*/
|
|
124
129
|
export interface CookieBannerConfig {
|
|
130
|
+
/**
|
|
131
|
+
* Consent mode. `'opt-out'` (default) lets analytics/marketing — including
|
|
132
|
+
* session-replay chunks — run until the visitor declines; FlowGrid collects
|
|
133
|
+
* data unless the customer chooses otherwise. `'opt-in'` (GDPR-safe) blocks
|
|
134
|
+
* non-essential tracking until the visitor accepts.
|
|
135
|
+
* Maps to {@link ConsentConfig.requireExplicitConsent}.
|
|
136
|
+
*/
|
|
137
|
+
mode?: 'opt-in' | 'opt-out';
|
|
138
|
+
/**
|
|
139
|
+
* Which non-essential categories to show as toggles in the customize panel.
|
|
140
|
+
* `necessary` is always shown locked-on and never listed here.
|
|
141
|
+
* Defaults to `['analytics', 'marketing']`.
|
|
142
|
+
*/
|
|
143
|
+
categories?: ConsentCategory[];
|
|
144
|
+
/**
|
|
145
|
+
* Drop FlowGrid's default inline styling and emit only the stable `.fg-cc-*`
|
|
146
|
+
* class hooks + CSS variables, so the banner can be fully styled from the
|
|
147
|
+
* page's own stylesheet (Tier 2 "bring your own CSS").
|
|
148
|
+
*/
|
|
149
|
+
unstyled?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* CSS selector for a "Manage cookies" re-open control (e.g. a footer link).
|
|
152
|
+
* Clicks on matching elements re-open the banner via the handle's `show()`.
|
|
153
|
+
*/
|
|
154
|
+
manageSelector?: string;
|
|
125
155
|
/** Banner title. Defaults to `"Cookie Preferences"`. */
|
|
126
156
|
title?: string;
|
|
127
157
|
/** Banner description text. */
|
|
@@ -212,5 +212,15 @@ export declare class Activation extends FlowGridTransport {
|
|
|
212
212
|
* @returns Promise resolving to activation response
|
|
213
213
|
*/
|
|
214
214
|
trackSignup(userId: string, method: 'email' | 'google' | 'github' | 'apple' | 'sso' | string, source?: string, properties?: Record<string, unknown>): Promise<ActivationResponse>;
|
|
215
|
+
/**
|
|
216
|
+
* Tracks a user login (returning-user signal — recorded as an event, not a
|
|
217
|
+
* funnel conversion).
|
|
218
|
+
*
|
|
219
|
+
* @param userId - User ID
|
|
220
|
+
* @param method - Login method (email, google, etc.)
|
|
221
|
+
* @param properties - Additional properties
|
|
222
|
+
* @returns Promise resolving to activation response
|
|
223
|
+
*/
|
|
224
|
+
trackLogin(userId: string, method?: 'email' | 'google' | 'github' | 'apple' | 'sso' | string, properties?: Record<string, unknown>): Promise<ActivationResponse>;
|
|
215
225
|
}
|
|
216
226
|
export default Activation;
|
|
@@ -173,6 +173,25 @@ class Activation extends transport_1.FlowGridTransport {
|
|
|
173
173
|
timestamp: new Date().toISOString()
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Tracks a user login (returning-user signal — recorded as an event, not a
|
|
178
|
+
* funnel conversion).
|
|
179
|
+
*
|
|
180
|
+
* @param userId - User ID
|
|
181
|
+
* @param method - Login method (email, google, etc.)
|
|
182
|
+
* @param properties - Additional properties
|
|
183
|
+
* @returns Promise resolving to activation response
|
|
184
|
+
*/
|
|
185
|
+
async trackLogin(userId, method, properties) {
|
|
186
|
+
return await this.init("login_completed", {
|
|
187
|
+
type: "activation",
|
|
188
|
+
subtype: "login",
|
|
189
|
+
userId,
|
|
190
|
+
method,
|
|
191
|
+
...properties,
|
|
192
|
+
timestamp: new Date().toISOString()
|
|
193
|
+
});
|
|
194
|
+
}
|
|
176
195
|
}
|
|
177
196
|
exports.Activation = Activation;
|
|
178
197
|
exports.default = Activation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activation.js","sourceRoot":"","sources":["../../../../src/lib/features/core/activation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;;;AAEH,sDAA2D;AA6G3D,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;;;;;;;;;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AAY;YACZ,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,cAAc,GAAG,CAAC,cAAc,GAAG,YAAY,CAAC,CAAC,GAAG,GAAG,CAAC;YACpF,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,gBAAgB,CAAC,MAAyB;QAC9C,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YACrC,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,cAAc;YACvB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,GAAG,MAAM,CAAC,UAAU;YACpB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,WAAW,CACf,MAAc,EACd,MAAgE,EAChE,MAAe,EACf,UAAoC;QAEpC,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;YACzC,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,QAAQ;YACjB,MAAM;YACN,MAAM;YACN,MAAM;YACN,GAAG,UAAU;YACb,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;CAEF;
|
|
1
|
+
{"version":3,"file":"activation.js","sourceRoot":"","sources":["../../../../src/lib/features/core/activation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;;;AAEH,sDAA2D;AA6G3D,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAa,UAAW,SAA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AU,CAAC"}
|
|
@@ -45,6 +45,10 @@ export interface DeclarativeExperimentHost {
|
|
|
45
45
|
getAssignments(): Record<string, string>;
|
|
46
46
|
};
|
|
47
47
|
track(eventName: string, properties?: Record<string, unknown>): unknown;
|
|
48
|
+
/** Record a signup (used by `data-fg-signup`). */
|
|
49
|
+
signup?(userId: string, method: string, source?: string, properties?: Record<string, unknown>): unknown;
|
|
50
|
+
/** Record a login (used by `data-fg-login`). */
|
|
51
|
+
login?(userId: string, method?: string, properties?: Record<string, unknown>): unknown;
|
|
48
52
|
}
|
|
49
53
|
/**
|
|
50
54
|
* Wire every `[data-fg-goal]` / `[data-fg-event]` element under `root` that
|
|
@@ -44,6 +44,8 @@ exports.wireDeclarativeExperiments = wireDeclarativeExperiments;
|
|
|
44
44
|
const WIRED_ATTR = "data-fg-wired";
|
|
45
45
|
const GOAL_ATTR = "data-fg-goal";
|
|
46
46
|
const EVENT_ATTR = "data-fg-event";
|
|
47
|
+
const SIGNUP_ATTR = "data-fg-signup";
|
|
48
|
+
const LOGIN_ATTR = "data-fg-login";
|
|
47
49
|
function parseTrigger(raw) {
|
|
48
50
|
switch ((raw || "").toLowerCase()) {
|
|
49
51
|
case "load": return "load";
|
|
@@ -93,6 +95,26 @@ function fire(host, el) {
|
|
|
93
95
|
}
|
|
94
96
|
catch { /* ignore */ }
|
|
95
97
|
}
|
|
98
|
+
// No-code signup/login: <button data-fg-signup="google">. The attribute
|
|
99
|
+
// value (or data-fg-method) is the method; data-fg-userid is optional (the
|
|
100
|
+
// funnel keys on the auto-attached visitor_id, so userId is just metadata).
|
|
101
|
+
if (el.hasAttribute(SIGNUP_ATTR) && host.signup) {
|
|
102
|
+
const method = el.getAttribute(SIGNUP_ATTR) || el.getAttribute("data-fg-method") || "unknown";
|
|
103
|
+
const userId = el.getAttribute("data-fg-userid") || "";
|
|
104
|
+
const source = el.getAttribute("data-fg-source") || undefined;
|
|
105
|
+
try {
|
|
106
|
+
void host.signup(userId, method, source, { source: "declarative" });
|
|
107
|
+
}
|
|
108
|
+
catch { /* ignore */ }
|
|
109
|
+
}
|
|
110
|
+
if (el.hasAttribute(LOGIN_ATTR) && host.login) {
|
|
111
|
+
const method = el.getAttribute(LOGIN_ATTR) || el.getAttribute("data-fg-method") || undefined;
|
|
112
|
+
const userId = el.getAttribute("data-fg-userid") || "";
|
|
113
|
+
try {
|
|
114
|
+
void host.login(userId, method, { source: "declarative" });
|
|
115
|
+
}
|
|
116
|
+
catch { /* ignore */ }
|
|
117
|
+
}
|
|
96
118
|
}
|
|
97
119
|
/**
|
|
98
120
|
* Wire every `[data-fg-goal]` / `[data-fg-event]` element under `root` that
|
|
@@ -152,7 +174,7 @@ function wireDeclarativeExperiments(host) {
|
|
|
152
174
|
}
|
|
153
175
|
};
|
|
154
176
|
const scan = (root = document) => {
|
|
155
|
-
const sel = `[${GOAL_ATTR}]:not([${WIRED_ATTR}]),[${EVENT_ATTR}]:not([${WIRED_ATTR}])`;
|
|
177
|
+
const sel = `[${GOAL_ATTR}]:not([${WIRED_ATTR}]),[${EVENT_ATTR}]:not([${WIRED_ATTR}]),[${SIGNUP_ATTR}]:not([${WIRED_ATTR}]),[${LOGIN_ATTR}]:not([${WIRED_ATTR}])`;
|
|
156
178
|
root.querySelectorAll(sel).forEach(wireElement);
|
|
157
179
|
};
|
|
158
180
|
scan();
|