@wireai/activation 0.14.3 → 0.15.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.
Files changed (59) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +73 -0
  3. package/README.md +11 -7
  4. package/dist/analytics/index.d.mts +5 -5
  5. package/dist/analytics/index.d.ts +5 -5
  6. package/dist/analytics/index.js.map +1 -1
  7. package/dist/analytics/index.mjs.map +1 -1
  8. package/dist/coachmarks/index.d.mts +1 -1
  9. package/dist/coachmarks/index.d.ts +1 -1
  10. package/dist/coachmarks/index.js +47 -2
  11. package/dist/coachmarks/index.js.map +1 -1
  12. package/dist/coachmarks/index.mjs +47 -2
  13. package/dist/coachmarks/index.mjs.map +1 -1
  14. package/dist/{currentSession-CW_5Mq4O.d.ts → currentSession-CFSRZ2wg.d.ts} +10 -4
  15. package/dist/{currentSession-CUvTOchb.d.mts → currentSession-orZy5p1e.d.mts} +10 -4
  16. package/dist/{decision-Bgo17oH7.d.mts → decision-3vWLuBlO.d.ts} +11 -2
  17. package/dist/{decision-Bkh_LigV.d.ts → decision-yBj2AyPW.d.mts} +11 -2
  18. package/dist/index.d.mts +2 -2
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/questionnaire/index.d.mts +3 -3
  23. package/dist/questionnaire/index.d.ts +3 -3
  24. package/dist/questionnaire/index.js +48 -3
  25. package/dist/questionnaire/index.js.map +1 -1
  26. package/dist/questionnaire/index.mjs +48 -3
  27. package/dist/questionnaire/index.mjs.map +1 -1
  28. package/dist/reviews/index.d.mts +10 -6
  29. package/dist/reviews/index.d.ts +10 -6
  30. package/dist/reviews/index.js +167 -18
  31. package/dist/reviews/index.js.map +1 -1
  32. package/dist/reviews/index.mjs +167 -18
  33. package/dist/reviews/index.mjs.map +1 -1
  34. package/dist/showcase/index.d.mts +1 -1
  35. package/dist/showcase/index.d.ts +1 -1
  36. package/dist/showcase/index.js +47 -2
  37. package/dist/showcase/index.js.map +1 -1
  38. package/dist/showcase/index.mjs +47 -2
  39. package/dist/showcase/index.mjs.map +1 -1
  40. package/dist/{transport-j5gFfJhK.d.mts → transport-s5QxA-ci.d.mts} +18 -13
  41. package/dist/{transport-B_0SgCBe.d.ts → transport-xqqSFqxs.d.ts} +18 -13
  42. package/dist/{types-Cju-1_jT.d.mts → types-Byx306Kv.d.mts} +25 -10
  43. package/dist/{types-BcmagF6K.d.mts → types-D_0B0yay.d.mts} +7 -2
  44. package/dist/{types-BcmagF6K.d.ts → types-D_0B0yay.d.ts} +7 -2
  45. package/dist/{types-h2BZvl1t.d.ts → types-tdATL5z0.d.ts} +25 -10
  46. package/package.json +1 -1
  47. package/src/WireOnboarding.tsx +4 -1
  48. package/src/coachmarks/runtime.ts +103 -2
  49. package/src/coachmarks/types.ts +7 -2
  50. package/src/context/deviceId.ts +32 -0
  51. package/src/reviews/ReviewGate.tsx +86 -37
  52. package/src/reviews/decision.ts +11 -1
  53. package/src/reviews/idempotency.ts +71 -0
  54. package/src/reviews/index.ts +4 -2
  55. package/src/reviews/runtime.ts +5 -3
  56. package/src/reviews/transport.ts +17 -12
  57. package/src/reviews/types.ts +7 -0
  58. package/src/types.ts +10 -4
  59. package/src/utils/submitResult.ts +17 -9
