saltfish 0.2.53 → 0.2.55

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.
@@ -6973,7 +6973,7 @@ class InteractionManager {
6973
6973
  * @param buttonConfig - The button configuration
6974
6974
  */
6975
6975
  async handleButtonClick(event, buttonConfig) {
6976
- var _a, _b;
6976
+ var _a, _b, _c, _d, _e;
6977
6977
  log(`InteractionManager: Button click detected on button "${buttonConfig.id}"`);
6978
6978
  event.preventDefault();
6979
6979
  event.stopPropagation();
@@ -6998,9 +6998,35 @@ class InteractionManager {
6998
6998
  };
6999
6999
  }
7000
7000
  });
7001
- const playlistPersistence = ((_a = currentStore.playlistOptions) == null ? void 0 : _a.persistence) ?? true;
7001
+ try {
7002
+ log(`InteractionManager: Updating backend with step ${buttonConfig.action.target} before redirect`);
7003
+ if (((_a = currentStore.config) == null ? void 0 : _a.token) && ((_b = currentStore.user) == null ? void 0 : _b.id) && !((_c = currentStore.user) == null ? void 0 : _c.__isAnonymous)) {
7004
+ const apiUrl = `https://player.saltfish.ai/clients/${currentStore.config.token}/users/${currentStore.user.id}/playlists/${currentStore.manifest.id}`;
7005
+ log(`InteractionManager: Making API call to ${apiUrl}`);
7006
+ const response = await fetch(apiUrl, {
7007
+ method: "POST",
7008
+ headers: {
7009
+ "Content-Type": "application/json"
7010
+ },
7011
+ body: JSON.stringify({
7012
+ status: "in_progress",
7013
+ currentStepId: buttonConfig.action.target
7014
+ })
7015
+ });
7016
+ if (!response.ok) {
7017
+ log(`InteractionManager: API call failed: ${response.statusText} (${response.status})`);
7018
+ } else {
7019
+ log(`InteractionManager: Backend update complete for step ${buttonConfig.action.target}`);
7020
+ }
7021
+ } else {
7022
+ log(`InteractionManager: Cannot update backend - user not identified or anonymous`);
7023
+ }
7024
+ } catch (error2) {
7025
+ console.error("InteractionManager: Full error:", error2);
7026
+ }
7027
+ const playlistPersistence = ((_d = currentStore.playlistOptions) == null ? void 0 : _d.persistence) ?? true;
7002
7028
  if (playlistPersistence) {
7003
- const userId = (_b = currentStore.user) == null ? void 0 : _b.id;
7029
+ const userId = (_e = currentStore.user) == null ? void 0 : _e.id;
7004
7030
  const updatedStore = useSaltfishStore.getState();
7005
7031
  this.storageManager.setProgress(updatedStore.progress, userId);
7006
7032
  log(`InteractionManager: Saved progress for step ${buttonConfig.action.target} before URL redirect`);
@@ -10323,7 +10349,7 @@ const SaltfishPlayer$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.de
10323
10349
  __proto__: null,
10324
10350
  SaltfishPlayer
10325
10351
  }, Symbol.toStringTag, { value: "Module" }));
10326
- const version = "0.2.53";
10352
+ const version = "0.2.55";
10327
10353
  const packageJson = {
10328
10354
  version
10329
10355
  };