@guidelytech/react 0.15.0 → 0.17.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.
- package/README.md +40 -1
- package/dist/index.cjs +188 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +99 -4
- package/dist/index.d.ts +99 -4
- package/dist/index.js +171 -38
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -66,7 +66,46 @@ they read the bootstrap payload — `<GuidelyProvider flagsPayload={…} flagAtt
|
|
|
66
66
|
`account`), so server HTML and hydration match; without a payload they return fallbacks.
|
|
67
67
|
`GuidelyProvider` also accepts `flags={false}` to turn flags off or `flags={{ … }}` for client options.
|
|
68
68
|
|
|
69
|
+
## Error monitoring
|
|
70
|
+
|
|
71
|
+
The client already reports uncaught errors and unhandled rejections, with breadcrumbs. React's
|
|
72
|
+
render errors never reach `window.onerror` in production, so catch them the way Sentry's React SDK
|
|
73
|
+
does (`Sentry.ErrorBoundary` → `GuidelyErrorBoundary`, `withErrorBoundary` →
|
|
74
|
+
`withGuidelyErrorBoundary`, `reactErrorHandler` → `guidelyReactErrorHandler`):
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import { GuidelyErrorBoundary, guidelyReactErrorHandler, useGuidely } from "@guidelytech/react";
|
|
78
|
+
|
|
79
|
+
<GuidelyErrorBoundary
|
|
80
|
+
fallback={({ error, eventId, resetError }) => <Oops onRetry={resetError} reference={eventId} />}
|
|
81
|
+
tags={{ area: "checkout" }}
|
|
82
|
+
beforeCapture={(context, error, componentStack) => { context.extra = { cartId }; }}
|
|
83
|
+
>
|
|
84
|
+
<Checkout />
|
|
85
|
+
</GuidelyErrorBoundary>;
|
|
86
|
+
|
|
87
|
+
// React 19 roots: errors no boundary catches, caught ones and recovered hydration errors.
|
|
88
|
+
createRoot(el, { onUncaughtError: guidelyReactErrorHandler(), onCaughtError: guidelyReactErrorHandler(), onRecoverableError: guidelyReactErrorHandler() });
|
|
89
|
+
|
|
90
|
+
// Anywhere below the provider: the full capture API.
|
|
91
|
+
const guidely = useGuidely();
|
|
92
|
+
guidely.captureException(err, { tags: { area: "billing" }, level: "warning" });
|
|
93
|
+
guidely.addBreadcrumb({ category: "cart", message: "Coupon applied" });
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
| Export | Description |
|
|
97
|
+
|---|---|
|
|
98
|
+
| `<GuidelyErrorBoundary>` | Reports render errors (`mechanism: react.errorboundary`, the component stack in `contexts.react`) and renders `fallback` (an element or `({ error, componentStack, eventId, resetError }) => …`; nothing without one). Props: `onError`, `beforeCapture(context, error, componentStack)`, `onReset`, `tags`, `extra`, `fingerprint`, `level`, `handled` (default: a fallback was given), `showDialog`, `client`. Errors in the provider's first render are sent as soon as it has its client. |
|
|
99
|
+
| `withGuidelyErrorBoundary(Component, props)` | The HOC form. |
|
|
100
|
+
| `useCaptureException(error, hint?)` | Reports an error page's `error` prop once (Next.js `error.tsx`, React Router `errorElement`); returns the event id. |
|
|
101
|
+
| `guidelyReactErrorHandler(client?, callback?)` | For `createRoot`/`hydrateRoot`'s `onUncaughtError` / `onCaughtError` / `onRecoverableError`. Errors a `GuidelyErrorBoundary` caught are left to it; each error object is sent once. `callback` replaces React's logging. |
|
|
102
|
+
| `useGuidely().captureException` / `captureMessage` / `addBreadcrumb` / `setTag(s)` / `setExtra(s)` / `setContext` / `setUser` | The client's capture API (no-ops that return `""` before the provider has a client). |
|
|
103
|
+
|
|
104
|
+
Options go under `errors` on the provider (`<GuidelyProvider errors={{ sampleRate: 0.5, beforeSend }}>`).
|
|
105
|
+
|
|
69
106
|
Types re-exported: `GuidelyClient`, `GuidelyOptions`, `GuidelyEvents`, `GuidelyUser`,
|
|
70
|
-
`ChecklistProgressState`, `PublishedGuide`, `GuideState`, `GuidelyProviderProps`,
|
|
107
|
+
`ChecklistProgressState`, `PublishedGuide`, `GuideState`, `GuidelyProviderProps`,
|
|
108
|
+
`GuidelyErrorBoundaryProps`, `ErrorBoundaryFallbackProps`, `ReactErrorInfo`, `Breadcrumb`,
|
|
109
|
+
`CaptureContext`, `ErrorEvent`, `ErrorLevelName`, `ErrorMonitoringOptions`, `ExceptionDetail`, and from
|
|
71
110
|
`@guidelytech/flags`: `FlagsClient`, `FlagsClientOptions`, `FlagDetails`, `FlagsBootstrap`,
|
|
72
111
|
`FlagsPayload`, `Attributes`, `JsonValue`, `EvaluationResult`.
|
package/dist/index.cjs
CHANGED
|
@@ -4,6 +4,7 @@ var __defProp = Object.defineProperty;
|
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
9
|
for (var name in all)
|
|
9
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -17,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
18
|
return to;
|
|
18
19
|
};
|
|
19
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
20
22
|
|
|
21
23
|
// src/index.tsx
|
|
22
24
|
var index_exports = {};
|
|
@@ -25,8 +27,11 @@ __export(index_exports, {
|
|
|
25
27
|
FeatureFlag: () => FeatureFlag,
|
|
26
28
|
FeatureValue: () => FeatureValue,
|
|
27
29
|
FlagsProvider: () => FlagsProvider,
|
|
30
|
+
GuidelyErrorBoundary: () => GuidelyErrorBoundary,
|
|
28
31
|
GuidelyProvider: () => GuidelyProvider,
|
|
32
|
+
guidelyReactErrorHandler: () => guidelyReactErrorHandler,
|
|
29
33
|
noopClient: () => noopClient,
|
|
34
|
+
useCaptureException: () => useCaptureException,
|
|
30
35
|
useChecklistProgress: () => useChecklistProgress,
|
|
31
36
|
useFeatureValue: () => useFeatureValue,
|
|
32
37
|
useFlag: () => useFlag,
|
|
@@ -38,26 +43,151 @@ __export(index_exports, {
|
|
|
38
43
|
useGuidely: () => useGuidely,
|
|
39
44
|
useGuidelyEvent: () => useGuidelyEvent,
|
|
40
45
|
useGuidelyIdentify: () => useGuidelyIdentify,
|
|
41
|
-
useGuidelyReady: () => useGuidelyReady
|
|
46
|
+
useGuidelyReady: () => useGuidelyReady,
|
|
47
|
+
withGuidelyErrorBoundary: () => withGuidelyErrorBoundary
|
|
42
48
|
});
|
|
43
49
|
module.exports = __toCommonJS(index_exports);
|
|
44
50
|
var import_flags2 = require("@guidelytech/flags");
|
|
51
|
+
var import_sdk_core2 = require("@guidelytech/sdk-core");
|
|
52
|
+
var import_react4 = require("react");
|
|
53
|
+
|
|
54
|
+
// src/context.ts
|
|
55
|
+
var import_react = require("react");
|
|
56
|
+
var GuidelyContext = (0, import_react.createContext)(null);
|
|
57
|
+
|
|
58
|
+
// src/errors.tsx
|
|
45
59
|
var import_sdk_core = require("@guidelytech/sdk-core");
|
|
46
60
|
var import_react2 = require("react");
|
|
61
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
62
|
+
var reported = /* @__PURE__ */ new WeakSet();
|
|
63
|
+
var stackOf = (info) => (info?.componentStack ?? "").slice(0, 8e3);
|
|
64
|
+
function liveClient(client) {
|
|
65
|
+
try {
|
|
66
|
+
if (client && !client.getState().destroyed) return client;
|
|
67
|
+
const current = import_sdk_core.GuidelyClient.get();
|
|
68
|
+
return current && !current.getState().destroyed ? current : null;
|
|
69
|
+
} catch {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
var pending = [];
|
|
74
|
+
function drainPendingErrors(client) {
|
|
75
|
+
for (const p of pending.splice(0)) {
|
|
76
|
+
let eventId = "";
|
|
77
|
+
try {
|
|
78
|
+
eventId = client.captureException(p.error, p.ctx) || "";
|
|
79
|
+
} catch {
|
|
80
|
+
}
|
|
81
|
+
if (eventId) p.done?.(eventId);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function capture(client, error, ctx, done) {
|
|
85
|
+
if (error && typeof error === "object") {
|
|
86
|
+
if (reported.has(error)) return "";
|
|
87
|
+
reported.add(error);
|
|
88
|
+
}
|
|
89
|
+
const c = liveClient(client);
|
|
90
|
+
if (!c) {
|
|
91
|
+
if (pending.length < 10) pending.push({ error, ctx, done });
|
|
92
|
+
return "";
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
return c.captureException(error, ctx) || "";
|
|
96
|
+
} catch {
|
|
97
|
+
return "";
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
var EMPTY = { error: null, componentStack: "", eventId: "" };
|
|
101
|
+
var GuidelyErrorBoundary = class extends import_react2.Component {
|
|
102
|
+
constructor() {
|
|
103
|
+
super(...arguments);
|
|
104
|
+
__publicField(this, "state", { ...EMPTY, failed: false });
|
|
105
|
+
__publicField(this, "resetError", () => {
|
|
106
|
+
const { error, componentStack, eventId } = this.state;
|
|
107
|
+
this.props.onReset?.(error, componentStack, eventId);
|
|
108
|
+
this.setState({ ...EMPTY, failed: false });
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
static getDerivedStateFromError(error) {
|
|
112
|
+
return { error, failed: true };
|
|
113
|
+
}
|
|
114
|
+
componentDidCatch(error, info) {
|
|
115
|
+
const { tags, extra, fingerprint, level, handled, fallback, beforeCapture, onError, showDialog } = this.props;
|
|
116
|
+
const componentStack = stackOf(info);
|
|
117
|
+
const ctx = {
|
|
118
|
+
level: level ?? "error",
|
|
119
|
+
...tags ? { tags: { ...tags } } : {},
|
|
120
|
+
...extra ? { extra: { ...extra } } : {},
|
|
121
|
+
...fingerprint ? { fingerprint } : {},
|
|
122
|
+
contexts: { react: { version: import_react2.version, componentStack } },
|
|
123
|
+
mechanism: { type: "react.errorboundary", handled: handled ?? !!fallback }
|
|
124
|
+
};
|
|
125
|
+
try {
|
|
126
|
+
beforeCapture?.(ctx, error, componentStack);
|
|
127
|
+
} catch {
|
|
128
|
+
}
|
|
129
|
+
const client = this.props.client ?? this.context;
|
|
130
|
+
const eventId = capture(client, error, ctx, (id) => {
|
|
131
|
+
if (this.state.error === error) this.setState({ eventId: id });
|
|
132
|
+
});
|
|
133
|
+
this.setState({ componentStack, eventId });
|
|
134
|
+
onError?.(error, componentStack, eventId);
|
|
135
|
+
if (showDialog && eventId) {
|
|
136
|
+
try {
|
|
137
|
+
liveClient(client)?.showBugReport?.();
|
|
138
|
+
} catch {
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
render() {
|
|
143
|
+
if (!this.state.failed) return this.props.children;
|
|
144
|
+
const { fallback } = this.props;
|
|
145
|
+
if (typeof fallback === "function") return fallback({ error: this.state.error, componentStack: this.state.componentStack, eventId: this.state.eventId, resetError: this.resetError });
|
|
146
|
+
return fallback ?? null;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
__publicField(GuidelyErrorBoundary, "contextType", GuidelyContext);
|
|
150
|
+
function withGuidelyErrorBoundary(Wrapped, options = {}) {
|
|
151
|
+
const name = Wrapped.displayName || Wrapped.name || "Component";
|
|
152
|
+
const WithBoundary = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GuidelyErrorBoundary, { ...options, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Wrapped, { ...props }) });
|
|
153
|
+
WithBoundary.displayName = `guidelyErrorBoundary(${name})`;
|
|
154
|
+
return WithBoundary;
|
|
155
|
+
}
|
|
156
|
+
function useCaptureException(error, hint) {
|
|
157
|
+
const client = (0, import_react2.useContext)(GuidelyContext);
|
|
158
|
+
const [eventId, setEventId] = (0, import_react2.useState)("");
|
|
159
|
+
(0, import_react2.useEffect)(() => {
|
|
160
|
+
if (error === null || error === void 0) return;
|
|
161
|
+
const id = capture(client, error, { ...hint ?? {}, mechanism: hint?.mechanism ?? { type: "react.errorpage", handled: true } }, setEventId);
|
|
162
|
+
if (id) setEventId(id);
|
|
163
|
+
}, [client, error]);
|
|
164
|
+
return eventId;
|
|
165
|
+
}
|
|
166
|
+
function guidelyReactErrorHandler(client, callback) {
|
|
167
|
+
return (error, errorInfo = {}) => {
|
|
168
|
+
let eventId = "";
|
|
169
|
+
if (!(errorInfo.errorBoundary instanceof GuidelyErrorBoundary)) {
|
|
170
|
+
const caught = errorInfo.errorBoundary !== void 0 && errorInfo.errorBoundary !== null;
|
|
171
|
+
eventId = capture(client ?? null, error, { contexts: { react: { version: import_react2.version, componentStack: stackOf(errorInfo) } }, mechanism: { type: "react", handled: caught } });
|
|
172
|
+
}
|
|
173
|
+
if (callback) callback(error, errorInfo, eventId);
|
|
174
|
+
else console.error(error);
|
|
175
|
+
};
|
|
176
|
+
}
|
|
47
177
|
|
|
48
178
|
// src/flags.tsx
|
|
49
179
|
var import_flags = require("@guidelytech/flags");
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var FlagsContext = (0,
|
|
53
|
-
var
|
|
180
|
+
var import_react3 = require("react");
|
|
181
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
182
|
+
var FlagsContext = (0, import_react3.createContext)(null);
|
|
183
|
+
var EMPTY2 = (0, import_flags.createStaticFlags)();
|
|
54
184
|
function useReader() {
|
|
55
|
-
const src = (0,
|
|
56
|
-
return src?.client ?? src?.bootstrap ??
|
|
185
|
+
const src = (0, import_react3.useContext)(FlagsContext);
|
|
186
|
+
return src?.client ?? src?.bootstrap ?? EMPTY2;
|
|
57
187
|
}
|
|
58
188
|
function useFlagsValue(select) {
|
|
59
189
|
const reader = useReader();
|
|
60
|
-
const cache = (0,
|
|
190
|
+
const cache = (0, import_react3.useRef)(null);
|
|
61
191
|
const get = () => {
|
|
62
192
|
const value = select(reader);
|
|
63
193
|
const c = cache.current;
|
|
@@ -65,7 +195,7 @@ function useFlagsValue(select) {
|
|
|
65
195
|
cache.current = { reader, value };
|
|
66
196
|
return value;
|
|
67
197
|
};
|
|
68
|
-
return (0,
|
|
198
|
+
return (0, import_react3.useSyncExternalStore)(reader.subscribe, get, get);
|
|
69
199
|
}
|
|
70
200
|
function useFlag(key, fallback = false) {
|
|
71
201
|
return useFlagsValue((r) => r.isEnabled(key, fallback));
|
|
@@ -83,29 +213,29 @@ function useFlagsReady() {
|
|
|
83
213
|
return useFlagsValue((r) => r.isReady());
|
|
84
214
|
}
|
|
85
215
|
function useFlagsClient() {
|
|
86
|
-
return (0,
|
|
216
|
+
return (0, import_react3.useContext)(FlagsContext)?.client ?? null;
|
|
87
217
|
}
|
|
88
218
|
function Feature({ flag, children, fallback = null }) {
|
|
89
|
-
return /* @__PURE__ */ (0,
|
|
219
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: useFlag(flag) ? children : fallback });
|
|
90
220
|
}
|
|
91
221
|
var FeatureFlag = Feature;
|
|
92
222
|
function FeatureValue({ flag, value, children, fallback = null }) {
|
|
93
223
|
const current = useFeatureValue(flag, null);
|
|
94
|
-
return /* @__PURE__ */ (0,
|
|
224
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: (0, import_flags.jsonEquals)(current, value) ? children : fallback });
|
|
95
225
|
}
|
|
96
226
|
function useBootstrap(payload, attributes) {
|
|
97
227
|
const key = (0, import_flags.stableStringify)(attributes);
|
|
98
|
-
return (0,
|
|
228
|
+
return (0, import_react3.useMemo)(() => payload ? (0, import_flags.createStaticFlags)({ payload, attributes }) : EMPTY2, [payload, key]);
|
|
99
229
|
}
|
|
100
230
|
function FlagsProvider({ children, client: external, payload, ...options }) {
|
|
101
|
-
const [created, setCreated] = (0,
|
|
102
|
-
const optionsRef = (0,
|
|
231
|
+
const [created, setCreated] = (0, import_react3.useState)(null);
|
|
232
|
+
const optionsRef = (0, import_react3.useRef)(options);
|
|
103
233
|
optionsRef.current = options;
|
|
104
234
|
const sdkKey = options.sdkKey ?? options.projectId;
|
|
105
235
|
const { apiUrl, environment } = options;
|
|
106
|
-
const payloadRef = (0,
|
|
236
|
+
const payloadRef = (0, import_react3.useRef)(payload);
|
|
107
237
|
payloadRef.current = payload;
|
|
108
|
-
(0,
|
|
238
|
+
(0, import_react3.useEffect)(() => {
|
|
109
239
|
if (external || !sdkKey || typeof window === "undefined") return;
|
|
110
240
|
let c;
|
|
111
241
|
try {
|
|
@@ -123,51 +253,51 @@ function FlagsProvider({ children, client: external, payload, ...options }) {
|
|
|
123
253
|
const client = external ?? created;
|
|
124
254
|
const attributes = options.attributes ?? {};
|
|
125
255
|
const attrsKey = (0, import_flags.stableStringify)(attributes);
|
|
126
|
-
(0,
|
|
256
|
+
(0, import_react3.useEffect)(() => {
|
|
127
257
|
if (client && options.attributes) client.setAttributes(options.attributes);
|
|
128
258
|
}, [client, attrsKey]);
|
|
129
259
|
const bootstrap = useBootstrap(payload, attributes);
|
|
130
|
-
const value = (0,
|
|
131
|
-
return /* @__PURE__ */ (0,
|
|
260
|
+
const value = (0, import_react3.useMemo)(() => ({ client, bootstrap }), [client, bootstrap]);
|
|
261
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(FlagsContext.Provider, { value, children });
|
|
132
262
|
}
|
|
133
263
|
|
|
134
264
|
// src/index.tsx
|
|
135
|
-
var
|
|
136
|
-
var GuidelyContext = (0, import_react2.createContext)(null);
|
|
265
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
137
266
|
function userAttributes(user) {
|
|
138
267
|
if (!user?.id) return {};
|
|
139
268
|
return { ...user.traits ?? {}, id: user.id, ...user.account ? { account: { ...user.account.traits ?? {}, id: user.account.id } } : {} };
|
|
140
269
|
}
|
|
141
270
|
function GuidelyProvider({ children, user, flagsPayload, flagAttributes, ...options }) {
|
|
142
|
-
const [client, setClient] = (0,
|
|
143
|
-
const optionsRef = (0,
|
|
271
|
+
const [client, setClient] = (0, import_react4.useState)(null);
|
|
272
|
+
const optionsRef = (0, import_react4.useRef)(options);
|
|
144
273
|
optionsRef.current = options;
|
|
145
|
-
const userRef = (0,
|
|
274
|
+
const userRef = (0, import_react4.useRef)(user);
|
|
146
275
|
userRef.current = user;
|
|
147
276
|
const flagsOpts = options.flags === false ? null : options.flags ?? {};
|
|
148
277
|
const payload = flagsPayload ?? flagsOpts?.payload ?? null;
|
|
149
|
-
const payloadRef = (0,
|
|
278
|
+
const payloadRef = (0, import_react4.useRef)(payload);
|
|
150
279
|
payloadRef.current = payload;
|
|
151
|
-
const appAttributes = (0,
|
|
152
|
-
const appAttributesRef = (0,
|
|
280
|
+
const appAttributes = (0, import_react4.useMemo)(() => ({ ...flagsOpts?.attributes ?? {}, ...flagAttributes ?? {} }), [(0, import_flags2.stableStringify)(flagsOpts?.attributes ?? {}), (0, import_flags2.stableStringify)(flagAttributes ?? {})]);
|
|
281
|
+
const appAttributesRef = (0, import_react4.useRef)(appAttributes);
|
|
153
282
|
appAttributesRef.current = appAttributes;
|
|
154
283
|
const { projectId, environment, apiUrl } = options;
|
|
155
|
-
(0,
|
|
284
|
+
(0, import_react4.useEffect)(() => {
|
|
156
285
|
if (typeof window === "undefined" || !projectId) return;
|
|
157
286
|
const o = optionsRef.current;
|
|
158
|
-
const c = (0,
|
|
287
|
+
const c = (0, import_sdk_core2.createGuidely)({ ...o, projectId, environment, apiUrl, user: userRef.current?.id ? userRef.current : void 0, flags: o.flags === false ? false : { ...o.flags ?? {}, payload: payloadRef.current ?? void 0, attributes: appAttributesRef.current } });
|
|
159
288
|
setClient(c);
|
|
289
|
+
drainPendingErrors(c);
|
|
160
290
|
return () => {
|
|
161
291
|
c.destroy();
|
|
162
292
|
setClient((cur) => cur === c ? null : cur);
|
|
163
293
|
};
|
|
164
294
|
}, [projectId, environment, apiUrl]);
|
|
165
|
-
(0,
|
|
295
|
+
(0, import_react4.useEffect)(() => {
|
|
166
296
|
client?.flags.setAttributes(appAttributes);
|
|
167
297
|
}, [client, appAttributes]);
|
|
168
298
|
const userKey = user ? JSON.stringify([user.id, user.traits ?? null, user.account ?? null]) : "";
|
|
169
|
-
const hadUser = (0,
|
|
170
|
-
(0,
|
|
299
|
+
const hadUser = (0, import_react4.useRef)(false);
|
|
300
|
+
(0, import_react4.useEffect)(() => {
|
|
171
301
|
if (!client) return;
|
|
172
302
|
if (user && user.id) {
|
|
173
303
|
hadUser.current = true;
|
|
@@ -178,8 +308,8 @@ function GuidelyProvider({ children, user, flagsPayload, flagAttributes, ...opti
|
|
|
178
308
|
}
|
|
179
309
|
}, [client, userKey]);
|
|
180
310
|
const bootstrap = useBootstrap(payload, { ...userAttributes(user), ...appAttributes });
|
|
181
|
-
const flags = (0,
|
|
182
|
-
return /* @__PURE__ */ (0,
|
|
311
|
+
const flags = (0, import_react4.useMemo)(() => ({ client: client?.flags ?? null, bootstrap }), [client, bootstrap]);
|
|
312
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(GuidelyContext.Provider, { value: client, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FlagsContext.Provider, { value: flags, children }) });
|
|
183
313
|
}
|
|
184
314
|
var NOOP_RESULTS = {
|
|
185
315
|
init: Promise.resolve(),
|
|
@@ -200,7 +330,9 @@ var NOOP_RESULTS = {
|
|
|
200
330
|
getSessionId: "",
|
|
201
331
|
isRecording: false,
|
|
202
332
|
agentConversation: false,
|
|
203
|
-
trackAgentTurn: false
|
|
333
|
+
trackAgentTurn: false,
|
|
334
|
+
captureException: "",
|
|
335
|
+
captureMessage: ""
|
|
204
336
|
};
|
|
205
337
|
var noopFlags = new Proxy((0, import_flags2.createStaticFlags)(), {
|
|
206
338
|
get(target, prop, receiver) {
|
|
@@ -228,12 +360,12 @@ var noopClient = new Proxy({}, {
|
|
|
228
360
|
}
|
|
229
361
|
});
|
|
230
362
|
function useGuidely() {
|
|
231
|
-
return (0,
|
|
363
|
+
return (0, import_react4.useContext)(GuidelyContext) ?? noopClient;
|
|
232
364
|
}
|
|
233
365
|
function useGuidelyReady() {
|
|
234
|
-
const client = (0,
|
|
235
|
-
const [ready, setReady] = (0,
|
|
236
|
-
(0,
|
|
366
|
+
const client = (0, import_react4.useContext)(GuidelyContext);
|
|
367
|
+
const [ready, setReady] = (0, import_react4.useState)(false);
|
|
368
|
+
(0, import_react4.useEffect)(() => {
|
|
237
369
|
if (!client) {
|
|
238
370
|
setReady(false);
|
|
239
371
|
return;
|
|
@@ -244,27 +376,27 @@ function useGuidelyReady() {
|
|
|
244
376
|
return ready;
|
|
245
377
|
}
|
|
246
378
|
function useGuidelyIdentify(userId, traits, account) {
|
|
247
|
-
const client = (0,
|
|
379
|
+
const client = (0, import_react4.useContext)(GuidelyContext);
|
|
248
380
|
const key = JSON.stringify([userId ?? null, traits ?? null, account ?? null]);
|
|
249
|
-
(0,
|
|
381
|
+
(0, import_react4.useEffect)(() => {
|
|
250
382
|
if (!client || !userId) return;
|
|
251
383
|
void client.identify(userId, traits, account);
|
|
252
384
|
}, [client, key]);
|
|
253
385
|
}
|
|
254
386
|
function useGuidelyEvent(event, handler) {
|
|
255
|
-
const client = (0,
|
|
256
|
-
const ref = (0,
|
|
387
|
+
const client = (0, import_react4.useContext)(GuidelyContext);
|
|
388
|
+
const ref = (0, import_react4.useRef)(handler);
|
|
257
389
|
ref.current = handler;
|
|
258
|
-
(0,
|
|
390
|
+
(0, import_react4.useEffect)(() => {
|
|
259
391
|
if (!client) return;
|
|
260
392
|
const cb = ((...args) => ref.current(...args));
|
|
261
393
|
return client.on(event, cb);
|
|
262
394
|
}, [client, event]);
|
|
263
395
|
}
|
|
264
396
|
function useChecklistProgress(idOrKey) {
|
|
265
|
-
const client = (0,
|
|
266
|
-
const [progress, setProgress] = (0,
|
|
267
|
-
(0,
|
|
397
|
+
const client = (0, import_react4.useContext)(GuidelyContext);
|
|
398
|
+
const [progress, setProgress] = (0, import_react4.useState)({ completedTaskIds: [], completedAt: null, dismissedAt: null });
|
|
399
|
+
(0, import_react4.useEffect)(() => {
|
|
268
400
|
if (!client) return;
|
|
269
401
|
const update = () => setProgress(client.getChecklistProgress(idOrKey));
|
|
270
402
|
update();
|
|
@@ -274,9 +406,9 @@ function useChecklistProgress(idOrKey) {
|
|
|
274
406
|
return progress;
|
|
275
407
|
}
|
|
276
408
|
function useGuideState(idOrKey) {
|
|
277
|
-
const client = (0,
|
|
278
|
-
const [state, setState] = (0,
|
|
279
|
-
(0,
|
|
409
|
+
const client = (0, import_react4.useContext)(GuidelyContext);
|
|
410
|
+
const [state, setState] = (0, import_react4.useState)({ active: false, completed: false, stepId: null, stepIndex: -1, guide: null });
|
|
411
|
+
(0, import_react4.useEffect)(() => {
|
|
280
412
|
if (!client) return;
|
|
281
413
|
const matches = (g) => g.id === idOrKey || g.key === idOrKey;
|
|
282
414
|
const compute = () => {
|
|
@@ -297,8 +429,11 @@ function useGuideState(idOrKey) {
|
|
|
297
429
|
FeatureFlag,
|
|
298
430
|
FeatureValue,
|
|
299
431
|
FlagsProvider,
|
|
432
|
+
GuidelyErrorBoundary,
|
|
300
433
|
GuidelyProvider,
|
|
434
|
+
guidelyReactErrorHandler,
|
|
301
435
|
noopClient,
|
|
436
|
+
useCaptureException,
|
|
302
437
|
useChecklistProgress,
|
|
303
438
|
useFeatureValue,
|
|
304
439
|
useFlag,
|
|
@@ -310,6 +445,7 @@ function useGuideState(idOrKey) {
|
|
|
310
445
|
useGuidely,
|
|
311
446
|
useGuidelyEvent,
|
|
312
447
|
useGuidelyIdentify,
|
|
313
|
-
useGuidelyReady
|
|
448
|
+
useGuidelyReady,
|
|
449
|
+
withGuidelyErrorBoundary
|
|
314
450
|
});
|
|
315
451
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx","../src/flags.tsx"],"sourcesContent":["import { createStaticFlags, stableStringify, type Attributes, type FlagDetails, type FlagsBootstrap, type FlagsClient } from \"@guidelytech/flags\";\nimport { createGuidely, type ChecklistProgressState, type GuidelyClient, type GuidelyEvents, type GuidelyOptions, type GuidelyUser, type PublishedGuide } from \"@guidelytech/sdk-core\";\nimport { createContext, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from \"react\";\nimport { FlagsContext, useBootstrap, type FlagsSource } from \"./flags\";\n\nexport type { GuidelyClient, GuidelyOptions, GuidelyEvents, GuidelyUser, ChecklistProgressState, PublishedGuide, AgentTurnInput, AgentTurnRedactor } from \"@guidelytech/sdk-core\";\nexport { useFlag, useFeatureValue, useFlagDetails, useFlags, useFlagsReady, useFlagsClient, Feature, FeatureFlag, FeatureValue, FlagsProvider } from \"./flags\";\nexport type { FeatureProps, FeatureValueProps, FlagsProviderProps } from \"./flags\";\nexport type { FlagsClient, FlagsClientOptions, FlagDetails, FlagsBootstrap, FlagsPayload, Attributes, JsonValue, EvaluationResult } from \"@guidelytech/flags\";\n\nconst GuidelyContext = createContext<GuidelyClient | null>(null);\n\nexport interface GuidelyProviderProps extends Omit<GuidelyOptions, \"user\"> {\n /** Identify this user as soon as the client is ready; `undefined` resets the identity. */\n user?: GuidelyUser | null;\n /**\n * Flags bootstrap from the server (`getFlagsBootstrap()` / `client.getPayload()`): flag hooks\n * render the same values on the server, during hydration and after.\n */\n flagsPayload?: FlagsBootstrap | null;\n /** Extra flag attributes (merged over the automatic identity, page and device attributes). */\n flagAttributes?: Attributes;\n children?: ReactNode;\n}\n\n/** The attributes the server knows about a user: what bootstrap snapshots evaluate with. */\nfunction userAttributes(user: GuidelyUser | null | undefined): Attributes {\n if (!user?.id) return {};\n return { ...(user.traits ?? {}), id: user.id, ...(user.account ? { account: { ...(user.account.traits ?? {}), id: user.account.id } } : {}) };\n}\n\n/**\n * Creates one Guidely client for the subtree. The client is created inside an effect (never\n * during SSR) and destroyed on unmount, so React Strict Mode's double-invoke is harmless.\n */\nexport function GuidelyProvider({ children, user, flagsPayload, flagAttributes, ...options }: GuidelyProviderProps) {\n const [client, setClient] = useState<GuidelyClient | null>(null);\n const optionsRef = useRef(options);\n optionsRef.current = options;\n const userRef = useRef(user);\n userRef.current = user;\n const flagsOpts = options.flags === false ? null : (options.flags ?? {});\n const payload = flagsPayload ?? flagsOpts?.payload ?? null;\n const payloadRef = useRef(payload);\n payloadRef.current = payload;\n const appAttributes = useMemo(() => ({ ...(flagsOpts?.attributes ?? {}), ...(flagAttributes ?? {}) }), [stableStringify(flagsOpts?.attributes ?? {}), stableStringify(flagAttributes ?? {})]);\n const appAttributesRef = useRef(appAttributes);\n appAttributesRef.current = appAttributes;\n const { projectId, environment, apiUrl } = options;\n\n useEffect(() => {\n if (typeof window === \"undefined\" || !projectId) return;\n const o = optionsRef.current;\n // The user is known up front so flags evaluate for them from the first render (no flicker).\n const c = createGuidely({ ...o, projectId, environment, apiUrl, user: userRef.current?.id ? userRef.current : undefined, flags: o.flags === false ? false : { ...(o.flags ?? {}), payload: payloadRef.current ?? undefined, attributes: appAttributesRef.current } });\n setClient(c);\n return () => {\n c.destroy();\n setClient((cur) => (cur === c ? null : cur));\n };\n }, [projectId, environment, apiUrl]);\n\n useEffect(() => {\n client?.flags.setAttributes(appAttributes);\n }, [client, appAttributes]);\n\n const userKey = user ? JSON.stringify([user.id, user.traits ?? null, user.account ?? null]) : \"\";\n const hadUser = useRef(false);\n useEffect(() => {\n if (!client) return;\n if (user && user.id) {\n hadUser.current = true;\n void client.identify(user.id, user.traits, user.account);\n } else if (hadUser.current) {\n hadUser.current = false;\n client.reset();\n }\n }, [client, userKey]);\n\n const bootstrap = useBootstrap(payload, { ...userAttributes(user), ...appAttributes });\n const flags = useMemo<FlagsSource>(() => ({ client: client?.flags ?? null, bootstrap }), [client, bootstrap]);\n return (\n <GuidelyContext.Provider value={client}>\n <FlagsContext.Provider value={flags}>{children}</FlagsContext.Provider>\n </GuidelyContext.Provider>\n );\n}\n\nconst NOOP_RESULTS: Record<string, unknown> = {\n init: Promise.resolve(),\n ready: Promise.resolve(),\n identify: Promise.resolve(),\n setAccount: Promise.resolve(),\n updateTraits: Promise.resolve(),\n refresh: Promise.resolve(),\n startGuide: false,\n getActiveGuide: null,\n getGuides: [],\n getChecklistProgress: { completedTaskIds: [], completedAt: null, dismissedAt: null },\n isGuideCompleted: false,\n on: () => {},\n getState: { ready: false, destroyed: false },\n getContext: null,\n getSessionId: \"\",\n isRecording: false,\n agentConversation: false,\n trackAgentTurn: false,\n};\n\n/** Flags that serve every fallback; `useGuidely().flags` before the provider has a client. */\nconst noopFlags = new Proxy(createStaticFlags() as unknown as FlagsClient, {\n get(target, prop, receiver) {\n if (prop in target) return Reflect.get(target, prop, receiver);\n if (prop === \"ready\" || prop === \"refresh\" || prop === \"flush\") return () => Promise.resolve();\n if (prop === \"getPayload\") return () => null;\n if (prop === \"forUser\") return () => target;\n return typeof prop === \"string\" ? () => undefined : undefined;\n },\n});\n\nconst missing = <T,>(key: string, fallback: T): FlagDetails<T> => ({ key, value: fallback, reason: \"FLAG_NOT_FOUND\", inExperiment: false, usedFallback: true });\n\n/** Methods whose no-op answer depends on the arguments (flag getters return the fallback). */\nconst NOOP_FUNCTIONS: Record<string, (...args: any[]) => unknown> = {\n isFeatureEnabled: (_key: string, fallback = false) => fallback,\n getFeatureValue: (_key: string, fallback: unknown) => fallback,\n getFeatureDetails: (key: string, fallback: unknown) => missing(key, fallback),\n onFlagsChange: () => () => {},\n};\n\n/** A client that ignores every call; returned by `useGuidely()` on the server and before the provider mounts. */\nexport const noopClient: GuidelyClient = new Proxy({} as GuidelyClient, {\n get(_target, prop) {\n if (prop === \"options\") return { projectId: \"\" };\n if (prop === \"flags\") return noopFlags;\n if (typeof prop !== \"string\") return undefined;\n return NOOP_FUNCTIONS[prop] ?? (() => NOOP_RESULTS[prop]);\n },\n});\n\n/** The Guidely client, or a no-op client during SSR / before the provider has mounted. */\nexport function useGuidely(): GuidelyClient {\n return useContext(GuidelyContext) ?? noopClient;\n}\n\n/** True once the client has loaded its configuration. */\nexport function useGuidelyReady(): boolean {\n const client = useContext(GuidelyContext);\n const [ready, setReady] = useState(false);\n useEffect(() => {\n if (!client) {\n setReady(false);\n return;\n }\n if (client.getState().ready) setReady(true);\n return client.on(\"ready\", () => setReady(true));\n }, [client]);\n return ready;\n}\n\n/** Identifies the user whenever the arguments change. */\nexport function useGuidelyIdentify(userId: string | null | undefined, traits?: Record<string, unknown>, account?: GuidelyUser[\"account\"]): void {\n const client = useContext(GuidelyContext);\n const key = JSON.stringify([userId ?? null, traits ?? null, account ?? null]);\n useEffect(() => {\n if (!client || !userId) return;\n void client.identify(userId, traits, account);\n }, [client, key]);\n}\n\n/** Subscribes to a client event for the lifetime of the component. */\nexport function useGuidelyEvent<K extends keyof GuidelyEvents>(event: K, handler: GuidelyEvents[K]): void {\n const client = useContext(GuidelyContext);\n const ref = useRef(handler);\n ref.current = handler;\n useEffect(() => {\n if (!client) return;\n const cb = ((...args: unknown[]) => (ref.current as (...a: unknown[]) => void)(...args)) as GuidelyEvents[K];\n return client.on(event, cb);\n }, [client, event]);\n}\n\n/** Live checklist progress for a checklist guide (by id or key). */\nexport function useChecklistProgress(idOrKey: string): ChecklistProgressState {\n const client = useContext(GuidelyContext);\n const [progress, setProgress] = useState<ChecklistProgressState>({ completedTaskIds: [], completedAt: null, dismissedAt: null });\n useEffect(() => {\n if (!client) return;\n const update = () => setProgress(client.getChecklistProgress(idOrKey));\n update();\n const offs = [client.on(\"ready\", update), client.on(\"identify\", update), client.on(\"checklist:task\", update), client.on(\"checklist:complete\", update)];\n return () => offs.forEach((off) => off());\n }, [client, idOrKey]);\n return progress;\n}\n\nexport interface GuideState {\n /** The guide is currently showing. */\n active: boolean;\n completed: boolean;\n stepId: string | null;\n stepIndex: number;\n guide: PublishedGuide | null;\n}\n\n/** Live state of a guide (by id or key): active, completed, current step. */\nexport function useGuideState(idOrKey: string): GuideState {\n const client = useContext(GuidelyContext);\n const [state, setState] = useState<GuideState>({ active: false, completed: false, stepId: null, stepIndex: -1, guide: null });\n useEffect(() => {\n if (!client) return;\n const matches = (g: PublishedGuide) => g.id === idOrKey || g.key === idOrKey;\n const compute = () => {\n const guide = client.getGuides().find(matches) ?? null;\n const active = client.getActiveGuide();\n const s = client.getState().activeGuide;\n setState({ active: !!active && matches(active), completed: client.isGuideCompleted(idOrKey), stepId: active && matches(active) ? ((s as { stepId?: string | null } | null)?.stepId ?? null) : null, stepIndex: active && matches(active) ? ((s as { stepIndex?: number } | null)?.stepIndex ?? -1) : -1, guide });\n };\n compute();\n const offs = ([\"ready\", \"identify\", \"guide:start\", \"guide:step\", \"guide:complete\", \"guide:dismiss\", \"guide:skip\"] as const).map((e) => client.on(e, compute));\n return () => offs.forEach((off) => off());\n }, [client, idOrKey]);\n return state;\n}\n","import { createFlagsClient, createStaticFlags, jsonEquals, stableStringify, type Attributes, type FlagDetails, type FlagValue, type FlagsBootstrap, type FlagsClient, type FlagsClientOptions, type FlagsReader, type JsonValue } from \"@guidelytech/flags\";\nimport { createContext, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore, type ReactNode } from \"react\";\n\n/** What the flag hooks read: the live client once created, else a static snapshot of the bootstrap payload. */\nexport interface FlagsSource {\n client: FlagsClient | null;\n bootstrap: FlagsReader;\n}\n\nexport const FlagsContext = createContext<FlagsSource | null>(null);\n\nconst EMPTY = createStaticFlags();\n\nfunction useReader(): FlagsReader {\n const src = useContext(FlagsContext);\n return src?.client ?? src?.bootstrap ?? EMPTY;\n}\n\n/**\n * Subscribes to the flags with `useSyncExternalStore`. Values are compared deeply so object\n * flags keep their identity between renders. The server snapshot is the bootstrap payload, so\n * server-rendered HTML and hydration agree.\n */\nfunction useFlagsValue<T>(select: (reader: FlagsReader) => T): T {\n const reader = useReader();\n const cache = useRef<{ reader: FlagsReader; value: T } | null>(null);\n const get = () => {\n const value = select(reader);\n const c = cache.current;\n if (c && c.reader === reader && jsonEquals(c.value, value)) return c.value;\n cache.current = { reader, value };\n return value;\n };\n return useSyncExternalStore(reader.subscribe, get, get);\n}\n\n/** Is the boolean flag on? `fallback` (default `false`) until flags load, or when missing. */\nexport function useFlag(key: string, fallback = false): boolean {\n return useFlagsValue((r) => r.isEnabled(key, fallback));\n}\n\n/** A flag's value (string, number, JSON…); `fallback` when missing or of a different type. */\nexport function useFeatureValue<T extends JsonValue>(key: string, fallback: T): FlagValue<T> {\n return useFlagsValue((r) => r.getValue(key, fallback));\n}\n\n/** A flag's value plus why it was served (reason, rule, variation, experiment). */\nexport function useFlagDetails<T extends JsonValue>(key: string, fallback: T): FlagDetails<FlagValue<T>> {\n return useFlagsValue((r) => r.getDetails(key, fallback));\n}\n\n/** Every flag's value (records no exposures). */\nexport function useFlags(): Record<string, JsonValue> {\n return useFlagsValue((r) => r.getAll());\n}\n\n/** True once flags have loaded (or failed to and serve fallbacks); true from the start with a bootstrap payload. */\nexport function useFlagsReady(): boolean {\n return useFlagsValue((r) => r.isReady());\n}\n\n/** The flags client (`null` on the server and before the provider has created it). */\nexport function useFlagsClient(): FlagsClient | null {\n return useContext(FlagsContext)?.client ?? null;\n}\n\nexport interface FeatureProps {\n flag: string;\n children?: ReactNode;\n /** Rendered while the flag is off (default: nothing). */\n fallback?: ReactNode;\n}\n\n/** Renders `children` when the boolean flag is on, else `fallback`. */\nexport function Feature({ flag, children, fallback = null }: FeatureProps) {\n return <>{useFlag(flag) ? children : fallback}</>;\n}\n\n/** Alias of {@link Feature}. */\nexport const FeatureFlag = Feature;\n\nexport interface FeatureValueProps extends FeatureProps {\n /** Renders `children` when the flag's value equals this (deep equality). */\n value: JsonValue;\n}\n\n/** Renders `children` when the flag's value equals `value` (e.g. an experiment variation), else `fallback`. */\nexport function FeatureValue({ flag, value, children, fallback = null }: FeatureValueProps) {\n const current = useFeatureValue<JsonValue>(flag, null);\n return <>{jsonEquals(current, value) ? children : fallback}</>;\n}\n\n/** A static snapshot for SSR and hydration, rebuilt only when the payload or attributes change. */\nexport function useBootstrap(payload: FlagsBootstrap | null | undefined, attributes: Attributes): FlagsReader {\n const key = stableStringify(attributes);\n return useMemo(() => (payload ? createStaticFlags({ payload, attributes }) : EMPTY), [payload, key]);\n}\n\nexport interface FlagsProviderProps extends Omit<FlagsClientOptions, \"payload\"> {\n /** Bootstrap from the server (`getPayload()`): renders the same values on the server and in the browser. */\n payload?: FlagsBootstrap | null;\n /** Use an existing client instead of creating one. */\n client?: FlagsClient;\n children?: ReactNode;\n}\n\n/**\n * Feature flags only (no guides or analytics). Creates a flags client in an effect (never during\n * SSR) and destroys it on unmount; until then hooks read the `payload` snapshot. Changing\n * `attributes` re-evaluates without recreating the client.\n *\n * ```tsx\n * <FlagsProvider sdkKey=\"pk_prod_…\" attributes={{ id: user.id, plan: user.plan }} payload={bootstrap}>\n * ```\n */\nexport function FlagsProvider({ children, client: external, payload, ...options }: FlagsProviderProps) {\n const [created, setCreated] = useState<FlagsClient | null>(null);\n const optionsRef = useRef(options);\n optionsRef.current = options;\n const sdkKey = options.sdkKey ?? options.projectId;\n const { apiUrl, environment } = options;\n const payloadRef = useRef(payload);\n payloadRef.current = payload;\n\n useEffect(() => {\n if (external || !sdkKey || typeof window === \"undefined\") return;\n let c: FlagsClient;\n try {\n c = createFlagsClient({ ...optionsRef.current, sdkKey, payload: payloadRef.current ?? undefined });\n } catch (err) {\n optionsRef.current.onError?.(err instanceof Error ? err : new Error(String(err)));\n return;\n }\n setCreated(c);\n return () => {\n c.destroy();\n setCreated((cur) => (cur === c ? null : cur));\n };\n }, [external, sdkKey, apiUrl, environment]);\n\n const client = external ?? created;\n const attributes = options.attributes ?? {};\n const attrsKey = stableStringify(attributes);\n useEffect(() => {\n if (client && options.attributes) client.setAttributes(options.attributes);\n }, [client, attrsKey]);\n\n const bootstrap = useBootstrap(payload, attributes);\n const value = useMemo<FlagsSource>(() => ({ client, bootstrap }), [client, bootstrap]);\n return <FlagsContext.Provider value={value}>{children}</FlagsContext.Provider>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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UAAU,QAAQ,MAAM,GAAG,WAAW,OAAO,iBAAiB,OAAO,GAAG,QAAQ,UAAU,QAAQ,MAAM,IAAM,GAAyC,UAAU,OAAQ,MAAM,WAAW,UAAU,QAAQ,MAAM,IAAM,GAAqC,aAAa,KAAM,IAAI,MAAM,CAAC;AAAA,IAClT;AACA,YAAQ;AACR,UAAM,OAAQ,CAAC,SAAS,YAAY,eAAe,cAAc,kBAAkB,iBAAiB,YAAY,EAAY,IAAI,CAAC,MAAM,OAAO,GAAG,GAAG,OAAO,CAAC;AAC5J,WAAO,MAAM,KAAK,QAAQ,CAAC,QAAQ,IAAI,CAAC;AAAA,EAC1C,GAAG,CAAC,QAAQ,OAAO,CAAC;AACpB,SAAO;AACT;","names":["import_flags","import_react","import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx","../src/context.ts","../src/errors.tsx","../src/flags.tsx"],"sourcesContent":["import { createStaticFlags, stableStringify, type Attributes, type FlagDetails, type FlagsBootstrap, type FlagsClient } from \"@guidelytech/flags\";\nimport { createGuidely, type ChecklistProgressState, type GuidelyClient, type GuidelyEvents, type GuidelyOptions, type GuidelyUser, type PublishedGuide } from \"@guidelytech/sdk-core\";\nimport { useContext, useEffect, useMemo, useRef, useState, type ReactNode } from \"react\";\nimport { GuidelyContext } from \"./context\";\nimport { drainPendingErrors } from \"./errors\";\nimport { FlagsContext, useBootstrap, type FlagsSource } from \"./flags\";\n\nexport type { GuidelyClient, GuidelyOptions, GuidelyEvents, GuidelyUser, ChecklistProgressState, PublishedGuide, AgentTurnInput, AgentTurnRedactor } from \"@guidelytech/sdk-core\";\nexport { useFlag, useFeatureValue, useFlagDetails, useFlags, useFlagsReady, useFlagsClient, Feature, FeatureFlag, FeatureValue, FlagsProvider } from \"./flags\";\nexport type { FeatureProps, FeatureValueProps, FlagsProviderProps } from \"./flags\";\nexport type { FlagsClient, FlagsClientOptions, FlagDetails, FlagsBootstrap, FlagsPayload, Attributes, JsonValue, EvaluationResult } from \"@guidelytech/flags\";\nexport { GuidelyErrorBoundary, withGuidelyErrorBoundary, useCaptureException, guidelyReactErrorHandler } from \"./errors\";\nexport type { GuidelyErrorBoundaryProps, ErrorBoundaryFallbackProps, ReactErrorInfo } from \"./errors\";\nexport type { Breadcrumb, CaptureContext, ErrorEvent, ErrorLevelName, ErrorMonitoringOptions, ExceptionDetail } from \"@guidelytech/sdk-core\";\n\nexport interface GuidelyProviderProps extends Omit<GuidelyOptions, \"user\"> {\n /** Identify this user as soon as the client is ready; `undefined` resets the identity. */\n user?: GuidelyUser | null;\n /**\n * Flags bootstrap from the server (`getFlagsBootstrap()` / `client.getPayload()`): flag hooks\n * render the same values on the server, during hydration and after.\n */\n flagsPayload?: FlagsBootstrap | null;\n /** Extra flag attributes (merged over the automatic identity, page and device attributes). */\n flagAttributes?: Attributes;\n children?: ReactNode;\n}\n\n/** The attributes the server knows about a user: what bootstrap snapshots evaluate with. */\nfunction userAttributes(user: GuidelyUser | null | undefined): Attributes {\n if (!user?.id) return {};\n return { ...(user.traits ?? {}), id: user.id, ...(user.account ? { account: { ...(user.account.traits ?? {}), id: user.account.id } } : {}) };\n}\n\n/**\n * Creates one Guidely client for the subtree. The client is created inside an effect (never\n * during SSR) and destroyed on unmount, so React Strict Mode's double-invoke is harmless.\n */\nexport function GuidelyProvider({ children, user, flagsPayload, flagAttributes, ...options }: GuidelyProviderProps) {\n const [client, setClient] = useState<GuidelyClient | null>(null);\n const optionsRef = useRef(options);\n optionsRef.current = options;\n const userRef = useRef(user);\n userRef.current = user;\n const flagsOpts = options.flags === false ? null : (options.flags ?? {});\n const payload = flagsPayload ?? flagsOpts?.payload ?? null;\n const payloadRef = useRef(payload);\n payloadRef.current = payload;\n const appAttributes = useMemo(() => ({ ...(flagsOpts?.attributes ?? {}), ...(flagAttributes ?? {}) }), [stableStringify(flagsOpts?.attributes ?? {}), stableStringify(flagAttributes ?? {})]);\n const appAttributesRef = useRef(appAttributes);\n appAttributesRef.current = appAttributes;\n const { projectId, environment, apiUrl } = options;\n\n useEffect(() => {\n if (typeof window === \"undefined\" || !projectId) return;\n const o = optionsRef.current;\n // The user is known up front so flags evaluate for them from the first render (no flicker).\n const c = createGuidely({ ...o, projectId, environment, apiUrl, user: userRef.current?.id ? userRef.current : undefined, flags: o.flags === false ? false : { ...(o.flags ?? {}), payload: payloadRef.current ?? undefined, attributes: appAttributesRef.current } });\n setClient(c);\n // Render errors caught before the client existed (the first render) go out now.\n drainPendingErrors(c);\n return () => {\n c.destroy();\n setClient((cur) => (cur === c ? null : cur));\n };\n }, [projectId, environment, apiUrl]);\n\n useEffect(() => {\n client?.flags.setAttributes(appAttributes);\n }, [client, appAttributes]);\n\n const userKey = user ? JSON.stringify([user.id, user.traits ?? null, user.account ?? null]) : \"\";\n const hadUser = useRef(false);\n useEffect(() => {\n if (!client) return;\n if (user && user.id) {\n hadUser.current = true;\n void client.identify(user.id, user.traits, user.account);\n } else if (hadUser.current) {\n hadUser.current = false;\n client.reset();\n }\n }, [client, userKey]);\n\n const bootstrap = useBootstrap(payload, { ...userAttributes(user), ...appAttributes });\n const flags = useMemo<FlagsSource>(() => ({ client: client?.flags ?? null, bootstrap }), [client, bootstrap]);\n return (\n <GuidelyContext.Provider value={client}>\n <FlagsContext.Provider value={flags}>{children}</FlagsContext.Provider>\n </GuidelyContext.Provider>\n );\n}\n\nconst NOOP_RESULTS: Record<string, unknown> = {\n init: Promise.resolve(),\n ready: Promise.resolve(),\n identify: Promise.resolve(),\n setAccount: Promise.resolve(),\n updateTraits: Promise.resolve(),\n refresh: Promise.resolve(),\n startGuide: false,\n getActiveGuide: null,\n getGuides: [],\n getChecklistProgress: { completedTaskIds: [], completedAt: null, dismissedAt: null },\n isGuideCompleted: false,\n on: () => {},\n getState: { ready: false, destroyed: false },\n getContext: null,\n getSessionId: \"\",\n isRecording: false,\n agentConversation: false,\n trackAgentTurn: false,\n captureException: \"\",\n captureMessage: \"\",\n};\n\n/** Flags that serve every fallback; `useGuidely().flags` before the provider has a client. */\nconst noopFlags = new Proxy(createStaticFlags() as unknown as FlagsClient, {\n get(target, prop, receiver) {\n if (prop in target) return Reflect.get(target, prop, receiver);\n if (prop === \"ready\" || prop === \"refresh\" || prop === \"flush\") return () => Promise.resolve();\n if (prop === \"getPayload\") return () => null;\n if (prop === \"forUser\") return () => target;\n return typeof prop === \"string\" ? () => undefined : undefined;\n },\n});\n\nconst missing = <T,>(key: string, fallback: T): FlagDetails<T> => ({ key, value: fallback, reason: \"FLAG_NOT_FOUND\", inExperiment: false, usedFallback: true });\n\n/** Methods whose no-op answer depends on the arguments (flag getters return the fallback). */\nconst NOOP_FUNCTIONS: Record<string, (...args: any[]) => unknown> = {\n isFeatureEnabled: (_key: string, fallback = false) => fallback,\n getFeatureValue: (_key: string, fallback: unknown) => fallback,\n getFeatureDetails: (key: string, fallback: unknown) => missing(key, fallback),\n onFlagsChange: () => () => {},\n};\n\n/** A client that ignores every call; returned by `useGuidely()` on the server and before the provider mounts. */\nexport const noopClient: GuidelyClient = new Proxy({} as GuidelyClient, {\n get(_target, prop) {\n if (prop === \"options\") return { projectId: \"\" };\n if (prop === \"flags\") return noopFlags;\n if (typeof prop !== \"string\") return undefined;\n return NOOP_FUNCTIONS[prop] ?? (() => NOOP_RESULTS[prop]);\n },\n});\n\n/** The Guidely client, or a no-op client during SSR / before the provider has mounted. */\nexport function useGuidely(): GuidelyClient {\n return useContext(GuidelyContext) ?? noopClient;\n}\n\n/** True once the client has loaded its configuration. */\nexport function useGuidelyReady(): boolean {\n const client = useContext(GuidelyContext);\n const [ready, setReady] = useState(false);\n useEffect(() => {\n if (!client) {\n setReady(false);\n return;\n }\n if (client.getState().ready) setReady(true);\n return client.on(\"ready\", () => setReady(true));\n }, [client]);\n return ready;\n}\n\n/** Identifies the user whenever the arguments change. */\nexport function useGuidelyIdentify(userId: string | null | undefined, traits?: Record<string, unknown>, account?: GuidelyUser[\"account\"]): void {\n const client = useContext(GuidelyContext);\n const key = JSON.stringify([userId ?? null, traits ?? null, account ?? null]);\n useEffect(() => {\n if (!client || !userId) return;\n void client.identify(userId, traits, account);\n }, [client, key]);\n}\n\n/** Subscribes to a client event for the lifetime of the component. */\nexport function useGuidelyEvent<K extends keyof GuidelyEvents>(event: K, handler: GuidelyEvents[K]): void {\n const client = useContext(GuidelyContext);\n const ref = useRef(handler);\n ref.current = handler;\n useEffect(() => {\n if (!client) return;\n const cb = ((...args: unknown[]) => (ref.current as (...a: unknown[]) => void)(...args)) as GuidelyEvents[K];\n return client.on(event, cb);\n }, [client, event]);\n}\n\n/** Live checklist progress for a checklist guide (by id or key). */\nexport function useChecklistProgress(idOrKey: string): ChecklistProgressState {\n const client = useContext(GuidelyContext);\n const [progress, setProgress] = useState<ChecklistProgressState>({ completedTaskIds: [], completedAt: null, dismissedAt: null });\n useEffect(() => {\n if (!client) return;\n const update = () => setProgress(client.getChecklistProgress(idOrKey));\n update();\n const offs = [client.on(\"ready\", update), client.on(\"identify\", update), client.on(\"checklist:task\", update), client.on(\"checklist:complete\", update)];\n return () => offs.forEach((off) => off());\n }, [client, idOrKey]);\n return progress;\n}\n\nexport interface GuideState {\n /** The guide is currently showing. */\n active: boolean;\n completed: boolean;\n stepId: string | null;\n stepIndex: number;\n guide: PublishedGuide | null;\n}\n\n/** Live state of a guide (by id or key): active, completed, current step. */\nexport function useGuideState(idOrKey: string): GuideState {\n const client = useContext(GuidelyContext);\n const [state, setState] = useState<GuideState>({ active: false, completed: false, stepId: null, stepIndex: -1, guide: null });\n useEffect(() => {\n if (!client) return;\n const matches = (g: PublishedGuide) => g.id === idOrKey || g.key === idOrKey;\n const compute = () => {\n const guide = client.getGuides().find(matches) ?? null;\n const active = client.getActiveGuide();\n const s = client.getState().activeGuide;\n setState({ active: !!active && matches(active), completed: client.isGuideCompleted(idOrKey), stepId: active && matches(active) ? ((s as { stepId?: string | null } | null)?.stepId ?? null) : null, stepIndex: active && matches(active) ? ((s as { stepIndex?: number } | null)?.stepIndex ?? -1) : -1, guide });\n };\n compute();\n const offs = ([\"ready\", \"identify\", \"guide:start\", \"guide:step\", \"guide:complete\", \"guide:dismiss\", \"guide:skip\"] as const).map((e) => client.on(e, compute));\n return () => offs.forEach((off) => off());\n }, [client, idOrKey]);\n return state;\n}\n","import type { GuidelyClient } from \"@guidelytech/sdk-core\";\nimport { createContext } from \"react\";\n\n/** The provider's client (null outside a `GuidelyProvider` and before it has created one). */\nexport const GuidelyContext = createContext<GuidelyClient | null>(null);\n","import { GuidelyClient, type CaptureContext, type ErrorLevelName } from \"@guidelytech/sdk-core\";\nimport { Component, useContext, useEffect, useState, version, type ComponentType, type ErrorInfo, type ReactNode } from \"react\";\nimport { GuidelyContext } from \"./context\";\n\n/**\n * Error monitoring for React (Sentry's `ErrorBoundary`, `withErrorBoundary` and `reactErrorHandler`):\n * render errors become `exception` events with the component stack in `contexts.react`. Kept out\n * of index.tsx so the provider only re-exports it.\n */\n\n/** Errors already reported, so a boundary and a root error handler never send the same error twice. */\nconst reported = new WeakSet<object>();\n\n/** The component stack React reports, trimmed (it rides in the error's 64 KB detail). */\nconst stackOf = (info: { componentStack?: string | null } | undefined) => (info?.componentStack ?? \"\").slice(0, 8000);\n\n/** The given client, else the provider's, else the live client `createGuidely()` made. Null when none is usable. */\nfunction liveClient(client: GuidelyClient | null | undefined): GuidelyClient | null {\n try {\n if (client && !client.getState().destroyed) return client;\n const current = GuidelyClient.get();\n return current && !current.getState().destroyed ? current : null;\n } catch {\n return null;\n }\n}\n\n/** `captureException`'s second argument. */\ntype Hint = CaptureContext & Record<string, unknown>;\n\ninterface Pending {\n error: unknown;\n ctx: Hint;\n done?: (eventId: string) => void;\n}\n\n/**\n * Errors thrown before any client exists: a render error in the provider's first render is caught\n * before the provider's effect creates the client. Sent by the next client the provider creates.\n */\nconst pending: Pending[] = [];\n\n/** Sends the errors kept while no client existed (called by `GuidelyProvider` once it has one). */\nexport function drainPendingErrors(client: GuidelyClient): void {\n for (const p of pending.splice(0)) {\n let eventId = \"\";\n try {\n eventId = client.captureException(p.error, p.ctx) || \"\";\n } catch {\n // never throw into the app\n }\n if (eventId) p.done?.(eventId);\n }\n}\n\n/**\n * Captures without ever throwing into the app; returns the event id (\"\" when nothing was sent, or\n * when the error waits for a client, in which case `done` gets the id later).\n */\nfunction capture(client: GuidelyClient | null, error: unknown, ctx: Hint, done?: (eventId: string) => void): string {\n if (error && typeof error === \"object\") {\n if (reported.has(error)) return \"\";\n reported.add(error);\n }\n const c = liveClient(client);\n if (!c) {\n if (pending.length < 10) pending.push({ error, ctx, done });\n return \"\";\n }\n try {\n return c.captureException(error, ctx) || \"\";\n } catch {\n return \"\";\n }\n}\n\nexport interface ErrorBoundaryFallbackProps {\n error: unknown;\n componentStack: string;\n /** The Guidely event id (\"\" when nothing was sent: error tracking off, no consent, filtered). */\n eventId: string;\n /** Clears the error and renders the children again. */\n resetError(): void;\n}\n\nexport interface GuidelyErrorBoundaryProps {\n children?: ReactNode;\n /** Rendered instead of the children after an error (an element, or a function of the error). Nothing is rendered without one. */\n fallback?: ReactNode | ((props: ErrorBoundaryFallbackProps) => ReactNode);\n /** Called after the error is reported (`eventId` is \"\" when it waits for the provider's client, or was not sent). */\n onError?: (error: unknown, componentStack: string, eventId: string) => void;\n /** Edit what is sent (`context.tags.area = \"checkout\"`), like Sentry's `beforeCapture(scope, …)`. */\n beforeCapture?: (context: CaptureContext, error: unknown, componentStack: string) => void;\n /** Called by `resetError()`, before the children render again. */\n onReset?: (error: unknown, componentStack: string, eventId: string) => void;\n /** Opens the bug-report dialog for the event, when this SDK version has one. */\n showDialog?: boolean;\n tags?: CaptureContext[\"tags\"];\n extra?: CaptureContext[\"extra\"];\n fingerprint?: string[];\n /** Default `error`. */\n level?: ErrorLevelName;\n /** Marks the error handled (default: true when a `fallback` is given, as Sentry does). */\n handled?: boolean;\n /** The client to report to (default: the `GuidelyProvider`'s, else the live `createGuidely()` client). */\n client?: GuidelyClient | null;\n}\n\ninterface BoundaryState {\n error: unknown;\n componentStack: string;\n eventId: string;\n}\n\nconst EMPTY: BoundaryState = { error: null, componentStack: \"\", eventId: \"\" };\n\n/**\n * Catches render errors in its children, reports them (`mechanism: react.errorboundary`) and\n * renders `fallback`. Works without a provider when a client was made with `createGuidely()`.\n *\n * ```tsx\n * <GuidelyErrorBoundary fallback={({ resetError }) => <button onClick={resetError}>Try again</button>} tags={{ area: \"checkout\" }}>\n * <Checkout />\n * </GuidelyErrorBoundary>\n * ```\n */\nexport class GuidelyErrorBoundary extends Component<GuidelyErrorBoundaryProps, BoundaryState & { failed: boolean }> {\n static override contextType = GuidelyContext;\n declare context: GuidelyClient | null;\n override state = { ...EMPTY, failed: false };\n\n static getDerivedStateFromError(error: unknown): Partial<BoundaryState & { failed: boolean }> {\n return { error, failed: true };\n }\n\n override componentDidCatch(error: unknown, info: ErrorInfo): void {\n const { tags, extra, fingerprint, level, handled, fallback, beforeCapture, onError, showDialog } = this.props;\n const componentStack = stackOf(info);\n const ctx: Hint = {\n level: level ?? \"error\",\n ...(tags ? { tags: { ...tags } } : {}),\n ...(extra ? { extra: { ...extra } } : {}),\n ...(fingerprint ? { fingerprint } : {}),\n contexts: { react: { version, componentStack } },\n mechanism: { type: \"react.errorboundary\", handled: handled ?? !!fallback },\n };\n try {\n beforeCapture?.(ctx, error, componentStack);\n } catch {\n // A throwing hook still reports the error as it was.\n }\n const client = this.props.client ?? this.context;\n const eventId = capture(client, error, ctx, (id) => {\n // Sent later, once the provider created its client: show the id if this error is still up.\n if (this.state.error === error) this.setState({ eventId: id });\n });\n this.setState({ componentStack, eventId });\n onError?.(error, componentStack, eventId);\n if (showDialog && eventId) {\n try {\n // The \"Report a bug\" dialog links the report to the page's last exception: this one.\n (liveClient(client) as unknown as { showBugReport?: () => void } | null)?.showBugReport?.();\n } catch {\n // No dialog: the error is reported all the same.\n }\n }\n }\n\n resetError = (): void => {\n const { error, componentStack, eventId } = this.state;\n this.props.onReset?.(error, componentStack, eventId);\n this.setState({ ...EMPTY, failed: false });\n };\n\n override render(): ReactNode {\n if (!this.state.failed) return this.props.children;\n const { fallback } = this.props;\n if (typeof fallback === \"function\") return fallback({ error: this.state.error, componentStack: this.state.componentStack, eventId: this.state.eventId, resetError: this.resetError });\n return fallback ?? null;\n }\n}\n\n/** Wraps a component in a `GuidelyErrorBoundary` (Sentry's `withErrorBoundary`). */\nexport function withGuidelyErrorBoundary<P extends object>(Wrapped: ComponentType<P>, options: Omit<GuidelyErrorBoundaryProps, \"children\"> = {}): ComponentType<P> {\n const name = Wrapped.displayName || Wrapped.name || \"Component\";\n const WithBoundary = (props: P) => (\n <GuidelyErrorBoundary {...options}>\n <Wrapped {...props} />\n </GuidelyErrorBoundary>\n );\n WithBoundary.displayName = `guidelyErrorBoundary(${name})`;\n return WithBoundary;\n}\n\n/**\n * Reports `error` once (per error object) when it is set: for error pages that receive the error as\n * a prop, such as Next.js `error.tsx` or React Router's `errorElement`. Returns the event id.\n */\nexport function useCaptureException(error: unknown, hint?: Hint): string {\n const client = useContext(GuidelyContext);\n const [eventId, setEventId] = useState(\"\");\n useEffect(() => {\n if (error === null || error === undefined) return;\n const id = capture(client, error, { ...(hint ?? {}), mechanism: hint?.mechanism ?? { type: \"react.errorpage\", handled: true } }, setEventId);\n if (id) setEventId(id);\n // The hint is read once per error; changing it alone does not report again.\n }, [client, error]);\n return eventId;\n}\n\n/** What React 19 passes to `onUncaughtError` / `onCaughtError` / `onRecoverableError`. */\nexport interface ReactErrorInfo {\n componentStack?: string | null;\n /** `onCaughtError` only: the boundary that caught the error. */\n errorBoundary?: unknown;\n}\n\n/**\n * React 19 root error hooks (Sentry's `reactErrorHandler`):\n *\n * ```ts\n * createRoot(el, {\n * onUncaughtError: guidelyReactErrorHandler(),\n * onCaughtError: guidelyReactErrorHandler(),\n * onRecoverableError: guidelyReactErrorHandler(),\n * });\n * ```\n *\n * Errors caught by a boundary are reported as handled; errors a `GuidelyErrorBoundary` caught are\n * left to it. The client defaults to the live `createGuidely()` / provider client at the time of\n * the error. `callback` replaces React's default logging (the error is `console.error`ed without one).\n */\nexport function guidelyReactErrorHandler(client?: GuidelyClient | null, callback?: (error: unknown, errorInfo: ReactErrorInfo, eventId: string) => void): (error: unknown, errorInfo?: ReactErrorInfo) => void {\n return (error, errorInfo = {}) => {\n let eventId = \"\";\n if (!(errorInfo.errorBoundary instanceof GuidelyErrorBoundary)) {\n const caught = errorInfo.errorBoundary !== undefined && errorInfo.errorBoundary !== null;\n eventId = capture(client ?? null, error, { contexts: { react: { version, componentStack: stackOf(errorInfo) } }, mechanism: { type: \"react\", handled: caught } });\n }\n if (callback) callback(error, errorInfo, eventId);\n else console.error(error);\n };\n}\n","import { createFlagsClient, createStaticFlags, jsonEquals, stableStringify, type Attributes, type FlagDetails, type FlagValue, type FlagsBootstrap, type FlagsClient, type FlagsClientOptions, type FlagsReader, type JsonValue } from \"@guidelytech/flags\";\nimport { createContext, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore, type ReactNode } from \"react\";\n\n/** What the flag hooks read: the live client once created, else a static snapshot of the bootstrap payload. */\nexport interface FlagsSource {\n client: FlagsClient | null;\n bootstrap: FlagsReader;\n}\n\nexport const FlagsContext = createContext<FlagsSource | null>(null);\n\nconst EMPTY = createStaticFlags();\n\nfunction useReader(): FlagsReader {\n const src = useContext(FlagsContext);\n return src?.client ?? src?.bootstrap ?? EMPTY;\n}\n\n/**\n * Subscribes to the flags with `useSyncExternalStore`. Values are compared deeply so object\n * flags keep their identity between renders. The server snapshot is the bootstrap payload, so\n * server-rendered HTML and hydration agree.\n */\nfunction useFlagsValue<T>(select: (reader: FlagsReader) => T): T {\n const reader = useReader();\n const cache = useRef<{ reader: FlagsReader; value: T } | null>(null);\n const get = () => {\n const value = select(reader);\n const c = cache.current;\n if (c && c.reader === reader && jsonEquals(c.value, value)) return c.value;\n cache.current = { reader, value };\n return value;\n };\n return useSyncExternalStore(reader.subscribe, get, get);\n}\n\n/** Is the boolean flag on? `fallback` (default `false`) until flags load, or when missing. */\nexport function useFlag(key: string, fallback = false): boolean {\n return useFlagsValue((r) => r.isEnabled(key, fallback));\n}\n\n/** A flag's value (string, number, JSON…); `fallback` when missing or of a different type. */\nexport function useFeatureValue<T extends JsonValue>(key: string, fallback: T): FlagValue<T> {\n return useFlagsValue((r) => r.getValue(key, fallback));\n}\n\n/** A flag's value plus why it was served (reason, rule, variation, experiment). */\nexport function useFlagDetails<T extends JsonValue>(key: string, fallback: T): FlagDetails<FlagValue<T>> {\n return useFlagsValue((r) => r.getDetails(key, fallback));\n}\n\n/** Every flag's value (records no exposures). */\nexport function useFlags(): Record<string, JsonValue> {\n return useFlagsValue((r) => r.getAll());\n}\n\n/** True once flags have loaded (or failed to and serve fallbacks); true from the start with a bootstrap payload. */\nexport function useFlagsReady(): boolean {\n return useFlagsValue((r) => r.isReady());\n}\n\n/** The flags client (`null` on the server and before the provider has created it). */\nexport function useFlagsClient(): FlagsClient | null {\n return useContext(FlagsContext)?.client ?? null;\n}\n\nexport interface FeatureProps {\n flag: string;\n children?: ReactNode;\n /** Rendered while the flag is off (default: nothing). */\n fallback?: ReactNode;\n}\n\n/** Renders `children` when the boolean flag is on, else `fallback`. */\nexport function Feature({ flag, children, fallback = null }: FeatureProps) {\n return <>{useFlag(flag) ? children : fallback}</>;\n}\n\n/** Alias of {@link Feature}. */\nexport const FeatureFlag = Feature;\n\nexport interface FeatureValueProps extends FeatureProps {\n /** Renders `children` when the flag's value equals this (deep equality). */\n value: JsonValue;\n}\n\n/** Renders `children` when the flag's value equals `value` (e.g. an experiment variation), else `fallback`. */\nexport function FeatureValue({ flag, value, children, fallback = null }: FeatureValueProps) {\n const current = useFeatureValue<JsonValue>(flag, null);\n return <>{jsonEquals(current, value) ? children : fallback}</>;\n}\n\n/** A static snapshot for SSR and hydration, rebuilt only when the payload or attributes change. */\nexport function useBootstrap(payload: FlagsBootstrap | null | undefined, attributes: Attributes): FlagsReader {\n const key = stableStringify(attributes);\n return useMemo(() => (payload ? createStaticFlags({ payload, attributes }) : EMPTY), [payload, key]);\n}\n\nexport interface FlagsProviderProps extends Omit<FlagsClientOptions, \"payload\"> {\n /** Bootstrap from the server (`getPayload()`): renders the same values on the server and in the browser. */\n payload?: FlagsBootstrap | null;\n /** Use an existing client instead of creating one. */\n client?: FlagsClient;\n children?: ReactNode;\n}\n\n/**\n * Feature flags only (no guides or analytics). Creates a flags client in an effect (never during\n * SSR) and destroys it on unmount; until then hooks read the `payload` snapshot. Changing\n * `attributes` re-evaluates without recreating the client.\n *\n * ```tsx\n * <FlagsProvider sdkKey=\"pk_prod_…\" attributes={{ id: user.id, plan: user.plan }} payload={bootstrap}>\n * ```\n */\nexport function FlagsProvider({ children, client: external, payload, ...options }: FlagsProviderProps) {\n const [created, setCreated] = useState<FlagsClient | null>(null);\n const optionsRef = useRef(options);\n optionsRef.current = options;\n const sdkKey = options.sdkKey ?? options.projectId;\n const { apiUrl, environment } = options;\n const payloadRef = useRef(payload);\n payloadRef.current = payload;\n\n useEffect(() => {\n if (external || !sdkKey || typeof window === \"undefined\") return;\n let c: FlagsClient;\n try {\n c = createFlagsClient({ ...optionsRef.current, sdkKey, payload: payloadRef.current ?? undefined });\n } catch (err) {\n optionsRef.current.onError?.(err instanceof Error ? err : new Error(String(err)));\n return;\n }\n setCreated(c);\n return () => {\n c.destroy();\n setCreated((cur) => (cur === c ? null : cur));\n };\n }, [external, sdkKey, apiUrl, environment]);\n\n const client = external ?? created;\n const attributes = options.attributes ?? {};\n const attrsKey = stableStringify(attributes);\n useEffect(() => {\n if (client && options.attributes) client.setAttributes(options.attributes);\n }, [client, attrsKey]);\n\n const bootstrap = useBootstrap(payload, attributes);\n const value = useMemo<FlagsSource>(() => ({ client, bootstrap }), [client, bootstrap]);\n return <FlagsContext.Provider value={value}>{children}</FlagsContext.Provider>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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