@wireai/activation 0.13.2 → 0.13.3

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 (69) hide show
  1. package/AGENTS.md +4 -3
  2. package/CHANGELOG.md +228 -4
  3. package/README.md +16 -2
  4. package/dist/analytics/index.d.mts +4 -4
  5. package/dist/analytics/index.d.ts +4 -4
  6. package/dist/analytics/index.js +104 -470
  7. package/dist/analytics/index.js.map +1 -1
  8. package/dist/analytics/index.mjs +102 -468
  9. package/dist/analytics/index.mjs.map +1 -1
  10. package/dist/coachmarks/index.d.mts +14 -1
  11. package/dist/coachmarks/index.d.ts +14 -1
  12. package/dist/coachmarks/index.js +58 -14
  13. package/dist/coachmarks/index.js.map +1 -1
  14. package/dist/coachmarks/index.mjs +58 -14
  15. package/dist/coachmarks/index.mjs.map +1 -1
  16. package/dist/{currentSession-ClkLjcJ0.d.mts → currentSession-BoWtr3Jp.d.mts} +2 -2
  17. package/dist/{currentSession-DOVZEWJl.d.ts → currentSession-CCOMlaQ2.d.ts} +2 -2
  18. package/dist/{decision-Bl_M2y3r.d.mts → decision-Cjw0jbEj.d.mts} +1 -1
  19. package/dist/{decision-Cau5KmP6.d.ts → decision-GfpXAsk_.d.ts} +1 -1
  20. package/dist/index.d.mts +25 -2
  21. package/dist/index.d.ts +25 -2
  22. package/dist/index.js +220 -573
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +217 -570
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/questionnaire/index.d.mts +42 -10
  27. package/dist/questionnaire/index.d.ts +42 -10
  28. package/dist/questionnaire/index.js +45 -13
  29. package/dist/questionnaire/index.js.map +1 -1
  30. package/dist/questionnaire/index.mjs +45 -13
  31. package/dist/questionnaire/index.mjs.map +1 -1
  32. package/dist/reviews/index.d.mts +4 -4
  33. package/dist/reviews/index.d.ts +4 -4
  34. package/dist/reviews/index.js +27 -7
  35. package/dist/reviews/index.js.map +1 -1
  36. package/dist/reviews/index.mjs +27 -7
  37. package/dist/reviews/index.mjs.map +1 -1
  38. package/dist/showcase/index.js +7 -2
  39. package/dist/showcase/index.js.map +1 -1
  40. package/dist/showcase/index.mjs +7 -2
  41. package/dist/showcase/index.mjs.map +1 -1
  42. package/dist/{transport-DsRe4epC.d.ts → transport-CefdERPs.d.mts} +44 -5
  43. package/dist/{transport-CF_eHwzC.d.mts → transport-DFuPyCoJ.d.ts} +44 -5
  44. package/dist/{types-Buj9Lw9t.d.ts → types-UVYt9BJe.d.ts} +41 -1
  45. package/dist/{types-CNUqMK0D.d.mts → types-l2tfg23P.d.mts} +41 -1
  46. package/package.json +4 -1
  47. package/src/OnboardingFlow.tsx +44 -15
  48. package/src/WireOnboarding.tsx +7 -6
  49. package/src/activation/wireActivation.ts +3 -3
  50. package/src/analytics/analyticsFacade.ts +2 -2
  51. package/src/analytics/eventQueue.ts +83 -20
  52. package/src/cards/CardGridSelectCard.tsx +1 -1
  53. package/src/cards/ChipSelectCard.tsx +2 -2
  54. package/src/cards/SelectionCard.tsx +1 -1
  55. package/src/coachmarks/runtime.ts +62 -2
  56. package/src/coachmarks/useCoachmarkTour.ts +62 -14
  57. package/src/context/deviceId.ts +4 -4
  58. package/src/features/WireFeaturesProvider.tsx +4 -1
  59. package/src/identity/userIdentity.ts +1 -1
  60. package/src/questionnaire/QuestionnaireGate.tsx +90 -10
  61. package/src/questionnaire/index.ts +9 -1
  62. package/src/questionnaire/transport.ts +46 -11
  63. package/src/reviews/ReviewGate.tsx +61 -6
  64. package/src/reviews/index.ts +10 -1
  65. package/src/reviews/transport.ts +58 -12
  66. package/src/session-analytics/useLifecycleEvents.ts +1 -1
  67. package/src/theme/ThemeContext.tsx +42 -1
  68. package/src/types.ts +1 -1
  69. package/src/utils/submitResult.ts +39 -0
