@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
@@ -1,12 +1,12 @@
1
1
  import React__default from 'react';
2
- import { R as ReviewGateProps, a as ReviewPresentation, U as UseReviewGateOptions, b as ReviewGateController, c as ReviewDecision, d as ReviewStoreConfig } from '../types-CNUqMK0D.mjs';
3
- export { e as RatingRoute, f as ReviewConfig, g as ReviewDecisionResponse, h as ReviewGateEvent, i as ReviewGateEventName, j as ReviewSubmission, k as ReviewTarget } from '../types-CNUqMK0D.mjs';
2
+ import { R as ReviewGateProps, a as ReviewPresentation, U as UseReviewGateOptions, b as ReviewGateController, c as ReviewDecision, d as ReviewStoreConfig } from '../types-Cju-1_jT.mjs';
3
+ export { e as RatingRoute, f as ReviewConfig, g as ReviewDecisionResponse, h as ReviewGateEvent, i as ReviewGateEventName, j as ReviewSubmission, k as ReviewTarget, S as SubmitResult } from '../types-Cju-1_jT.mjs';
4
4
  export { C as ReviewModal, a as ReviewModalHandle, b as ReviewModalProps } from '../CenteredModal-C3qQBHsA.mjs';
5
- export { G as GateRules, a as GateSignals, b as buildReviewSubmission, d as decideReview, e as evaluateGate, r as resolveRules, c as routeRating } from '../decision-Bl_M2y3r.mjs';
5
+ export { G as GateRules, a as GateSignals, b as buildReviewSubmission, d as decideReview, e as evaluateGate, r as resolveRules, c as routeRating } from '../decision-Bgo17oH7.mjs';
6
6
  import { c as OnboardingFonts } from '../types-BKfpdZzX.mjs';
7
- export { F as FetchReviewDecisionOptions, R as ReportAppEventOptions, f as fetchReviewDecision, r as reportAppEvent, s as submitReview } from '../transport-CF_eHwzC.mjs';
7
+ export { F as FetchReviewDecisionOptions, R as ReportAppEventOptions, a as ReviewSubmitResult, f as fetchReviewDecision, r as reportAppEvent, s as submitReview } from '../transport-j5gFfJhK.mjs';
8
8
  import '../types-BcmagF6K.mjs';
9
- import '../types-CKFhyrMu.mjs';
9
+ import '../types-BpwiRpA8.mjs';
10
10
 
11
11
  /**
12
12
  * Runtime helpers for the review gate: the `wire_review_*` gate keys and small
@@ -1,12 +1,12 @@
1
1
  import React__default from 'react';
2
- import { R as ReviewGateProps, a as ReviewPresentation, U as UseReviewGateOptions, b as ReviewGateController, c as ReviewDecision, d as ReviewStoreConfig } from '../types-Buj9Lw9t.js';
3
- export { e as RatingRoute, f as ReviewConfig, g as ReviewDecisionResponse, h as ReviewGateEvent, i as ReviewGateEventName, j as ReviewSubmission, k as ReviewTarget } from '../types-Buj9Lw9t.js';
2
+ import { R as ReviewGateProps, a as ReviewPresentation, U as UseReviewGateOptions, b as ReviewGateController, c as ReviewDecision, d as ReviewStoreConfig } from '../types-h2BZvl1t.js';
3
+ export { e as RatingRoute, f as ReviewConfig, g as ReviewDecisionResponse, h as ReviewGateEvent, i as ReviewGateEventName, j as ReviewSubmission, k as ReviewTarget, S as SubmitResult } from '../types-h2BZvl1t.js';
4
4
  export { C as ReviewModal, a as ReviewModalHandle, b as ReviewModalProps } from '../CenteredModal-Cdgns6--.js';
5
- export { G as GateRules, a as GateSignals, b as buildReviewSubmission, d as decideReview, e as evaluateGate, r as resolveRules, c as routeRating } from '../decision-Cau5KmP6.js';
5
+ export { G as GateRules, a as GateSignals, b as buildReviewSubmission, d as decideReview, e as evaluateGate, r as resolveRules, c as routeRating } from '../decision-Bkh_LigV.js';
6
6
  import { c as OnboardingFonts } from '../types-BKfpdZzX.js';
7
- export { F as FetchReviewDecisionOptions, R as ReportAppEventOptions, f as fetchReviewDecision, r as reportAppEvent, s as submitReview } from '../transport-DsRe4epC.js';
7
+ export { F as FetchReviewDecisionOptions, R as ReportAppEventOptions, a as ReviewSubmitResult, f as fetchReviewDecision, r as reportAppEvent, s as submitReview } from '../transport-B_0SgCBe.js';
8
8
  import '../types-BcmagF6K.js';
9
- import '../types-CKFhyrMu.js';
9
+ import '../types-BpwiRpA8.js';
10
10
 
11
11
  /**
12
12
  * Runtime helpers for the review gate: the `wire_review_*` gate keys and small
@@ -60,7 +60,12 @@ var defaultOnboardingTheme = {
60
60
  var mergeTheme = (override) => {
61
61
  return defaultOnboardingTheme;
62
62
  };
63
- var OnboardingThemeContext = React7.createContext(null);
63
+ var THEME_CONTEXT_SLOT = /* @__PURE__ */ Symbol.for("@wireai/activation:themeContext");
64
+ var themeGlobal = globalThis;
65
+ if (!themeGlobal[THEME_CONTEXT_SLOT]) {
66
+ themeGlobal[THEME_CONTEXT_SLOT] = React7.createContext(null);
67
+ }
68
+ var OnboardingThemeContext = themeGlobal[THEME_CONTEXT_SLOT];
64
69
  var useOnboardingTheme = () => {
65
70
  const ctx = React7.useContext(OnboardingThemeContext);
66
71
  return ctx != null ? ctx : mergeTheme();
@@ -747,13 +752,15 @@ var toWireEvents = (events) => events.map((event) => {
747
752
  return rest;
748
753
  }
749
754
  });
