@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.
- package/CHANGELOG.md +55 -0
- package/README.md +33 -4
- package/dist/analytics/index.d.mts +21 -3
- package/dist/analytics/index.d.ts +21 -3
- package/dist/analytics/index.js +94 -61
- package/dist/analytics/index.js.map +1 -1
- package/dist/analytics/index.mjs +91 -62
- package/dist/analytics/index.mjs.map +1 -1
- package/dist/{currentSession-DdDkprpM.d.mts → currentSession-C0_odnIW.d.mts} +101 -1
- package/dist/{currentSession-D0Vq7_VE.d.ts → currentSession-DdnUq2HQ.d.ts} +101 -1
- package/dist/index.d.mts +3 -49
- package/dist/index.d.ts +3 -49
- package/dist/index.js +50 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -42
- package/dist/index.mjs.map +1 -1
- package/dist/questionnaire/index.js +10 -2
- package/dist/questionnaire/index.js.map +1 -1
- package/dist/questionnaire/index.mjs +10 -2
- package/dist/questionnaire/index.mjs.map +1 -1
- package/dist/reviews/index.d.mts +1 -1
- package/dist/reviews/index.d.ts +1 -1
- package/dist/reviews/index.js +24 -9
- package/dist/reviews/index.js.map +1 -1
- package/dist/reviews/index.mjs +24 -9
- package/dist/reviews/index.mjs.map +1 -1
- package/dist/{transport-Bzb-bcB2.d.mts → transport-BGW9uXZJ.d.mts} +0 -15
- package/dist/{transport-B31G0Cib.d.ts → transport-jUJd5kxu.d.ts} +0 -15
- package/llms.txt +8 -0
- package/package.json +1 -1
- package/src/analytics/analyticsFacade.ts +72 -9
- package/src/analytics/eventQueue.ts +12 -11
- package/src/analytics/index.ts +9 -0
- package/src/analytics/reportClientEvent.ts +12 -2
- package/src/context/userContext.ts +55 -0
- package/src/identity/userIdentity.ts +10 -0
- package/src/index.ts +5 -1
- package/src/questionnaire/transport.ts +5 -1
- package/src/reviews/decision.ts +8 -1
- package/src/reviews/transport.ts +6 -8
- package/src/session-analytics/lifecycle.ts +6 -11
- package/src/session-analytics/useLifecycleEvents.ts +41 -27
package/dist/index.mjs
CHANGED
|
@@ -3376,6 +3376,7 @@ var sanitizeUserId = (raw) => {
|
|
|
3376
3376
|
if (!trimmed) return void 0;
|
|
3377
3377
|
return trimmed.length > USER_ID_MAX_LENGTH ? trimmed.slice(0, USER_ID_MAX_LENGTH) : trimmed;
|
|
3378
3378
|
};
|
|
3379
|
+
var looksLikeEmail = (value) => typeof value === "string" && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value.trim());
|
|
3379
3380
|
var identifyOnboarding = async (opts) => {
|
|
3380
3381
|
var _a2, _b, _c;
|
|
3381
3382
|
const userId = sanitizeUserId(opts.userId);
|
|
@@ -4091,6 +4092,21 @@ var namespaceExtra = (extra) => {
|
|
|
4091
4092
|
}
|
|
4092
4093
|
return out;
|
|
4093
4094
|
};
|
|
4095
|
+
var analyticsUserIdStorageKey = (appId) => `wireai:analytics:userId:${appId != null ? appId : "default"}`;
|
|
4096
|
+
var clearPiiFromContext = (ctx = {}) => {
|
|
4097
|
+
const rest = {};
|
|
4098
|
+
if (typeof ctx.appVersion === "string") rest.appVersion = ctx.appVersion;
|
|
4099
|
+
if (typeof ctx.deviceKey === "string") rest.deviceKey = ctx.deviceKey;
|
|
4100
|
+
return rest;
|
|
4101
|
+
};
|
|
4102
|
+
var clearUserContext = async (opts = {}) => {
|
|
4103
|
+
const storage = opts.storage;
|
|
4104
|
+
if (!storage) return;
|
|
4105
|
+
try {
|
|
4106
|
+
await storage.removeItem(analyticsUserIdStorageKey(opts.appId));
|
|
4107
|
+
} catch {
|
|
4108
|
+
}
|
|
4109
|
+
};
|
|
4094
4110
|
var resolveUserContext = (ctx = {}, opts = {}) => {
|
|
4095
4111
|
var _a2;
|
|
4096
4112
|
const result = {};
|
|
@@ -4384,16 +4400,9 @@ var routeLifecycleEvent = (event, opts) => {
|
|
|
4384
4400
|
opts.sink(event);
|
|
4385
4401
|
return;
|
|
4386
4402
|
}
|
|
4387
|
-
const
|
|
4388
|
-
if (!
|
|
4389
|
-
|
|
4390
|
-
const headers = { "Content-Type": "application/json" };
|
|
4391
|
-
if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;
|
|
4392
|
-
void fetch(url, {
|
|
4393
|
-
method: "POST",
|
|
4394
|
-
headers,
|
|
4395
|
-
body: JSON.stringify({ events: [event] })
|
|
4396
|
-
}).catch(() => {
|
|
4403
|
+
const req = buildEventsRequest(opts.target, [event]);
|
|
4404
|
+
if (!req) return;
|
|
4405
|
+
void fetch(req.url, req.init).catch(() => {
|
|
4397
4406
|
});
|
|
4398
4407
|
} catch {
|
|
4399
4408
|
}
|
|
@@ -4505,6 +4514,7 @@ var createEventQueue = (options) => {
|
|
|
4505
4514
|
var _a3;
|
|
4506
4515
|
const env = resolveEnvelope();
|
|
4507
4516
|
const stamped = { ...event };
|
|
4517
|
+
if (stamped.ts === void 0) stamped.ts = Date.now();
|
|
4508
4518
|
if (!env) return stamped;
|
|
4509
4519
|
if (!stamped.device && env.device) stamped.device = env.device;
|
|
4510
4520
|
if (!stamped.session_id && env.sessionId) stamped.session_id = env.sessionId;
|
|
@@ -4560,19 +4570,12 @@ var createEventQueue = (options) => {
|
|
|
4560
4570
|
}
|
|
4561
4571
|
})();
|
|
4562
4572
|
const postBatch = async (events) => {
|
|
4563
|
-
|
|
4573
|
+
const req = buildEventsRequest(target, events);
|
|
4574
|
+
if (!req) return false;
|
|
4564
4575
|
const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
4565
4576
|
const timer = setTimeout(() => controller == null ? void 0 : controller.abort(), 15e3);
|
|
4566
4577
|
try {
|
|
4567
|
-
const
|
|
4568
|
-
const headers = { "Content-Type": "application/json" };
|
|
4569
|
-
if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;
|
|
4570
|
-
const res = await fetch(url, {
|
|
4571
|
-
method: "POST",
|
|
4572
|
-
headers,
|
|
4573
|
-
body: JSON.stringify({ events }),
|
|
4574
|
-
signal: controller == null ? void 0 : controller.signal
|
|
4575
|
-
});
|
|
4578
|
+
const res = await fetch(req.url, { ...req.init, signal: controller == null ? void 0 : controller.signal });
|
|
4576
4579
|
return !!(res && res.ok);
|
|
4577
4580
|
} catch {
|
|
4578
4581
|
return false;
|
|
@@ -4678,6 +4681,28 @@ var useLifecycleEvents = (config, options = {}) => {
|
|
|
4678
4681
|
var _a3;
|
|
4679
4682
|
return (cfg == null ? void 0 : cfg.serverUrl) ? { serverUrl: cfg.serverUrl, apiKey: (_a3 = cfg.apiKey) != null ? _a3 : "" } : void 0;
|
|
4680
4683
|
};
|
|
4684
|
+
const mountOpenSessionId = makeSessionId();
|
|
4685
|
+
const fireSession = (sessionId) => {
|
|
4686
|
+
var _a3;
|
|
4687
|
+
const { config: cfg, options: opts } = latest.current;
|
|
4688
|
+
if (opts.enabled === false) return;
|
|
4689
|
+
if (!(cfg == null ? void 0 : cfg.serverUrl) && !opts.sink) return;
|
|
4690
|
+
const device = collectDeviceContext();
|
|
4691
|
+
if (cfg == null ? void 0 : cfg.appVersion) device.appVersion = cfg.appVersion;
|
|
4692
|
+
reportSessionStart({
|
|
4693
|
+
target: targetOf(cfg),
|
|
4694
|
+
sink: resolveSink(),
|
|
4695
|
+
sessionId,
|
|
4696
|
+
userId: opts.userId,
|
|
4697
|
+
deviceKey: opts.deviceKey,
|
|
4698
|
+
sessionCount: opts.sessionCount,
|
|
4699
|
+
appVersion: (_a3 = cfg == null ? void 0 : cfg.appVersion) != null ? _a3 : device.appVersion,
|
|
4700
|
+
platform: Platform.OS,
|
|
4701
|
+
device,
|
|
4702
|
+
meta: opts.meta
|
|
4703
|
+
});
|
|
4704
|
+
};
|
|
4705
|
+
fireSession(mountOpenSessionId);
|
|
4681
4706
|
{
|
|
4682
4707
|
const { config: cfg, options: opts } = latest.current;
|
|
4683
4708
|
if (opts.enabled !== false) {
|
|
@@ -4686,6 +4711,7 @@ var useLifecycleEvents = (config, options = {}) => {
|
|
|
4686
4711
|
reportFirstOpen({
|
|
4687
4712
|
target: targetOf(cfg),
|
|
4688
4713
|
sink: resolveSink(),
|
|
4714
|
+
sessionId: mountOpenSessionId,
|
|
4689
4715
|
storage: cfg == null ? void 0 : cfg.storage,
|
|
4690
4716
|
appId: cfg == null ? void 0 : cfg.appId,
|
|
4691
4717
|
userId: opts.userId,
|
|
@@ -4698,27 +4724,6 @@ var useLifecycleEvents = (config, options = {}) => {
|
|
|
4698
4724
|
});
|
|
4699
4725
|
}
|
|
4700
4726
|
}
|
|
4701
|
-
const fireSession = () => {
|
|
4702
|
-
var _a3;
|
|
4703
|
-
const { config: cfg, options: opts } = latest.current;
|
|
4704
|
-
if (opts.enabled === false) return;
|
|
4705
|
-
if (!(cfg == null ? void 0 : cfg.serverUrl) && !opts.sink) return;
|
|
4706
|
-
const device = collectDeviceContext();
|
|
4707
|
-
if (cfg == null ? void 0 : cfg.appVersion) device.appVersion = cfg.appVersion;
|
|
4708
|
-
reportSessionStart({
|
|
4709
|
-
target: targetOf(cfg),
|
|
4710
|
-
sink: resolveSink(),
|
|
4711
|
-
// A fresh per-open id each fire; the emitter's once-guard dedupes within the open.
|
|
4712
|
-
userId: opts.userId,
|
|
4713
|
-
deviceKey: opts.deviceKey,
|
|
4714
|
-
sessionCount: opts.sessionCount,
|
|
4715
|
-
appVersion: (_a3 = cfg == null ? void 0 : cfg.appVersion) != null ? _a3 : device.appVersion,
|
|
4716
|
-
platform: Platform.OS,
|
|
4717
|
-
device,
|
|
4718
|
-
meta: opts.meta
|
|
4719
|
-
});
|
|
4720
|
-
};
|
|
4721
|
-
fireSession();
|
|
4722
4727
|
let backgroundedAt = null;
|
|
4723
4728
|
const onChange = (state) => {
|
|
4724
4729
|
if (state === "background" || state === "inactive") {
|
|
@@ -4738,6 +4743,6 @@ var useLifecycleEvents = (config, options = {}) => {
|
|
|
4738
4743
|
}, []);
|
|
4739
4744
|
};
|
|
4740
4745
|
|
|
4741
|
-
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, attributionMetadata, bumpActivationRevalidation, clearPersistedSession, collectDeviceContext, createWireActivation, defaultIllustrations, defaultOnboardingTheme, defaultWireFeatures, deriveAnswers, detectAppVersion, detectNativeModel, deviceIdStorageKey, featuresCacheKey, featuresEqual, fetchWireFeatures, firstOpenStorageKey, getActivationRevalidationVersion, getCurrentSessionId, hashEmailFnv1a, identifyOnboarding, isFeaturesFresh, isOnboardingEnabled, isWireScalar, loadPersistedSession, 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 };
|
|
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 };
|
|
4742
4747
|
//# sourceMappingURL=index.mjs.map
|
|
4743
4748
|
//# sourceMappingURL=index.mjs.map
|