@sensiblestats/widget-react 0.101.0 → 0.102.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/dist/index.js CHANGED
@@ -1168,7 +1168,7 @@ function isEnglishLocale(locale) {
1168
1168
  }
1169
1169
 
1170
1170
  // src/version.generated.ts
1171
- var WIDGET_REACT_VERSION = "0.101.0";
1171
+ var WIDGET_REACT_VERSION = "0.102.0";
1172
1172
 
1173
1173
  // src/config.ts
1174
1174
  function normalizeUi(cfg) {
@@ -1998,7 +1998,7 @@ function footballMatchPinIds(pins) {
1998
1998
  }
1999
1999
 
2000
2000
  // src/slip.ts
2001
- import { slipSportOf as slipSportOf2, sportOf as sportOf4 } from "@sensiblestats/widget-sdk";
2001
+ import { slipSportOf as slipSportOf2, sportOf as sportOf4, toWireSport } from "@sensiblestats/widget-sdk";
2002
2002
  var ADD_TO_SLIP_TIMEOUT_MS = 1e4;
2003
2003
  var takesSport = (slip, sport) => !!slip.onAddToSlip && !!slip.slipSports?.includes(sport);
2004
2004
  function slipOpenFor(slip, sport) {
@@ -2011,7 +2011,7 @@ var MAX_LINE = 32;
2011
2011
  var MAX_ODDS = 1e4;
2012
2012
  function slipPickFields(selection, label, line) {
2013
2013
  const fields = {};
2014
- if (sportOf4(selection.sport) === void 0 && Number.isSafeInteger(selection.matchId) && selection.matchId > 0) fields.matchId = selection.matchId;
2014
+ if ((sportOf4(selection.sport) === void 0 || toWireSport(selection.sport) !== void 0) && Number.isSafeInteger(selection.matchId) && selection.matchId > 0) fields.matchId = selection.matchId;
2015
2015
  if (label && label.trim() && label.length <= MAX_SELECTION) fields.selection = label;
2016
2016
  if (line && line.trim() && line.length <= MAX_LINE) fields.line = line;
2017
2017
  const odds = selection.oddsDecimal;
@@ -2258,7 +2258,7 @@ function createMatchViews(storageKey, options = {}) {
2258
2258
  }
2259
2259
 
2260
2260
  // src/slipLedger.ts
2261
- import { mayPinOrSlip as mayPinOrSlip3, slipSportOf as slipSportOf4 } from "@sensiblestats/widget-sdk";
2261
+ import { mayPinOrSlip as mayPinOrSlip3, slipSportOf as slipSportOf4, toWireSport as toWireSport2 } from "@sensiblestats/widget-sdk";
2262
2262
  var LEDGER_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
2263
2263
  var LEDGER_MAX = 100;
2264
2264
  var BET_REPORT_MAX = 25;
@@ -2361,6 +2361,7 @@ function createSlipLedger(storageKey, options = {}) {
2361
2361
  };
2362
2362
  }
2363
2363
  function toSlipEvent(name, entry) {
2364
+ const sport = toWireSport2(entry.sport);
2364
2365
  return {
2365
2366
  name,
2366
2367
  entityType: "market",
@@ -2369,7 +2370,8 @@ function toSlipEvent(name, entry) {
2369
2370
  matchId: entry.matchId,
2370
2371
  selection: entry.selection,
2371
2372
  line: entry.line,
2372
- odds: entry.odds
2373
+ odds: entry.odds,
2374
+ ...sport ? { sport } : {}
2373
2375
  };
2374
2376
  }
2375
2377
 
@@ -4793,7 +4795,7 @@ import { useCallback as useCallback14, useState as useState17 } from "react";
4793
4795
 
4794
4796
  // src/slipAdd.ts
4795
4797
  import { useCallback as useCallback13 } from "react";
4796
- import { isAddToSlipResult } from "@sensiblestats/widget-sdk";
4798
+ import { isAddToSlipResult, toWireSport as toWireSport3 } from "@sensiblestats/widget-sdk";
4797
4799
 
4798
4800
  // src/slipStateContext.ts
4799
4801
  import { createContext as createContext2, useContext as useContext2 } from "react";
@@ -4817,8 +4819,10 @@ function useSlipAdd(slip, ui) {
4817
4819
  return useCallback13(async (selection, { marketDeveloperName, selectionLabel, line }) => {
4818
4820
  if (!handler) return { kind: "failed" };
4819
4821
  const pick = slipPickFields(selection, rawLabels ? selectionLabel : void 0, line);
4822
+ const wireSport = toWireSport3(selection.sport);
4823
+ const sportField = wireSport ? { sport: wireSport } : {};
4820
4824
  if (marketDeveloperName !== void 0) {
4821
- log?.log({ name: "slip_click", entityType: "market", marketDeveloperName, entityId: marketDeveloperName, ...pick });
4825
+ log?.log({ name: "slip_click", entityType: "market", marketDeveloperName, entityId: marketDeveloperName, ...pick, ...sportField });
4822
4826
  }
4823
4827
  try {
4824
4828
  const raw = await withTimeout(Promise.resolve(handler(selection)));
@@ -4831,7 +4835,8 @@ function useSlipAdd(slip, ui) {
4831
4835
  marketDeveloperName,
4832
4836
  entityId: marketDeveloperName,
4833
4837
  outcome: slipOutcome(result),
4834
- ...pick
4838
+ ...pick,
4839
+ ...sportField
4835
4840
  });
4836
4841
  }
4837
4842
  if (slipState) {
@@ -4843,7 +4848,7 @@ function useSlipAdd(slip, ui) {
4843
4848
  return { kind: "answered", result };
4844
4849
  } catch {
4845
4850
  if (marketDeveloperName !== void 0) {
4846
- log?.log({ name: "slip_result", entityType: "market", marketDeveloperName, entityId: marketDeveloperName, outcome: "timeout", ...pick });
4851
+ log?.log({ name: "slip_result", entityType: "market", marketDeveloperName, entityId: marketDeveloperName, outcome: "timeout", ...pick, ...sportField });
4847
4852
  }
4848
4853
  return { kind: "failed" };
4849
4854
  }
@@ -4975,6 +4980,7 @@ function Crest2({ url, name, kind, abbr }) {
4975
4980
 
4976
4981
  // src/components/PinToggle.tsx
4977
4982
  import { useCallback as useCallback15, useState as useState19 } from "react";
4983
+ import { qualifiedId, toWireSport as toWireSport4 } from "@sensiblestats/widget-sdk";
4978
4984
  import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
4979
4985
  var PIN_GLYPHS = {
4980
4986
  pin: { viewBox: "0 0 24 24", strokeWidth: 1.4, transform: "scale(1.5)", d: "M9.5 1.5 14.5 6.5 13 8l-.5-.5-3 3 .3 2.2-1.4 1.4L5.6 11.3l-3.3 3.3-1-1 3.3-3.3L1.9 7.5l1.4-1.4 2.2.3 3-3L8 2.9z" },
@@ -4987,6 +4993,8 @@ function PinToggle({ pin, monitor, ui, market }) {
4987
4993
  const log = useEventLog();
4988
4994
  if (!monitor || !monitor.enabled) return null;
4989
4995
  const key = pinKey(pin);
4996
+ const wireSport = toWireSport4(pin.sport);
4997
+ const sportField = wireSport ? { sport: wireSport } : {};
4990
4998
  const pinned = monitor.isPinned(key);
4991
4999
  const labels = pin.kind === "match" ? { pin: ui.matchPinLabel, unpin: ui.matchUnpinLabel } : { pin: ui.pinLabel, unpin: ui.unpinLabel };
4992
5000
  const onClick = (e) => {
@@ -4994,7 +5002,13 @@ function PinToggle({ pin, monitor, ui, market }) {
4994
5002
  if (pin.kind === "match" && !monitor.isPinned(key)) {
4995
5003
  const result2 = monitor.pinMatch({ matchId: pin.matchId, marketDeveloperName: market, sport: pin.sport });
4996
5004
  if (result2 === "added") {
4997
- log?.log({ name: "pin_add", entityType: "match", entityId: String(pin.matchId), marketDeveloperName: pin.marketDeveloperName });
5005
+ log?.log({
5006
+ name: "pin_add",
5007
+ entityType: "match",
5008
+ entityId: qualifiedId(pin.sport, "game", String(pin.matchId)),
5009
+ marketDeveloperName: pin.marketDeveloperName,
5010
+ ...sportField
5011
+ });
4998
5012
  } else if (result2 === "match_limit") {
4999
5013
  setToast({ kind: "error", text: ui.matchLimitToast });
5000
5014
  }
@@ -5005,8 +5019,9 @@ function PinToggle({ pin, monitor, ui, market }) {
5005
5019
  log?.log({
5006
5020
  name: result === "added" ? "pin_add" : "pin_remove",
5007
5021
  entityType: pin.kind === "match" ? "match" : "market",
5008
- entityId: pin.kind === "match" ? String(pin.matchId) : pin.marketDeveloperName,
5009
- marketDeveloperName: pin.marketDeveloperName
5022
+ entityId: pin.kind === "match" ? qualifiedId(pin.sport, "game", String(pin.matchId)) : qualifiedId(pin.sport, "market", pin.marketDeveloperName),
5023
+ marketDeveloperName: pin.marketDeveloperName,
5024
+ ...sportField
5010
5025
  });
5011
5026
  } else if (result === "market_limit") {
5012
5027
  setToast({ kind: "error", text: ui.marketLimitToast });