@sensiblestats/widget-react 0.161.0 → 0.162.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 +11 -0
- package/dist/index.cjs +39 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +39 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @sensiblestats/widget-react
|
|
2
2
|
|
|
3
|
+
## 0.162.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Client events: `widget_loaded.loadMs` counts from the mount, or from a `loadStart` prop the embed and `/m` pass. A first-render throw still sends `widget_error`. `market_suspended_shown` records each suspension spell, and market card impressions are keyed on the sport.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @sensiblestats/widget-sdk@0.119.0
|
|
13
|
+
|
|
3
14
|
## 0.161.0
|
|
4
15
|
|
|
5
16
|
### 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.
|
|
1425
|
+
var WIDGET_REACT_VERSION = "0.162.0";
|
|
1426
1426
|
|
|
1427
1427
|
// src/config.ts
|
|
1428
1428
|
var COLOR_KEYS = ["accent", "cta", "surface", "ink"];
|
|
@@ -7330,6 +7330,9 @@ function impressionOnce(key) {
|
|
|
7330
7330
|
seen.add(key);
|
|
7331
7331
|
return true;
|
|
7332
7332
|
}
|
|
7333
|
+
function impressionForget(key) {
|
|
7334
|
+
seen.delete(key);
|
|
7335
|
+
}
|
|
7333
7336
|
function useImpressions(entries) {
|
|
7334
7337
|
const record2 = useRecord();
|
|
7335
7338
|
const entriesRef = (0, import_react41.useRef)(entries);
|
|
@@ -7626,7 +7629,7 @@ function MarketOddsCard({ vm, ui, slip, monitor, inSlipIds, hideHeader, pinRef }
|
|
|
7626
7629
|
const staleTime = isStale && live ? fmtHhMm(live.asOfUtc, ui.locale, clockOf(ui), ui.timeZone) : null;
|
|
7627
7630
|
const record2 = useRecord();
|
|
7628
7631
|
const origin = useSlipSurface();
|
|
7629
|
-
const scope = `${origin?.impressionScope ?? origin?.turnId ?? origin?.surface ?? "none"}|${vm.id}`;
|
|
7632
|
+
const scope = `${origin?.impressionScope ?? origin?.turnId ?? origin?.surface ?? "none"}|${vm.sport ?? "football"}|${vm.id}`;
|
|
7630
7633
|
const matchId = String(vm.matchId);
|
|
7631
7634
|
const slipReason = !vm.addToSlipEnabled || isClosed ? null : isStale ? "hold" : slip.onAddToSlip && !slipOpenFor(slip, vm.sport) ? "closed" : slip.onAddToSlip && nflStarted(vm, Date.now()) ? "started" : null;
|
|
7632
7635
|
const shown2 = [];
|
|
@@ -9144,7 +9147,7 @@ function useLoadTelemetry(input) {
|
|
|
9144
9147
|
(0, import_react62.useEffect)(() => {
|
|
9145
9148
|
if (!hasClient || loadedRef.current) return;
|
|
9146
9149
|
loadedRef.current = true;
|
|
9147
|
-
recordRef.current({ name: "widget_loaded", props: { loadMs: Math.max(0, Date.now() - inputRef.current.
|
|
9150
|
+
recordRef.current({ name: "widget_loaded", props: { loadMs: Math.max(0, Date.now() - inputRef.current.loadStart) } });
|
|
9148
9151
|
}, [hasClient]);
|
|
9149
9152
|
(0, import_react62.useEffect)(() => {
|
|
9150
9153
|
if (!hasClient) return;
|
|
@@ -12689,11 +12692,11 @@ function MarketAccordion({ match, monitor, ui, slip }) {
|
|
|
12689
12692
|
const suspendedKey = markets.filter((m) => m.suspended).map((m) => m.marketDeveloperName).join("|");
|
|
12690
12693
|
(0, import_react86.useEffect)(() => {
|
|
12691
12694
|
for (const m of markets) {
|
|
12692
|
-
|
|
12693
|
-
|
|
12694
|
-
}
|
|
12695
|
+
const key = `market_suspended_shown|${match.sport}|${match.matchId}|${m.marketDeveloperName}`;
|
|
12696
|
+
if (!m.suspended) impressionForget(key);
|
|
12697
|
+
else if (impressionOnce(key)) record2({ name: "market_suspended_shown", props: { matchId: String(match.matchId), market: m.marketDeveloperName } });
|
|
12695
12698
|
}
|
|
12696
|
-
}, [suspendedKey, match.matchId, record2]);
|
|
12699
|
+
}, [suspendedKey, match.sport, match.matchId, record2]);
|
|
12697
12700
|
if (markets.length === 0) return null;
|
|
12698
12701
|
const mk = monitorMatchKey(match.sport, match.matchId);
|
|
12699
12702
|
const open = monitor.openMarket[mk] ?? null;
|
|
@@ -23628,7 +23631,6 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
|
|
|
23628
23631
|
// src/StatsWidget.tsx
|
|
23629
23632
|
var import_jsx_runtime165 = require("react/jsx-runtime");
|
|
23630
23633
|
var NO_OWNER = {};
|
|
23631
|
-
var SCRIPT_START = Date.now();
|
|
23632
23634
|
function buildClient(props, onUnavailable) {
|
|
23633
23635
|
try {
|
|
23634
23636
|
if ("client" in props && props.client) {
|
|
@@ -23652,10 +23654,36 @@ function injectStyles(root) {
|
|
|
23652
23654
|
el.textContent = WIDGET_CSS;
|
|
23653
23655
|
host.appendChild(el);
|
|
23654
23656
|
}
|
|
23657
|
+
function reportBeforeReady(props, body) {
|
|
23658
|
+
try {
|
|
23659
|
+
let client;
|
|
23660
|
+
let identity;
|
|
23661
|
+
if ("client" in props && props.client) {
|
|
23662
|
+
client = props.client;
|
|
23663
|
+
} else {
|
|
23664
|
+
const cfg = props.config;
|
|
23665
|
+
client = new import_widget_sdk42.StatsWidgetClient(toClientOptions(cfg));
|
|
23666
|
+
identity = { operatorUserId: cfg.userContext?.operatorUserId, anonymousUserId: cfg.userContext?.anonymousUserId };
|
|
23667
|
+
}
|
|
23668
|
+
const surface = props.mobile ? "mobile" : props.surface ?? "react";
|
|
23669
|
+
const logger = client.createEventLogger(identity, {
|
|
23670
|
+
context: () => ({ widgetVersion: WIDGET_REACT_VERSION, surface, ...props.mobile?.client ? { client: props.mobile.client } : {} })
|
|
23671
|
+
});
|
|
23672
|
+
logger.log({ name: "widget_error", props: body });
|
|
23673
|
+
void logger.flushNow().finally(() => logger.dispose());
|
|
23674
|
+
} catch {
|
|
23675
|
+
}
|
|
23676
|
+
}
|
|
23655
23677
|
function StatsWidget(props) {
|
|
23656
23678
|
const sink = (0, import_react131.useRef)(null);
|
|
23657
|
-
const
|
|
23658
|
-
|
|
23679
|
+
const propsRef = (0, import_react131.useRef)(props);
|
|
23680
|
+
propsRef.current = props;
|
|
23681
|
+
const report = (0, import_react131.useCallback)((body) => {
|
|
23682
|
+
if (sink.current) sink.current(body);
|
|
23683
|
+
else reportBeforeReady(propsRef.current, body);
|
|
23684
|
+
}, []);
|
|
23685
|
+
const mountStart = (0, import_react131.useRef)(Date.now()).current;
|
|
23686
|
+
return /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(TelemetryBoundary, { component: "widget", report, children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(StatsWidgetBody, { ...props, errorSink: sink, mountStart }) });
|
|
23659
23687
|
}
|
|
23660
23688
|
function StatsWidgetBody(props) {
|
|
23661
23689
|
const injectedClient = "client" in props ? props.client : void 0;
|
|
@@ -24157,7 +24185,7 @@ function StatsWidgetBody(props) {
|
|
|
24157
24185
|
panelOpen,
|
|
24158
24186
|
mobile: props.mobile !== void 0,
|
|
24159
24187
|
scriptUrl: props.scriptUrl,
|
|
24160
|
-
|
|
24188
|
+
loadStart: props.loadStart ?? props.mountStart
|
|
24161
24189
|
});
|
|
24162
24190
|
props.errorSink.current = reportError;
|
|
24163
24191
|
(0, import_react131.useEffect)(() => {
|