@genex-ai/embed-sdk 0.12.0 → 0.13.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.
@@ -2,6 +2,7 @@
2
2
  var PROTOCOL_VERSION = 1;
3
3
  var RETRY_FLAG = "genex:embed:retry";
4
4
  var POPOVER_DISMISSED_FLAG = "genex:guest:popover-dismissed";
5
+ var PLAYER_ID_KEY = "genex:player";
5
6
  var config = null;
6
7
  var state = "pending";
7
8
  var user = null;
@@ -70,6 +71,20 @@ function writePopoverDismissed() {
70
71
  } catch {
71
72
  }
72
73
  }
74
+ function playerId() {
75
+ try {
76
+ const store = win()?.localStorage;
77
+ if (!store) return "no-storage";
78
+ let id = store.getItem(PLAYER_ID_KEY);
79
+ if (!id) {
80
+ id = typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
81
+ store.setItem(PLAYER_ID_KEY, id);
82
+ }
83
+ return id;
84
+ } catch {
85
+ return "no-storage";
86
+ }
87
+ }
73
88
  function initEmbed(cfg) {
74
89
  const w = win();
75
90
  if (!w) return;
@@ -471,7 +486,10 @@ async function requestGuestSession() {
471
486
  const res = await doFetch(`${config.apiUrl}/api/embed/guest-session`, {
472
487
  method: "POST",
473
488
  headers: { "Content-Type": "application/json" },
474
- body: JSON.stringify({ slug: config.slug })
489
+ // playerId is analytics-only: the SERVER still mints the session's own
490
+ // guest id and the token is unchanged — this just lets the play event
491
+ // key on something that survives the tab.
492
+ body: JSON.stringify({ slug: config.slug, playerId: playerId() })
475
493
  });
476
494
  if (epoch !== identityEpoch) return;
477
495
  if (!res.ok) {
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  submitScore,
18
18
  waitForAuth,
19
19
  waitForPlayer
20
- } from "./chunk-EEOKYBXG.js";
20
+ } from "./chunk-XGTGIWVQ.js";
21
21
  export {
22
22
  __resetForTests,
23
23
  _stashTicketFromUrl,
package/dist/sentry.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  _stashTicketFromUrl,
3
3
  getUser,
4
4
  on
5
- } from "./chunk-EEOKYBXG.js";
5
+ } from "./chunk-XGTGIWVQ.js";
6
6
 
7
7
  // src/sentry.ts
8
8
  import * as Sentry from "@sentry/browser";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genex-ai/embed-sdk",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Player identity + durable game state for genex games \u2014 signed-in or guest play, per-player save slots, shared world state, and soft-trust leaderboards.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",