@mushi-mushi/core 1.18.0 → 1.19.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.d.cts CHANGED
@@ -102,6 +102,20 @@ interface MushiWidgetConfig {
102
102
  brandFooter?: boolean;
103
103
  /** How the widget should surface SDK freshness warnings. Defaults to auto. */
104
104
  outdatedBanner?: 'auto' | 'banner' | 'console-only' | 'off';
105
+ /**
106
+ * Privacy nudge shown beside an attached screenshot preview, reminding the
107
+ * reporter to remove anything sensitive (balances, PII, tokens) before they
108
+ * submit. The widget always renders the captured image as a visible preview
109
+ * so the user can see exactly what will be sent and remove it if needed; this
110
+ * flag only controls the accompanying caption.
111
+ * - `true` (default) — show the localized default caption.
112
+ * - string — show this custom caption verbatim.
113
+ * - `false` — hide the caption (the preview + remove control still show).
114
+ *
115
+ * Settable per-host via the SDK config and remotely via the Mushi console
116
+ * runtime config (it travels in the `widget` block of `GET /v1/sdk/config`).
117
+ */
118
+ screenshotSensitiveHint?: boolean | string;
105
119
  /**
106
120
  * Beta mode: injects discreet "early access" messaging into the widget panel.
107
121
  * Shows a beta strip on the category step and a contact footer on the success
package/dist/index.d.ts CHANGED
@@ -102,6 +102,20 @@ interface MushiWidgetConfig {
102
102
  brandFooter?: boolean;
103
103
  /** How the widget should surface SDK freshness warnings. Defaults to auto. */
104
104
  outdatedBanner?: 'auto' | 'banner' | 'console-only' | 'off';
105
+ /**
106
+ * Privacy nudge shown beside an attached screenshot preview, reminding the
107
+ * reporter to remove anything sensitive (balances, PII, tokens) before they
108
+ * submit. The widget always renders the captured image as a visible preview
109
+ * so the user can see exactly what will be sent and remove it if needed; this
110
+ * flag only controls the accompanying caption.
111
+ * - `true` (default) — show the localized default caption.
112
+ * - string — show this custom caption verbatim.
113
+ * - `false` — hide the caption (the preview + remove control still show).
114
+ *
115
+ * Settable per-host via the SDK config and remotely via the Mushi console
116
+ * runtime config (it travels in the `widget` block of `GET /v1/sdk/config`).
117
+ */
118
+ screenshotSensitiveHint?: boolean | string;
105
119
  /**
106
120
  * Beta mode: injects discreet "early access" messaging into the widget panel.
107
121
  * Shows a beta strip on the category step and a contact footer on the success
package/dist/index.js CHANGED
@@ -998,6 +998,30 @@ function createOfflineQueue(config = {}) {
998
998
  lsWrite(rows);
999
999
  }
1000
1000
  }
1001
+ async function removeRow(backend, rowId) {
1002
+ try {
1003
+ if (backend === "indexeddb") await idbDelete(rowId);
1004
+ else lsDelete(rowId);
1005
+ } catch (err) {
1006
+ queueLog.debug("Offline queue: row removal failed (will age out)", {
1007
+ id: rowId,
1008
+ err: String(err)
1009
+ });
1010
+ }
1011
+ }
1012
+ async function persistRow(backend, row) {
1013
+ try {
1014
+ if (backend === "indexeddb") await idbPutRow(row);
1015
+ else lsUpdateRow(row);
1016
+ return true;
1017
+ } catch (err) {
1018
+ queueLog.debug("Offline queue: row persist failed", {
1019
+ id: row.id,
1020
+ err: String(err)
1021
+ });
1022
+ return false;
1023
+ }
1024
+ }
1001
1025
  async function enqueue(report) {
1002
1026
  if (!enabled) return;
1003
1027
  const currentSize = await size();
@@ -1043,12 +1067,7 @@ function createOfflineQueue(config = {}) {
1043
1067
  for (const row of rows) {
1044
1068
  if (isExpired(row, now)) {
1045
1069
  const rowId = row.id;
1046
- try {
1047
- if (backend === "indexeddb") await idbDelete(rowId);
1048
- else lsDelete(rowId);
1049
- } catch {
1050
- lsDelete(rowId);
1051
- }
1070
+ await removeRow(backend, rowId);
1052
1071
  queueLog.debug("Offline queue: evicting stale report", { id: rowId });
1053
1072
  } else {
1054
1073
  fresh.push(row);
@@ -1063,23 +1082,13 @@ function createOfflineQueue(config = {}) {
1063
1082
  const rowId = row.id;
1064
1083
  const report = await unwrapForSend(row);
1065
1084
  if (!report) {
1066
- try {
1067
- if (backend === "indexeddb") await idbDelete(rowId);
1068
- else lsDelete(rowId);
1069
- } catch {
1070
- lsDelete(rowId);
1071
- }
1085
+ await removeRow(backend, rowId);
1072
1086
  failed++;
1073
1087
  continue;
1074
1088
  }
1075
1089
  const result = await client.submitReport(report);
1076
1090
  if (result.ok) {
1077
- try {
1078
- if (backend === "indexeddb") await idbDelete(rowId);
1079
- else lsDelete(rowId);
1080
- } catch {
1081
- lsDelete(rowId);
1082
- }
1091
+ await removeRow(backend, rowId);
1083
1092
  sent++;
1084
1093
  } else {
1085
1094
  const permanent = result.error?.code === "HTTP_400" || result.error?.code === "HTTP_413" || result.error?.code === "HTTP_422" || result.error?.code === "INGEST_ERROR" || result.error?.code === "VALIDATION_ERROR" || // A payload that exceeds the size guard will never shrink on its own;
@@ -1091,21 +1100,11 @@ function createOfflineQueue(config = {}) {
1091
1100
  );
1092
1101
  const transient = !permanent && (result.error?.code === "NETWORK_ERROR" || result.error?.code === "HTTP_403" || result.error?.code === "HTTP_429" || result.error?.code === "HTTP_502" || result.error?.code === "HTTP_503" || result.error?.code === "HTTP_504" || typeof result.error?.code === "string" && result.error.code.startsWith("HTTP_5"));
1093
1102
  if (permanent) {
1094
- try {
1095
- if (backend === "indexeddb") await idbDelete(rowId);
1096
- else lsDelete(rowId);
1097
- } catch {
1098
- lsDelete(rowId);
1099
- }
1103
+ await removeRow(backend, rowId);
1100
1104
  } else if (transient) {
1101
1105
  const nextAttempts = rowAttempts(row) + 1;
1102
1106
  if (nextAttempts >= MAX_DELIVERY_ATTEMPTS) {
1103
- try {
1104
- if (backend === "indexeddb") await idbDelete(rowId);
1105
- else lsDelete(rowId);
1106
- } catch {
1107
- lsDelete(rowId);
1108
- }
1107
+ await removeRow(backend, rowId);
1109
1108
  queueLog.warn("Offline queue: giving up on report after repeated failures", {
1110
1109
  id: rowId,
1111
1110
  attempts: nextAttempts,
@@ -1113,17 +1112,20 @@ function createOfflineQueue(config = {}) {
1113
1112
  });
1114
1113
  } else {
1115
1114
  row.attempts = nextAttempts;
1116
- try {
1117
- if (backend === "indexeddb") await idbPutRow(row);
1118
- else lsUpdateRow(row);
1119
- } catch {
1120
- lsUpdateRow(row);
1115
+ const persisted = await persistRow(backend, row);
1116
+ if (persisted) {
1117
+ queueLog.debug("Offline queue: transient failure, will retry", {
1118
+ id: rowId,
1119
+ attempts: nextAttempts,
1120
+ code: result.error?.code
1121
+ });
1122
+ } else {
1123
+ await removeRow(backend, rowId);
1124
+ queueLog.warn("Offline queue: dropping report (attempt counter unpersistable)", {
1125
+ id: rowId,
1126
+ code: result.error?.code
1127
+ });
1121
1128
  }
1122
- queueLog.debug("Offline queue: transient failure, will retry", {
1123
- id: rowId,
1124
- attempts: nextAttempts,
1125
- code: result.error?.code
1126
- });
1127
1129
  }
1128
1130
  }
1129
1131
  failed++;