@wireai/activation 0.13.2 → 0.13.5

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 (82) hide show
  1. package/AGENTS.md +6 -3
  2. package/CHANGELOG.md +291 -4
  3. package/INTEGRATION_PROMPT.md +7 -1
  4. package/README.md +68 -2
  5. package/dist/analytics/index.d.mts +86 -6
  6. package/dist/analytics/index.d.ts +86 -6
  7. package/dist/analytics/index.js +271 -472
  8. package/dist/analytics/index.js.map +1 -1
  9. package/dist/analytics/index.mjs +269 -471
  10. package/dist/analytics/index.mjs.map +1 -1
  11. package/dist/coachmarks/index.d.mts +15 -2
  12. package/dist/coachmarks/index.d.ts +15 -2
  13. package/dist/coachmarks/index.js +58 -14
  14. package/dist/coachmarks/index.js.map +1 -1
  15. package/dist/coachmarks/index.mjs +58 -14
  16. package/dist/coachmarks/index.mjs.map +1 -1
  17. package/dist/{currentSession-ClkLjcJ0.d.mts → currentSession-DgJf0fRz.d.mts} +4 -4
  18. package/dist/{currentSession-DOVZEWJl.d.ts → currentSession-EOHU64QD.d.ts} +4 -4
  19. package/dist/{decision-Bl_M2y3r.d.mts → decision-Bgo17oH7.d.mts} +1 -1
  20. package/dist/{decision-Cau5KmP6.d.ts → decision-Bkh_LigV.d.ts} +1 -1
  21. package/dist/index.d.mts +27 -4
  22. package/dist/index.d.ts +27 -4
  23. package/dist/index.js +224 -575
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.mjs +221 -572
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/questionnaire/index.d.mts +43 -11
  28. package/dist/questionnaire/index.d.ts +43 -11
  29. package/dist/questionnaire/index.js +45 -13
  30. package/dist/questionnaire/index.js.map +1 -1
  31. package/dist/questionnaire/index.mjs +45 -13
  32. package/dist/questionnaire/index.mjs.map +1 -1
  33. package/dist/reviews/index.d.mts +5 -5
  34. package/dist/reviews/index.d.ts +5 -5
  35. package/dist/reviews/index.js +31 -9
  36. package/dist/reviews/index.js.map +1 -1
  37. package/dist/reviews/index.mjs +31 -9
  38. package/dist/reviews/index.mjs.map +1 -1
  39. package/dist/showcase/index.d.mts +1 -1
  40. package/dist/showcase/index.d.ts +1 -1
  41. package/dist/showcase/index.js +7 -2
  42. package/dist/showcase/index.js.map +1 -1
  43. package/dist/showcase/index.mjs +7 -2
  44. package/dist/showcase/index.mjs.map +1 -1
  45. package/dist/{transport-CF_eHwzC.d.mts → transport-B_0SgCBe.d.ts} +44 -5
  46. package/dist/{transport-DsRe4epC.d.ts → transport-j5gFfJhK.d.mts} +44 -5
  47. package/dist/{types-CKFhyrMu.d.mts → types-BpwiRpA8.d.mts} +1 -1
  48. package/dist/{types-CKFhyrMu.d.ts → types-BpwiRpA8.d.ts} +1 -1
  49. package/dist/{types-CNUqMK0D.d.mts → types-Cju-1_jT.d.mts} +42 -2
  50. package/dist/{types-Buj9Lw9t.d.ts → types-h2BZvl1t.d.ts} +42 -2
  51. package/llms.txt +1 -1
  52. package/package.json +6 -1
  53. package/src/OnboardingFlow.tsx +44 -15
  54. package/src/WireOnboarding.tsx +7 -6
  55. package/src/activation/revalidation.ts +9 -1
  56. package/src/activation/wireActivation.ts +3 -3
  57. package/src/analytics/analyticsFacade.ts +2 -2
  58. package/src/analytics/currentSession.ts +10 -0
  59. package/src/analytics/eventQueue.ts +88 -20
  60. package/src/analytics/index.ts +6 -0
  61. package/src/analytics/reportClientEvent.ts +29 -7
  62. package/src/analytics/wireDoctor.ts +330 -0
  63. package/src/cards/CardGridSelectCard.tsx +1 -1
  64. package/src/cards/ChipSelectCard.tsx +2 -2
  65. package/src/cards/SelectionCard.tsx +1 -1
  66. package/src/coachmarks/runtime.ts +72 -3
  67. package/src/coachmarks/useCoachmarkTour.ts +62 -14
  68. package/src/context/deviceId.ts +14 -5
  69. package/src/features/WireFeaturesProvider.tsx +12 -1
  70. package/src/identity/identityRecord.ts +9 -1
  71. package/src/identity/userIdentity.ts +1 -1
  72. package/src/questionnaire/QuestionnaireGate.tsx +90 -10
  73. package/src/questionnaire/index.ts +9 -1
  74. package/src/questionnaire/transport.ts +46 -11
  75. package/src/reviews/ReviewGate.tsx +61 -6
  76. package/src/reviews/index.ts +10 -1
  77. package/src/reviews/runtime.ts +11 -1
  78. package/src/reviews/transport.ts +58 -12
  79. package/src/session-analytics/useLifecycleEvents.ts +1 -1
  80. package/src/theme/ThemeContext.tsx +49 -1
  81. package/src/types.ts +1 -1
  82. package/src/utils/submitResult.ts +39 -0
