@wireai/activation 0.4.0 → 0.7.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 +1 -1
- package/CHANGELOG.md +57 -0
- package/dist/analytics/index.d.mts +15 -2
- package/dist/analytics/index.d.ts +15 -2
- package/dist/analytics/index.js +181 -13
- package/dist/analytics/index.js.map +1 -1
- package/dist/analytics/index.mjs +179 -14
- package/dist/analytics/index.mjs.map +1 -1
- package/dist/{eventQueue-CA1d8Fmn.d.mts → currentSession-BJBB7i4-.d.mts} +143 -15
- package/dist/{eventQueue-CrNB9gzH.d.ts → currentSession-CxnP7gAa.d.ts} +143 -15
- package/dist/index.d.mts +37 -37
- package/dist/index.d.ts +37 -37
- package/dist/index.js +158 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +149 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/WireOnboarding.tsx +4 -3
- package/src/analytics/analyticsFacade.ts +74 -11
- package/src/analytics/contextEnvelope.ts +13 -7
- package/src/analytics/currentSession.ts +35 -0
- package/src/analytics/index.ts +3 -0
- package/src/context/userContext.ts +210 -0
- package/src/device/appVersion.ts +103 -0
- package/src/device/deviceContext.ts +17 -5
- package/src/identity/userIdentity.ts +5 -0
- package/src/index.ts +23 -0
- package/src/session-analytics/reportSessionStart.ts +7 -0
- package/src/session-analytics/useLifecycleEvents.ts +4 -2
- package/src/session-analytics/useSessionStart.ts +2 -1
- package/src/types.ts +6 -5
package/dist/index.mjs
CHANGED
|
@@ -6,6 +6,12 @@ import { SafeAreaView } from 'react-native-safe-area-context';
|
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
|
|
8
8
|
var __defProp = Object.defineProperty;
|
|
9
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
10
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
11
|
+
}) : x)(function(x) {
|
|
12
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
|
+
});
|
|
9
15
|
var __export = (target, all) => {
|
|
10
16
|
for (var name in all)
|
|
11
17
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -2343,6 +2349,57 @@ var onboardingComponents = [
|
|
|
2343
2349
|
NumberStepperCard,
|
|
2344
2350
|
InterstitialCard
|
|
2345
2351
|
];
|
|
2352
|
+
|
|
2353
|
+
// src/device/appVersion.ts
|
|
2354
|
+
var coerceVersion = (value) => {
|
|
2355
|
+
if (typeof value !== "string") return void 0;
|
|
2356
|
+
const trimmed = value.trim();
|
|
2357
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
2358
|
+
};
|
|
2359
|
+
var runtimeRequire = (moduleName) => {
|
|
2360
|
+
try {
|
|
2361
|
+
if (typeof __require !== "function") return void 0;
|
|
2362
|
+
return __require(moduleName);
|
|
2363
|
+
} catch {
|
|
2364
|
+
return void 0;
|
|
2365
|
+
}
|
|
2366
|
+
};
|
|
2367
|
+
var interop = (mod) => {
|
|
2368
|
+
if (!mod || typeof mod !== "object") return void 0;
|
|
2369
|
+
const def = mod.default;
|
|
2370
|
+
if (def && typeof def === "object") return def;
|
|
2371
|
+
return mod;
|
|
2372
|
+
};
|
|
2373
|
+
var safeInterop = (requireModule, moduleName) => {
|
|
2374
|
+
try {
|
|
2375
|
+
return interop(requireModule(moduleName));
|
|
2376
|
+
} catch {
|
|
2377
|
+
return void 0;
|
|
2378
|
+
}
|
|
2379
|
+
};
|
|
2380
|
+
var detectAppVersion = (requireModule = runtimeRequire) => {
|
|
2381
|
+
try {
|
|
2382
|
+
const constants = safeInterop(requireModule, "expo-constants");
|
|
2383
|
+
if (constants) {
|
|
2384
|
+
const expoConfig = constants.expoConfig;
|
|
2385
|
+
if (expoConfig && typeof expoConfig === "object") {
|
|
2386
|
+
const fromExpoConfig = coerceVersion(expoConfig.version);
|
|
2387
|
+
if (fromExpoConfig) return fromExpoConfig;
|
|
2388
|
+
}
|
|
2389
|
+
const fromNative = coerceVersion(constants.nativeAppVersion);
|
|
2390
|
+
if (fromNative) return fromNative;
|
|
2391
|
+
}
|
|
2392
|
+
const application = safeInterop(requireModule, "expo-application");
|
|
2393
|
+
if (application) {
|
|
2394
|
+
const fromApplication = coerceVersion(application.nativeApplicationVersion);
|
|
2395
|
+
if (fromApplication) return fromApplication;
|
|
2396
|
+
}
|
|
2397
|
+
} catch {
|
|
2398
|
+
}
|
|
2399
|
+
return void 0;
|
|
2400
|
+
};
|
|
2401
|
+
|
|
2402
|
+
// src/device/deviceContext.ts
|
|
2346
2403
|
var deriveFormFactor = (iosIdiom, width, height) => {
|
|
2347
2404
|
if (iosIdiom === "pad") return "tablet";
|
|
2348
2405
|
if (iosIdiom === "phone") return "phone";
|
|
@@ -2412,9 +2469,21 @@ var collectDeviceContext = () => {
|
|
|
2412
2469
|
if (resolved.timeZone) ctx.timeZone = resolved.timeZone;
|
|
2413
2470
|
} catch {
|
|
2414
2471
|
}
|
|
2472
|
+
const appVersion = detectAppVersion();
|
|
2473
|
+
if (appVersion) ctx.appVersion = appVersion;
|
|
2415
2474
|
return ctx;
|
|
2416
2475
|
};
|
|
2417
2476
|
|
|
2477
|
+
// src/analytics/currentSession.ts
|
|
2478
|
+
var _currentSessionId;
|
|
2479
|
+
var setCurrentSessionId = (id) => {
|
|
2480
|
+
if (typeof id === "string" && id.length > 0) _currentSessionId = id;
|
|
2481
|
+
};
|
|
2482
|
+
var getCurrentSessionId = () => _currentSessionId;
|
|
2483
|
+
var resetCurrentSessionId = () => {
|
|
2484
|
+
_currentSessionId = void 0;
|
|
2485
|
+
};
|
|
2486
|
+
|
|
2418
2487
|
// src/session/persistedSession.ts
|
|
2419
2488
|
var DEFAULT_SESSION_TTL_MS = 36e5;
|
|
2420
2489
|
var READ_TIMEOUT_MS = 1500;
|
|
@@ -2493,6 +2562,7 @@ var identifyOnboarding = async (opts) => {
|
|
|
2493
2562
|
contextId = stored == null ? void 0 : stored.id;
|
|
2494
2563
|
}
|
|
2495
2564
|
}
|
|
2565
|
+
if (!contextId) contextId = getCurrentSessionId();
|
|
2496
2566
|
if (!contextId) return false;
|
|
2497
2567
|
reportClientEvent(
|
|
2498
2568
|
{ serverUrl: opts.config.serverUrl, apiKey: opts.config.apiKey },
|
|
@@ -3149,6 +3219,80 @@ var attributionMetadata = (a) => {
|
|
|
3149
3219
|
return { attribution };
|
|
3150
3220
|
};
|
|
3151
3221
|
|
|
3222
|
+
// src/context/userContext.ts
|
|
3223
|
+
var RESERVED_USER_CONTEXT_KEYS = [
|
|
3224
|
+
"device_key",
|
|
3225
|
+
"app_version",
|
|
3226
|
+
"app_build",
|
|
3227
|
+
"network_type",
|
|
3228
|
+
"session_count",
|
|
3229
|
+
"returning",
|
|
3230
|
+
"platform",
|
|
3231
|
+
"user_email",
|
|
3232
|
+
"user_email_hashed"
|
|
3233
|
+
];
|
|
3234
|
+
var EXTRA_KEY_PREFIX = "custom.";
|
|
3235
|
+
var isWireScalar = (value) => {
|
|
3236
|
+
const t = typeof value;
|
|
3237
|
+
if (t === "string" || t === "boolean") return true;
|
|
3238
|
+
if (t === "number") return Number.isFinite(value);
|
|
3239
|
+
return false;
|
|
3240
|
+
};
|
|
3241
|
+
var hashEmailFnv1a = (email) => {
|
|
3242
|
+
const normalized = email.trim().toLowerCase();
|
|
3243
|
+
let hash = 2166136261;
|
|
3244
|
+
for (let i = 0; i < normalized.length; i++) {
|
|
3245
|
+
hash ^= normalized.charCodeAt(i);
|
|
3246
|
+
hash = Math.imul(hash, 16777619);
|
|
3247
|
+
}
|
|
3248
|
+
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
3249
|
+
};
|
|
3250
|
+
var cleanString = (value) => {
|
|
3251
|
+
if (typeof value !== "string") return void 0;
|
|
3252
|
+
const trimmed = value.trim();
|
|
3253
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
3254
|
+
};
|
|
3255
|
+
var namespaceExtra = (extra) => {
|
|
3256
|
+
const out = {};
|
|
3257
|
+
if (!extra || typeof extra !== "object") return out;
|
|
3258
|
+
for (const [key, value] of Object.entries(extra)) {
|
|
3259
|
+
const cleanKey = cleanString(key);
|
|
3260
|
+
if (!cleanKey) continue;
|
|
3261
|
+
if (!isWireScalar(value)) continue;
|
|
3262
|
+
out[`${EXTRA_KEY_PREFIX}${cleanKey}`] = value;
|
|
3263
|
+
}
|
|
3264
|
+
return out;
|
|
3265
|
+
};
|
|
3266
|
+
var resolveUserContext = (ctx = {}, opts = {}) => {
|
|
3267
|
+
var _a;
|
|
3268
|
+
const result = {};
|
|
3269
|
+
const bucket = {};
|
|
3270
|
+
const userId = sanitizeUserId(ctx.userId);
|
|
3271
|
+
if (userId) result.userId = userId;
|
|
3272
|
+
const deviceKey = cleanString(ctx.deviceKey);
|
|
3273
|
+
if (deviceKey) {
|
|
3274
|
+
result.deviceKey = deviceKey;
|
|
3275
|
+
bucket.device_key = deviceKey;
|
|
3276
|
+
}
|
|
3277
|
+
const appVersion = (_a = cleanString(ctx.appVersion)) != null ? _a : cleanString(opts.autoAppVersion);
|
|
3278
|
+
if (appVersion) {
|
|
3279
|
+
result.appVersion = appVersion;
|
|
3280
|
+
bucket.app_version = appVersion;
|
|
3281
|
+
}
|
|
3282
|
+
const email = cleanString(ctx.userEmail);
|
|
3283
|
+
if (email) {
|
|
3284
|
+
if (ctx.hashEmail) {
|
|
3285
|
+
bucket.user_email = hashEmailFnv1a(email);
|
|
3286
|
+
bucket.user_email_hashed = true;
|
|
3287
|
+
} else {
|
|
3288
|
+
bucket.user_email = email;
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
Object.assign(bucket, namespaceExtra(ctx.extra));
|
|
3292
|
+
if (Object.keys(bucket).length > 0) result.userContext = bucket;
|
|
3293
|
+
return result;
|
|
3294
|
+
};
|
|
3295
|
+
|
|
3152
3296
|
// src/session-analytics/reportSessionStart.ts
|
|
3153
3297
|
var SESSION_STARTED_EVENT = "app.session_started";
|
|
3154
3298
|
var _emitted = /* @__PURE__ */ new Set();
|
|
@@ -3161,6 +3305,7 @@ var reportSessionStart = (opts) => {
|
|
|
3161
3305
|
const target = opts.target;
|
|
3162
3306
|
if (!opts.sink && !(target == null ? void 0 : target.serverUrl)) return;
|
|
3163
3307
|
const sessionId = (_a = opts.sessionId) != null ? _a : makeSessionId();
|
|
3308
|
+
setCurrentSessionId(sessionId);
|
|
3164
3309
|
if (opts.once !== false) {
|
|
3165
3310
|
if (_emitted.has(sessionId)) return;
|
|
3166
3311
|
if (_emitted.size >= _GUARD_MAX) {
|
|
@@ -3217,7 +3362,7 @@ var useSessionStart = (config, options = {}) => {
|
|
|
3217
3362
|
if (opts.enabled === false) return;
|
|
3218
3363
|
const target = { serverUrl: cfg.serverUrl, apiKey: (_a = cfg.apiKey) != null ? _a : "" };
|
|
3219
3364
|
const device = collectDeviceContext();
|
|
3220
|
-
if (cfg.appVersion
|
|
3365
|
+
if (cfg.appVersion) device.appVersion = cfg.appVersion;
|
|
3221
3366
|
reportSessionStart({
|
|
3222
3367
|
target,
|
|
3223
3368
|
// A fresh per-open id each fire; the emitter's once-guard dedupes within the open.
|
|
@@ -3591,7 +3736,7 @@ var useLifecycleEvents = (config, options = {}) => {
|
|
|
3591
3736
|
const { config: cfg, options: opts } = latest.current;
|
|
3592
3737
|
if (opts.enabled !== false) {
|
|
3593
3738
|
const device = collectDeviceContext();
|
|
3594
|
-
if (
|
|
3739
|
+
if (cfg == null ? void 0 : cfg.appVersion) device.appVersion = cfg.appVersion;
|
|
3595
3740
|
reportFirstOpen({
|
|
3596
3741
|
target: targetOf(cfg),
|
|
3597
3742
|
sink: resolveSink(),
|
|
@@ -3613,7 +3758,7 @@ var useLifecycleEvents = (config, options = {}) => {
|
|
|
3613
3758
|
if (opts.enabled === false) return;
|
|
3614
3759
|
if (!(cfg == null ? void 0 : cfg.serverUrl) && !opts.sink) return;
|
|
3615
3760
|
const device = collectDeviceContext();
|
|
3616
|
-
if (
|
|
3761
|
+
if (cfg == null ? void 0 : cfg.appVersion) device.appVersion = cfg.appVersion;
|
|
3617
3762
|
reportSessionStart({
|
|
3618
3763
|
target: targetOf(cfg),
|
|
3619
3764
|
sink: resolveSink(),
|
|
@@ -3647,6 +3792,6 @@ var useLifecycleEvents = (config, options = {}) => {
|
|
|
3647
3792
|
}, []);
|
|
3648
3793
|
};
|
|
3649
3794
|
|
|
3650
|
-
export { AnimatedSparkle, BACKGROUND_SESSION_MS, CardHandoff, CenteredModal, ChipSelectCard, CompletionView, DEFAULT_FEATURES_TTL_MS, DEFAULT_SESSION_TTL_MS, DemoOnboarding, DoneBlock, ErrorBlock, FIRST_OPEN_EVENT, IllustrationProvider, InterstitialCard, LoadingBlock, LoadingScreen, NumberStepperCard, Button as OnboardingButton, OnboardingFlow, OnboardingScaffold, OnboardingThemeProvider, SESSION_STARTED_EVENT, SelectionCard, StatusCard, StepProgress, TextInputCard, USER_ID_MAX_LENGTH, WIRE_ONBOARDING_EVENTS, WireFeaturesProvider, WireOnboarding, attributionMetadata, clearPersistedSession, collectDeviceContext, defaultIllustrations, defaultOnboardingTheme, defaultWireFeatures, deriveAnswers, featuresCacheKey, featuresEqual, fetchWireFeatures, firstOpenStorageKey, identifyOnboarding, isFeaturesFresh, isOnboardingEnabled, loadPersistedSession, makeSessionId, mergeTheme, motionSpec_exports as motionSpec, onboardingComponents, parseWireFeatures, peekPersistedSession, readCachedFeatures, readProgress, reportClientEvent, reportClientEvents, reportFirstOpen, reportSessionStart, resetFirstOpenLatch, resetSessionStartGuard, sanitizeUserId, savePersistedSession, sessionStorageKey, themeFromBrand, toAnalyticsEvent, useIllustration, useLifecycleEvents, useOnboardingTheme, useReducedMotion, useResolvedFeatures, useSessionStart, useWireFeatures, useWireFeaturesContext, wireConfigFromEnv, wireLifecycleEvents, writeCachedFeatures };
|
|
3795
|
+
export { AnimatedSparkle, BACKGROUND_SESSION_MS, CardHandoff, CenteredModal, ChipSelectCard, CompletionView, DEFAULT_FEATURES_TTL_MS, DEFAULT_SESSION_TTL_MS, DemoOnboarding, DoneBlock, EXTRA_KEY_PREFIX, ErrorBlock, FIRST_OPEN_EVENT, 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_ONBOARDING_EVENTS, WireFeaturesProvider, WireOnboarding, attributionMetadata, clearPersistedSession, collectDeviceContext, defaultIllustrations, defaultOnboardingTheme, defaultWireFeatures, deriveAnswers, detectAppVersion, featuresCacheKey, featuresEqual, fetchWireFeatures, firstOpenStorageKey, getCurrentSessionId, hashEmailFnv1a, identifyOnboarding, isFeaturesFresh, isOnboardingEnabled, isWireScalar, loadPersistedSession, makeSessionId, mergeTheme, motionSpec_exports as motionSpec, namespaceExtra, onboardingComponents, parseWireFeatures, peekPersistedSession, readCachedFeatures, readProgress, reportClientEvent, reportClientEvents, reportFirstOpen, reportSessionStart, resetCurrentSessionId, resetFirstOpenLatch, resetSessionStartGuard, resolveUserContext, sanitizeUserId, savePersistedSession, sessionStorageKey, setCurrentSessionId, themeFromBrand, toAnalyticsEvent, useIllustration, useLifecycleEvents, useOnboardingTheme, useReducedMotion, useResolvedFeatures, useSessionStart, useWireFeatures, useWireFeaturesContext, wireConfigFromEnv, wireLifecycleEvents, writeCachedFeatures };
|
|
3651
3796
|
//# sourceMappingURL=index.mjs.map
|
|
3652
3797
|
//# sourceMappingURL=index.mjs.map
|