@databuddy/sdk 2.3.29 → 2.4.0

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.
@@ -1,7 +1,7 @@
1
- import { D as DatabuddyConfig } from '../shared/@databuddy/sdk.BsF1xr6_.mjs';
2
- export { c as clear, f as flush, d as getAnonymousId, e as getSessionId, g as getTracker, h as getTrackingIds, j as getTrackingParams, i as isTrackerAvailable, t as track, b as trackError } from '../shared/@databuddy/sdk.BsF1xr6_.mjs';
1
+ import { D as DatabuddyConfig } from '../shared/@databuddy/sdk.DOtKE9NQ.mjs';
2
+ export { f as clear, g as flush, h as getAnonymousId, i as getSessionId, j as getTracker, k as getTrackingIds, l as getTrackingParams, m as isTrackerAvailable, t as track, o as trackError } from '../shared/@databuddy/sdk.DOtKE9NQ.mjs';
3
3
  import React, { ReactNode } from 'react';
4
- import { F as FlagsConfig, a as FeatureState, b as FlagState, c as FlagsContext } from '../shared/@databuddy/sdk.CdLp6SQb.mjs';
4
+ import { F as FlagsConfig, a as FlagState, b as FlagsContext } from '../shared/@databuddy/sdk.rnu91OSC.mjs';
5
5
 
6
6
  /**
7
7
  * React/Next.js component that injects the Databuddy tracking script.
@@ -38,7 +38,6 @@ import { F as FlagsConfig, a as FeatureState, b as FlagState, c as FlagsContext
38
38
  * <Databuddy
39
39
  * clientId="your-client-id"
40
40
  * trackWebVitals
41
- * trackScrollDepth
42
41
  * trackOutgoingLinks
43
42
  * />
44
43
  * ```
@@ -59,56 +58,14 @@ declare function Databuddy(props: DatabuddyConfig): null;
59
58
  interface FlagsProviderProps extends FlagsConfig {
60
59
  children: ReactNode;
61
60
  }
62
- /**
63
- * Flags provider component
64
- * Creates a manager instance and provides flag methods to children
65
- */
66
61
  declare function FlagsProvider({ children, ...config }: FlagsProviderProps): React.JSX.Element;
67
- /**
68
- * Access the full flags context
69
- * @example
70
- * const { isOn, getFlag, refresh } = useFlags();
71
- */
72
62
  declare function useFlags(): FlagsContext;
73
63
  /**
74
- * Get a flag's full state with loading/error handling
75
64
  * @example
76
65
  * const flag = useFlag("my-feature");
77
66
  * if (flag.loading) return <Skeleton />;
78
67
  * return flag.on ? <NewFeature /> : <OldFeature />;
79
68
  */
80
69
  declare function useFlag(key: string): FlagState;
81
- /**
82
- * Simple feature check - returns { on, loading, value, variant }
83
- * @example
84
- * const { on, loading } = useFeature("dark-mode");
85
- * if (loading) return <Skeleton />;
86
- * return on ? <DarkTheme /> : <LightTheme />;
87
- */
88
- declare function useFeature(key: string): FeatureState;
89
- /**
90
- * Boolean-only feature check with default value
91
- * Useful for SSR-safe rendering where you need a boolean immediately
92
- * @example
93
- * const isDarkMode = useFeatureOn("dark-mode", false);
94
- * return isDarkMode ? <DarkTheme /> : <LightTheme />;
95
- */
96
- declare function useFeatureOn(key: string, defaultValue?: boolean): boolean;
97
- /**
98
- * Get a flag's typed value
99
- * @example
100
- * const maxItems = useFlagValue("max-items", 10);
101
- * const theme = useFlagValue<"light" | "dark">("theme", "light");
102
- */
103
- declare function useFlagValue<T extends boolean | string | number = boolean>(key: string, defaultValue?: T): T;
104
- /**
105
- * Get variant for A/B testing
106
- * @example
107
- * const variant = useVariant("checkout-experiment");
108
- * if (variant === "control") return <OldCheckout />;
109
- * if (variant === "treatment-a") return <NewCheckoutA />;
110
- * return <NewCheckoutB />;
111
- */
112
- declare function useVariant(key: string): string | undefined;
113
70
 
