@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
package/dist/index.mjs
CHANGED
|
@@ -1512,6 +1512,23 @@ var buildEventsRequest = (target, events) => {
|
|
|
1512
1512
|
return null;
|
|
1513
1513
|
}
|
|
1514
1514
|
};
|
|
1515
|
+
var warnOnSkippedEvents = (res) => {
|
|
1516
|
+
try {
|
|
1517
|
+
const json = res == null ? void 0 : res.json;
|
|
1518
|
+
if (typeof json !== "function") return;
|
|
1519
|
+
void Promise.resolve(json.call(res)).then((body) => {
|
|
1520
|
+
const skipped = body == null ? void 0 : body.skipped;
|
|
1521
|
+
if (typeof skipped !== "number" || skipped <= 0) return;
|
|
1522
|
+
if (typeof __DEV__ !== "undefined" && __DEV__ && typeof console !== "undefined" && console.warn) {
|
|
1523
|
+
console.warn(
|
|
1524
|
+
`[wireai] the server ACCEPTED the /v1/events POST but DISCARDED ${skipped} event(s) (skipped in the response body) \u2014 they are gone, not retried. The usual cause is an event with a missing or empty session_id.`
|
|
1525
|
+
);
|
|
1526
|
+
}
|
|
1527
|
+
}).catch(() => {
|
|
1528
|
+
});
|
|
1529
|
+
} catch {
|
|
1530
|
+
}
|
|
1531
|
+
};
|
|
1515
1532
|
var reportClientEvents = (target, events) => {
|
|
1516
1533
|
try {
|
|
1517
1534
|
const req = buildEventsRequest(target, events);
|
|
@@ -3308,6 +3325,28 @@ var getCurrentSessionId = () => globalSlot[CURRENT_SESSION_ID_SLOT];
|
|
|
3308
3325
|
var resetCurrentSessionId = () => {
|
|
3309
3326
|
globalSlot[CURRENT_SESSION_ID_SLOT] = void 0;
|
|
3310
3327
|
};
|
|
3328
|
+
var warnInDev = (message) => {
|
|
3329
|
+
if (typeof __DEV__ !== "undefined" && __DEV__ && typeof console !== "undefined" && console.warn) {
|
|
3330
|
+
console.warn(message);
|
|
3331
|
+
return true;
|
|
3332
|
+
}
|
|
3333
|
+
return false;
|
|
3334
|
+
};
|
|
3335
|
+
var MINT_WARNING = "[wireai] No app-open session was registered, so a session id was minted for this event (the server drops an event that has no session_id, and still answers 200). Mount useLifecycleEvents at your app root so events correlate to a real app-open.";
|
|
3336
|
+
var MINT_WARNED_SLOT = /* @__PURE__ */ Symbol.for(
|
|
3337
|
+
"@wireai/activation:currentSessionIdMintWarned"
|
|
3338
|
+
);
|
|
3339
|
+
var warnSlot = globalThis;
|
|
3340
|
+
var ensureCurrentSessionId = () => {
|
|
3341
|
+
const existing = globalSlot[CURRENT_SESSION_ID_SLOT];
|
|
3342
|
+
if (typeof existing === "string" && existing.length > 0) return existing;
|
|
3343
|
+
const minted = makeSessionId();
|
|
3344
|
+
globalSlot[CURRENT_SESSION_ID_SLOT] = minted;
|
|
3345
|
+
if (!warnSlot[MINT_WARNED_SLOT] && warnInDev(MINT_WARNING)) {
|
|
3346
|
+
warnSlot[MINT_WARNED_SLOT] = true;
|
|
3347
|
+
}
|
|
3348
|
+
return minted;
|
|
3349
|
+
};
|
|
3311
3350
|
|
|
3312
3351
|
// src/session/persistedSession.ts
|
|
3313
3352
|
var DEFAULT_SESSION_TTL_MS = 36e5;
|
|
@@ -4107,6 +4146,10 @@ var clearUserContext = async (opts = {}) => {
|
|
|
4107
4146
|
} catch {
|
|
4108
4147
|
}
|
|
4109
4148
|
};
|
|
4149
|
+
var activationJoinContext = (deviceKey) => {
|
|
4150
|
+
var _a2;
|
|
4151
|
+
return (_a2 = resolveUserContext({ deviceKey }).userContext) != null ? _a2 : {};
|
|
4152
|
+
};
|
|
4110
4153
|
var resolveUserContext = (ctx = {}, opts = {}) => {
|
|
4111
4154
|
var _a2;
|
|
4112
4155
|
const result = {};
|
|
@@ -4145,6 +4188,47 @@ var mintDeviceId = () => {
|
|
|
4145
4188
|
const time = Date.now().toString(36);
|
|
4146
4189
|
return `${AUTO_DEVICE_ID_PREFIX}${time}_${randomChunk()}${randomChunk()}`;
|
|
4147
4190
|
};
|
|
4191
|
+
var AUTO_DEVICE_KEY_SLOT = /* @__PURE__ */ Symbol.for("@wireai/activation:autoDeviceKeys");
|
|
4192
|
+
var deviceKeyGlobal = globalThis;
|
|
4193
|
+
var autoDeviceKeyRegistry = () => {
|
|
4194
|
+
const existing = deviceKeyGlobal[AUTO_DEVICE_KEY_SLOT];
|
|
4195
|
+
if (existing) return existing;
|
|
4196
|
+
const created = { keys: /* @__PURE__ */ new Map(), hydrating: /* @__PURE__ */ new Set() };
|
|
4197
|
+
deviceKeyGlobal[AUTO_DEVICE_KEY_SLOT] = created;
|
|
4198
|
+
return created;
|
|
4199
|
+
};
|
|
4200
|
+
var resolveAutoDeviceKey = (opts = {}) => {
|
|
4201
|
+
var _a2, _b;
|
|
4202
|
+
const registry = autoDeviceKeyRegistry();
|
|
4203
|
+
const appId = (_a2 = opts.appId) != null ? _a2 : "default";
|
|
4204
|
+
let id = registry.keys.get(appId);
|
|
4205
|
+
if (!id) {
|
|
4206
|
+
id = mintDeviceId();
|
|
4207
|
+
registry.keys.set(appId, id);
|
|
4208
|
+
}
|
|
4209
|
+
const storage = opts.storage;
|
|
4210
|
+
if (storage && !registry.hydrating.has(appId)) {
|
|
4211
|
+
registry.hydrating.add(appId);
|
|
4212
|
+
const slot = deviceIdStorageKey(appId);
|
|
4213
|
+
const minted = id;
|
|
4214
|
+
try {
|
|
4215
|
+
void Promise.resolve(storage.getItem(slot)).then((saved) => {
|
|
4216
|
+
const persisted = typeof saved === "string" && saved.trim() ? saved.trim() : void 0;
|
|
4217
|
+
if (persisted) registry.keys.set(appId, persisted);
|
|
4218
|
+
else void Promise.resolve(storage.setItem(slot, minted)).catch(() => {
|
|
4219
|
+
});
|
|
4220
|
+
}).catch(() => {
|
|
4221
|
+
});
|
|
4222
|
+
} catch {
|
|
4223
|
+
}
|
|
4224
|
+
}
|
|
4225
|
+
return (_b = registry.keys.get(appId)) != null ? _b : id;
|
|
4226
|
+
};
|
|
4227
|
+
var resetAutoDeviceKeys = () => {
|
|
4228
|
+
const registry = autoDeviceKeyRegistry();
|
|
4229
|
+
registry.keys.clear();
|
|
4230
|
+
registry.hydrating.clear();
|
|
4231
|
+
};
|
|
4148
4232
|
|
|
4149
4233
|
// src/activation/revalidation.ts
|
|
4150
4234
|
var REVALIDATION_SLOT = /* @__PURE__ */ Symbol.for(
|
|
@@ -4192,22 +4276,20 @@ var createWireActivation = (config) => {
|
|
|
4192
4276
|
var _a2, _b;
|
|
4193
4277
|
const target = { serverUrl: config.serverUrl, apiKey: config.apiKey };
|
|
4194
4278
|
const explicitDeviceKey = (_b = clean(config.deviceKey)) != null ? _b : clean((_a2 = config.userContext) == null ? void 0 : _a2.deviceKey);
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
if (persisted) autoDeviceKey = persisted;
|
|
4202
|
-
else void storage.setItem(key, autoDeviceKey).catch(() => {
|
|
4203
|
-
});
|
|
4204
|
-
}).catch(() => {
|
|
4205
|
-
});
|
|
4206
|
-
}
|
|
4279
|
+
const autoDeviceKeyOptions = {
|
|
4280
|
+
appId: config.appId,
|
|
4281
|
+
// An explicit key opts out of minting AND persisting (unchanged contract).
|
|
4282
|
+
storage: explicitDeviceKey ? void 0 : config.storage
|
|
4283
|
+
};
|
|
4284
|
+
if (!explicitDeviceKey) resolveAutoDeviceKey(autoDeviceKeyOptions);
|
|
4207
4285
|
const applyContext = (event) => {
|
|
4208
4286
|
var _a3, _b2;
|
|
4209
4287
|
const resolved = resolveUserContext(
|
|
4210
|
-
|
|
4288
|
+
// `??` is lazy on purpose: an explicit key must never even touch the auto registry.
|
|
4289
|
+
{
|
|
4290
|
+
...(_a3 = config.userContext) != null ? _a3 : {},
|
|
4291
|
+
deviceKey: explicitDeviceKey != null ? explicitDeviceKey : resolveAutoDeviceKey(autoDeviceKeyOptions)
|
|
4292
|
+
},
|
|
4211
4293
|
{ autoAppVersion: config.appVersion }
|
|
4212
4294
|
);
|
|
4213
4295
|
if (resolved.userContext) {
|
|
@@ -4216,8 +4298,8 @@ var createWireActivation = (config) => {
|
|
|
4216
4298
|
if (resolved.userId && !event.user_id) event.user_id = resolved.userId;
|
|
4217
4299
|
};
|
|
4218
4300
|
const track = async (name2, meta) => {
|
|
4219
|
-
|
|
4220
|
-
|
|
4301
|
+
if (!clean(name2)) return false;
|
|
4302
|
+
const sessionId = ensureCurrentSessionId();
|
|
4221
4303
|
const event = {
|
|
4222
4304
|
event_type: "app_event",
|
|
4223
4305
|
session_id: sessionId,
|
|
@@ -4244,9 +4326,16 @@ var useActivationRevalidation = () => useSyncExternalStore(
|
|
|
4244
4326
|
getActivationRevalidationVersion
|
|
4245
4327
|
);
|
|
4246
4328
|
var useWireActivation = (config) => {
|
|
4329
|
+
var _a2;
|
|
4247
4330
|
const ref = useRef(void 0);
|
|
4248
4331
|
const prevKeys = useRef("");
|
|
4249
|
-
const currentKeys =
|
|
4332
|
+
const currentKeys = [
|
|
4333
|
+
config.serverUrl,
|
|
4334
|
+
config.apiKey,
|
|
4335
|
+
config.appId,
|
|
4336
|
+
config.deviceKey,
|
|
4337
|
+
(_a2 = config.userContext) == null ? void 0 : _a2.deviceKey
|
|
4338
|
+
].join("|");
|
|
4250
4339
|
if (!ref.current || prevKeys.current !== currentKeys) {
|
|
4251
4340
|
prevKeys.current = currentKeys;
|
|
4252
4341
|
ref.current = createWireActivation(config);
|
|
@@ -4255,6 +4344,154 @@ var useWireActivation = (config) => {
|
|
|
4255
4344
|
return { track: ref.current.track, sessionId: ref.current.sessionId, revalidation };
|
|
4256
4345
|
};
|
|
4257
4346
|
|
|
4347
|
+
// src/revenuecat/purchaseEvents.ts
|
|
4348
|
+
var WIRE_PURCHASE_EVENTS = {
|
|
4349
|
+
/** The paywall became visible (offerings loaded). */
|
|
4350
|
+
paywallShown: "wire_paywall_shown",
|
|
4351
|
+
/** The user tapped buy; the store sheet is about to open. */
|
|
4352
|
+
checkoutStarted: "wire_checkout_started",
|
|
4353
|
+
/** The store confirmed the purchase AND the entitlement is now active. */
|
|
4354
|
+
purchased: "wire_purchase_completed",
|
|
4355
|
+
/** The purchase did not land: a user cancel or a real store/network error (see `reason`). */
|
|
4356
|
+
purchaseFailed: "wire_purchase_failed",
|
|
4357
|
+
/** A restore ran (whether or not it produced an entitlement; see `plan_tier`). */
|
|
4358
|
+
restored: "wire_purchase_restored"
|
|
4359
|
+
};
|
|
4360
|
+
var PLAN_TIER_CONTEXT_KEY = "plan_tier";
|
|
4361
|
+
var asRecord = (value) => typeof value === "object" && value !== null ? value : void 0;
|
|
4362
|
+
var activeEntitlement = (info, entitlementId) => {
|
|
4363
|
+
var _a2, _b;
|
|
4364
|
+
const active = asRecord((_b = asRecord((_a2 = asRecord(info)) == null ? void 0 : _a2.entitlements)) == null ? void 0 : _b.active);
|
|
4365
|
+
const found = active == null ? void 0 : active[entitlementId];
|
|
4366
|
+
const entitlement = asRecord(found);
|
|
4367
|
+
if (!entitlement) return void 0;
|
|
4368
|
+
return entitlement.isActive === false ? void 0 : entitlement;
|
|
4369
|
+
};
|
|
4370
|
+
var isTrial = (entitlement) => typeof entitlement.periodType === "string" && entitlement.periodType.toUpperCase() === "TRIAL";
|
|
4371
|
+
var resolvePlanTier = (info, entitlementId) => {
|
|
4372
|
+
const entitlement = activeEntitlement(info, entitlementId);
|
|
4373
|
+
if (!entitlement) return "free";
|
|
4374
|
+
return isTrial(entitlement) ? "trial" : "paid";
|
|
4375
|
+
};
|
|
4376
|
+
var describePackage = (pkg) => {
|
|
4377
|
+
const props = {};
|
|
4378
|
+
if (!pkg) return props;
|
|
4379
|
+
if (typeof pkg.identifier === "string") props.package_id = pkg.identifier;
|
|
4380
|
+
if (typeof pkg.packageType === "string") props.package_type = pkg.packageType;
|
|
4381
|
+
if (typeof pkg.offeringIdentifier === "string") props.offering_id = pkg.offeringIdentifier;
|
|
4382
|
+
const product = asRecord(pkg.product);
|
|
4383
|
+
if (product) {
|
|
4384
|
+
if (typeof product.identifier === "string") props.product_id = product.identifier;
|
|
4385
|
+
if (typeof product.price === "number" && Number.isFinite(product.price)) {
|
|
4386
|
+
props.price = product.price;
|
|
4387
|
+
}
|
|
4388
|
+
if (typeof product.currencyCode === "string") props.currency = product.currencyCode;
|
|
4389
|
+
}
|
|
4390
|
+
return props;
|
|
4391
|
+
};
|
|
4392
|
+
var describeEntitlement = (info, entitlementId) => {
|
|
4393
|
+
const entitlement = activeEntitlement(info, entitlementId);
|
|
4394
|
+
const props = {
|
|
4395
|
+
entitlement: entitlementId,
|
|
4396
|
+
plan_tier: entitlement ? isTrial(entitlement) ? "trial" : "paid" : "free"
|
|
4397
|
+
};
|
|
4398
|
+
if (!entitlement) return props;
|
|
4399
|
+
if (typeof entitlement.periodType === "string") props.period_type = entitlement.periodType;
|
|
4400
|
+
props.is_trial = isTrial(entitlement);
|
|
4401
|
+
if (typeof entitlement.willRenew === "boolean") props.will_renew = entitlement.willRenew;
|
|
4402
|
+
if (typeof entitlement.store === "string") props.store = entitlement.store;
|
|
4403
|
+
if (typeof entitlement.productIdentifier === "string") {
|
|
4404
|
+
props.product_id = entitlement.productIdentifier;
|
|
4405
|
+
}
|
|
4406
|
+
if (typeof entitlement.isSandbox === "boolean") props.is_sandbox = entitlement.isSandbox;
|
|
4407
|
+
return props;
|
|
4408
|
+
};
|
|
4409
|
+
var PURCHASE_CANCELLED_CODE = "1";
|
|
4410
|
+
var isUserCancelled = (error) => {
|
|
4411
|
+
const record = asRecord(error);
|
|
4412
|
+
if (!record) return false;
|
|
4413
|
+
if (record.userCancelled === true) return true;
|
|
4414
|
+
return record.code === PURCHASE_CANCELLED_CODE;
|
|
4415
|
+
};
|
|
4416
|
+
var describeFailure = (error) => {
|
|
4417
|
+
const record = asRecord(error);
|
|
4418
|
+
const code = typeof (record == null ? void 0 : record.code) === "string" ? record.code : "unknown";
|
|
4419
|
+
return { reason: isUserCancelled(error) ? "cancelled" : "error", code };
|
|
4420
|
+
};
|
|
4421
|
+
|
|
4422
|
+
// src/revenuecat/revenueCatBridge.ts
|
|
4423
|
+
var createRevenueCatBridge = (config) => {
|
|
4424
|
+
const { analytics, entitlementId } = config;
|
|
4425
|
+
const writeTier = config.writePlanTier !== false;
|
|
4426
|
+
const emit = (event, props) => {
|
|
4427
|
+
try {
|
|
4428
|
+
const result = analytics.track(event, { ...config.commonProps, ...props });
|
|
4429
|
+
if (result && typeof result.catch === "function") {
|
|
4430
|
+
void result.catch(() => {
|
|
4431
|
+
});
|
|
4432
|
+
}
|
|
4433
|
+
} catch {
|
|
4434
|
+
}
|
|
4435
|
+
};
|
|
4436
|
+
const syncPlanTier = (customerInfo) => {
|
|
4437
|
+
var _a2;
|
|
4438
|
+
const tier = resolvePlanTier(customerInfo, entitlementId);
|
|
4439
|
+
if (!writeTier) return tier;
|
|
4440
|
+
try {
|
|
4441
|
+
(_a2 = analytics.setUserContext) == null ? void 0 : _a2.call(analytics, { extra: { [PLAN_TIER_CONTEXT_KEY]: tier } });
|
|
4442
|
+
} catch {
|
|
4443
|
+
}
|
|
4444
|
+
return tier;
|
|
4445
|
+
};
|
|
4446
|
+
const paywallShown = (offering, props) => {
|
|
4447
|
+
var _a2, _b;
|
|
4448
|
+
const shown = {
|
|
4449
|
+
packages_count: (_b = (_a2 = offering == null ? void 0 : offering.availablePackages) == null ? void 0 : _a2.length) != null ? _b : 0
|
|
4450
|
+
};
|
|
4451
|
+
if (typeof (offering == null ? void 0 : offering.identifier) === "string") shown.offering_id = offering.identifier;
|
|
4452
|
+
emit(WIRE_PURCHASE_EVENTS.paywallShown, { ...shown, ...props });
|
|
4453
|
+
};
|
|
4454
|
+
const checkoutStarted = (pkg, props) => {
|
|
4455
|
+
emit(WIRE_PURCHASE_EVENTS.checkoutStarted, { ...describePackage(pkg), ...props });
|
|
4456
|
+
};
|
|
4457
|
+
const purchaseCompleted = (customerInfo, pkg, props) => {
|
|
4458
|
+
const tier = syncPlanTier(customerInfo);
|
|
4459
|
+
const entitled = tier !== "free";
|
|
4460
|
+
if (entitled) {
|
|
4461
|
+
emit(WIRE_PURCHASE_EVENTS.purchased, {
|
|
4462
|
+
...describePackage(pkg),
|
|
4463
|
+
...describeEntitlement(customerInfo, entitlementId),
|
|
4464
|
+
...props
|
|
4465
|
+
});
|
|
4466
|
+
return true;
|
|
4467
|
+
}
|
|
4468
|
+
emit(WIRE_PURCHASE_EVENTS.purchaseFailed, {
|
|
4469
|
+
...describePackage(pkg),
|
|
4470
|
+
reason: "not_entitled",
|
|
4471
|
+
code: "unknown",
|
|
4472
|
+
entitlement: entitlementId,
|
|
4473
|
+
...props
|
|
4474
|
+
});
|
|
4475
|
+
return false;
|
|
4476
|
+
};
|
|
4477
|
+
const purchaseFailed = (error, pkg, props) => {
|
|
4478
|
+
emit(WIRE_PURCHASE_EVENTS.purchaseFailed, {
|
|
4479
|
+
...describePackage(pkg),
|
|
4480
|
+
...describeFailure(error),
|
|
4481
|
+
...props
|
|
4482
|
+
});
|
|
4483
|
+
};
|
|
4484
|
+
const purchasesRestored = (customerInfo, props) => {
|
|
4485
|
+
const tier = syncPlanTier(customerInfo);
|
|
4486
|
+
emit(WIRE_PURCHASE_EVENTS.restored, {
|
|
4487
|
+
...describeEntitlement(customerInfo, entitlementId),
|
|
4488
|
+
...props
|
|
4489
|
+
});
|
|
4490
|
+
return tier !== "free";
|
|
4491
|
+
};
|
|
4492
|
+
return { paywallShown, checkoutStarted, purchaseCompleted, purchaseFailed, purchasesRestored, syncPlanTier };
|
|
4493
|
+
};
|
|
4494
|
+
|
|
4258
4495
|
// src/session-analytics/reportSessionStart.ts
|
|
4259
4496
|
var SESSION_STARTED_EVENT = "app.session_started";
|
|
4260
4497
|
var _emitted = /* @__PURE__ */ new Set();
|
|
@@ -4307,6 +4544,8 @@ var reportSessionStart = (opts) => {
|
|
|
4307
4544
|
method: "POST",
|
|
4308
4545
|
headers,
|
|
4309
4546
|
body: JSON.stringify({ events: [event] })
|
|
4547
|
+
}).then((res) => {
|
|
4548
|
+
warnOnSkippedEvents(res);
|
|
4310
4549
|
}).catch(() => {
|
|
4311
4550
|
});
|
|
4312
4551
|
} catch {
|
|
@@ -4437,11 +4676,13 @@ var reportFirstOpen = (opts) => {
|
|
|
4437
4676
|
})();
|
|
4438
4677
|
};
|
|
4439
4678
|
var wireLifecycleEvents = (opts) => {
|
|
4440
|
-
|
|
4679
|
+
var _a2;
|
|
4680
|
+
const sessionId = (_a2 = opts.sessionId) != null ? _a2 : makeSessionId();
|
|
4681
|
+
reportFirstOpen({ ...opts, sessionId });
|
|
4441
4682
|
reportSessionStart({
|
|
4442
4683
|
target: opts.target,
|
|
4443
4684
|
sink: opts.sink,
|
|
4444
|
-
sessionId
|
|
4685
|
+
sessionId,
|
|
4445
4686
|
userId: opts.userId,
|
|
4446
4687
|
deviceKey: opts.deviceKey,
|
|
4447
4688
|
sessionCount: opts.sessionCount,
|
|
@@ -4576,6 +4817,7 @@ var createEventQueue = (options) => {
|
|
|
4576
4817
|
const timer = setTimeout(() => controller == null ? void 0 : controller.abort(), 15e3);
|
|
4577
4818
|
try {
|
|
4578
4819
|
const res = await fetch(req.url, { ...req.init, signal: controller == null ? void 0 : controller.signal });
|
|
4820
|
+
warnOnSkippedEvents(res);
|
|
4579
4821
|
return !!(res && res.ok);
|
|
4580
4822
|
} catch {
|
|
4581
4823
|
return false;
|
|
@@ -4681,6 +4923,12 @@ var useLifecycleEvents = (config, options = {}) => {
|
|
|
4681
4923
|
var _a3;
|
|
4682
4924
|
return (cfg == null ? void 0 : cfg.serverUrl) ? { serverUrl: cfg.serverUrl, apiKey: (_a3 = cfg.apiKey) != null ? _a3 : "" } : void 0;
|
|
4683
4925
|
};
|
|
4926
|
+
const resolveDeviceKey = (cfg, opts) => {
|
|
4927
|
+
const host = typeof opts.deviceKey === "string" && opts.deviceKey.trim() ? opts.deviceKey : void 0;
|
|
4928
|
+
if (host) return host;
|
|
4929
|
+
if (!(cfg == null ? void 0 : cfg.storage)) return void 0;
|
|
4930
|
+
return resolveAutoDeviceKey({ appId: cfg.appId, storage: cfg.storage });
|
|
4931
|
+
};
|
|
4684
4932
|
const mountOpenSessionId = makeSessionId();
|
|
4685
4933
|
const fireSession = (sessionId) => {
|
|
4686
4934
|
var _a3;
|
|
@@ -4694,7 +4942,7 @@ var useLifecycleEvents = (config, options = {}) => {
|
|
|
4694
4942
|
sink: resolveSink(),
|
|
4695
4943
|
sessionId,
|
|
4696
4944
|
userId: opts.userId,
|
|
4697
|
-
deviceKey: opts
|
|
4945
|
+
deviceKey: resolveDeviceKey(cfg, opts),
|
|
4698
4946
|
sessionCount: opts.sessionCount,
|
|
4699
4947
|
appVersion: (_a3 = cfg == null ? void 0 : cfg.appVersion) != null ? _a3 : device.appVersion,
|
|
4700
4948
|
platform: Platform.OS,
|
|
@@ -4715,7 +4963,7 @@ var useLifecycleEvents = (config, options = {}) => {
|
|
|
4715
4963
|
storage: cfg == null ? void 0 : cfg.storage,
|
|
4716
4964
|
appId: cfg == null ? void 0 : cfg.appId,
|
|
4717
4965
|
userId: opts.userId,
|
|
4718
|
-
deviceKey: opts
|
|
4966
|
+
deviceKey: resolveDeviceKey(cfg, opts),
|
|
4719
4967
|
sessionCount: opts.sessionCount,
|
|
4720
4968
|
appVersion: (_a2 = cfg == null ? void 0 : cfg.appVersion) != null ? _a2 : device.appVersion,
|
|
4721
4969
|
platform: Platform.OS,
|
|
@@ -4743,6 +4991,6 @@ var useLifecycleEvents = (config, options = {}) => {
|
|
|
4743
4991
|
}, []);
|
|
4744
4992
|
};
|
|
4745
4993
|
|
|
4746
|
-
export { AUTO_DEVICE_ID_PREFIX, AnimatedSparkle, BACKGROUND_SESSION_MS, CardGridSelectCard, CardHandoff, CenteredModal, ChipSelectCard, CompletionView, DEFAULT_FEATURES_TTL_MS, DEFAULT_SESSION_TTL_MS, DemoOnboarding, DoneBlock, EXTRA_KEY_PREFIX, ErrorBlock, FIRST_OPEN_EVENT, IconRegistryProvider, IllustrationProvider, InterstitialCard, LoadingBlock, LoadingScreen, NumberStepperCard, Button as OnboardingButton, OnboardingFlow, OnboardingScaffold, OnboardingThemeProvider, RESERVED_USER_CONTEXT_KEYS, SESSION_STARTED_EVENT, SelectionCard, StatusCard, StepProgress, TextInputCard, USER_ID_MAX_LENGTH, WIRE_ICON_GLYPHS, WIRE_ICON_NAMES, WIRE_ONBOARDING_EVENTS, WireFeaturesProvider, WireIcon, WireOnboarding, analyticsUserIdStorageKey, attributionMetadata, bumpActivationRevalidation, clearPersistedSession, clearPiiFromContext, clearUserContext, collectDeviceContext, createWireActivation, defaultIllustrations, defaultOnboardingTheme, defaultWireFeatures, deriveAnswers, detectAppVersion, detectNativeModel, deviceIdStorageKey, featuresCacheKey, featuresEqual, fetchWireFeatures, firstOpenStorageKey, getActivationRevalidationVersion, getCurrentSessionId, hashEmailFnv1a, identifyOnboarding, isFeaturesFresh, isOnboardingEnabled, isWireScalar, loadPersistedSession, looksLikeEmail, lookupIconGlyph, makeSessionId, mergeTheme, mintDeviceId, motionSpec_exports as motionSpec, namespaceExtra, onboardingComponents, parseWireFeatures, peekPersistedSession, readCachedFeatures, readProgress, reportClientEvent, reportClientEventAwait, reportClientEvents, reportClientEventsAwait, reportFirstOpen, reportSessionStart, resetActivationRevalidation, resetCurrentSessionId, resetFirstOpenLatch, resetSessionStartGuard, resolveUserContext, sanitizeUserId, savePersistedSession, sessionStorageKey, setCurrentSessionId, subscribeActivationRevalidation, themeFromBrand, toAnalyticsEvent, useActivationRevalidation, useHostIcon, useIllustration, useLifecycleEvents, useOnboardingTheme, useReducedMotion, useResolvedFeatures, useSessionStart, useWireActivation, useWireFeatures, useWireFeaturesContext, wireConfigFromEnv, wireLifecycleEvents, writeCachedFeatures };
|
|
4994
|
+
export { AUTO_DEVICE_ID_PREFIX, AnimatedSparkle, BACKGROUND_SESSION_MS, CardGridSelectCard, CardHandoff, CenteredModal, ChipSelectCard, CompletionView, DEFAULT_FEATURES_TTL_MS, DEFAULT_SESSION_TTL_MS, DemoOnboarding, DoneBlock, EXTRA_KEY_PREFIX, ErrorBlock, FIRST_OPEN_EVENT, IconRegistryProvider, IllustrationProvider, InterstitialCard, LoadingBlock, LoadingScreen, NumberStepperCard, Button as OnboardingButton, OnboardingFlow, OnboardingScaffold, OnboardingThemeProvider, PLAN_TIER_CONTEXT_KEY, RESERVED_USER_CONTEXT_KEYS, SESSION_STARTED_EVENT, SelectionCard, StatusCard, StepProgress, TextInputCard, USER_ID_MAX_LENGTH, WIRE_ICON_GLYPHS, WIRE_ICON_NAMES, WIRE_ONBOARDING_EVENTS, WIRE_PURCHASE_EVENTS, WireFeaturesProvider, WireIcon, WireOnboarding, activationJoinContext, activeEntitlement, analyticsUserIdStorageKey, attributionMetadata, bumpActivationRevalidation, clearPersistedSession, clearPiiFromContext, clearUserContext, collectDeviceContext, createRevenueCatBridge, createWireActivation, defaultIllustrations, defaultOnboardingTheme, defaultWireFeatures, deriveAnswers, describeEntitlement, describeFailure, describePackage, detectAppVersion, detectNativeModel, deviceIdStorageKey, ensureCurrentSessionId, featuresCacheKey, featuresEqual, fetchWireFeatures, firstOpenStorageKey, getActivationRevalidationVersion, getCurrentSessionId, hashEmailFnv1a, identifyOnboarding, isFeaturesFresh, isOnboardingEnabled, isUserCancelled, isWireScalar, loadPersistedSession, looksLikeEmail, lookupIconGlyph, makeSessionId, mergeTheme, mintDeviceId, motionSpec_exports as motionSpec, namespaceExtra, onboardingComponents, parseWireFeatures, peekPersistedSession, readCachedFeatures, readProgress, reportClientEvent, reportClientEventAwait, reportClientEvents, reportClientEventsAwait, reportFirstOpen, reportSessionStart, resetActivationRevalidation, resetAutoDeviceKeys, resetCurrentSessionId, resetFirstOpenLatch, resetSessionStartGuard, resolveAutoDeviceKey, resolvePlanTier, resolveUserContext, sanitizeUserId, savePersistedSession, sessionStorageKey, setCurrentSessionId, subscribeActivationRevalidation, themeFromBrand, toAnalyticsEvent, useActivationRevalidation, useHostIcon, useIllustration, useLifecycleEvents, useOnboardingTheme, useReducedMotion, useResolvedFeatures, useSessionStart, useWireActivation, useWireFeatures, useWireFeaturesContext, wireConfigFromEnv, wireLifecycleEvents, writeCachedFeatures };
|
|
4747
4995
|
//# sourceMappingURL=index.mjs.map
|
|
4748
4996
|
//# sourceMappingURL=index.mjs.map
|