@sensiblestats/widget-react 0.162.0 → 0.164.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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @sensiblestats/widget-react
2
2
 
3
+ ## 0.164.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Send the visitor ids with the live monitor request, as headers.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @sensiblestats/widget-sdk@0.120.0
13
+
14
+ ## 0.163.0
15
+
16
+ ### Minor Changes
17
+
18
+ - `StatsWidget` takes `scriptUrls` (was `scriptUrl`): a window error or rejected promise counts as the widget's when its file or stack names any of them.
19
+
3
20
  ## 0.162.0
4
21
 
5
22
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -1422,7 +1422,7 @@ function parseCustomTotal(text2, format2) {
1422
1422
  }
1423
1423
 
1424
1424
  // src/version.generated.ts
1425
- var WIDGET_REACT_VERSION = "0.162.0";
1425
+ var WIDGET_REACT_VERSION = "0.164.0";
1426
1426
 
1427
1427
  // src/config.ts
1428
1428
  var COLOR_KEYS = ["accent", "cta", "surface", "ink"];
@@ -9115,7 +9115,7 @@ function safely(fn) {
9115
9115
  }
9116
9116
  }
9117
9117
  function useLoadTelemetry(input) {
9118
- const { client, stringsState, stringsAttempt, resolvedTag, language, scriptUrl } = input;
9118
+ const { client, stringsState, stringsAttempt, resolvedTag, language, scriptUrls } = input;
9119
9119
  const signedIn = !!input.operatorUserId;
9120
9120
  const inputRef = (0, import_react62.useRef)(input);
9121
9121
  inputRef.current = input;
@@ -9196,15 +9196,18 @@ function useLoadTelemetry(input) {
9196
9196
  if (failedLimit(`${endpoint}|${status2}`)) recordRef.current({ name: "request_failed", props: { endpoint, status: status2 } });
9197
9197
  });
9198
9198
  }, [client]);
9199
+ const urlsKey = scriptUrls?.join("\n") ?? "";
9199
9200
  (0, import_react62.useEffect)(() => {
9200
- if (!hasClient || !scriptUrl) return;
9201
+ const urls = urlsKey.split("\n").filter((u) => u.length > 0);
9202
+ if (!hasClient || urls.length === 0) return;
9203
+ const fromWidget = (text2) => urls.some((u) => text2.includes(u));
9201
9204
  const onError = (e) => {
9202
- if (!e.filename || !e.filename.includes(scriptUrl)) return;
9205
+ if (!e.filename || !fromWidget(e.filename)) return;
9203
9206
  reportError({ errorClass: e.error?.name || "Error", component: "window" });
9204
9207
  };
9205
9208
  const onRejection = (e) => {
9206
9209
  const reason = e.reason;
9207
- if (typeof reason?.stack !== "string" || !reason.stack.includes(scriptUrl)) return;
9210
+ if (typeof reason?.stack !== "string" || !fromWidget(reason.stack)) return;
9208
9211
  reportError({ errorClass: typeof reason.name === "string" && reason.name ? reason.name : "Error", component: "promise" });
9209
9212
  };
9210
9213
  window.addEventListener("error", onError);
@@ -9213,7 +9216,7 @@ function useLoadTelemetry(input) {
9213
9216
  window.removeEventListener("error", onError);
9214
9217
  window.removeEventListener("unhandledrejection", onRejection);
9215
9218
  };
9216
- }, [hasClient, scriptUrl, reportError]);
9219
+ }, [hasClient, urlsKey, reportError]);
9217
9220
  return { reportError };
9218
9221
  }
9219
9222
 
@@ -23760,8 +23763,10 @@ function StatsWidgetBody(props) {
23760
23763
  }, [controller.state.messages]);
23761
23764
  const requestTag = hostTag(cfg);
23762
23765
  const clubFixturesResult = useClubFixtures(built?.conversation ?? null);
23766
+ const operatorUserId = cfg?.userContext?.operatorUserId;
23767
+ const anonymousUserId = cfg?.userContext?.anonymousUserId;
23763
23768
  const monitor = useLiveMonitor({
23764
- getLiveMonitor: (pins) => built ? built.conversation.getLiveMonitor(pins, requestTag) : Promise.resolve(null),
23769
+ getLiveMonitor: (pins) => built ? built.conversation.getLiveMonitor(pins, requestTag, operatorUserId, anonymousUserId) : Promise.resolve(null),
23765
23770
  getMarketOdds: (matchId, dev, sport) => built ? built.conversation.getMarketOdds(matchId, dev, sport) : Promise.resolve(null),
23766
23771
  getPlayerProps: (matchId, sport) => built ? built.conversation.getPlayerProps(matchId, sport, requestTag) : Promise.resolve(null),
23767
23772
  storageKey: `ss-w-pins:${cfg?.operatorId ?? ""}:${cfg?.userContext?.operatorUserId ?? "anon"}`,
@@ -23770,8 +23775,6 @@ function StatsWidgetBody(props) {
23770
23775
  clubEnabled: clubFixturesResult.enabled,
23771
23776
  record: record2
23772
23777
  });
23773
- const operatorUserId = cfg?.userContext?.operatorUserId;
23774
- const anonymousUserId = cfg?.userContext?.anonymousUserId;
23775
23778
  const getSchedule = (0, import_react131.useCallback)(
23776
23779
  (localDate, utcOffsetMinutes) => built ? built.conversation.getSchedule(localDate, utcOffsetMinutes, operatorUserId, anonymousUserId) : Promise.resolve(null),
23777
23780
  [built, operatorUserId, anonymousUserId]
@@ -24184,7 +24187,7 @@ function StatsWidgetBody(props) {
24184
24187
  hasSlipHandler: !!props.config?.onAddToSlip,
24185
24188
  panelOpen,
24186
24189
  mobile: props.mobile !== void 0,
24187
- scriptUrl: props.scriptUrl,
24190
+ scriptUrls: props.scriptUrls,
24188
24191
  loadStart: props.loadStart ?? props.mountStart
24189
24192
  });
24190
24193
  props.errorSink.current = reportError;