@allstak/react 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -33,40 +33,63 @@ __export(index_exports, {
33
33
  AllStak: () => AllStak,
34
34
  AllStakClient: () => AllStakClient,
35
35
  AllStakErrorBoundary: () => AllStakErrorBoundary,
36
+ AllStakProvider: () => AllStakProvider,
36
37
  HttpRequestModule: () => HttpRequestModule,
37
38
  INGEST_HOST: () => INGEST_HOST,
38
39
  ReplayRecorder: () => ReplayRecorder,
39
40
  SDK_NAME: () => SDK_NAME,
40
41
  SDK_VERSION: () => SDK_VERSION,
41
42
  Scope: () => Scope,
43
+ __resetConsoleInstrumentationFlagForTest: () => __resetConsoleInstrumentationFlagForTest,
44
+ __resetProviderInstanceForTest: () => __resetProviderInstanceForTest,
45
+ __resetWebVitalsFlagForTest: () => __resetWebVitalsFlagForTest,
42
46
  instrumentBrowserNavigation: () => instrumentBrowserNavigation,
43
47
  instrumentConsole: () => instrumentConsole,
44
48
  instrumentFetch: () => instrumentFetch,
45
49
  instrumentNextRouter: () => instrumentNextRouter,
46
50
  instrumentReactRouter: () => instrumentReactRouter,
51
+ startWebVitals: () => startWebVitals,
47
52
  useAllStak: () => useAllStak,
48
53
  withAllStakProfiler: () => withAllStakProfiler
49
54
  });
50
55
  module.exports = __toCommonJS(index_exports);
51
- var React = __toESM(require("react"));
56
+ var React2 = __toESM(require("react"));
52
57
 
53
58
  // src/transport.ts
54
- var REQUEST_TIMEOUT = 3e3;
59
+ var REQUEST_TIMEOUT = 2e3;
55
60
  var MAX_BUFFER = 100;
