@getsoren/shared-module 2.47.1 → 2.48.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 CHANGED
@@ -53,7 +53,7 @@ export default App;
53
53
  | GTMSendPageView | React Component | Send page view event to Google Tag Manager | @getsoren/react-google-tag-manager & react-router-dom |
54
54
  | InitializeAxiosConfig | React Component | Initialize Axios with custom default config options | Axios |
55
55
  | InitializeI18nConfig | React Component | Initialize i18n with custom config options | i18next & react-i18next & i18next-browser-languagedetector |
56
- | InitializeSentryConfig | React Component | Initialize Sentry | @sentry/react & react-router-dom |
56
+ | InitializeSentryConfig | React Component | Initialize Sentry (tracing + buffered replay) | @sentry/react & react-router-dom |
57
57
  | InitializeMapBoxConfig | React Component | Initialize MapBox | mapbox-gl |
58
58
  | InitializeDaysJSConfig | React Component | Initialize DayJS | dayjs |
59
59
  | InitializeHubSpot | React Component | Initialize HubSpot chat widget | - |
@@ -1,3 +1,4 @@
1
+ import { ErrorEvent } from '@sentry/react';
1
2
  import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
2
3
  interface InitializeSentryConfigProps {
3
4
  /**
@@ -13,10 +14,7 @@ interface InitializeSentryConfigProps {
13
14
  */
14
15
  dsn: string;
15
16
  /**
16
- * List of integrations that should be installed after SDK was initialized.
17
- */
18
- /**
19
- * List of integrations that should be installed after SDK was initialized.
17
+ * Extra integrations installed after the SDK is initialized, on top of the built-in browser tracing and replay ones.
20
18
  */
21
19
  integrations?: any[];
22
20
  /**
@@ -25,15 +23,21 @@ interface InitializeSentryConfigProps {
25
23
  */
26
24
  tracesSampleRate?: number;
27
25
  /**
28
- * The sample rate for session-long replays.
29
- * 1.0 will record all sessions and 0 will record none.
26
+ * The sample rate for session-long replays. 1.0 records every session, 0 records none.
27
+ * Defaults to `0`: replays stay in memory (buffer mode) and are only uploaded for errors, see `replaysOnErrorSampleRate`.
30
28
  */
31
29
  replaysSessionSampleRate?: number;
32
30
  /**
33
- * The sample rate for sessions that has had an error occur.
34
- * This is independent of sessionSampleRate. 1.0 will record all sessions and 0 will record none.
31
+ * The sample rate for sessions that had an error occur, independent of `replaysSessionSampleRate`.
32
+ * Defaults to `1.0`. Which errors flush the buffered replay is decided by `replayBeforeErrorSampling`.
35
33
  */
36
34
  replaysOnErrorSampleRate?: number;
35
+ /**
36
+ * Decides, per error, whether the buffered replay is uploaded. Defaults to keeping only errors tagged with
37
+ * `SENTRY_KEEP_REPLAY` (`sentry.captureException(error, { tags: SENTRY_KEEP_REPLAY })`). Pass `() => true` to
38
+ * upload a replay for every error. Only applies in buffer mode; session-long replays are always sent.
39
+ */
40
+ replayBeforeErrorSampling?: (event: ErrorEvent) => boolean;
37
41
  /**
38
42
  * List of strings/regex controlling to which outgoing requests the SDK will attach tracing headers.
39
43
  * By default, the SDK will attach those headers to all requests to localhost and same origin. If this option is provided, the SDK will match the request URL of outgoing requests against the items in this array, and only attach tracing headers if a match was found.
@@ -71,11 +75,12 @@ interface InitializeSentryConfigProps {
71
75
  * @param tracesSampleRate
72
76
  * @param replaysSessionSampleRate
73
77
  * @param replaysOnErrorSampleRate
78
+ * @param replayBeforeErrorSampling
74
79
  * @param tracePropagationTargets
75
80
  * @param ignoreErrors
76
81
  * @param debug
77
82
  * @param environment
78
83
  * @constructor
79
84
  */
80
- declare const InitializeSentryConfig: ({ dsn, integrations, tracesSampleRate, replaysSessionSampleRate, replaysOnErrorSampleRate, tracePropagationTargets, ignoreErrors, debug, environment, release, ...props }: InitializeSentryConfigProps) => null;
85
+ declare const InitializeSentryConfig: ({ dsn, integrations, tracesSampleRate, tracePropagationTargets, ignoreErrors, debug, environment, release, replaysSessionSampleRate, replaysOnErrorSampleRate, replayBeforeErrorSampling, ...props }: InitializeSentryConfigProps) => null;
81
86
  export default InitializeSentryConfig;
@@ -0,0 +1,13 @@
1
+ import { ErrorEvent } from '@sentry/react';
2
+ /**
3
+ * Tag opting an error into a replay upload when replays run in buffer mode (session sample rate at 0).
4
+ * Spread it into the capture context: `sentry.captureException(error, { tags: SENTRY_KEEP_REPLAY })`.
5
+ */
6
+ export declare const SENTRY_KEEP_REPLAY: {
7
+ readonly replay: "keep";
8
+ };
9
+ /**
10
+ * Default `beforeErrorSampling` of the replay integration: only errors tagged with `SENTRY_KEEP_REPLAY` flush the
11
+ * buffered replay, so a noisy error never burns the replay quota by itself.
12
+ */
13
+ export declare const isReplayKeptForError: (event: ErrorEvent) => boolean;
package/dist/main.d.ts CHANGED
@@ -22,6 +22,7 @@ export * from './components/Utils/RequireAuth';
22
22
  export { default as RequireAuth } from './components/Utils/RequireAuth';
23
23
  export * from './components/Utils/ShowHubSpotBubble';
24
24
  export { default as ShowHubSpotBubble } from './components/Utils/ShowHubSpotBubble';
25
+ export * from './constants/sentry';
25
26
  export * from './context/ChatProvider';
26
27
  export { default as ChatProvider } from './context/ChatProvider';
27
28
  export * from './context/InjectDependenciesProvider';
package/dist/main.js CHANGED
@@ -129,17 +129,17 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
129
129
  value: i,
130
130
  children: e
131
131
  });
