@sensiblestats/widget-react 0.160.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 +22 -0
- package/README.md +3 -3
- package/dist/index.cjs +40 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +40 -13
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
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
|
+
|
|
14
|
+
## 0.161.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- `baseUrl` is now required. The SDK no longer falls back to a default gateway host, because every operator box has its own gateway. `new StatsWidgetClient` throws when `baseUrl` is missing or blank, and `StatsWidgetConfig.baseUrl` is a required string. The embed script still infers it from its own `src`.
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
- @sensiblestats/widget-sdk@0.118.0
|
|
24
|
+
|
|
3
25
|
## 0.160.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ export function App() {
|
|
|
20
20
|
config={{
|
|
21
21
|
operatorId: 'sandbox1',
|
|
22
22
|
publicKey: 'wgk_…',
|
|
23
|
-
baseUrl: 'https
|
|
23
|
+
baseUrl: 'https://<your-box-gateway-host>',
|
|
24
24
|
locale: 'en-GB',
|
|
25
25
|
}}
|
|
26
26
|
/>
|
|
@@ -32,7 +32,7 @@ Common `config` fields:
|
|
|
32
32
|
|
|
33
33
|
- `operatorId`, `publicKey` — your gateway credentials (both browser-safe; the
|
|
34
34
|
public key is origin-gated at the gateway).
|
|
35
|
-
- `baseUrl` —
|
|
35
|
+
- `baseUrl` — required. The widget gateway URL of your operator box; there is no default host, and omitting it is a type error.
|
|
36
36
|
- `locale` — any language tag in the server's registry (`'en-GB'`, `'en-US'`, `'tr-TR'`, `'de'`, ...). It is
|
|
37
37
|
sent whole to the server as the language (`defaultLanguage`) and picks the widget's own chrome text. A host
|
|
38
38
|
with no `locale` sends no language and gets the operator's default (en-GB when the operator has none).
|
|
@@ -280,7 +280,7 @@ import { StatsWidget } from '@sensiblestats/widget-react'
|
|
|
280
280
|
const widgetConfig = {
|
|
281
281
|
operatorId: 'sandbox1',
|
|
282
282
|
publicKey: 'wgk_…',
|
|
283
|
-
baseUrl: 'https
|
|
283
|
+
baseUrl: 'https://<your-box-gateway-host>',
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
export function AppLayout() {
|
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"];
|
|
@@ -1829,8 +1829,7 @@ function normalizeUi(cfg, loaded) {
|
|
|
1829
1829
|
};
|
|
1830
1830
|
}
|
|
1831
1831
|
function toClientOptions(cfg) {
|
|
1832
|
-
const opts = { operatorId: cfg.operatorId, publicKey: cfg.publicKey, client: `${cfg.transport?.client ?? "widget-react"}/${WIDGET_REACT_VERSION}` };
|
|
1833
|
-
if (cfg.baseUrl !== void 0) opts.baseUrl = cfg.baseUrl;
|
|
1832
|
+
const opts = { operatorId: cfg.operatorId, publicKey: cfg.publicKey, baseUrl: cfg.baseUrl, client: `${cfg.transport?.client ?? "widget-react"}/${WIDGET_REACT_VERSION}` };
|
|
1834
1833
|
if (cfg.transport?.fetch !== void 0) opts.fetch = cfg.transport.fetch;
|
|
1835
1834
|
const timeZone = validZone(cfg.timeZone);
|
|
1836
1835
|
if (timeZone !== void 0) opts.timeZone = timeZone;
|
|
@@ -7331,6 +7330,9 @@ function impressionOnce(key) {
|
|
|
7331
7330
|
seen.add(key);
|
|
7332
7331
|
return true;
|
|
7333
7332
|
}
|
|
7333
|
+
function impressionForget(key) {
|
|
7334
|
+
seen.delete(key);
|
|
7335
|
+
}
|
|
7334
7336
|
function useImpressions(entries) {
|
|
7335
7337
|
const record2 = useRecord();
|
|
7336
7338
|
const entriesRef = (0, import_react41.useRef)(entries);
|
|
@@ -7627,7 +7629,7 @@ function MarketOddsCard({ vm, ui, slip, monitor, inSlipIds, hideHeader, pinRef }
|
|
|
7627
7629
|
const staleTime = isStale && live ? fmtHhMm(live.asOfUtc, ui.locale, clockOf(ui), ui.timeZone) : null;
|
|
7628
7630
|
const record2 = useRecord();
|
|
7629
7631
|
const origin = useSlipSurface();
|
|
7630
|
-
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}`;
|
|
7631
7633
|
const matchId = String(vm.matchId);
|
|
7632
7634
|
const slipReason = !vm.addToSlipEnabled || isClosed ? null : isStale ? "hold" : slip.onAddToSlip && !slipOpenFor(slip, vm.sport) ? "closed" : slip.onAddToSlip && nflStarted(vm, Date.now()) ? "started" : null;
|
|
7633
7635
|
const shown2 = [];
|
|
@@ -9145,7 +9147,7 @@ function useLoadTelemetry(input) {
|
|
|
9145
9147
|
(0, import_react62.useEffect)(() => {
|
|
9146
9148
|
if (!hasClient || loadedRef.current) return;
|
|
9147
9149
|
loadedRef.current = true;
|
|
9148
|
-
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) } });
|
|
9149
9151
|
}, [hasClient]);
|
|
9150
9152
|
(0, import_react62.useEffect)(() => {
|
|
9151
9153
|
if (!hasClient) return;
|
|
@@ -12690,11 +12692,11 @@ function MarketAccordion({ match, monitor, ui, slip }) {
|
|
|
12690
12692
|
const suspendedKey = markets.filter((m) => m.suspended).map((m) => m.marketDeveloperName).join("|");
|
|
12691
12693
|
(0, import_react86.useEffect)(() => {
|
|
12692
12694
|
for (const m of markets) {
|
|
12693
|
-
|
|
12694
|
-
|
|
12695
|
-
}
|
|
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 } });
|
|
12696
12698
|
}
|
|
12697
|
-
}, [suspendedKey, match.matchId, record2]);
|
|
12699
|
+
}, [suspendedKey, match.sport, match.matchId, record2]);
|
|
12698
12700
|
if (markets.length === 0) return null;
|
|
12699
12701
|
const mk = monitorMatchKey(match.sport, match.matchId);
|
|
12700
12702
|
const open = monitor.openMarket[mk] ?? null;
|
|
@@ -23629,7 +23631,6 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
|
|
|
23629
23631
|
// src/StatsWidget.tsx
|
|
23630
23632
|
var import_jsx_runtime165 = require("react/jsx-runtime");
|
|
23631
23633
|
var NO_OWNER = {};
|
|
23632
|
-
var SCRIPT_START = Date.now();
|
|
23633
23634
|
function buildClient(props, onUnavailable) {
|
|
23634
23635
|
try {
|
|
23635
23636
|
if ("client" in props && props.client) {
|
|
@@ -23653,10 +23654,36 @@ function injectStyles(root) {
|
|
|
23653
23654
|
el.textContent = WIDGET_CSS;
|
|
23654
23655
|
host.appendChild(el);
|
|
23655
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
|
+
}
|
|
23656
23677
|
function StatsWidget(props) {
|
|
23657
23678
|
const sink = (0, import_react131.useRef)(null);
|
|
23658
|
-
const
|
|
23659
|
-
|
|
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 }) });
|
|
23660
23687
|
}
|
|
23661
23688
|
function StatsWidgetBody(props) {
|
|
23662
23689
|
const injectedClient = "client" in props ? props.client : void 0;
|
|
@@ -24158,7 +24185,7 @@ function StatsWidgetBody(props) {
|
|
|
24158
24185
|
panelOpen,
|
|
24159
24186
|
mobile: props.mobile !== void 0,
|
|
24160
24187
|
scriptUrl: props.scriptUrl,
|
|
24161
|
-
|
|
24188
|
+
loadStart: props.loadStart ?? props.mountStart
|
|
24162
24189
|
});
|
|
24163
24190
|
props.errorSink.current = reportError;
|
|
24164
24191
|
(0, import_react131.useEffect)(() => {
|