61
+ var FAILURE_THRESHOLD = 3;
62
+ var BACKOFF_BASE_MS = 500;
63
+ var BACKOFF_MAX_MS = 3e4;
56
64
  var HttpTransport = class {
57
65
  constructor(baseUrl, apiKey) {
58
66
  this.baseUrl = baseUrl;
59
67
  this.apiKey = apiKey;
60
68
  this.buffer = [];
61
69
  this.flushing = false;
70
+ this.consecutiveFailures = 0;
71
+ this.circuitOpenUntil = 0;
72
+ }
73
+ send(path, payload) {
74
+ this.enqueueOrDispatch({ path, payload });
75
+ return Promise.resolve();
76
+ }
77
+ enqueueOrDispatch(item) {
78
+ if (Date.now() < this.circuitOpenUntil) {
79
+ this.push(item);
80
+ return;
81
+ }
82
+ void this.dispatch(item).catch(() => void 0);
62
83
  }
63
- async send(path, payload) {
84
+ async dispatch(item) {
64
85
  try {
65
- await this.doFetch(path, payload);
66
- await this.flushBuffer();
67
- } catch {
68
- if (this.buffer.length >= MAX_BUFFER) this.buffer.shift();
69
- this.buffer.push({ path, payload });
86
+ await this.doFetch(item.path, item.payload);
87
+ this.consecutiveFailures = 0;
88
+ this.circuitOpenUntil = 0;
89
+ this.scheduleFlush();
90
+ } catch (err) {
91
+ this.recordFailure(err);
92
+ this.push(item);
70
93
  }
71
94
  }
72
95
  async doFetch(path, payload) {
@@ -88,21 +111,49 @@ var HttpTransport = class {
88
111
  clearTimeout(timeoutId);
89
112
  }
90
113
  }
114
+ push(item) {
115
+ if (this.buffer.length >= MAX_BUFFER) this.buffer.shift();
116
+ this.buffer.push(item);
117
+ }
118
+ scheduleFlush() {
119
+ if (this.flushing || this.buffer.length === 0) return;
120
+ const delay = Math.max(0, this.circuitOpenUntil - Date.now());
121
+ const timer = setTimeout(() => {
122
+ void this.flushBuffer().catch(() => void 0);
123
+ }, delay);
124
+ if (typeof timer === "object" && typeof timer.unref === "function") timer.unref();
125
+ }
91
126
  async flushBuffer() {
92
127
  if (this.flushing || this.buffer.length === 0) return;
93
128
  this.flushing = true;
94
129
  try {
95
130
  const items = this.buffer.splice(0, this.buffer.length);
96
131
  for (const item of items) {
132
+ if (Date.now() < this.circuitOpenUntil) {
133
+ this.push(item);
134
+ continue;
135
+ }
97
136
  try {
98
137
  await this.doFetch(item.path, item.payload);
99
- } catch {
138
+ this.consecutiveFailures = 0;
139
+ this.circuitOpenUntil = 0;
140
+ } catch (err) {
141
+ this.recordFailure(err);
142
+ this.push(item);
100
143
  }
101
144
  }
102
145
  } finally {
103
146
  this.flushing = false;
147
+ if (this.buffer.length > 0) this.scheduleFlush();
104
148
  }
105
149
  }
150
+ recordFailure(error) {
151
+ this.consecutiveFailures++;
152
+ if (this.consecutiveFailures < FAILURE_THRESHOLD) return;
153
+ const retryAfterMs = retryAfterFromError(error);
154
+ const backoff = retryAfterMs ?? jitteredBackoff(this.consecutiveFailures);
155
+ this.circuitOpenUntil = Date.now() + backoff;
156
+ }
106
157
  getBufferSize() {
107
158
  return this.buffer.length;
108
159
  }
@@ -122,6 +173,14 @@ var HttpTransport = class {
122
173
  return true;
123
174
  }
124
175
  };
176
+ function jitteredBackoff(failures) {
177
+ const exp = Math.min(BACKOFF_MAX_MS, BACKOFF_BASE_MS * 2 ** Math.min(8, failures - FAILURE_THRESHOLD));
178
+ return Math.floor(exp / 2 + Math.random() * (exp / 2));
179
+ }
180
+ function retryAfterFromError(error) {
181
+ const message = error instanceof Error ? error.message : "";
182
+ return /HTTP\s+(429|503)/.test(message) ? BACKOFF_MAX_MS : null;
183
+ }
125
184
 
126
185
  // src/stack.ts
127
186
  var V8_FRAME_RE = /^\s*at\s+(?:(.+?)\s+\()?((?:.+?):(\d+):(\d+))\)?\s*$/;
@@ -222,36 +281,92 @@ function instrumentFetch(addBreadcrumb, ownBaseUrl) {
222
281
  wrapped[FETCH_FLAG] = true;
223
282
  g.fetch = wrapped;
224
283
  }
225
- function instrumentConsole(addBreadcrumb) {
284
+ var CONSOLE_DEFAULTS = {
285
+ log: false,
286
+ info: false,
287
+ warn: true,
288
+ error: true
289
+ };
290
+ var CONSOLE_METHOD_TO_LEVEL = {
291
+ log: "info",
292
+ info: "info",
293
+ warn: "warn",
294
+ error: "error"
295
+ };
296
+ var MAX_ARG_BYTES = 5e3;
297
+ function instrumentConsole(addBreadcrumb, options = {}) {
226
298
  if (typeof console === "undefined") return;
227
299
  if (console[CONSOLE_FLAG]) return;
228
- const origWarn = console.warn;
229
- const origError = console.error;
230
- console.warn = function(...args) {
231
- try {
232
- addBreadcrumb("log", args.map(safeString).join(" "), "warn");
233
- } catch {
234
- }
235
- return origWarn.apply(console, args);
300
+ const opts = {
301
+ log: options.log ?? CONSOLE_DEFAULTS.log,
302
+ info: options.info ?? CONSOLE_DEFAULTS.info,
303
+ warn: options.warn ?? CONSOLE_DEFAULTS.warn,
304
+ error: options.error ?? CONSOLE_DEFAULTS.error
236
305
  };
237
- console.error = function(...args) {
238
- try {
239
- addBreadcrumb("log", args.map(safeString).join(" "), "error");
240
- } catch {
241
- }
242
- return origError.apply(console, args);
306
+ const wrap = (method) => {
307
+ const orig = console[method];
308
+ if (typeof orig !== "function") return;
309
+ const level = CONSOLE_METHOD_TO_LEVEL[method];
310
+ console[method] = function(...args) {
311
+ if (opts[method]) {
312
+ try {
313
+ const serialized = args.map(safeStringifyArg);
314
+ const message = truncate(serialized.join(" "));
315
+ addBreadcrumb("log", message, level, {
316
+ category: "console",
317
+ method,
318
+ args: serialized
319
+ });
320
+ } catch {
321
+ }
322
+ }
323
+ return orig.apply(console, args);
324
+ };
243
325
  };
326
+ if (opts.log) wrap("log");
327
+ if (opts.info) wrap("info");
328
+ if (opts.warn) wrap("warn");
329
+ if (opts.error) wrap("error");
244
330
  console[CONSOLE_FLAG] = true;
245
331
  }
246
- function safeString(v) {
247
- if (v == null) return String(v);
332
+ function __resetConsoleInstrumentationFlagForTest() {
333
+ if (typeof console !== "undefined") {
334
+ delete console[CONSOLE_FLAG];
335
+ }
336
+ }
337
+ function safeStringifyArg(v) {
338
+ if (v === null || v === void 0) return String(v);
248
339
  if (typeof v === "string") return v;
249
- if (v instanceof Error) return `${v.name}: ${v.message}`;
250
- try {
251
- return typeof v === "object" ? JSON.stringify(v) : String(v);
252
- } catch {
253
- return Object.prototype.toString.call(v);
340
+ if (typeof v === "number" || typeof v === "boolean" || typeof v === "bigint") return String(v);
341
+ if (typeof v === "symbol") return v.toString();
342
+ if (typeof v === "function") return `[Function${v.name ? ` ${v.name}` : ""}]`;
343
+ if (v instanceof Error) {
344
+ return `${v.name || "Error"}: ${v.message}${v.stack ? `
345
+ ${v.stack}` : ""}`;
346
+ }
347
+ if (typeof v === "object") {
348
+ try {
349
+ const seen = /* @__PURE__ */ new WeakSet();
350
+ const out = JSON.stringify(v, (_key, val) => {
351
+ if (typeof val === "object" && val !== null) {
352
+ if (seen.has(val)) return "[Circular]";
353
+ seen.add(val);
354
+ }
355
+ if (typeof val === "bigint") return val.toString();
356
+ if (typeof val === "function") return `[Function${val.name ? ` ${val.name}` : ""}]`;
357
+ if (typeof val === "symbol") return val.toString();
358
+ return val;
359
+ });
360
+ return out ?? Object.prototype.toString.call(v);
361
+ } catch {
362
+ return Object.prototype.toString.call(v);
363
+ }
254
364
  }
365
+ return String(v);
366
+ }
367
+ function truncate(s) {
368
+ if (s.length <= MAX_ARG_BYTES) return s;
369
+ return s.slice(0, MAX_ARG_BYTES) + "\u2026[truncated]";
255
370
  }
256
371
 
257
372
  // src/navigation.ts
@@ -1268,10 +1383,115 @@ function installHttpInstrumentation(module2, options, ownIngestHost) {
1268
1383
  };
1269
1384
  }
1270
1385
 
1386
+ // src/web-vitals.ts
1387
+ var FLAG3 = "__allstak_web_vitals_started__";
1388
+ function startWebVitals(report) {
1389
+ const noop = { destroy: () => {
1390
+ } };
1391
+ if (typeof window === "undefined") return noop;
1392
+ if (typeof PerformanceObserver === "undefined") return noop;
1393
+ if (window[FLAG3]) return noop;
1394
+ window[FLAG3] = true;
1395
+ const observers = [];
1396
+ let lastLcp = 0;
1397
+ try {
1398
+ const obs = new PerformanceObserver((list) => {
1399
+ const entries = list.getEntries();
1400
+ const last = entries[entries.length - 1];
1401
+ if (last && typeof last.startTime === "number") {
1402
+ lastLcp = last.startTime;
1403
+ }
1404
+ });
1405
+ obs.observe({ type: "largest-contentful-paint", buffered: true });
1406
+ observers.push(obs);
1407
+ } catch {
1408
+ }
1409
+ let cls = 0;
1410
+ try {
1411
+ const obs = new PerformanceObserver((list) => {
1412
+ for (const entry of list.getEntries()) {
1413
+ if (!entry.hadRecentInput && typeof entry.value === "number") {
1414
+ cls += entry.value;
1415
+ }
1416
+ }
1417
+ });
1418
+ obs.observe({ type: "layout-shift", buffered: true });
1419
+ observers.push(obs);
1420
+ } catch {
1421
+ }
1422
+ let maxInteraction = 0;
1423
+ try {
1424
+ const obs = new PerformanceObserver((list) => {
1425
+ for (const entry of list.getEntries()) {
1426
+ if (typeof entry.duration === "number" && entry.duration > maxInteraction) {
1427
+ maxInteraction = entry.duration;
1428
+ }
1429
+ }
1430
+ });
1431
+ obs.observe({ type: "event", buffered: true, durationThreshold: 40 });
1432
+ observers.push(obs);
1433
+ } catch {
1434
+ }
1435
+ let fcp = 0;
1436
+ try {
1437
+ const obs = new PerformanceObserver((list) => {
1438
+ for (const entry of list.getEntries()) {
1439
+ if (entry.name === "first-contentful-paint") {
1440
+ fcp = entry.startTime;
1441
+ }
1442
+ }
1443
+ });
1444
+ obs.observe({ type: "paint", buffered: true });
1445
+ observers.push(obs);
1446
+ } catch {
1447
+ }
1448
+ const reportTtfb = () => {
1449
+ try {
1450
+ const navEntry = performance.getEntriesByType("navigation")[0];
1451
+ if (navEntry && typeof navEntry.responseStart === "number" && typeof navEntry.requestStart === "number") {
1452
+ const ttfb = Math.max(0, navEntry.responseStart - navEntry.requestStart);
1453
+ report({ name: "TTFB", value: ttfb });
1454
+ }
1455
+ } catch {
1456
+ }
1457
+ };
1458
+ const finalize = () => {
1459
+ if (lastLcp > 0) report({ name: "LCP", value: lastLcp });
1460
+ report({ name: "CLS", value: cls });
1461
+ if (maxInteraction > 0) report({ name: "INP", value: maxInteraction });
1462
+ if (fcp > 0) report({ name: "FCP", value: fcp });
1463
+ reportTtfb();
1464
+ };
1465
+ const onVisibility = () => {
1466
+ if (document.visibilityState === "hidden") finalize();
1467
+ };
1468
+ document.addEventListener("visibilitychange", onVisibility);
1469
+ const onPagehide = () => finalize();
1470
+ window.addEventListener("pagehide", onPagehide);
1471
+ return {
1472
+ destroy: () => {
1473
+ for (const o of observers) {
1474
+ try {
1475
+ o.disconnect();
1476
+ } catch {
1477
+ }
1478
+ }
1479
+ document.removeEventListener("visibilitychange", onVisibility);
1480
+ window.removeEventListener("pagehide", onPagehide);
1481
+ window[FLAG3] = false;
1482
+ }
1483
+ };
1484
+ }
1485
+ function __resetWebVitalsFlagForTest() {
1486
+ if (typeof window !== "undefined") {
1487
+ window[FLAG3] = false;
1488
+ }
1489
+ }
1490
+
1271
1491
  // src/client.ts
1272
1492
  var INGEST_HOST = "https://api.allstak.sa";
1273
1493
  var SDK_NAME = "allstak-react";
1274
- var SDK_VERSION = "0.3.0";
1494
+ var SDK_VERSION = "0.3.1";
1275
1495
  var ERRORS_PATH = "/ingest/v1/errors";
1276
1496
  var LOGS_PATH = "/ingest/v1/logs";
1277
1497
  var VALID_BREADCRUMB_TYPES = /* @__PURE__ */ new Set(["http", "log", "ui", "navigation", "query", "default"]);
@@ -1305,6 +1525,7 @@ var AllStakClient = class {
1305
1525
  this._instrumentAxios = null;
1306
1526
  this.onErrorHandler = null;
1307
1527
  this.onRejectionHandler = null;
1528
+ this.webVitals = null;
1308
1529
  if (!config.apiKey) throw new Error("AllStak: config.apiKey is required");
1309
1530
  this.config = { ...config };
1310
1531
  if (!this.config.environment) this.config.environment = "production";
@@ -1331,7 +1552,7 @@ var AllStakClient = class {
1331
1552
  }
1332
1553
  if (config.autoBreadcrumbsConsole !== false) {
1333
1554
  try {
1334
- instrumentConsole(safeAddBreadcrumb);
1555
+ instrumentConsole(safeAddBreadcrumb, config.captureConsole);
1335
1556
  } catch {
1336
1557
  }
1337
1558
  }
@@ -1341,6 +1562,32 @@ var AllStakClient = class {
1341
1562
  } catch {
1342
1563
  }
1343
1564
  }
1565
+ if (config.autoWebVitals !== false) {
1566
+ try {
1567
+ const send = (m) => {
1568
+ this.transport.send(LOGS_PATH, {
1569
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1570
+ level: "info",
1571
+ message: `web-vital:${m.name}=${m.value.toFixed(2)}`,
1572
+ sessionId: this.sessionId,
1573
+ environment: this.config.environment,
1574
+ release: this.config.release,
1575
+ platform: this.config.platform,
1576
+ sdkName: this.config.sdkName,
1577
+ sdkVersion: this.config.sdkVersion,
1578
+ metadata: {
1579
+ category: "web-vital",
1580
+ name: m.name,
1581
+ value: m.value,
1582
+ ...m.id ? { id: m.id } : {},
1583
+ ...this.releaseTags()
1584
+ }
1585
+ });
1586
+ };
1587
+ this.webVitals = startWebVitals(send);
1588
+ } catch {
1589
+ }
1590
+ }
1344
1591
  if (config.replay && (config.replay.enabled ?? true)) {
1345
1592
  try {
1346
1593
  this.replay = new ReplayRecorder(this.transport, this.sessionId, safeAddBreadcrumb, config.replay);
@@ -1565,6 +1812,10 @@ var AllStakClient = class {
1565
1812
  this.httpRequests.destroy();
1566
1813
  this.httpRequests = null;
1567
1814
  }
1815
+ if (this.webVitals) {
1816
+ this.webVitals.destroy();
1817
+ this.webVitals = null;
1818
+ }
1568
1819
  this._instrumentAxios = null;
1569
1820
  this.breadcrumbs = [];
1570
1821
  }
@@ -1794,8 +2045,154 @@ var AllStak = {
1794
2045
  }
1795
2046
  };
1796
2047
 
2048
+ // src/provider.tsx
2049
+ var React = __toESM(require("react"));
2050
+ var AllStakContext = React.createContext(null);
2051
+ var __providerOwnedInstance = null;
2052
+ var AllStakErrorBoundaryInner = class extends React.Component {
2053
+ constructor() {
2054
+ super(...arguments);
2055
+ this.state = { error: null };
2056
+ this.resetError = () => this.setState({ error: null });
2057
+ }
2058
+ static getDerivedStateFromError(error) {
2059
+ return { error };
2060
+ }
2061
+ componentDidCatch(error, info) {
2062
+ try {
2063
+ AllStak.addBreadcrumb("ui", "React error boundary caught error", "error", {
2064
+ componentStack: info.componentStack ?? ""
2065
+ });
2066
+ AllStak.captureException(error, {
2067
+ componentStack: info.componentStack ?? "",
2068
+ source: "AllStakProvider.ErrorBoundary"
2069
+ });
2070
+ if (this.props.debug) {
2071
+ console.log(`[AllStak] Captured render error: ${error.message}`);
2072
+ }
2073
+ } catch {
2074
+ }
2075
+ try {
2076
+ this.props.onError?.(error, info.componentStack ?? void 0);
2077
+ } catch {
2078
+ }
2079
+ }
2080
+ render() {
2081
+ if (this.state.error) {
2082
+ const { fallback } = this.props;
2083
+ if (typeof fallback === "function") {
2084
+ return fallback({ error: this.state.error, resetError: this.resetError });
2085
+ }
2086
+ if (fallback !== void 0) return fallback;
2087
+ return null;
2088
+ }
2089
+ return this.props.children;
2090
+ }
2091
+ };
2092
+ function AllStakProvider({
2093
+ children,
2094
+ apiKey,
2095
+ environment,
2096
+ release,
2097
+ host,
2098
+ user,
2099
+ tags,
2100
+ debug,
2101
+ enableHttpTracking,
2102
+ httpTracking,
2103
+ captureConsole,
2104
+ sampleRate,
2105
+ beforeSend,
2106
+ replay,
2107
+ tracesSampleRate,
2108
+ service,
2109
+ dist,
2110
+ autoCaptureBrowserErrors,
2111
+ autoBreadcrumbsFetch,
2112
+ autoBreadcrumbsConsole,
2113
+ autoBreadcrumbsNavigation,
2114
+ autoWebVitals,
2115
+ destroyOnUnmount = false,
2116
+ fallback,
2117
+ onError
2118
+ }) {
2119
+ const clientRef = React.useRef(null);
2120
+ if (!clientRef.current) {
2121
+ const existing = AllStak._getInstance();
2122
+ if (existing && __providerOwnedInstance === existing) {
2123
+ clientRef.current = existing;
2124
+ if (debug) {
2125
+ console.log(`[AllStak] Reusing session ${AllStak.getSessionId()}`);
2126
+ }
2127
+ } else {
2128
+ const config = {
2129
+ apiKey,
2130
+ environment,
2131
+ release,
2132
+ host,
2133
+ user,
2134
+ tags,
2135
+ enableHttpTracking,
2136
+ httpTracking,
2137
+ captureConsole,
2138
+ sampleRate,
2139
+ beforeSend,
2140
+ replay,
2141
+ tracesSampleRate,
2142
+ service,
2143
+ dist,
2144
+ autoCaptureBrowserErrors,
2145
+ autoBreadcrumbsFetch,
2146
+ autoBreadcrumbsConsole,
2147
+ autoBreadcrumbsNavigation,
2148
+ autoWebVitals
2149
+ };
2150
+ clientRef.current = AllStak.init(config);
2151
+ __providerOwnedInstance = clientRef.current;
2152
+ if (debug) {
2153
+ console.log(`[AllStak] Initialized \u2014 session ${AllStak.getSessionId()}`);
2154
+ if (autoBreadcrumbsNavigation !== false) {
2155
+ console.log("[AllStak] Navigation auto-instrumentation enabled");
2156
+ } else {
2157
+ console.log("[AllStak] Navigation auto-instrumentation not applied; use manual fallback");
2158
+ }
2159
+ }
2160
+ }
2161
+ }
2162
+ React.useEffect(() => {
2163
+ return () => {
2164
+ if (destroyOnUnmount) {
2165
+ AllStak.destroy();
2166
+ __providerOwnedInstance = null;
2167
+ clientRef.current = null;
2168
+ if (debug) {
2169
+ console.log("[AllStak] Destroyed on unmount");
2170
+ }
2171
+ }
2172
+ };
2173
+ }, [destroyOnUnmount, debug]);
2174
+ return /* @__PURE__ */ React.createElement(AllStakContext.Provider, { value: clientRef.current }, /* @__PURE__ */ React.createElement(AllStakErrorBoundaryInner, { fallback, onError, debug }, children));
2175
+ }
2176
+ function useAllStak() {
2177
+ return React.useMemo(
2178
+ () => ({
2179
+ captureException: (error, ctx) => AllStak.captureException(error, ctx),
2180
+ captureMessage: (msg, level = "info") => AllStak.captureMessage(msg, level),
2181
+ setUser: (user) => AllStak.setUser(user),
2182
+ setTag: (key, value) => AllStak.setTag(key, value),
2183
+ setContext: (name, ctx) => AllStak.setContext(name, ctx),
2184
+ addBreadcrumb: (type, message, level, data) => AllStak.addBreadcrumb(type, message, level, data),
2185
+ flush: (timeoutMs) => AllStak.flush(timeoutMs)
2186
+ }),
2187
+ []
2188
+ );
2189
+ }
2190
+ function __resetProviderInstanceForTest() {
2191
+ __providerOwnedInstance = null;
2192
+ }
2193
+
1797
2194
  // src/index.ts
1798
- var AllStakErrorBoundary = class extends React.Component {
2195
+ var AllStakErrorBoundary = class extends React2.Component {
1799
2196
  constructor() {
1800
2197
  super(...arguments);
1801
2198
  this.state = { error: null };
@@ -1838,25 +2235,13 @@ var AllStakErrorBoundary = class extends React.Component {
1838
2235
  return this.props.children;
1839
2236
  }
1840
2237
  };
1841
- function useAllStak() {
1842
- return React.useMemo(
1843
- () => ({
1844
- captureException: (error, ctx) => AllStak.captureException(error, ctx),
1845
- captureMessage: (msg, level = "info") => AllStak.captureMessage(msg, level),
1846
- setUser: (user) => AllStak.setUser(user),
1847
- setTag: (key, value) => AllStak.setTag(key, value),
1848
- addBreadcrumb: (type, message, level, data) => AllStak.addBreadcrumb(type, message, level, data)
1849
- }),
1850
- []
1851
- );
1852
- }
1853
- function withAllStakProfiler(Component2, name) {
1854
- const displayName = name ?? Component2.displayName ?? Component2.name ?? "AnonymousComponent";
2238
+ function withAllStakProfiler(Component3, name) {
2239
+ const displayName = name ?? Component3.displayName ?? Component3.name ?? "AnonymousComponent";
1855
2240
  const Wrapped = (props) => {
1856
- React.useEffect(() => {
2241
+ React2.useEffect(() => {
1857
2242
  AllStak.addBreadcrumb("navigation", `Mounted <${displayName}>`, "info");
1858
2243
  }, []);
1859
- return React.createElement(Component2, props);
2244
+ return React2.createElement(Component3, props);
1860
2245
  };
1861
2246
  Wrapped.displayName = `withAllStakProfiler(${displayName})`;
1862
2247
  return Wrapped;