114
- export { Databuddy, FlagsProvider, useFeature, useFeatureOn, useFlag, useFlagValue, useFlags, useVariant };
71
+ export { Databuddy, FlagsProvider, useFlag, useFlags };
@@ -1,7 +1,7 @@
1
- import { D as DatabuddyConfig } from '../shared/@databuddy/sdk.BsF1xr6_.js';
2
- export { c as clear, f as flush, d as getAnonymousId, e as getSessionId, g as getTracker, h as getTrackingIds, j as getTrackingParams, i as isTrackerAvailable, t as track, b as trackError } from '../shared/@databuddy/sdk.BsF1xr6_.js';
1
+ import { D as DatabuddyConfig } from '../shared/@databuddy/sdk.DOtKE9NQ.js';
2
+ export { f as clear, g as flush, h as getAnonymousId, i as getSessionId, j as getTracker, k as getTrackingIds, l as getTrackingParams, m as isTrackerAvailable, t as track, o as trackError } from '../shared/@databuddy/sdk.DOtKE9NQ.js';
3
3
  import React, { ReactNode } from 'react';
4
- import { F as FlagsConfig, a as FeatureState, b as FlagState, c as FlagsContext } from '../shared/@databuddy/sdk.CdLp6SQb.js';
4
+ import { F as FlagsConfig, a as FlagState, b as FlagsContext } from '../shared/@databuddy/sdk.rnu91OSC.js';
5
5
 
6
6
  /**
7
7
  * React/Next.js component that injects the Databuddy tracking script.
@@ -38,7 +38,6 @@ import { F as FlagsConfig, a as FeatureState, b as FlagState, c as FlagsContext
38
38
  * <Databuddy
39
39
  * clientId="your-client-id"
40
40
  * trackWebVitals
41
- * trackScrollDepth
42
41
  * trackOutgoingLinks
43
42
  * />
44
43
  * ```
@@ -59,56 +58,14 @@ declare function Databuddy(props: DatabuddyConfig): null;
59
58
  interface FlagsProviderProps extends FlagsConfig {
60
59
  children: ReactNode;
61
60
  }
62
- /**
63
- * Flags provider component
64
- * Creates a manager instance and provides flag methods to children
65
- */
66
61
  declare function FlagsProvider({ children, ...config }: FlagsProviderProps): React.JSX.Element;
67
- /**
68
- * Access the full flags context
69
- * @example
70
- * const { isOn, getFlag, refresh } = useFlags();
71
- */
72
62
  declare function useFlags(): FlagsContext;
73
63
  /**
74
- * Get a flag's full state with loading/error handling
75
64
  * @example
76
65
  * const flag = useFlag("my-feature");
77
66
  * if (flag.loading) return <Skeleton />;
78
67
  * return flag.on ? <NewFeature /> : <OldFeature />;
79
68
  */
80
69
  declare function useFlag(key: string): FlagState;
81
- /**
82
- * Simple feature check - returns { on, loading, value, variant }
83
- * @example
84
- * const { on, loading } = useFeature("dark-mode");
85
- * if (loading) return <Skeleton />;
86
- * return on ? <DarkTheme /> : <LightTheme />;
87
- */
88
- declare function useFeature(key: string): FeatureState;
89
- /**
90
- * Boolean-only feature check with default value
91
- * Useful for SSR-safe rendering where you need a boolean immediately
92
- * @example
93
- * const isDarkMode = useFeatureOn("dark-mode", false);
94
- * return isDarkMode ? <DarkTheme /> : <LightTheme />;
95
- */
96
- declare function useFeatureOn(key: string, defaultValue?: boolean): boolean;
97
- /**
98
- * Get a flag's typed value
99
- * @example
100
- * const maxItems = useFlagValue("max-items", 10);
101
- * const theme = useFlagValue<"light" | "dark">("theme", "light");
102
- */
103
- declare function useFlagValue<T extends boolean | string | number = boolean>(key: string, defaultValue?: T): T;
104
- /**
105
- * Get variant for A/B testing
106
- * @example
107
- * const variant = useVariant("checkout-experiment");
108
- * if (variant === "control") return <OldCheckout />;
109
- * if (variant === "treatment-a") return <NewCheckoutA />;
110
- * return <NewCheckoutB />;
111
- */
112
- declare function useVariant(key: string): string | undefined;
113
70
 
114
- export { Databuddy, FlagsProvider, useFeature, useFeatureOn, useFlag, useFlagValue, useFlags, useVariant };
71
+ export { Databuddy, FlagsProvider, useFlag, useFlags };
@@ -2,10 +2,10 @@
2
2
 
3
3
  import { detectClientId } from '../core/index.mjs';
4
4
  export { clear, flush, getAnonymousId, getSessionId, getTracker, getTrackingIds, getTrackingParams, isTrackerAvailable, track, trackError } from '../core/index.mjs';