@@ -54,7 +54,12 @@ var defaultOnboardingTheme = {
54
54
  var mergeTheme = (override) => {
55
55
  return defaultOnboardingTheme;
56
56
  };
57
- var OnboardingThemeContext = createContext(null);
57
+ var THEME_CONTEXT_SLOT = /* @__PURE__ */ Symbol.for("@wireai/activation:themeContext");
58
+ var themeGlobal = globalThis;
59
+ if (!themeGlobal[THEME_CONTEXT_SLOT]) {
60
+ themeGlobal[THEME_CONTEXT_SLOT] = createContext(null);
61
+ }
62
+ var OnboardingThemeContext = themeGlobal[THEME_CONTEXT_SLOT];
58
63
  var useOnboardingTheme = () => {
59
64
  const ctx = useContext(OnboardingThemeContext);
60
65
  return ctx != null ? ctx : mergeTheme();
@@ -741,13 +746,15 @@ var toWireEvents = (events) => events.map((event) => {
741
746
  return rest;
742
747
  }
743
748
  });
744
- var buildEventsRequest = (target, events) => {
749
+ var buildEventsRequest = (target, events, options) => {
745
750
  if (!(target == null ? void 0 : target.serverUrl) || events.length === 0) return null;
746
751
  try {
747
752
  const url = `${target.serverUrl.replace(/\/$/, "")}/v1/events`;
748
753
  const headers = { "Content-Type": "application/json" };
749
754
  if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;
750
- const body = JSON.stringify({ events: toWireEvents(events) });
755
+ const envelope = { events: toWireEvents(events) };
756
+ if ((options == null ? void 0 : options.dryRun) === true) ;
757
+ const body = JSON.stringify(envelope);
751
758
  return { url, init: { method: "POST", headers, body } };
752
759
  } catch {
753
760
  return null;
@@ -786,19 +793,21 @@ var ensureCurrentSessionId = () => {
786
793
  };
787
794
 
788
795
  // src/reviews/transport.ts
789
- var submitReview = (target, review) => {
790
- if (!(target == null ? void 0 : target.serverUrl)) return;
796
+ var submitReview = async (target, review) => {
797
+ if (!(target == null ? void 0 : target.serverUrl)) return "unsent";
791
798
  try {
792
799
  const url = `${target.serverUrl.replace(/\/$/, "")}/v1/reviews`;
793
800
  const headers = { "Content-Type": "application/json" };
794
801
  if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;
795
- void fetch(url, {
802
+ const res = await fetch(url, {
796
803
  method: "POST",
797
804
  headers,
798
805
  body: JSON.stringify(review)
799
- }).catch(() => {
800
806
  });
807
+ if (!res) return "unsent";
808
+ return res.ok ? "accepted" : "rejected";
801
809
  } catch {
810
+ return "unsent";
802
811
  }
803
812
  };
804
813
  var fetchReviewDecision = async (target, options = {}) => {
@@ -887,17 +896,30 @@ var _ReviewGate = ({
887
896
  onResolved == null ? void 0 : onResolved();
888
897
  }, [onResolved]);
889
898
  const postedRef = React7.useRef(false);
899
+ const unackedRef = React7.useRef(null);
890
900
  const postOnce = useCallback(
891
901
  (body) => {
892
902
  if (postedRef.current) return;
893
903
  postedRef.current = true;
894
- submitReview(target, body);
904
+ unackedRef.current = body;
905
+ void submitReview(target, body).then((result) => {
906
+ if (result === "unsent") {
907
+ postedRef.current = false;
908
+ return;
909
+ }
910
+ unackedRef.current = null;
911
+ });
895
912
  },
896
913
  [target]
897
914
  );
898
915
  const abandonRef = React7.useRef(() => {
899
916
  });
900
917
  abandonRef.current = () => {
918
+ const undelivered = unackedRef.current;
919
+ if (undelivered && !postedRef.current) {
920
+ postOnce(undelivered);
921
+ return;
922
+ }
901
923
  if (postedRef.current || stars < 1) return;
902
924
  postOnce(
903
925
  buildReviewSubmission({
@@ -1265,7 +1287,7 @@ var useWireFeatures = (config) => {
1265
1287
  return flags;
1266
1288
  };
1267
1289
  var CONTEXT_SYMBOL = /* @__PURE__ */ Symbol.for("wireai.features.context");
1268
- var globalObj = global;
1290
+ var globalObj = globalThis;
1269
1291
  if (!globalObj[CONTEXT_SYMBOL]) {
1270
1292
  globalObj[CONTEXT_SYMBOL] = createContext(null);
1271
1293
  }