@@ -213,9 +213,54 @@ var isCoachmarkTesting = () => coachmarkRuntime().testing;
213
213
  var coachmarkGateKey = (tourId) => `wire_coachmark_${tourId}_seen`;
214
214
  var showcaseGateKey = (showcaseId) => `wire_showcase_${showcaseId}_seen`;
215
215
  var SEEN_VALUE = "1";
216
+ var GATE_PROBE_KEY = "wire_gate_probe";
217
+ var ASYNC_GATE_STORAGE_WARNED_SLOT = /* @__PURE__ */ Symbol.for(
218
+ "@wireai/activation:asyncGateStorageWarned"
219
+ );
220
+ var asyncGateWarnGlobal = globalThis;
221
+ var closedGateStorage = Object.freeze({
222
+ getItem: () => SEEN_VALUE,
223
+ setItem: () => {
224
+ }
225
+ });
226
+ var syncGateAdapters = /* @__PURE__ */ new WeakSet();
227
+ var asyncGateAdapters = /* @__PURE__ */ new WeakSet();
228
+ var warnAsyncGateStorage = () => {
229
+ if (asyncGateWarnGlobal[ASYNC_GATE_STORAGE_WARNED_SLOT]) return;
230
+ if (typeof __DEV__ === "undefined" || !__DEV__) return;
231
+ if (typeof console === "undefined" || !console.warn) return;
232
+ asyncGateWarnGlobal[ASYNC_GATE_STORAGE_WARNED_SLOT] = true;
233
+ console.warn(
234
+ "[wireai] the gate storage's getItem returned a Promise \u2014 an async adapter (e.g. AsyncStorage) cannot drive the once-per-user gates, so coachmark tours, showcases and the review/questionnaire gates are all DISABLED (fail closed: nothing shows, nothing fires) until a synchronous adapter is provided. Pass a sync adapter (e.g. MMKV: `{ getItem: (k) => mmkv.getString(k) ?? null, setItem: (k, v) => mmkv.set(k, v) }`) to CoachmarkProvider or the gate's `storage` prop."
235
+ );
236
+ };
237
+ var validateGateStorage = (storage) => {
238
+ if (!storage) return null;
239
+ if (syncGateAdapters.has(storage)) return storage;
240
+ if (asyncGateAdapters.has(storage)) return closedGateStorage;
241
+ let probed;
242
+ try {
243
+ probed = storage.getItem(GATE_PROBE_KEY);
244
+ } catch {
245
+ syncGateAdapters.add(storage);
246
+ return storage;
247
+ }
248
+ if (probed != null && typeof probed.then === "function") {
249
+ asyncGateAdapters.add(storage);
250
+ try {
251
+ probed.then(void 0, () => {
252
+ });
253
+ } catch {
254
+ }
255
+ warnAsyncGateStorage();
256
+ return closedGateStorage;
257
+ }
258
+ syncGateAdapters.add(storage);
259
+ return storage;
260
+ };
216
261
  var hasSeenGate = (key, storageOverride, testingOverride) => {
217
262
  if (testingOverride != null ? testingOverride : isCoachmarkTesting()) return false;
218
- const storage = storageOverride != null ? storageOverride : getCoachmarkStorage();
263
+ const storage = validateGateStorage(storageOverride != null ? storageOverride : getCoachmarkStorage());
219
264
  if (!storage) return false;
220
265
  try {
221
266
  return storage.getItem(key) === SEEN_VALUE;
@@ -225,7 +270,7 @@ var hasSeenGate = (key, storageOverride, testingOverride) => {
225
270
  };
226
271
  var markSeenGate = (key, storageOverride, testingOverride) => {
227
272
  if (testingOverride != null ? testingOverride : isCoachmarkTesting()) return;
228
- const storage = storageOverride != null ? storageOverride : getCoachmarkStorage();
273
+ const storage = validateGateStorage(storageOverride != null ? storageOverride : getCoachmarkStorage());
229
274
  if (!storage) return;
230
275
  try {
231
276
  storage.setItem(key, SEEN_VALUE);