750
- var buildEventsRequest = (target, events) => {
755
+ var buildEventsRequest = (target, events, options) => {
751
756
  if (!(target == null ? void 0 : target.serverUrl) || events.length === 0) return null;
752
757
  try {
753
758
  const url = `${target.serverUrl.replace(/\/$/, "")}/v1/events`;
754
759
  const headers = { "Content-Type": "application/json" };
755
760
  if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;
756
- const body = JSON.stringify({ events: toWireEvents(events) });
761
+ const envelope = { events: toWireEvents(events) };
762
+ if ((options == null ? void 0 : options.dryRun) === true) ;
763
+ const body = JSON.stringify(envelope);
757
764
  return { url, init: { method: "POST", headers, body } };
758
765
  } catch {
759
766
  return null;
@@ -792,19 +799,21 @@ var ensureCurrentSessionId = () => {
792
799
  };
793
800
 
794
801
  // src/reviews/transport.ts
795
- var submitReview = (target, review) => {
796
- if (!(target == null ? void 0 : target.serverUrl)) return;
802
+ var submitReview = async (target, review) => {
803
+ if (!(target == null ? void 0 : target.serverUrl)) return "unsent";
797
804
  try {
798
805
  const url = `${target.serverUrl.replace(/\/$/, "")}/v1/reviews`;
799
806
  const headers = { "Content-Type": "application/json" };
800
807
  if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;
801
- void fetch(url, {
808
+ const res = await fetch(url, {
802
809
  method: "POST",
803
810
  headers,
804
811
  body: JSON.stringify(review)
805
- }).catch(() => {
806
812
  });
813
+ if (!res) return "unsent";
814
+ return res.ok ? "accepted" : "rejected";
807
815
  } catch {
816
+ return "unsent";
808
817
  }
809
818
  };
810
819
  var fetchReviewDecision = async (target, options = {}) => {
@@ -893,17 +902,30 @@ var _ReviewGate = ({
893
902
  onResolved == null ? void 0 : onResolved();
894
903
  }, [onResolved]);
895
904
  const postedRef = React7__default.default.useRef(false);
905
+ const unackedRef = React7__default.default.useRef(null);
896
906
  const postOnce = React7.useCallback(
897
907
  (body) => {
898
908
  if (postedRef.current) return;
899
909
  postedRef.current = true;
900
- submitReview(target, body);
910
+ unackedRef.current = body;
911
+ void submitReview(target, body).then((result) => {
912
+ if (result === "unsent") {
913
+ postedRef.current = false;
914
+ return;
915
+ }
916
+ unackedRef.current = null;
917
+ });
901
918
  },
902
919
  [target]
903
920
  );
904
921
  const abandonRef = React7__default.default.useRef(() => {
905
922
  });
906
923
  abandonRef.current = () => {
924
+ const undelivered = unackedRef.current;
925
+ if (undelivered && !postedRef.current) {
926
+ postOnce(undelivered);
927
+ return;
928
+ }
907
929
  if (postedRef.current || stars < 1) return;
908
930
  postOnce(
909
931
  buildReviewSubmission({
@@ -1271,7 +1293,7 @@ var useWireFeatures = (config) => {
1271
1293
  return flags;
1272
1294
  };
1273
1295
  var CONTEXT_SYMBOL = /* @__PURE__ */ Symbol.for("wireai.features.context");
1274
- var globalObj = global;
1296
+ var globalObj = globalThis;
1275
1297
  if (!globalObj[CONTEXT_SYMBOL]) {
1276
1298
  globalObj[CONTEXT_SYMBOL] = React7.createContext(null);
1277
1299
  }