@vllnt/analytics 0.1.1 → 0.2.0-canary.8064ae0

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.
@@ -0,0 +1,256 @@
1
+ // src/consent.ts
2
+ var CONSENT_VERSION = 1;
3
+ var CONSENT_STORAGE_KEY = "vllnt:analytics-consent";
4
+ var CONSENT_COOKIE_NAME = "vllnt-consent";
5
+ function isValidConsentState(value) {
6
+ if (typeof value !== "object" || value === null) return false;
7
+ const state = value;
8
+ return typeof state.analytics === "boolean" && typeof state.functional === "boolean" && typeof state.timestamp === "string" && typeof state.version === "number";
9
+ }
10
+ function isStorageAvailable() {
11
+ if (typeof window === "undefined") return false;
12
+ try {
13
+ const testKey = "__storage_test__";
14
+ localStorage.setItem(testKey, testKey);
15
+ localStorage.removeItem(testKey);
16
+ return true;
17
+ } catch {
18
+ return false;
19
+ }
20
+ }
21
+ function loadConsent() {
22
+ if (!isStorageAvailable()) return null;
23
+ try {
24
+ const raw = localStorage.getItem(CONSENT_STORAGE_KEY);
25
+ if (!raw) return null;
26
+ const parsed = JSON.parse(raw);
27
+ if (!isValidConsentState(parsed)) return null;
28
+ return parsed;
29
+ } catch {
30
+ return null;
31
+ }
32
+ }
33
+ function saveConsent(state) {
34
+ if (!isStorageAvailable()) return;
35
+ try {
36
+ localStorage.setItem(CONSENT_STORAGE_KEY, JSON.stringify(state));
37
+ const expires = /* @__PURE__ */ new Date();
38
+ expires.setFullYear(expires.getFullYear() + 1);
39
+ const cookieValue = state.analytics ? "1" : "0";
40
+ document.cookie = `${CONSENT_COOKIE_NAME}=${cookieValue}; expires=${expires.toUTCString()}; path=/; SameSite=Lax`;
41
+ } catch (error) {
42
+ console.warn("Failed to save consent:", error);
43
+ }
44
+ }
45
+ function clearConsent() {
46
+ if (!isStorageAvailable()) return;
47
+ try {
48
+ localStorage.removeItem(CONSENT_STORAGE_KEY);
49
+ document.cookie = `${CONSENT_COOKIE_NAME}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; SameSite=Lax`;
50
+ } catch {
51
+ }
52
+ }
53
+ function createAcceptAllConsent() {
54
+ return {
55
+ analytics: true,
56
+ functional: true,
57
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
58
+ version: CONSENT_VERSION
59
+ };
60
+ }
61
+ function createDeclineAnalyticsConsent() {
62
+ return {
63
+ analytics: false,
64
+ functional: true,
65
+ // Functional always enabled
66
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
67
+ version: CONSENT_VERSION
68
+ };
69
+ }
70
+ function updateConsentCategory(current, category, value) {
71
+ if (category === "functional" && !value) {
72
+ return current;
73
+ }
74
+ return {
75
+ ...current,
76
+ [category]: value,
77
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
78
+ };
79
+ }
80
+ function needsRePrompt(consent, currentVersion) {
81
+ return consent.version < currentVersion;
82
+ }
83
+ function isDoNotTrackEnabled() {
84
+ if (typeof window === "undefined") return false;
85
+ const dnt = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
86
+ return dnt === "1" || dnt === "yes";
87
+ }
88
+ function getConsentFromCookie(cookieString) {
89
+ const match = new RegExp(`(?:^|;\\s*)${CONSENT_COOKIE_NAME}=([^;]+)`).exec(
90
+ cookieString
91
+ );
92
+ if (!match) return null;
93
+ return match[1] === "1";
94
+ }
95
+
96
+ // src/analytics.ts
97
+ var analyticsState;
98
+ var eventQueue = [];
99
+ var isInitialized = false;
100
+ var isBlocked = false;
101
+ function debugLog(type, data) {
102
+ if (analyticsState?.debug) {
103
+ console.log(`[analytics:${type}]`, data);
104
+ }
105
+ }
106
+ function sendEvent(name, properties) {
107
+ debugLog("track", { name, properties });
108
+ }
109
+ function initAnalytics(config) {
110
+ if (analyticsState) return;
111
+ if (isDoNotTrackEnabled()) {
112
+ isBlocked = true;
113
+ debugLog("init", "Do Not Track enabled, analytics blocked");
114
+ return;
115
+ }
116
+ const consent = loadConsent();
117
+ if (consent && !consent.analytics) {
118
+ isBlocked = true;
119
+ debugLog("init", "Analytics consent declined");
120
+ return;
121
+ }
122
+ analyticsState = {
123
+ app: config.app,
124
+ debug: config.debug,
125
+ version: config.version
126
+ };
127
+ isInitialized = true;
128
+ debugLog("init", { app: config.app, version: config.version });
129
+ processQueue();
130
+ }
131
+ function processQueue() {
132
+ if (!analyticsState || isBlocked) return;
133
+ const queue = [...eventQueue];
134
+ eventQueue = [];
135
+ for (const event of queue) {
136
+ if (event.name === "__page__") {
137
+ debugLog("page", event.properties);
138
+ } else {
139
+ sendEvent(event.name, event.properties);
140
+ }
141
+ }
142
+ }
143
+ function track(name, properties) {
144
+ if (typeof window === "undefined") return;
145
+ if (typeof name !== "string" || name === "") return;
146
+ if (isBlocked) return;
147
+ const event = {
148
+ name,
149
+ properties,
150
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
151
+ };
152
+ if (!isInitialized) {
153
+ eventQueue.push(event);
154
+ return;
155
+ }
156
+ sendEvent(name, properties);
157
+ }
158
+ function trackPage(properties) {
159
+ if (typeof window === "undefined") return;
160
+ if (isBlocked) return;
161
+ if (!isInitialized) {
162
+ eventQueue.push({
163
+ name: "__page__",
164
+ properties,
165
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
166
+ });
167
+ return;
168
+ }
169
+ debugLog("page", properties);
170
+ }
171
+ function identify(userId, traits) {
172
+ if (typeof window === "undefined") return;
173
+ if (typeof userId !== "string" || userId === "") return;
174
+ if (isBlocked) return;
175
+ if (!isInitialized || !analyticsState) {
176
+ return;
177
+ }
178
+ analyticsState.userId = userId;
179
+ analyticsState.traits = traits;
180
+ debugLog("identify", { traits, userId });
181
+ }
182
+ function resetAnalytics() {
183
+ if (typeof window === "undefined") return;
184
+ if (analyticsState) {
185
+ analyticsState.userId = void 0;
186
+ analyticsState.traits = void 0;
187
+ }
188
+ debugLog("reset", void 0);
189
+ }
190
+ function enableAnalytics(config) {
191
+ if (isBlocked && !isDoNotTrackEnabled()) {
192
+ isBlocked = false;
193
+ analyticsState = void 0;
194
+ initAnalytics(config);
195
+ }
196
+ }
197
+ function disableAnalytics() {
198
+ isBlocked = true;
199
+ eventQueue.length = 0;
200
+ }
201
+ function isAnalyticsEnabled() {
202
+ return isInitialized && !isBlocked;
203
+ }
204
+ function getAnalyticsState() {
205
+ return analyticsState;
206
+ }
207
+ function trackTutorialStart(properties) {
208
+ track("tutorial_start", properties);
209
+ }
210
+ function trackSectionView(properties) {
211
+ track("tutorial_section_view", properties);
212
+ }
213
+ function trackSectionComplete(properties) {
214
+ track("tutorial_section_complete", properties);
215
+ }
216
+ function trackTutorialComplete(properties) {
217
+ track("tutorial_complete", properties);
218
+ }
219
+ function trackTutorialNavigation(properties) {
220
+ track("tutorial_navigation", properties);
221
+ }
222
+ function trackTimeSpent(properties) {
223
+ track("tutorial_time_spent", properties);
224
+ }
225
+
226
+ export {
227
+ CONSENT_VERSION,
228
+ CONSENT_STORAGE_KEY,
229
+ CONSENT_COOKIE_NAME,
230
+ isValidConsentState,
231
+ isStorageAvailable,
232
+ loadConsent,
233
+ saveConsent,
234
+ clearConsent,
235
+ createAcceptAllConsent,
236
+ createDeclineAnalyticsConsent,
237
+ updateConsentCategory,
238
+ needsRePrompt,
239
+ isDoNotTrackEnabled,
240
+ getConsentFromCookie,
241
+ initAnalytics,
242
+ track,
243
+ trackPage,
244
+ identify,
245
+ resetAnalytics,
246
+ enableAnalytics,
247
+ disableAnalytics,
248
+ isAnalyticsEnabled,
249
+ getAnalyticsState,
250
+ trackTutorialStart,
251
+ trackSectionView,
252
+ trackSectionComplete,
253
+ trackTutorialComplete,
254
+ trackTutorialNavigation,
255
+ trackTimeSpent
256
+ };
@@ -0,0 +1,256 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/consent.ts
2
+ var CONSENT_VERSION = 1;
3
+ var CONSENT_STORAGE_KEY = "vllnt:analytics-consent";
4
+ var CONSENT_COOKIE_NAME = "vllnt-consent";
5
+ function isValidConsentState(value) {
6
+ if (typeof value !== "object" || value === null) return false;
7
+ const state = value;
8
+ return typeof state.analytics === "boolean" && typeof state.functional === "boolean" && typeof state.timestamp === "string" && typeof state.version === "number";
9
+ }
10
+ function isStorageAvailable() {
11
+ if (typeof window === "undefined") return false;
12
+ try {
13
+ const testKey = "__storage_test__";
14
+ localStorage.setItem(testKey, testKey);
15
+ localStorage.removeItem(testKey);
16
+ return true;
17
+ } catch (e) {
18
+ return false;
19
+ }
20
+ }
21
+ function loadConsent() {
22
+ if (!isStorageAvailable()) return null;
23
+ try {
24
+ const raw = localStorage.getItem(CONSENT_STORAGE_KEY);
25
+ if (!raw) return null;
26
+ const parsed = JSON.parse(raw);
27
+ if (!isValidConsentState(parsed)) return null;
28
+ return parsed;
29
+ } catch (e2) {
30
+ return null;
31
+ }
32
+ }
33
+ function saveConsent(state) {
34
+ if (!isStorageAvailable()) return;
35
+ try {
36
+ localStorage.setItem(CONSENT_STORAGE_KEY, JSON.stringify(state));
37
+ const expires = /* @__PURE__ */ new Date();
38
+ expires.setFullYear(expires.getFullYear() + 1);
39
+ const cookieValue = state.analytics ? "1" : "0";
40
+ document.cookie = `${CONSENT_COOKIE_NAME}=${cookieValue}; expires=${expires.toUTCString()}; path=/; SameSite=Lax`;
41
+ } catch (error) {
42
+ console.warn("Failed to save consent:", error);
43
+ }
44
+ }
45
+ function clearConsent() {
46
+ if (!isStorageAvailable()) return;
47
+ try {
48
+ localStorage.removeItem(CONSENT_STORAGE_KEY);
49
+ document.cookie = `${CONSENT_COOKIE_NAME}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; SameSite=Lax`;
50
+ } catch (e3) {
51
+ }
52
+ }
53
+ function createAcceptAllConsent() {
54
+ return {
55
+ analytics: true,
56
+ functional: true,
57
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
58
+ version: CONSENT_VERSION
59
+ };
60
+ }
61
+ function createDeclineAnalyticsConsent() {
62
+ return {
63
+ analytics: false,
64
+ functional: true,
65
+ // Functional always enabled
66
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
67
+ version: CONSENT_VERSION
68
+ };
69
+ }
70
+ function updateConsentCategory(current, category, value) {
71
+ if (category === "functional" && !value) {
72
+ return current;
73
+ }
74
+ return {
75
+ ...current,
76
+ [category]: value,
77
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
78
+ };
79
+ }
80
+ function needsRePrompt(consent, currentVersion) {
81
+ return consent.version < currentVersion;
82
+ }
83
+ function isDoNotTrackEnabled() {
84
+ if (typeof window === "undefined") return false;
85
+ const dnt = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
86
+ return dnt === "1" || dnt === "yes";
87
+ }
88
+ function getConsentFromCookie(cookieString) {
89
+ const match = new RegExp(`(?:^|;\\s*)${CONSENT_COOKIE_NAME}=([^;]+)`).exec(
90
+ cookieString
91
+ );
92
+ if (!match) return null;
93
+ return match[1] === "1";
94
+ }
95
+
96
+ // src/analytics.ts
97
+ var analyticsState;
98
+ var eventQueue = [];
99
+ var isInitialized = false;
100
+ var isBlocked = false;
101
+ function debugLog(type, data) {
102
+ if (_optionalChain([analyticsState, 'optionalAccess', _ => _.debug])) {
103
+ console.log(`[analytics:${type}]`, data);
104
+ }
105
+ }
106
+ function sendEvent(name, properties) {
107
+ debugLog("track", { name, properties });
108
+ }
109
+ function initAnalytics(config) {
110
+ if (analyticsState) return;
111
+ if (isDoNotTrackEnabled()) {
112
+ isBlocked = true;
113
+ debugLog("init", "Do Not Track enabled, analytics blocked");
114
+ return;
115
+ }
116
+ const consent = loadConsent();
117
+ if (consent && !consent.analytics) {
118
+ isBlocked = true;
119
+ debugLog("init", "Analytics consent declined");
120
+ return;
121
+ }
122
+ analyticsState = {
123
+ app: config.app,
124
+ debug: config.debug,
125
+ version: config.version
126
+ };
127
+ isInitialized = true;
128
+ debugLog("init", { app: config.app, version: config.version });
129
+ processQueue();
130
+ }
131
+ function processQueue() {
132
+ if (!analyticsState || isBlocked) return;
133
+ const queue = [...eventQueue];
134
+ eventQueue = [];
135
+ for (const event of queue) {
136
+ if (event.name === "__page__") {
137
+ debugLog("page", event.properties);
138
+ } else {
139
+ sendEvent(event.name, event.properties);
140
+ }
141
+ }
142
+ }
143
+ function track(name, properties) {
144
+ if (typeof window === "undefined") return;
145
+ if (typeof name !== "string" || name === "") return;
146
+ if (isBlocked) return;
147
+ const event = {
148
+ name,
149
+ properties,
150
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
151
+ };
152
+ if (!isInitialized) {
153
+ eventQueue.push(event);
154
+ return;
155
+ }
156
+ sendEvent(name, properties);
157
+ }
158
+ function trackPage(properties) {
159
+ if (typeof window === "undefined") return;
160
+ if (isBlocked) return;
161
+ if (!isInitialized) {
162
+ eventQueue.push({
163
+ name: "__page__",
164
+ properties,
165
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
166
+ });
167
+ return;
168
+ }
169
+ debugLog("page", properties);
170
+ }
171
+ function identify(userId, traits) {
172
+ if (typeof window === "undefined") return;
173
+ if (typeof userId !== "string" || userId === "") return;
174
+ if (isBlocked) return;
175
+ if (!isInitialized || !analyticsState) {
176
+ return;
177
+ }
178
+ analyticsState.userId = userId;
179
+ analyticsState.traits = traits;
180
+ debugLog("identify", { traits, userId });
181
+ }
182
+ function resetAnalytics() {
183
+ if (typeof window === "undefined") return;
184
+ if (analyticsState) {
185
+ analyticsState.userId = void 0;
186
+ analyticsState.traits = void 0;
187
+ }
188
+ debugLog("reset", void 0);
189
+ }
190
+ function enableAnalytics(config) {
191
+ if (isBlocked && !isDoNotTrackEnabled()) {
192
+ isBlocked = false;
193
+ analyticsState = void 0;
194
+ initAnalytics(config);
195
+ }
196
+ }
197
+ function disableAnalytics() {
198
+ isBlocked = true;
199
+ eventQueue.length = 0;
200
+ }
201
+ function isAnalyticsEnabled() {
202
+ return isInitialized && !isBlocked;
203
+ }
204
+ function getAnalyticsState() {
205
+ return analyticsState;
206
+ }
207
+ function trackTutorialStart(properties) {
208
+ track("tutorial_start", properties);
209
+ }
210
+ function trackSectionView(properties) {
211
+ track("tutorial_section_view", properties);
212
+ }
213
+ function trackSectionComplete(properties) {
214
+ track("tutorial_section_complete", properties);
215
+ }
216
+ function trackTutorialComplete(properties) {
217
+ track("tutorial_complete", properties);
218
+ }
219
+ function trackTutorialNavigation(properties) {
220
+ track("tutorial_navigation", properties);
221
+ }
222
+ function trackTimeSpent(properties) {
223
+ track("tutorial_time_spent", properties);
224
+ }
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+ exports.CONSENT_VERSION = CONSENT_VERSION; exports.CONSENT_STORAGE_KEY = CONSENT_STORAGE_KEY; exports.CONSENT_COOKIE_NAME = CONSENT_COOKIE_NAME; exports.isValidConsentState = isValidConsentState; exports.isStorageAvailable = isStorageAvailable; exports.loadConsent = loadConsent; exports.saveConsent = saveConsent; exports.clearConsent = clearConsent; exports.createAcceptAllConsent = createAcceptAllConsent; exports.createDeclineAnalyticsConsent = createDeclineAnalyticsConsent; exports.updateConsentCategory = updateConsentCategory; exports.needsRePrompt = needsRePrompt; exports.isDoNotTrackEnabled = isDoNotTrackEnabled; exports.getConsentFromCookie = getConsentFromCookie; exports.initAnalytics = initAnalytics; exports.track = track; exports.trackPage = trackPage; exports.identify = identify; exports.resetAnalytics = resetAnalytics; exports.enableAnalytics = enableAnalytics; exports.disableAnalytics = disableAnalytics; exports.isAnalyticsEnabled = isAnalyticsEnabled; exports.getAnalyticsState = getAnalyticsState; exports.trackTutorialStart = trackTutorialStart; exports.trackSectionView = trackSectionView; exports.trackSectionComplete = trackSectionComplete; exports.trackTutorialComplete = trackTutorialComplete; exports.trackTutorialNavigation = trackTutorialNavigation; exports.trackTimeSpent = trackTimeSpent;
package/dist/index.cjs ADDED
@@ -0,0 +1,62 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+ var _chunkMVOBIOKZcjs = require('./chunk-MVOBIOKZ.cjs');
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+ exports.CONSENT_COOKIE_NAME = _chunkMVOBIOKZcjs.CONSENT_COOKIE_NAME; exports.CONSENT_STORAGE_KEY = _chunkMVOBIOKZcjs.CONSENT_STORAGE_KEY; exports.CONSENT_VERSION = _chunkMVOBIOKZcjs.CONSENT_VERSION; exports.clearConsent = _chunkMVOBIOKZcjs.clearConsent; exports.createAcceptAllConsent = _chunkMVOBIOKZcjs.createAcceptAllConsent; exports.createDeclineAnalyticsConsent = _chunkMVOBIOKZcjs.createDeclineAnalyticsConsent; exports.disableAnalytics = _chunkMVOBIOKZcjs.disableAnalytics; exports.enableAnalytics = _chunkMVOBIOKZcjs.enableAnalytics; exports.getAnalyticsState = _chunkMVOBIOKZcjs.getAnalyticsState; exports.getConsentFromCookie = _chunkMVOBIOKZcjs.getConsentFromCookie; exports.identify = _chunkMVOBIOKZcjs.identify; exports.initAnalytics = _chunkMVOBIOKZcjs.initAnalytics; exports.isAnalyticsEnabled = _chunkMVOBIOKZcjs.isAnalyticsEnabled; exports.isDoNotTrackEnabled = _chunkMVOBIOKZcjs.isDoNotTrackEnabled; exports.isStorageAvailable = _chunkMVOBIOKZcjs.isStorageAvailable; exports.isValidConsentState = _chunkMVOBIOKZcjs.isValidConsentState; exports.loadConsent = _chunkMVOBIOKZcjs.loadConsent; exports.needsRePrompt = _chunkMVOBIOKZcjs.needsRePrompt; exports.resetAnalytics = _chunkMVOBIOKZcjs.resetAnalytics; exports.saveConsent = _chunkMVOBIOKZcjs.saveConsent; exports.track = _chunkMVOBIOKZcjs.track; exports.trackPage = _chunkMVOBIOKZcjs.trackPage; exports.trackSectionComplete = _chunkMVOBIOKZcjs.trackSectionComplete; exports.trackSectionView = _chunkMVOBIOKZcjs.trackSectionView; exports.trackTimeSpent = _chunkMVOBIOKZcjs.trackTimeSpent; exports.trackTutorialComplete = _chunkMVOBIOKZcjs.trackTutorialComplete; exports.trackTutorialNavigation = _chunkMVOBIOKZcjs.trackTutorialNavigation; exports.trackTutorialStart = _chunkMVOBIOKZcjs.trackTutorialStart; exports.updateConsentCategory = _chunkMVOBIOKZcjs.updateConsentCategory;
@@ -0,0 +1,55 @@
1
+ import { C as ConsentState, a as ConsentCategory } from './analytics-DdAxcZwX.cjs';
2
+ export { A as AnalyticsConfig, b as AnalyticsEvent, T as TutorialEventName, c as TutorialEventProperties, U as UseConsentOptions, d as UseConsentReturn, e as disableAnalytics, f as enableAnalytics, g as getAnalyticsState, i as identify, h as initAnalytics, j as isAnalyticsEnabled, r as resetAnalytics, t as track, k as trackPage, l as trackSectionComplete, m as trackSectionView, n as trackTimeSpent, o as trackTutorialComplete, p as trackTutorialNavigation, q as trackTutorialStart } from './analytics-DdAxcZwX.cjs';
3
+
4
+ /** Current consent schema version - bump to re-prompt users */
5
+ declare const CONSENT_VERSION = 1;
6
+ /** localStorage key for consent state */
7
+ declare const CONSENT_STORAGE_KEY = "vllnt:analytics-consent";
8
+ /** Cookie name for SSR consent detection */
9
+ declare const CONSENT_COOKIE_NAME = "vllnt-consent";
10
+ /**
11
+ * Type guard to validate consent state from storage
12
+ */
13
+ declare function isValidConsentState(value: unknown): value is ConsentState;
14
+ /**
15
+ * Check if localStorage is available
16
+ */
17
+ declare function isStorageAvailable(): boolean;
18
+ /**
19
+ * Load consent state from localStorage
20
+ */
21
+ declare function loadConsent(): ConsentState | null;
22
+ /**
23
+ * Save consent state to localStorage and cookie
24
+ */
25
+ declare function saveConsent(state: ConsentState): void;
26
+ /**
27
+ * Clear consent state (for re-prompting)
28
+ */
29
+ declare function clearConsent(): void;
30
+ /**
31
+ * Create a new consent state with all categories accepted
32
+ */
33
+ declare function createAcceptAllConsent(): ConsentState;
34
+ /**
35
+ * Create a consent state with analytics declined
36
+ */
37
+ declare function createDeclineAnalyticsConsent(): ConsentState;
38
+ /**
39
+ * Update a specific consent category
40
+ */
41
+ declare function updateConsentCategory(current: ConsentState, category: ConsentCategory, value: boolean): ConsentState;
42
+ /**
43
+ * Check if consent needs to be re-prompted (version mismatch)
44
+ */
45
+ declare function needsRePrompt(consent: ConsentState, currentVersion: number): boolean;
46
+ /**
47
+ * Check Do Not Track browser setting
48
+ */
49
+ declare function isDoNotTrackEnabled(): boolean;
50
+ /**
51
+ * Get consent from cookie (for SSR)
52
+ */
53
+ declare function getConsentFromCookie(cookieString: string): boolean | null;
54
+
55
+ export { CONSENT_COOKIE_NAME, CONSENT_STORAGE_KEY, CONSENT_VERSION, ConsentCategory, ConsentState, clearConsent, createAcceptAllConsent, createDeclineAnalyticsConsent, getConsentFromCookie, isDoNotTrackEnabled, isStorageAvailable, isValidConsentState, loadConsent, needsRePrompt, saveConsent, updateConsentCategory };
@@ -0,0 +1,55 @@
1
+ import { C as ConsentState, a as ConsentCategory } from './analytics-DdAxcZwX.js';
2
+ export { A as AnalyticsConfig, b as AnalyticsEvent, T as TutorialEventName, c as TutorialEventProperties, U as UseConsentOptions, d as UseConsentReturn, e as disableAnalytics, f as enableAnalytics, g as getAnalyticsState, i as identify, h as initAnalytics, j as isAnalyticsEnabled, r as resetAnalytics, t as track, k as trackPage, l as trackSectionComplete, m as trackSectionView, n as trackTimeSpent, o as trackTutorialComplete, p as trackTutorialNavigation, q as trackTutorialStart } from './analytics-DdAxcZwX.js';
3
+
4
+ /** Current consent schema version - bump to re-prompt users */
5
+ declare const CONSENT_VERSION = 1;
6
+ /** localStorage key for consent state */
7
+ declare const CONSENT_STORAGE_KEY = "vllnt:analytics-consent";
8
+ /** Cookie name for SSR consent detection */
9
+ declare const CONSENT_COOKIE_NAME = "vllnt-consent";
10
+ /**
11
+ * Type guard to validate consent state from storage
12
+ */
13
+ declare function isValidConsentState(value: unknown): value is ConsentState;
14
+ /**
15
+ * Check if localStorage is available
16
+ */
17
+ declare function isStorageAvailable(): boolean;
18
+ /**
19
+ * Load consent state from localStorage
20
+ */
21
+ declare function loadConsent(): ConsentState | null;
22
+ /**
23
+ * Save consent state to localStorage and cookie
24
+ */
25
+ declare function saveConsent(state: ConsentState): void;
26
+ /**
27
+ * Clear consent state (for re-prompting)
28
+ */
29
+ declare function clearConsent(): void;
30
+ /**
31
+ * Create a new consent state with all categories accepted
32
+ */
33
+ declare function createAcceptAllConsent(): ConsentState;
34
+ /**
35
+ * Create a consent state with analytics declined
36
+ */
37
+ declare function createDeclineAnalyticsConsent(): ConsentState;
38
+ /**
39
+ * Update a specific consent category
40
+ */
41
+ declare function updateConsentCategory(current: ConsentState, category: ConsentCategory, value: boolean): ConsentState;
42
+ /**
43
+ * Check if consent needs to be re-prompted (version mismatch)
44
+ */
45
+ declare function needsRePrompt(consent: ConsentState, currentVersion: number): boolean;
46
+ /**
47
+ * Check Do Not Track browser setting
48
+ */
49
+ declare function isDoNotTrackEnabled(): boolean;
50
+ /**
51
+ * Get consent from cookie (for SSR)
52
+ */
53
+ declare function getConsentFromCookie(cookieString: string): boolean | null;
54
+
55
+ export { CONSENT_COOKIE_NAME, CONSENT_STORAGE_KEY, CONSENT_VERSION, ConsentCategory, ConsentState, clearConsent, createAcceptAllConsent, createDeclineAnalyticsConsent, getConsentFromCookie, isDoNotTrackEnabled, isStorageAvailable, isValidConsentState, loadConsent, needsRePrompt, saveConsent, updateConsentCategory };