@wireai/activation 0.11.0 → 0.12.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.
- package/AGENTS.md +51 -0
- package/CHANGELOG.md +58 -3
- package/INTEGRATION_PROMPT.md +13 -1
- package/README.md +73 -0
- package/dist/analytics/index.d.mts +17 -6
- package/dist/analytics/index.d.ts +17 -6
- package/dist/analytics/index.js +130 -35
- package/dist/analytics/index.js.map +1 -1
- package/dist/analytics/index.mjs +126 -36
- package/dist/analytics/index.mjs.map +1 -1
- package/dist/{currentSession-DdnUq2HQ.d.ts → currentSession-D6RiVtc8.d.ts} +88 -30
- package/dist/{currentSession-C0_odnIW.d.mts → currentSession-DsSDHqor.d.mts} +88 -30
- package/dist/index.d.mts +236 -36
- package/dist/index.d.ts +236 -36
- package/dist/index.js +281 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +269 -21
- package/dist/index.mjs.map +1 -1
- package/dist/questionnaire/index.d.mts +1 -1
- package/dist/questionnaire/index.d.ts +1 -1
- package/dist/questionnaire/index.js +49 -6
- package/dist/questionnaire/index.js.map +1 -1
- package/dist/questionnaire/index.mjs +49 -6
- package/dist/questionnaire/index.mjs.map +1 -1
- package/dist/reviews/index.d.mts +2 -2
- package/dist/reviews/index.d.ts +2 -2
- package/dist/reviews/index.js +73 -8
- package/dist/reviews/index.js.map +1 -1
- package/dist/reviews/index.mjs +73 -8
- package/dist/reviews/index.mjs.map +1 -1
- package/dist/{transport-BGW9uXZJ.d.mts → transport-CF_eHwzC.d.mts} +15 -1
- package/dist/{transport-jUJd5kxu.d.ts → transport-DsRe4epC.d.ts} +15 -1
- package/llms.txt +1 -0
- package/package.json +1 -1
- package/src/activation/useWireActivation.ts +12 -1
- package/src/activation/wireActivation.ts +36 -24
- package/src/analytics/analyticsFacade.ts +41 -20
- package/src/analytics/currentSession.ts +83 -0
- package/src/analytics/eventQueue.ts +9 -1
- package/src/analytics/index.ts +20 -1
- package/src/analytics/reportClientEvent.ts +38 -0
- package/src/analytics/screenTracking.ts +6 -1
- package/src/analytics/useAnalytics.ts +22 -1
- package/src/context/deviceId.ts +109 -0
- package/src/context/userContext.ts +18 -0
- package/src/index.ts +45 -1
- package/src/questionnaire/runtime.ts +12 -2
- package/src/questionnaire/useQuestionnaireGate.ts +9 -7
- package/src/revenuecat/index.ts +55 -0
- package/src/revenuecat/purchaseEvents.ts +167 -0
- package/src/revenuecat/revenueCatBridge.ts +221 -0
- package/src/revenuecat/types.ts +95 -0
- package/src/reviews/runtime.ts +92 -1
- package/src/reviews/transport.ts +21 -2
- package/src/reviews/useReviewGate.ts +12 -7
- package/src/session-analytics/lifecycle.ts +9 -2
- package/src/session-analytics/reportSessionStart.ts +15 -4
- package/src/session-analytics/useLifecycleEvents.ts +28 -2
|
@@ -290,7 +290,7 @@ declare const fetchQuestionnaireDecision: (target: QuestionnaireTarget | undefin
|
|
|
290
290
|
declare const questionnaireSeenKey: (id: string, version?: string) => string;
|
|
291
291
|
/** Last-shown timestamp key (epoch ms), for the cooldown rule. */
|
|
292
292
|
declare const questionnaireLastShownKey: (id: string) => string;
|
|
293
|
-
/** Session-count key, incremented once per
|
|
293
|
+
/** Session-count key, incremented once per APP-OPEN (not per mount), for the min-sessions rule. */
|
|
294
294
|
declare const questionnaireSessionsKey: (id: string) => string;
|
|
295
295
|
|
|
296
296
|
export { type FetchQuestionnaireDecisionOptions, type QuestionnaireAnswers, type QuestionnaireDecision, type QuestionnaireDecisionResponse, type QuestionnaireDefinition, QuestionnaireGate, type QuestionnaireGateController, type QuestionnaireGateEvent, type QuestionnaireGateEventName, type QuestionnaireGateProps, type QuestionnaireMeta, type QuestionnaireSubmission, type QuestionnaireTarget, type UseQuestionnaireGateOptions, buildQuestionnaireSubmission, decideQuestionnaire, fetchQuestionnaireDecision, questionnaireLastShownKey, questionnaireSeenKey, questionnaireSessionsKey, submitQuestionnaireResponse, useQuestionnaireGate };
|
|
@@ -290,7 +290,7 @@ declare const fetchQuestionnaireDecision: (target: QuestionnaireTarget | undefin
|
|
|
290
290
|
declare const questionnaireSeenKey: (id: string, version?: string) => string;
|
|
291
291
|
/** Last-shown timestamp key (epoch ms), for the cooldown rule. */
|
|
292
292
|
declare const questionnaireLastShownKey: (id: string) => string;
|
|
293
|
-
/** Session-count key, incremented once per
|
|
293
|
+
/** Session-count key, incremented once per APP-OPEN (not per mount), for the min-sessions rule. */
|
|
294
294
|
declare const questionnaireSessionsKey: (id: string) => string;
|
|
295
295
|
|
|
296
296
|
export { type FetchQuestionnaireDecisionOptions, type QuestionnaireAnswers, type QuestionnaireDecision, type QuestionnaireDecisionResponse, type QuestionnaireDefinition, QuestionnaireGate, type QuestionnaireGateController, type QuestionnaireGateEvent, type QuestionnaireGateEventName, type QuestionnaireGateProps, type QuestionnaireMeta, type QuestionnaireSubmission, type QuestionnaireTarget, type UseQuestionnaireGateOptions, buildQuestionnaireSubmission, decideQuestionnaire, fetchQuestionnaireDecision, questionnaireLastShownKey, questionnaireSeenKey, questionnaireSessionsKey, submitQuestionnaireResponse, useQuestionnaireGate };
|
|
@@ -1290,6 +1290,16 @@ var sameDecision = (a, b) => {
|
|
|
1290
1290
|
return a.fire === b.fire && a.reason === b.reason;
|
|
1291
1291
|
};
|
|
1292
1292
|
|
|
1293
|
+
// src/analytics/reportClientEvent.ts
|
|
1294
|
+
var makeSessionId = () => `wire_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1295
|
+
|
|
1296
|
+
// src/analytics/currentSession.ts
|
|
1297
|
+
var CURRENT_SESSION_ID_SLOT = /* @__PURE__ */ Symbol.for(
|
|
1298
|
+
"@wireai/activation:currentSessionId"
|
|
1299
|
+
);
|
|
1300
|
+
var globalSlot = globalThis;
|
|
1301
|
+
var getCurrentSessionId = () => globalSlot[CURRENT_SESSION_ID_SLOT];
|
|
1302
|
+
|
|
1293
1303
|
// src/reviews/runtime.ts
|
|
1294
1304
|
var resolveStorage = (override) => override != null ? override : getCoachmarkStorage();
|
|
1295
1305
|
var readInt = (storage, key) => {
|
|
@@ -1309,11 +1319,46 @@ var writeInt = (storage, key, value) => {
|
|
|
1309
1319
|
} catch {
|
|
1310
1320
|
}
|
|
1311
1321
|
};
|
|
1322
|
+
var readStr = (storage, key) => {
|
|
1323
|
+
if (!storage) return void 0;
|
|
1324
|
+
try {
|
|
1325
|
+
const raw = storage.getItem(key);
|
|
1326
|
+
return typeof raw === "string" && raw.length > 0 ? raw : void 0;
|
|
1327
|
+
} catch {
|
|
1328
|
+
return void 0;
|
|
1329
|
+
}
|
|
1330
|
+
};
|
|
1331
|
+
var PROCESS_OPEN_ID_SLOT = /* @__PURE__ */ Symbol.for("@wireai/activation:processOpenId");
|
|
1332
|
+
var openIdGlobal = globalThis;
|
|
1333
|
+
var currentOpenId = () => {
|
|
1334
|
+
const live = getCurrentSessionId();
|
|
1335
|
+
if (live) return live;
|
|
1336
|
+
const existing = openIdGlobal[PROCESS_OPEN_ID_SLOT];
|
|
1337
|
+
if (existing) return existing;
|
|
1338
|
+
const created = makeSessionId();
|
|
1339
|
+
openIdGlobal[PROCESS_OPEN_ID_SLOT] = created;
|
|
1340
|
+
return created;
|
|
1341
|
+
};
|
|
1342
|
+
var bumpSessionCount = (storage, sessionsKey, openKey, openId = currentOpenId()) => {
|
|
1343
|
+
const lastOpen = readStr(storage, openKey);
|
|
1344
|
+
const stored = readInt(storage, sessionsKey);
|
|
1345
|
+
if (lastOpen === openId) return stored > 0 ? stored : 1;
|
|
1346
|
+
const next = stored + 1;
|
|
1347
|
+
writeInt(storage, sessionsKey, next);
|
|
1348
|
+
if (storage) {
|
|
1349
|
+
try {
|
|
1350
|
+
storage.setItem(openKey, openId);
|
|
1351
|
+
} catch {
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
return next;
|
|
1355
|
+
};
|
|
1312
1356
|
|
|
1313
1357
|
// src/questionnaire/runtime.ts
|
|
1314
1358
|
var questionnaireSeenKey = (id, version) => version ? `wire_questionnaire_${id}_${version}_seen` : `wire_questionnaire_${id}_seen`;
|
|
1315
1359
|
var questionnaireLastShownKey = (id) => `wire_questionnaire_${id}_last`;
|
|
1316
1360
|
var questionnaireSessionsKey = (id) => `wire_questionnaire_${id}_sessions`;
|
|
1361
|
+
var questionnaireSessionOpenKey = (id) => `wire_questionnaire_${id}_open`;
|
|
1317
1362
|
|
|
1318
1363
|
// src/questionnaire/useQuestionnaireGate.ts
|
|
1319
1364
|
var useStableValue2 = (value, isEqual) => {
|
|
@@ -1340,12 +1385,10 @@ var useQuestionnaireGate = ({
|
|
|
1340
1385
|
);
|
|
1341
1386
|
const lastKey = questionnaireLastShownKey(config.id);
|
|
1342
1387
|
const sessionsKey = questionnaireSessionsKey(config.id);
|
|
1343
|
-
const
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
return next;
|
|
1348
|
-
})[0];
|
|
1388
|
+
const sessionOpenKey = questionnaireSessionOpenKey(config.id);
|
|
1389
|
+
const sessions = React8.useState(
|
|
1390
|
+
() => bumpSessionCount(resolveStorage(storage), sessionsKey, sessionOpenKey)
|
|
1391
|
+
)[0];
|
|
1349
1392
|
const hasServerDecision = decision != null;
|
|
1350
1393
|
const timeoutMs = config.timeoutFallbackMs;
|
|
1351
1394
|
const waits = !hasServerDecision && timeoutMs != null && timeoutMs > 0;
|