@wireai/activation 0.10.0 → 0.11.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 (42) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +33 -4
  3. package/dist/analytics/index.d.mts +21 -3
  4. package/dist/analytics/index.d.ts +21 -3
  5. package/dist/analytics/index.js +94 -61
  6. package/dist/analytics/index.js.map +1 -1
  7. package/dist/analytics/index.mjs +91 -62
  8. package/dist/analytics/index.mjs.map +1 -1
  9. package/dist/{currentSession-DdDkprpM.d.mts → currentSession-C0_odnIW.d.mts} +101 -1
  10. package/dist/{currentSession-D0Vq7_VE.d.ts → currentSession-DdnUq2HQ.d.ts} +101 -1
  11. package/dist/index.d.mts +3 -49
  12. package/dist/index.d.ts +3 -49
  13. package/dist/index.js +50 -41
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +47 -42
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/questionnaire/index.js +10 -2
  18. package/dist/questionnaire/index.js.map +1 -1
  19. package/dist/questionnaire/index.mjs +10 -2
  20. package/dist/questionnaire/index.mjs.map +1 -1
  21. package/dist/reviews/index.d.mts +1 -1
  22. package/dist/reviews/index.d.ts +1 -1
  23. package/dist/reviews/index.js +24 -9
  24. package/dist/reviews/index.js.map +1 -1
  25. package/dist/reviews/index.mjs +24 -9
  26. package/dist/reviews/index.mjs.map +1 -1
  27. package/dist/{transport-Bzb-bcB2.d.mts → transport-BGW9uXZJ.d.mts} +0 -15
  28. package/dist/{transport-B31G0Cib.d.ts → transport-jUJd5kxu.d.ts} +0 -15
  29. package/llms.txt +8 -0
  30. package/package.json +1 -1
  31. package/src/analytics/analyticsFacade.ts +72 -9
  32. package/src/analytics/eventQueue.ts +12 -11
  33. package/src/analytics/index.ts +9 -0
  34. package/src/analytics/reportClientEvent.ts +12 -2
  35. package/src/context/userContext.ts +55 -0
  36. package/src/identity/userIdentity.ts +10 -0
  37. package/src/index.ts +5 -1
  38. package/src/questionnaire/transport.ts +5 -1
  39. package/src/reviews/decision.ts +8 -1
  40. package/src/reviews/transport.ts +6 -8
  41. package/src/session-analytics/lifecycle.ts +6 -11
  42. package/src/session-analytics/useLifecycleEvents.ts +41 -27
@@ -498,7 +498,14 @@ var resolveRules = (config) => {
498
498
  var _a, _b, _c, _d, _e;
499
499
  return {
500
500
  enabled: (_a = config.enabled) != null ? _a : true,
501
- minSessions: (_b = config.minSessions) != null ? _b : 0,
501
+ // FAIL-CLOSED on the first session (behavior change, 0.11.0). An unconfigured host with no
502
+ // server decision must NOT prompt on the very first mount: `minSessions` defaults to 2 so the
503
+ // gate needs at least a second session before the LOCAL rules can fire. This is the client-side
504
+ // floor only — a server `decision` (from `fetchReviewDecision`) still OVERRIDES everything, and a
505
+ // host that genuinely wants first-session prompting can set `minSessions: 1` (or `0`) explicitly.
506
+ // Mirrors the 2026-07-16 incident: a first-session user, no server decision, got the prompt and
507
+ // left 1 star. See `evaluateGate` (`min_sessions` reason) and the CHANGELOG.
508
+ minSessions: (_b = config.minSessions) != null ? _b : 2,
502
509
  minEvents: (_c = config.minEvents) != null ? _c : 0,
503
510
  cooldownDays: (_d = config.cooldownDays) != null ? _d : 0,
504
511
  oncePerVersion: (_e = config.oncePerVersion) != null ? _e : true
@@ -722,6 +729,19 @@ var requestStoreReview = async (store) => {
722
729
  return opened ? "store_url" : "none";
723
730
  };
724
731
 
732
+ // src/analytics/reportClientEvent.ts
733
+ var buildEventsRequest = (target, events) => {
734
+ if (!(target == null ? void 0 : target.serverUrl) || events.length === 0) return null;
735
+ try {
736
+ const url = `${target.serverUrl.replace(/\/$/, "")}/v1/events`;
737
+ const headers = { "Content-Type": "application/json" };
738
+ if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;
739
+ return { url, init: { method: "POST", headers, body: JSON.stringify({ events }) } };
740
+ } catch {
741
+ return null;
742
+ }
743
+ };
744
+
725
745
  // src/reviews/transport.ts
726
746
  var submitReview = (target, review) => {
727
747
  if (!(target == null ? void 0 : target.serverUrl)) return;
@@ -761,9 +781,6 @@ var fetchReviewDecision = async (target, options = {}) => {
761
781
  var reportAppEvent = (target, name, options = {}) => {
762
782
  if (!(target == null ? void 0 : target.serverUrl) || !name) return;
763
783
  try {
764
- const url = `${target.serverUrl.replace(/\/$/, "")}/v1/events`;
765
- const headers = { "Content-Type": "application/json" };
766
- if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;
767
784
  const event = {
768
785
  event_type: "app_event",
769
786
  question_key: name
@@ -773,11 +790,9 @@ var reportAppEvent = (target, name, options = {}) => {
773
790
  if (options.meta && Object.keys(options.meta).length > 0) {
774
791
  event.meta = JSON.stringify(options.meta);
775
792
  }
776
- void fetch(url, {
777
- method: "POST",
778
- headers,
779
- body: JSON.stringify({ events: [event] })
780
- }).catch(() => {
793
+ const req = buildEventsRequest(target, [event]);
794
+ if (!req) return;
795
+ void fetch(req.url, req.init).catch(() => {
781
796
  });
782
797
  } catch {
783
798
  }