@@ -1,10 +1,10 @@
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-l2tfg23P.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-l2tfg23P.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-Cjw0jbEj.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-CefdERPs.mjs';
8
8
  import '../types-BcmagF6K.mjs';
9
9
  import '../types-CKFhyrMu.mjs';
10
10
 
@@ -1,10 +1,10 @@
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-UVYt9BJe.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-UVYt9BJe.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-GfpXAsk_.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-DFuPyCoJ.js';
8
8
  import '../types-BcmagF6K.js';
9
9
  import '../types-CKFhyrMu.js';
10
10
 
@@ -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();
@@ -792,19 +797,21 @@ var ensureCurrentSessionId = () => {
792
797
  };
793
798
 
794
799
  // src/reviews/transport.ts
795
- var submitReview = (target, review) => {
796
- if (!(target == null ? void 0 : target.serverUrl)) return;
800
+ var submitReview = async (target, review) => {
801
+ if (!(target == null ? void 0 : target.serverUrl)) return "unsent";
797
802
  try {
798
803
  const url = `${target.serverUrl.replace(/\/$/, "")}/v1/reviews`;
799
804
  const headers = { "Content-Type": "application/json" };
800
805
  if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;
801
- void fetch(url, {
806
+ const res = await fetch(url, {
802
807
  method: "POST",
803
808
  headers,
804
809
  body: JSON.stringify(review)
805
- }).catch(() => {
806
810
  });
811
+ if (!res) return "unsent";
812
+ return res.ok ? "accepted" : "rejected";
807
813
  } catch {
814
+ return "unsent";
808
815
  }
809
816
  };
810
817
  var fetchReviewDecision = async (target, options = {}) => {
@@ -893,17 +900,30 @@ var _ReviewGate = ({
893
900
  onResolved == null ? void 0 : onResolved();
894
901
  }, [onResolved]);
895
902
  const postedRef = React7__default.default.useRef(false);
903
+ const unackedRef = React7__default.default.useRef(null);
896
904
  const postOnce = React7.useCallback(
897
905
  (body) => {
898
906
  if (postedRef.current) return;
899
907
  postedRef.current = true;
900
- submitReview(target, body);
908
+ unackedRef.current = body;
909
+ void submitReview(target, body).then((result) => {
910
+ if (result === "unsent") {
911
+ postedRef.current = false;
912
+ return;
913
+ }
914
+ unackedRef.current = null;
915
+ });
901
916
  },
902
917
  [target]
903
918
  );
904
919
  const abandonRef = React7__default.default.useRef(() => {
905
920
  });
906
921
  abandonRef.current = () => {
922
+ const undelivered = unackedRef.current;
923
+ if (undelivered && !postedRef.current) {
924
+ postOnce(undelivered);
925
+ return;
926
+ }
907
927
  if (postedRef.current || stars < 1) return;
908
928
  postOnce(
909
929
  buildReviewSubmission({
@@ -1271,7 +1291,7 @@ var useWireFeatures = (config) => {
1271
1291
  return flags;
1272
1292
  };
1273
1293
  var CONTEXT_SYMBOL = /* @__PURE__ */ Symbol.for("wireai.features.context");
1274
- var globalObj = global;
1294
+ var globalObj = globalThis;
1275
1295
  if (!globalObj[CONTEXT_SYMBOL]) {
1276
1296
  globalObj[CONTEXT_SYMBOL] = React7.createContext(null);
1277
1297
  }