132
- }, b = 900 * 1e3, x = 60 * 1e3, S = 600 * 1e3, C = "auto-reload-on-new-version-timestamp", w = /<meta[^>]*name="version"[^>]*content="([^"]*)"/, ee = (e) => {
132
+ }, b = 900 * 1e3, x = 60 * 1e3, S = 600 * 1e3, C = "auto-reload-on-new-version-timestamp", w = /<meta[^>]*name="version"[^>]*content="([^"]*)"/, T = (e) => {
133
133
  try {
134
134
  return sessionStorage.getItem(e);
135
135
  } catch {
136
136
  return null;
137
137
  }
138
- }, T = (e, t) => {
138
+ }, E = (e, t) => {
139
139
  try {
140
140
  sessionStorage.setItem(e, t);
141
141
  } catch {}
142
- }, E = ({ version: e, checkInterval: t = b, children: n, ...r }) => {
142
+ }, D = ({ version: e, checkInterval: t = b, children: n, ...r }) => {
143
143
  let { libraries: i } = a(v), s = r?.reactRouter || i?.reactRouter, l = c(!1), d = c(0);
144
144
  if (!s) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of AutoReloadOnNewVersion.");
145
145
  let { useLocation: f, Outlet: p } = s, { pathname: m } = f(), h = c(m);
@@ -164,10 +164,10 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
164
164
  }, [e, t]), o(() => {
165
165
  if (m === h.current || (h.current = m, !l.current)) return;
166
166
  l.current = !1;
167
- let e = Number(ee(C) || "0");
168
- Date.now() - e < S || (T(C, String(Date.now())), window.location.reload());
167
+ let e = Number(T(C) || "0");
168
+ Date.now() - e < S || (E(C, String(Date.now())), window.location.reload());
169
169
  }, [m]), n ?? /* @__PURE__ */ u(p, {});
170
- }, D = ({ data: e, ...t }) => {
170
+ }, O = ({ data: e, ...t }) => {
171
171
  let { libraries: n } = a(v), r = t?.reactRouter || n?.reactRouter, i = t?.gtm || n?.gtm;
172
172
  if (!r) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
173
173
  if (!i) throw Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
@@ -183,7 +183,7 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
183
183
  d,
184
184
  f
185
185
  ]), /* @__PURE__ */ u(l, {});