5
- import { i as isScriptInjected, c as createScript } from '../shared/@databuddy/sdk.urY7MmVr.mjs';
6
- import React, { useRef, useMemo, useEffect, useSyncExternalStore, createContext, useContext } from 'react';
7
- import { B as BrowserFlagStorage, C as CoreFlagsManager } from '../shared/@databuddy/sdk.DE24-JrU.mjs';
8
- import { l as logger } from '../shared/@databuddy/sdk.CALvx07o.mjs';
5
+ import { i as isScriptInjected, c as createScript } from '../shared/@databuddy/sdk.P9GHqNXr.mjs';
6
+ import React, { useMemo, useRef, useEffect, useSyncExternalStore, useContext, createContext } from 'react';
7
+ import { B as BrowserFlagStorage } from '../shared/@databuddy/sdk.GM10R1Kp.mjs';
8
+ import { B as BrowserFlagsManager, l as logger } from '../shared/@databuddy/sdk.Ugr1p2j9.mjs';
9
9
 
10
10
  function Databuddy(props) {
11
11
  const clientId = detectClientId(props.clientId);
@@ -25,66 +25,32 @@ function Databuddy(props) {
25
25
  }
26
26
 
27
27
  const FlagsReactContext = createContext(null);
28
- function createFlagState(result, isLoading, isPending) {
28
+ function toFlagState(result, isLoading, isPending) {
29
29
  if (isPending) {
30
- return {
31
- on: false,
32
- enabled: false,
33
- status: "pending",
34
- loading: true,
35
- isLoading: true,
36
- isReady: false
37
- };
30
+ return { on: false, status: "pending", loading: true };
38
31
  }
39
32
  if (isLoading || !result) {
40
- return {
41
- on: false,
42
- enabled: false,
43
- status: "loading",
44
- loading: true,
45
- isLoading: true,
46
- isReady: false
47
- };
33
+ return { on: false, status: "loading", loading: true };
48
34
  }
49
35
  const status = result.reason === "ERROR" ? "error" : "ready";
50
36
  return {
51
37
  on: result.enabled,
52
- enabled: result.enabled,
53
38
  status,
54
39
  loading: false,
55
- isLoading: false,
56
- isReady: true,
57
40
  value: result.value,
58
41
  variant: result.variant
59
42
  };
60
43
  }
61
44
  function FlagsProvider({ children, ...config }) {
62
- const storeRef = useRef({ flags: {}, isReady: false });
63
- const listenersRef = useRef(/* @__PURE__ */ new Set());
64
45
  const manager = useMemo(() => {
65
46
  const storage = config.skipStorage ? void 0 : new BrowserFlagStorage();
66
- return new CoreFlagsManager({
67
- config,
68
- storage,
69
- onFlagsUpdate: (flags) => {
70
- storeRef.current = { ...storeRef.current, flags };
71
- for (const listener of listenersRef.current) {
72
- listener();
73
- }
74
- },
75
- onReady: () => {
76
- storeRef.current = { ...storeRef.current, isReady: true };
77
- for (const listener of listenersRef.current) {
78
- listener();
79
- }
80
- }
81
- });
47
+ return new BrowserFlagsManager({ config, storage });
82
48
  }, [config.clientId]);
83
49
  const prevConfigRef = useRef(config);
84
50
  useEffect(() => {
85
- const prevConfig = prevConfigRef.current;
86
- const configChanged = prevConfig.apiUrl !== config.apiUrl || prevConfig.isPending !== config.isPending || prevConfig.user?.userId !== config.user?.userId || prevConfig.user?.email !== config.user?.email || prevConfig.environment !== config.environment || prevConfig.disabled !== config.disabled || prevConfig.autoFetch !== config.autoFetch || prevConfig.cacheTtl !== config.cacheTtl || prevConfig.staleTime !== config.staleTime;
87
- if (configChanged) {
51
+ const prev = prevConfigRef.current;
52
+ const changed = prev.apiUrl !== config.apiUrl || prev.isPending !== config.isPending || prev.user?.userId !== config.user?.userId || prev.user?.email !== config.user?.email || prev.environment !== config.environment || prev.disabled !== config.disabled || prev.autoFetch !== config.autoFetch || prev.cacheTtl !== config.cacheTtl || prev.staleTime !== config.staleTime;
53
+ if (changed) {
88
54
  prevConfigRef.current = config;
89
55
  manager.updateConfig(config);
90
56
  }
@@ -94,39 +60,29 @@ function FlagsProvider({ children, ...config }) {
94
60
  manager.destroy();
95
61
  };
96
62
  }, [manager]);
97
- const subscribe = useMemo(
98
- () => (callback) => {
99
- listenersRef.current.add(callback);
100
- return () => {
101
- listenersRef.current.delete(callback);
102
- };
103
- },
104
- []
63
+ const store = useSyncExternalStore(
64
+ manager.subscribe,
65
+ manager.getSnapshot,
66
+ manager.getSnapshot
105
67
  );
106
- const getSnapshot = useMemo(() => () => storeRef.current, []);
107
- const store = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
108
68
  const contextValue = useMemo(
109
69
  () => ({
110
- // Cleaner API: getFlag returns FlagState
111
70
  getFlag: (key) => {
112
71
  const result = store.flags[key];
113
72
  const managerState = manager.isEnabled(key);
114
- return createFlagState(
73
+ return toFlagState(
115
74
  result,
116
- managerState.isLoading,
75
+ managerState.loading,
117
76
  config.isPending ?? false
118
77
  );
119
78
  },
120
- // Simple boolean check
121
79
  isOn: (key) => {
122
80
  const result = store.flags[key];
123
81
  if (result) {
124
82
  return result.enabled;
125
83
  }
126
- const state = manager.isEnabled(key);
127
- return state.enabled;
84
+ return manager.isEnabled(key).on;
128
85
  },
129
- // Get typed value
130
86
  getValue: (key, defaultValue) => {
131
87
  const result = store.flags[key];
132
88
  if (result) {
@@ -134,22 +90,11 @@ function FlagsProvider({ children, ...config }) {
134
90
  }
135
91
  return manager.getValue(key, defaultValue);
136
92
  },
137
- // Async fetch
138
93
  fetchFlag: (key) => manager.getFlag(key),
139
94
  fetchAllFlags: () => manager.fetchAllFlags(),
140
95
  updateUser: (user) => manager.updateUser(user),
141
96
  refresh: (forceClear = false) => manager.refresh(forceClear),
142
- isReady: store.isReady,
143
- // Deprecated: kept for backwards compatibility
144
- isEnabled: (key) => {
145
- const result = store.flags[key];
146
- const managerState = manager.isEnabled(key);
147
- return createFlagState(
148
- result,
149
- managerState.isLoading,
150
- config.isPending ?? false
151
- );
152
- }
97
+ isReady: store.isReady
153
98
  }),
154
99
  [manager, store, config.isPending]
155
100
  );
@@ -160,8 +105,7 @@ function useFlags() {
160
105
  if (!context) {
161
106
  logger.warn("useFlags called outside FlagsProvider");
162
107
  return {
163
- isEnabled: () => createFlagState(void 0, false, false),
164
- getFlag: () => createFlagState(void 0, false, false),
108
+ getFlag: () => toFlagState(void 0, false, false),
165
109
  isOn: () => false,
166
110
  getValue: (_key, defaultValue) => defaultValue ?? false,
167
111
  fetchFlag: async () => ({
@@ -185,31 +129,5 @@ function useFlag(key) {
185
129
  const { getFlag } = useFlags();
186
130
  return getFlag(key);
187
131
  }
188
- function useFeature(key) {
189
- const flag = useFlag(key);
190
- return {
191
- on: flag.on,
192
- loading: flag.loading,
193
- status: flag.status,
194
- value: flag.value,
195
- variant: flag.variant
196
- };
197
- }
198
- function useFeatureOn(key, defaultValue = false) {
199
- const { isOn, isReady } = useFlags();
200
- const flag = useFlag(key);
201
- if (flag.loading || !isReady) {
202
- return defaultValue;
203
- }
204
- return isOn(key);
205
- }
206
- function useFlagValue(key, defaultValue) {
207
- const { getValue } = useFlags();
208
- return getValue(key, defaultValue);
209
- }
210
- function useVariant(key) {
211
- const flag = useFlag(key);
212
- return flag.variant;
213
- }
214
132
 
215
- export { Databuddy, FlagsProvider, useFeature, useFeatureOn, useFlag, useFlagValue, useFlags, useVariant };
133
+ export { Databuddy, FlagsProvider, useFlag, useFlags };
@@ -8,7 +8,6 @@
8
8
  * apiUrl="https://basket.databuddy.cc"
9
9
  * trackWebVitals
10
10
  * trackErrors
11
- * trackScrollDepth
12
11
  * samplingRate={0.5}
13
12
  * />
14
13
  * ```
@@ -18,7 +17,7 @@ interface DatabuddyConfig {
18
17
  * Your Databuddy project client ID.
19
18
  * If not provided, will automatically detect from NEXT_PUBLIC_DATABUDDY_CLIENT_ID environment variable.
20
19
  * Get this from your Databuddy dashboard.
21
- * Example: '3ed1fce1-5a56-4cbc-a917-66864f6d18e3'
20
+ * Example: UUID-style or short public id (dashboard client ID).
22
21
  */
23
22
  clientId?: string;
24
23
  /**
@@ -71,10 +70,6 @@ interface DatabuddyConfig {
71
70
  * Track user interactions (default: false).
72
71
  */
73
72
  trackInteractions?: boolean;
74
- /**
75
- * Track scroll depth (default: false).
76
- */
77
- trackScrollDepth?: boolean;
78
73
  /**
79
74
  * Track page performance metrics (default: true).
80
75
  */
@@ -93,7 +88,7 @@ interface DatabuddyConfig {
93
88
  */
94
89
  samplingRate?: number;
95
90
  /**
96
- * Enable retries for failed requests (default: false).
91
+ * Enable retries for failed requests (default: true).
97
92
  */
98
93
  enableRetries?: boolean;
99
94
  /**
@@ -193,19 +188,18 @@ interface EventProperties extends BaseEventProperties {
193
188
  */
194
189
  interface EventTypeMap {
195
190
  screen_view: {
191
+ page_count?: number;
196
192
  time_on_page?: number;
197
193
  scroll_depth?: number;
198
194
  interaction_count?: number;
199
- has_exit_intent?: boolean;
200
- is_bounce?: 0 | 1;
201
195
  };
202
196
  page_exit: {
197
+ path?: string;
198
+ timestamp?: number;
203
199
  time_on_page: number;
204
200
  scroll_depth: number;
205
201
  interaction_count: number;
206
- has_exit_intent: boolean;
207
202
  page_count: number;
208
- is_bounce: 0 | 1;
209
203
  };
210
204
  button_click: {
211
205
  button_text?: string;
@@ -583,5 +577,5 @@ declare function getTrackingIds(urlParams?: URLSearchParams): {
583
577
  */
584
578
  declare function getTrackingParams(urlParams?: URLSearchParams): string;
585
579
 
586
- export { trackCustomEvent as a, trackError as b, clear as c, getAnonymousId as d, getSessionId as e, flush as f, getTracker as g, getTrackingIds as h, isTrackerAvailable as i, getTrackingParams as j, track as t };
587
- export type { BaseEventProperties as B, DatabuddyConfig as D, EventProperties as E, PropertiesForEvent as P, ScreenViewFunction as S, TrackFunction as T, EventTypeMap as k, EventName as l, DatabuddyTracker as m, DataAttributes as n, SetGlobalPropertiesFunction as o };
580
+ export { clear as f, flush as g, getAnonymousId as h, getSessionId as i, getTracker as j, getTrackingIds as k, getTrackingParams as l, isTrackerAvailable as m, trackCustomEvent as n, trackError as o, track as t };
581
+ export type { BaseEventProperties as B, DatabuddyConfig as D, EventName as E, PropertiesForEvent as P, ScreenViewFunction as S, TrackFunction as T, DataAttributes as a, DatabuddyTracker as b, EventProperties as c, EventTypeMap as d, SetGlobalPropertiesFunction as e };
@@ -8,7 +8,6 @@
8
8
  * apiUrl="https://basket.databuddy.cc"
9
9
  * trackWebVitals
10
10
  * trackErrors
11
- * trackScrollDepth
12
11
  * samplingRate={0.5}
13
12
  * />
14
13
  * ```
@@ -18,7 +17,7 @@ interface DatabuddyConfig {
18
17
  * Your Databuddy project client ID.
19
18
  * If not provided, will automatically detect from NEXT_PUBLIC_DATABUDDY_CLIENT_ID environment variable.
20
19
  * Get this from your Databuddy dashboard.
21
- * Example: '3ed1fce1-5a56-4cbc-a917-66864f6d18e3'
20
+ * Example: UUID-style or short public id (dashboard client ID).
22
21
  */
23
22
  clientId?: string;
24
23
  /**
@@ -71,10 +70,6 @@ interface DatabuddyConfig {
71
70
  * Track user interactions (default: false).
72
71
  */
73
72
  trackInteractions?: boolean;
74
- /**
75
- * Track scroll depth (default: false).
76
- */
77
- trackScrollDepth?: boolean;
78
73
  /**
79
74
  * Track page performance metrics (default: true).
80
75
  */
@@ -93,7 +88,7 @@ interface DatabuddyConfig {
93
88
  */
94
89
  samplingRate?: number;
95
90
  /**
96
- * Enable retries for failed requests (default: false).
91
+ * Enable retries for failed requests (default: true).
97
92
  */
98
93
  enableRetries?: boolean;
99
94
  /**
@@ -193,19 +188,18 @@ interface EventProperties extends BaseEventProperties {
193
188
  */
194
189
  interface EventTypeMap {
195
190
  screen_view: {
191
+ page_count?: number;
196
192
  time_on_page?: number;
197
193
  scroll_depth?: number;
198
194
  interaction_count?: number;
199
- has_exit_intent?: boolean;
200
- is_bounce?: 0 | 1;
201
195
  };
202
196
  page_exit: {
197
+ path?: string;
198
+ timestamp?: number;
203
199
  time_on_page: number;
204
200
  scroll_depth: number;
205
201
  interaction_count: number;
206
- has_exit_intent: boolean;
207
202
  page_count: number;
208
- is_bounce: 0 | 1;
209
203
  };
210
204
  button_click: {
211
205
  button_text?: string;
@@ -583,5 +577,5 @@ declare function getTrackingIds(urlParams?: URLSearchParams): {
583
577
  */
584
578
  declare function getTrackingParams(urlParams?: URLSearchParams): string;
585
579
 
586
- export { trackCustomEvent as a, trackError as b, clear as c, getAnonymousId as d, getSessionId as e, flush as f, getTracker as g, getTrackingIds as h, isTrackerAvailable as i, getTrackingParams as j, track as t };
587
- export type { BaseEventProperties as B, DatabuddyConfig as D, EventProperties as E, PropertiesForEvent as P, ScreenViewFunction as S, TrackFunction as T, EventTypeMap as k, EventName as l, DatabuddyTracker as m, DataAttributes as n, SetGlobalPropertiesFunction as o };
580
+ export { clear as f, flush as g, getAnonymousId as h, getSessionId as i, getTracker as j, getTrackingIds as k, getTrackingParams as l, isTrackerAvailable as m, trackCustomEvent as n, trackError as o, track as t };
581
+ export type { BaseEventProperties as B, DatabuddyConfig as D, EventName as E, PropertiesForEvent as P, ScreenViewFunction as S, TrackFunction as T, DataAttributes as a, DatabuddyTracker as b, EventProperties as c, EventTypeMap as d, SetGlobalPropertiesFunction as e };
@@ -0,0 +1,46 @@
1
+ const isBrowser = typeof window !== "undefined" && typeof localStorage !== "undefined";
2
+ const STORAGE_KEY = "db-flags";
3
+ const DEFAULT_TTL = 24 * 60 * 60 * 1e3;
4
+ class BrowserFlagStorage {
5
+ ttl;
6
+ constructor(ttl = DEFAULT_TTL) {
7
+ this.ttl = ttl;
8
+ }
9
+ getAll() {
10
+ if (!isBrowser) {
11
+ return {};
12
+ }
13
+ try {
14
+ const raw = localStorage.getItem(STORAGE_KEY);
15
+ if (!raw) {
16
+ return {};
17
+ }
18
+ const blob = JSON.parse(raw);
19
+ if (Date.now() - blob.savedAt > this.ttl) {
20
+ localStorage.removeItem(STORAGE_KEY);
21
+ return {};
22
+ }
23
+ return blob.flags;
24
+ } catch {
25
+ return {};
26
+ }
27
+ }
28
+ setAll(flags) {
29
+ if (!isBrowser) {
30
+ return;
31
+ }
32
+ try {
33
+ const blob = { flags, savedAt: Date.now() };
34
+ localStorage.setItem(STORAGE_KEY, JSON.stringify(blob));
35
+ } catch {
36
+ }
37
+ }
38
+ clear() {
39
+ if (!isBrowser) {
40
+ return;
41
+ }
42
+ localStorage.removeItem(STORAGE_KEY);
43
+ }
44
+ }
45
+
46
+ export { BrowserFlagStorage as B };
@@ -1,4 +1,4 @@
1
- const version = "2.3.28";
1
+ const version = "2.3.30";
2
2
 
3
3
  const INJECTED_SCRIPT_ATTRIBUTE = "data-databuddy-injected";
4
4
  function isScriptInjected() {