186
- }, O = "[data-amp-track-feature]", k = [
186
+ }, k = "[data-amp-track-feature]", A = [
187
187
  "a",
188
188
  "button",
189
189
  "input",
@@ -195,28 +195,28 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
195
195
  "[contenteditable=\"true\" i]",
196
196
  "[data-amp-default-track]",
197
197
  ".amp-default-track"
198
- ], A = { defaultMaskLevel: "medium" }, j = (e, t) => {
198
+ ], j = { defaultMaskLevel: "medium" }, M = (e, t) => {
199
199
  if (e === !1) return !1;
200
200
  let n = e === !0 ? {} : e;
201
201
  return {
202
- cssSelectorAllowlist: [...t, O],
202
+ cssSelectorAllowlist: [...t, k],
203
203
  ...n
204
204
  };
205
- }, M = (e, t) => !t || e === !1 ? !1 : {
205
+ }, ee = (e, t) => !t || e === !1 ? !1 : {
206
206
  deadClicks: !0,
207
207
  rageClicks: !0,
208
208
  ...e === !0 ? {} : e
209
- }, N = ({ apiKey: e, appVersion: t, elementInteractions: n = !0, frustrationInteractions: r = !0, platform: i = "desktop", serverZone: s, sessionReplayPrivacy: c = A, sessionReplaySampleRate: l, ...u }) => {
209
+ }, N = ({ apiKey: e, appVersion: t, elementInteractions: n = !0, frustrationInteractions: r = !0, platform: i = "desktop", serverZone: s, sessionReplayPrivacy: c = j, sessionReplaySampleRate: l, ...u }) => {
210
210
  let { libraries: d } = a(v), f = u.amplitude || d?.amplitude;
211
211
  return o(() => {
212
212
  let a = f?.analytics, o = f?.sessionReplayPlugin;
213
213
  if (!(e && a)) return;
214
- let u = "platform-enrichment", d = j(n, a.Types?.DEFAULT_CSS_SELECTOR_ALLOWLIST ?? k);
214
+ let u = "platform-enrichment", d = M(n, a.Types?.DEFAULT_CSS_SELECTOR_ALLOWLIST ?? A);
215
215
  return a.init(e, {
216
216
  appVersion: t,
217
217
  autocapture: {
218
218
  elementInteractions: d,
219
- frustrationInteractions: M(r, d !== !1),
219
+ frustrationInteractions: ee(r, d !== !1),
220
220
  pageViews: { trackHistoryChanges: "pathOnly" }
221
221
  },
222
222
  serverZone: s
@@ -312,18 +312,18 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
312
312
  }), o.on("languageChanged", (e) => {
313
313
  document.documentElement.setAttribute("lang", e);
314
314
  }), null);
315
- }, ae = ({ dsn: e, integrations: t, tracesSampleRate: n, replaysSessionSampleRate: r, replaysOnErrorSampleRate: i, tracePropagationTargets: s, ignoreErrors: c, debug: l, environment: u, release: d, ...f }) => {
316
- let { libraries: p } = a(v), m = f?.sentry || p?.sentry, h = f?.reactRouter || p?.reactRouter;
317
- if (!m) throw Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
318
- if (!h) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
319
- if (m.isInitialized()) return null;
320
- let { createRoutesFromChildren: g, matchRoutes: _, useLocation: y, useNavigationType: b } = h;
321
- return (l || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && m.init({
322
- debug: l,
315
+ }, V = { replay: "keep" }, H = (e) => e.tags?.replay === V.replay, ae = ({ dsn: e, integrations: t, tracesSampleRate: n, tracePropagationTargets: r, ignoreErrors: i, debug: s, environment: c, release: l, replaysSessionSampleRate: u = 0, replaysOnErrorSampleRate: d = 1, replayBeforeErrorSampling: f = H, ...p }) => {
316
+ let { libraries: m } = a(v), h = p?.sentry || m?.sentry, g = p?.reactRouter || m?.reactRouter;
317
+ if (!h) throw Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
318
+ if (!g) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
319
+ if (h.isInitialized()) return null;
320
+ let { createRoutesFromChildren: _, matchRoutes: y, useLocation: b, useNavigationType: x } = g, S = u > 0 || d > 0;
321
+ return (s || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && h.init({
322
+ debug: s,
323
323
  dsn: e,
324
- environment: u || "production",
324
+ environment: c || "production",
325
325
  ignoreErrors: [
326
- ...c || [],
326
+ ...i || [],
327
327
  /dynamically imported module/,
328
328
  /Cannot read properties of undefined \(reading 'default'\)/,
329
329
  /Loading chunk \d+ failed/,
@@ -331,25 +331,29 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
331
331
  /Failed to fetch dynamically imported module/,
332
332
  /vite:preloadError/
333
333
  ],
334
- integrations: [m.reactRouterV6BrowserTracingIntegration({
335
- createRoutesFromChildren: g,
336
- matchRoutes: _,
337
- useEffect: o,
338
- useLocation: y,
339
- useNavigationType: b
340
- }), ...t || []],
341
- release: d,
342
- replaysOnErrorSampleRate: i || 1,
343
- replaysSessionSampleRate: r || .1,
344
- tracePropagationTargets: s,
345
- tracesSampleRate: n || 1
334
+ integrations: [
335
+ h.reactRouterV6BrowserTracingIntegration({
336
+ createRoutesFromChildren: _,
337
+ matchRoutes: y,
338
+ useEffect: o,
339
+ useLocation: b,
340
+ useNavigationType: x
341
+ }),
342
+ ...S ? [h.replayIntegration({ beforeErrorSampling: f })] : [],
343
+ ...t || []
344
+ ],
345
+ release: l,
346
+ replaysOnErrorSampleRate: d,
347
+ replaysSessionSampleRate: u,
348
+ tracePropagationTargets: r,
349
+ tracesSampleRate: n ?? 1
346
350
  }), null;
347
- }, V = /* @__PURE__ */ new WeakMap(), oe = "user", se = ({ Fallback: e, isLogged: n, loginPath: r = "/login", redirect401Path: i = "/login", ...s }) => {
351
+ }, U = /* @__PURE__ */ new WeakMap(), oe = "user", se = ({ Fallback: e, isLogged: n, loginPath: r = "/login", redirect401Path: i = "/login", ...s }) => {
348
352
  let { libraries: c, localStorageKeys: d } = a(v), f = s?.reactRouter || c?.reactRouter, p = s?.axios || c?.axios, m = s?.localStorageKey || d?.user || oe;
349
353
  if (!f) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
350
354
  let [h, g] = l(null), { useLocation: _, Navigate: y, Outlet: b } = f, x = _(), S = typeof n == "function" ? n() : !!n, C = typeof S == "boolean" ? S : S?.isLogged;
351
355
  return o(() => {
352
- p && (V.has(p) || (V.set(p, !0), p.interceptors.response.use((e) => e, (e) => (typeof e == "object" && e && "response" in e && e.response && typeof e.response == "object" && "status" in e.response && e.response && typeof e.response == "object" && "status" in e.response && e?.response?.status === 401 && (typeof e == "object" && e && "config" in e && e.config && typeof e.config == "object" && "headers" in e.config && e.config.headers && typeof e.config.headers == "object" && "Authorization" in e.config.headers && e.config.headers.Authorization && (p.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(m)), g(i)), Promise.reject(e)))));
356
+ p && (U.has(p) || (U.set(p, !0), p.interceptors.response.use((e) => e, (e) => (typeof e == "object" && e && "response" in e && e.response && typeof e.response == "object" && "status" in e.response && e.response && typeof e.response == "object" && "status" in e.response && e?.response?.status === 401 && (typeof e == "object" && e && "config" in e && e.config && typeof e.config == "object" && "headers" in e.config && e.config.headers && typeof e.config.headers == "object" && "Authorization" in e.config.headers && e.config.headers.Authorization && (p.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(m)), g(i)), Promise.reject(e)))));
353
357
  }, [
354
358
  p,
355
359
  m,
@@ -365,10 +369,10 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
365
369
  state: { from: x },
366
370
  replace: !0
367
371
  });
368
- }, H = /* @__PURE__ */ new Set(), ce = () => (o(() => {
372
+ }, W = /* @__PURE__ */ new Set(), ce = () => (o(() => {
369
373
  let e = Symbol();
370
- return H.add(e), document.documentElement.removeAttribute(B), () => {
371
- H.delete(e), H.size === 0 && document.documentElement.setAttribute(B, "");
374
+ return W.add(e), document.documentElement.removeAttribute(B), () => {
375
+ W.delete(e), W.size === 0 && document.documentElement.setAttribute(B, "");
372
376
  };
373
377
  }, []), null), le = "user", ue = {
374
378
  client: "/v2/threads/ws",
@@ -380,19 +384,19 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
380
384
  } catch {
381
385
  return null;
382
386
  }
383
- }, U = n(null), pe = ({ children: e, token: t, url: n, wsPath: r, maxReconnectAttempts: s, reconnectBaseDelay: d, maxMessageBodyLength: f = 1e4, reconnect: p = !0, enabled: m = !0, context: h = "client" }) => {
384
- let [_, y] = l(!1), [b, x] = l(!1), [S, C] = l(0), [w, ee] = l(m), T = m && w, { apiURL: E, localStorageKeys: D } = a(v), O = D?.user || le, k = c(null), A = c(/* @__PURE__ */ new Set());
387
+ }, G = n(null), pe = ({ children: e, token: t, url: n, wsPath: r, maxReconnectAttempts: s, reconnectBaseDelay: d, maxMessageBodyLength: f = 1e4, reconnect: p = !0, enabled: m = !0, context: h = "client" }) => {
388
+ let [_, y] = l(!1), [b, x] = l(!1), [S, C] = l(0), [w, T] = l(m), E = m && w, { apiURL: D, localStorageKeys: O } = a(v), k = O?.user || le, A = c(null), j = c(/* @__PURE__ */ new Set());
385
389
  o(() => {
386
- if (!T) return;
387
- let e = r ?? ue[h], i = n || (E ? de(E, e) : null);
390
+ if (!E) return;
391
+ let e = r ?? ue[h], i = n || (D ? de(D, e) : null);
388
392
  if (!i) return;
389
- let a = () => t ?? fe(O), o = (e) => {
393
+ let a = () => t ?? fe(k), o = (e) => {
390
394
  switch (e.type) {
391
395
  case "ready":
392
396
  x(!0), C(e.unreadCount ?? 0);
393
397
  break;
394
398
  }
395
- for (let t of A.current) t(e);
399
+ for (let t of j.current) t(e);
396
400
  }, c = setTimeout(() => {
397
401
  let e = new g({
398
402
  getToken: a,
@@ -406,34 +410,34 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
406
410
  reconnectBaseDelay: d,
407
411
  url: i
408
412
  });
409
- k.current = e, e.connect();
413
+ A.current = e, e.connect();
410
414
  }, 0);
411
415
  return () => {
412
- clearTimeout(c), k.current?.disconnect(), k.current = null;
416
+ clearTimeout(c), A.current?.disconnect(), A.current = null;
413
417
  };
414
418
  }, [
415
- T,
419
+ E,
416
420
  n,
417
421
  r,
418
422
  h,
419
423
  t,
420
424
  p,
421
- E,
422
- O,
425
+ D,
426
+ k,
423
427
  f,
424
428
  s,
425
429
  d
426
430
  ]);
427
- let j = i((e) => {
428
- k.current?.joinThread(e);
429
- }, []), M = i((e) => {
430
- k.current?.leaveThread(e);
431
+ let M = i((e) => {
432
+ A.current?.joinThread(e);
433
+ }, []), ee = i((e) => {
434
+ A.current?.leaveThread(e);
431
435
  }, []), N = i((e, t) => {
432
- k.current?.sendMessage(e, t);
436
+ A.current?.sendMessage(e, t);
433
437
  }, []), P = i((e) => {
434
- k.current?.markRead(e);
438
+ A.current?.markRead(e);
435
439
  }, []), F = i((e, t) => {
436
- k.current?.listThreads(e, t);
440
+ A.current?.listThreads(e, t);
437
441
  }, []), I = i((e = 1) => {
438
442
  C((t) => t + e);
439
443
  }, []), L = {
@@ -441,25 +445,25 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
441
445
  C((t) => Math.max(0, t - e));
442
446
  }, []),
443
447
  disconnect: i(() => {
444
- k.current?.disconnect(), k.current = null;
448
+ A.current?.disconnect(), A.current = null;
445
449
  }, []),
446
450
  incrementUnreadCount: I,
447
451
  isConnected: _,
448
452
  isReady: b,
449
- joinThread: j,
450
- leaveThread: M,
453
+ joinThread: M,
454
+ leaveThread: ee,
451
455
  listThreads: F,
452
456
  markRead: P,
453
457
  sendMessage: N,
454
458
  setEnabled: i((e) => {
455
- ee(e);
459
+ T(e);
456
460
  }, []),
457
- subscribe: i((e) => (A.current.add(e), () => {
458
- A.current.delete(e);
461
+ subscribe: i((e) => (j.current.add(e), () => {
462
+ j.current.delete(e);
459
463
  }), []),
460
464
  unreadCount: S
461
465
  };
462
- return /* @__PURE__ */ u(U.Provider, {
466
+ return /* @__PURE__ */ u(G.Provider, {
463
467
  value: L,
464
468
  children: e
465
469
  });
@@ -482,10 +486,10 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
482
486
  client: l.current,
483
487
  children: e
484
488
  });
485
- }, W = ({ library: e, date: t, format: n = "ll" }) => e(t).format(n), G = (e, t) => {
489
+ }, K = ({ library: e, date: t, format: n = "ll" }) => e(t).format(n), q = (e, t) => {
486
490
  let { fractionDigits: n = 0, metric: r = "km", spacingBetween: i = !0 } = t || {}, a = Number(e), o = i ? " " : "";
487
491
  return Number.isNaN(a) ? `0${o}${r}` : `${a.toFixed(n)}${o}${r}`;
488
- }, K = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((e) => e.length > 0 ? e.charAt(0).toUpperCase() + e.slice(1) : e).join(" "), _e = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, ve = ({ path: e, size: t, apiURL: n }) => {
492
+ }, J = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((e) => e.length > 0 ? e.charAt(0).toUpperCase() + e.slice(1) : e).join(" "), _e = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, ve = ({ path: e, size: t, apiURL: n }) => {
489
493
  if (!e) return "";
490
494
  let r = `${n}${_e(e)}`, i = r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
491
495
  return typeof t == "number" && i ? `${r.replace("/files", `/thumbs/${t}`)}` : r;
@@ -494,13 +498,13 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
494
498
  return {
495
499
  dateAdapter: (e, t) => {
496
500
  if (!r) throw Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
497
- return W({
501
+ return K({
498
502
  date: e,
499
503
  format: t,
500
504
  library: r
501
505
  });
502
506
  },
503
- distanceAdapter: G,
507
+ distanceAdapter: q,
504
508
  filePathAdapter: (e, n) => {
505
509
  if (!t) throw Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");
506
510
  return typeof e == "string" && /^https?:\/\//.test(e) ? e : ve({
@@ -509,7 +513,7 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
509
513
  size: n
510
514
  });
511
515
  },
512
- worksiteNameAdapter: K
516
+ worksiteNameAdapter: J
513
517
  };
514
518
  }, be = () => {
515
519
  let { libraries: e } = a(v), t = e?.amplitude?.analytics, n = i((e, n) => {
@@ -581,7 +585,7 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
581
585
  n.onclick = () => r(e);
582
586
  }
583
587
  }, we = (e) => {
584
- let t = a(U);
588
+ let t = a(G);
585
589
  if (!t) throw Error("useChat must be used within ChatProvider");
586
590
  let { subscribe: n, setEnabled: r, ...i } = t, s = c(e);
587
591
  return s.current = e, o(() => {
@@ -623,15 +627,15 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
623
627
  break;
624
628
  }
625
629
  }), [n]), i;
626
- }, q = (e, t) => t === "short" ? e.split("-")[0] : e, Te = (e, t = "full") => {
630
+ }, Y = (e, t) => t === "short" ? e.split("-")[0] : e, Te = (e, t = "full") => {
627
631
  let [n, r] = l(() => {
628
632
  let n = e?.language || navigator.language;
629
- return e && "isInitialized" in e && e.isInitialized, q(n, t);
633
+ return e && "isInitialized" in e && e.isInitialized, Y(n, t);
630
634
  });
631
635
  return o(() => {
632
- e && "isInitialized" in e && e.isInitialized && e.language && r(q(e.language, t));
636
+ e && "isInitialized" in e && e.isInitialized && e.language && r(Y(e.language, t));
633
637
  let n = (e) => {
634
- r(q(e, t));
638
+ r(Y(e, t));
635
639
  };
636
640
  return e?.on?.("languageChanged", n), () => {
637
641
  e?.off?.("languageChanged", n);
@@ -642,13 +646,13 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
642
646
  getFilters: () => ({}),
643
647
  handleFilter: () => () => {},
644
648
  setFilter: () => {}
645
- }, J = (e) => {
649
+ }, X = (e) => {
646
650
  try {
647
651
  return JSON.parse(e);
648
652
  } catch {
649
653
  return e;
650
654
  }
651
- }, Y = (e, t, n) => `${n}_${e}=>${t}`, Oe = (e) => e.reduce((e, t) => {
655
+ }, Z = (e, t, n) => `${n}_${e}=>${t}`, Oe = (e) => e.reduce((e, t) => {
652
656
  let n = localStorage.getItem(t);
653
657
  if (n) try {
654
658
  let t = JSON.parse(n), r = Object.keys(t)?.[0];
@@ -660,7 +664,7 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
660
664
  if (P) return De;
661
665
  if (!r) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");
662
666
  let m = () => Object.keys(localStorage).filter((t) => t.startsWith(d) && t.endsWith(e?.pathname || i)), h = (t, n, r = !0) => {
663
- let a = Y(t, e?.pathname || i, d);
667
+ let a = Z(t, e?.pathname || i, d);
664
668
  if (!n || Array.isArray(n) && !n.length) {
665
669
  f ? (o.delete(t), s(o)) : u((e) => {
666
670
  let n = { ...e };
@@ -680,13 +684,13 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
680
684
  getFilter: (t, n) => {
681
685
  if (f) {
682
686
  let e = o.get(t);
683
- if (e) return J(e);
687
+ if (e) return X(e);
684
688
  } else {
685
689
  let e = c[t];
686
690
  if (e !== void 0) return e;
687
691
  }
688
692
  if (p) {
689
- let n = Y(t, e?.pathname || i, d), r = localStorage.getItem(n);
693
+ let n = Z(t, e?.pathname || i, d), r = localStorage.getItem(n);
690
694
  if (r) try {
691
695
  let e = JSON.parse(r)[t];
692
696
  return !f && e !== void 0 && u((n) => ({
@@ -700,7 +704,7 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
700
704
  getFilters: () => {
701
705
  let e = p ? Oe(m()) : {};
702
706
  if (f) {
703
- let t = Array.from(o.entries()).reduce((e, [t, n]) => (e[t] = J(n), e), {});
707
+ let t = Array.from(o.entries()).reduce((e, [t, n]) => (e[t] = X(n), e), {});
704
708
  return {
705
709
  ...e,
706
710
  ...t
@@ -721,7 +725,7 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
721
725
  },
722
726
  setFilter: h
723
727
  };
724
- }, X = () => document.getElementById(R), Ae = () => {
728
+ }, Ae = () => document.getElementById(R), je = () => {
725
729
  let [e, t] = l(() => !!window.HubSpotConversations);
726
730
  return o(() => {
727
731
  if (window.HubSpotConversations) {
@@ -731,16 +735,16 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
731
735
  window.hsConversationsOnReady = [() => t(!0)];
732
736
  }, []), o(() => {
733
737
  e && window.HubSpotConversations?.on("widgetClosed", () => {
734
- X()?.classList.remove(z);
738
+ Ae()?.classList.remove(z);
735
739
  });
736
740
  }, [e]), {
737
741
  isAvailable: e,
738
742
  toggle: i(() => {
739
- let e = window.HubSpotConversations, t = X();
743
+ let e = window.HubSpotConversations, t = Ae();
740
744
  e && t && (t.classList.contains("hs-show") ? (e.widget.close(), t.classList.remove(z)) : (t.classList.add(z), e.widget.open()));
741
745
  }, [])
742
746
  };
743
- }, je = ({ data: e, fetchNextPage: t, isFetchingNextPage: n, isInitialLoading: r, isLoading: a, enabled: o = !0 }) => {
747
+ }, Me = ({ data: e, fetchNextPage: t, isFetchingNextPage: n, isInitialLoading: r, isLoading: a, enabled: o = !0 }) => {
744
748
  let c = i(async (e) => {
745
749
  n || !o || await t({ pageParam: e?.pageParam || e.visibleRowsCount });
746
750
  }, [
@@ -756,7 +760,7 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
756
760
  loadingVariant: r ? "skeleton" : "linear-progress",
757
761
  rows: l
758
762
  };
759
- }, Me = (e) => {
763
+ }, Ne = (e) => {
760
764
  let { libraries: t } = a(v), n = e?.i18 || t?.i18, r = e?.i18?.translateFunction || t?.i18?.translateFunction, o = n?.i18next?.t || r || ((e) => e), { unknownErrorTranslationKey: s = "error.unknownError" } = e || {}, c = o(s), l = i((e) => {
761
765
  if (e && typeof e == "object" && "response" in e) {
762
766
  let { response: t } = e || {};
@@ -780,38 +784,38 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
780
784
  }, []),
781
785
  printError: l
782
786
  };
783
- }, Z = "chunk-reload-timestamp", Q = "chunk-reload", Ne = 1e4, $ = 2, Pe = !1;
787
+ }, Pe = "chunk-reload-timestamp", Q = "chunk-reload", Fe = 1e4, $ = 2, Ie = !1;
784
788
  if (!P && typeof window < "u") {
785
789
  try {
786
790
  let e = new URL(window.location.href);
787
- e.searchParams.has(Q) && (Pe = !0, e.searchParams.delete(Q), window.history.replaceState(null, "", e.toString()));
791
+ e.searchParams.has(Q) && (Ie = !0, e.searchParams.delete(Q), window.history.replaceState(null, "", e.toString()));
788
792
  } catch {}
789
793
  window.addEventListener("vite:preloadError", (e) => {
790
794
  e.preventDefault();
791
795
  });
792
796
  }
793
- var Fe = (e) => {
797
+ var Le = (e) => {
794
798
  if (!(e instanceof Error)) return !1;
795
799
  let t = e.message.toLowerCase();
796
800
  return t.includes("dynamically imported module") || t.includes("importing a module script failed") || t.includes("loading chunk") || t.includes("loading css chunk") || t.includes("unable to preload css") || t.includes("failed to fetch") || t.includes("error loading dynamically imported module") || t.includes("load failed") || t.includes("without a valid default export") || e.name === "ChunkLoadError";
797
- }, Ie = /import\s*\(\s*(['"])((\w+:(\/?\/?))?[^\s,]+)\1/, Le = (e) => e.toString().match(Ie)?.[2] ?? null, Re = (e) => {
801
+ }, Re = /import\s*\(\s*(['"])((\w+:(\/?\/?))?[^\s,]+)\1/, ze = (e) => e.toString().match(Re)?.[2] ?? null, Be = (e) => {
798
802
  try {
799
803
  return sessionStorage.getItem(e);
800
804
  } catch {
801
805
  return null;
802
806
  }
803
- }, ze = (e, t) => {
807
+ }, Ve = (e, t) => {
804
808
  try {
805
809
  sessionStorage.setItem(e, t);
806
810
  } catch {}
807
- }, Be = (e) => Function("url", "return import(url)")(e), Ve = async (e) => {
811
+ }, He = (e) => Function("url", "return import(url)")(e), Ue = async (e) => {
808
812
  for (let t = 0; t < $; t++) try {
809
- return await Be(`${e}?t=${Date.now()}`);
813
+ return await He(`${e}?t=${Date.now()}`);
810
814
  } catch {
811
815
  t < $ - 1 && await new Promise((e) => setTimeout(e, 500 * 2 ** t));
812
816
  }
813
817
  throw Error(`Failed to import ${e} after ${$} retries`);
814
- }, He = async () => {
818
+ }, We = async () => {
815
819
  try {
816
820
  if (typeof navigator < "u" && "serviceWorker" in navigator) {
817
821
  let e = await navigator.serviceWorker.getRegistrations();
@@ -822,27 +826,27 @@ var Fe = (e) => {
822
826
  await Promise.all(e.map((e) => caches.delete(e)));
823
827
  }
824
828
  } catch {}
825
- }, Ue = async () => {
826
- await He();
829
+ }, Ge = async () => {
830
+ await We();
827
831
  let e = new URL(window.location.href);
828
832
  e.searchParams.set(Q, String(Date.now())), window.location.replace(e.toString());
829
- }, We = (e) => e != null && e.default !== void 0, Ge = (e) => r(async () => {
833
+ }, Ke = (e) => e != null && e.default !== void 0, qe = (e) => r(async () => {
830
834
  let t;
831
835
  try {
832
836
  let n = await e();
833
- if (We(n)) return n;
837
+ if (Ke(n)) return n;
834
838
  t = /* @__PURE__ */ Error("Module resolved without a valid default export");
835
839
  } catch (e) {
836
840
  t = e;
837
841
  }
838
- if (P || !Fe(t)) throw t;
839
- let n = Le(e);
842
+ if (P || !Le(t)) throw t;
843
+ let n = ze(e);
840
844
  if (n) try {
841
- let e = await Ve(n);
842
- if (We(e)) return e;
845
+ let e = await Ue(n);
846
+ if (Ke(e)) return e;
843
847
  } catch {}
844
- let r = Number(Re(Z) || "0");
845
- return Date.now() - r < Ne || Pe || (ze(Z, String(Date.now())), await Ue()), { default: () => null };
848
+ let r = Number(Be(Pe) || "0");
849
+ return Date.now() - r < Fe || Ie || (Ve(Pe, String(Date.now())), await Ge()), { default: () => null };
846
850
  });
847
851
  //#endregion
848
- export { O as AMPLITUDE_FEATURE_SELECTOR, E as AutoReloadOnNewVersion, g as ChatClient, U as ChatContext, pe as ChatProvider, D as GTMSendPageView, N as InitializeAmplitude, I as InitializeAxiosConfig, ne as InitializeDaysJSConfig, re as InitializeHubSpot, ie as InitializeI18nConfig, ae as InitializeSentryConfig, v as InjectDependenciesContext, y as InjectDependenciesProvider, _ as MaskTextField, ge as QueryProvider, se as RequireAuth, L as SUPPORTED_LANGUAGE, ce as ShowHubSpotBubble, W as dateAdapter, G as distanceAdapter, e as getOrvalConfig, Ge as lazyWithRetry, ye as useAdapter, be as useAmplitude, xe as useAuth, we as useChat, Te as useCurrentLanguage, ke as useFilters, Ae as useHubSpot, je as useInfiniteDataGrid, Me as useResponseError, K as worksiteNameAdapter };
852
+ export { k as AMPLITUDE_FEATURE_SELECTOR, D as AutoReloadOnNewVersion, g as ChatClient, G as ChatContext, pe as ChatProvider, O as GTMSendPageView, N as InitializeAmplitude, I as InitializeAxiosConfig, ne as InitializeDaysJSConfig, re as InitializeHubSpot, ie as InitializeI18nConfig, ae as InitializeSentryConfig, v as InjectDependenciesContext, y as InjectDependenciesProvider, _ as MaskTextField, ge as QueryProvider, se as RequireAuth, V as SENTRY_KEEP_REPLAY, L as SUPPORTED_LANGUAGE, ce as ShowHubSpotBubble, K as dateAdapter, q as distanceAdapter, e as getOrvalConfig, H as isReplayKeptForError, qe as lazyWithRetry, ye as useAdapter, be as useAmplitude, xe as useAuth, we as useChat, Te as useCurrentLanguage, ke as useFilters, je as useHubSpot, Me as useInfiniteDataGrid, Ne as useResponseError, J as worksiteNameAdapter };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getsoren/shared-module",
3
- "version": "2.47.1",
3
+ "version": "2.48.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "types": "./dist/main.d.ts",