@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.js
CHANGED
|
@@ -12,6 +12,12 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
12
12
|
var React14__default = /*#__PURE__*/_interopDefault(React14);
|
|
13
13
|
|
|
14
14
|
var __defProp = Object.defineProperty;
|
|
15
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
16
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
17
|
+
}) : x)(function(x) {
|
|
18
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
19
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
20
|
+
});
|
|
15
21
|
var __export = (target, all) => {
|
|
16
22
|
for (var name in all)
|
|
17
23
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -2349,6 +2355,57 @@ var onboardingComponents = [
|
|
|
2349
2355
|
NumberStepperCard,
|
|
2350
2356
|
InterstitialCard
|
|
2351
2357
|
];
|
|
2358
|
+
|
|
2359
|
+
// src/device/appVersion.ts
|
|
2360
|
+
var coerceVersion = (value) => {
|
|
2361
|
+
if (typeof value !== "string") return void 0;
|
|
2362
|
+
const trimmed = value.trim();
|
|
2363
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
2364
|
+
};
|
|
2365
|
+
var runtimeRequire = (moduleName) => {
|
|
2366
|
+
try {
|
|
2367
|
+
if (typeof __require !== "function") return void 0;
|
|
2368
|
+
return __require(moduleName);
|
|
2369
|
+
} catch {
|
|
2370
|
+
return void 0;
|
|
2371
|
+
}
|
|
2372
|
+
};
|
|
2373
|
+
var interop = (mod) => {
|
|
2374
|
+
if (!mod || typeof mod !== "object") return void 0;
|
|
2375
|
+
const def = mod.default;
|
|
2376
|
+
if (def && typeof def === "object") return def;
|
|
2377
|
+
return mod;
|
|
2378
|
+
};
|
|
2379
|
+
var safeInterop = (requireModule, moduleName) => {
|
|
2380
|
+
try {
|
|
2381
|
+
return interop(requireModule(moduleName));
|
|
2382
|
+
} catch {
|
|
2383
|
+
return void 0;
|
|
2384
|
+
}
|
|
2385
|
+
};
|
|
2386
|
+
var detectAppVersion = (requireModule = runtimeRequire) => {
|
|
2387
|
+
try {
|
|
2388
|
+
const constants = safeInterop(requireModule, "expo-constants");
|
|
2389
|
+
if (constants) {
|
|
2390
|
+
const expoConfig = constants.expoConfig;
|
|
2391
|
+
if (expoConfig && typeof expoConfig === "object") {
|
|
2392
|
+
const fromExpoConfig = coerceVersion(expoConfig.version);
|
|
2393
|
+
if (fromExpoConfig) return fromExpoConfig;
|
|
2394
|
+
}
|
|
2395
|
+
const fromNative = coerceVersion(constants.nativeAppVersion);
|
|
2396
|
+
if (fromNative) return fromNative;
|
|
2397
|
+
}
|
|
2398
|
+
const application = safeInterop(requireModule, "expo-application");
|
|
2399
|
+
if (application) {
|
|
2400
|
+
const fromApplication = coerceVersion(application.nativeApplicationVersion);
|
|
2401
|
+
if (fromApplication) return fromApplication;
|
|
2402
|
+
}
|
|
2403
|
+
} catch {
|
|
2404
|
+
}
|
|
2405
|
+
return void 0;
|
|
2406
|
+
};
|
|
2407
|
+
|
|
2408
|
+
// src/device/deviceContext.ts
|
|
2352
2409
|
var deriveFormFactor = (iosIdiom, width, height) => {
|
|
2353
2410
|
if (iosIdiom === "pad") return "tablet";
|
|
2354
2411
|
if (iosIdiom === "phone") return "phone";
|
|
@@ -2418,9 +2475,21 @@ var collectDeviceContext = () => {
|
|
|
2418
2475
|
if (resolved.timeZone) ctx.timeZone = resolved.timeZone;
|
|
2419
2476
|
} catch {
|
|
2420
2477
|
}
|
|
2478
|
+
const appVersion = detectAppVersion();
|
|
2479
|
+
if (appVersion) ctx.appVersion = appVersion;
|
|
2421
2480
|
return ctx;
|
|
2422
2481
|
};
|
|
2423
2482
|
|
|
2483
|
+
// src/analytics/currentSession.ts
|
|
2484
|
+
var _currentSessionId;
|
|
2485
|
+
var setCurrentSessionId = (id) => {
|
|
2486
|
+
if (typeof id === "string" && id.length > 0) _currentSessionId = id;
|
|
2487
|
+
};
|
|
2488
|
+
var getCurrentSessionId = () => _currentSessionId;
|
|
2489
|
+
var resetCurrentSessionId = () => {
|
|
2490
|
+
_currentSessionId = void 0;
|
|
2491
|
+
};
|
|
2492
|
+
|
|
2424
2493
|
// src/session/persistedSession.ts
|
|
2425
2494
|
var DEFAULT_SESSION_TTL_MS = 36e5;
|
|
2426
2495
|
var READ_TIMEOUT_MS = 1500;
|
|
@@ -2499,6 +2568,7 @@ var identifyOnboarding = async (opts) => {
|
|
|
2499
2568
|
contextId = stored == null ? void 0 : stored.id;
|
|
2500
2569
|
}
|
|
2501
2570
|
}
|
|
2571
|
+
if (!contextId) contextId = getCurrentSessionId();
|
|
2502
2572
|
if (!contextId) return false;
|
|
2503
2573
|
reportClientEvent(
|
|
2504
2574
|
{ serverUrl: opts.config.serverUrl, apiKey: opts.config.apiKey },
|
|
@@ -3155,6 +3225,80 @@ var attributionMetadata = (a) => {
|
|
|
3155
3225
|
return { attribution };
|
|
3156
3226
|
};
|
|
3157
3227
|
|
|
3228
|
+
// src/context/userContext.ts
|
|
3229
|
+
var RESERVED_USER_CONTEXT_KEYS = [
|
|
3230
|
+
"device_key",
|
|
3231
|
+
"app_version",
|
|
3232
|
+
"app_build",
|
|
3233
|
+
"network_type",
|
|
3234
|
+
"session_count",
|
|
3235
|
+
"returning",
|
|
3236
|
+
"platform",
|
|
3237
|
+
"user_email",
|
|
3238
|
+
"user_email_hashed"
|
|
3239
|
+
];
|
|
3240
|
+
var EXTRA_KEY_PREFIX = "custom.";
|
|
3241
|
+
var isWireScalar = (value) => {
|
|
3242
|
+
const t = typeof value;
|
|
3243
|
+
if (t === "string" || t === "boolean") return true;
|
|
3244
|
+
if (t === "number") return Number.isFinite(value);
|
|
3245
|
+
return false;
|
|
3246
|
+
};
|
|
3247
|
+
var hashEmailFnv1a = (email) => {
|
|
3248
|
+
const normalized = email.trim().toLowerCase();
|
|
3249
|
+
let hash = 2166136261;
|
|
3250
|
+
for (let i = 0; i < normalized.length; i++) {
|
|
3251
|
+
hash ^= normalized.charCodeAt(i);
|
|
3252
|
+
hash = Math.imul(hash, 16777619);
|
|
3253
|
+
}
|
|
3254
|
+
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
3255
|
+
};
|
|
3256
|
+
var cleanString = (value) => {
|
|
3257
|
+
if (typeof value !== "string") return void 0;
|
|
3258
|
+
const trimmed = value.trim();
|
|
3259
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
3260
|
+
};
|
|
3261
|
+
var namespaceExtra = (extra) => {
|
|
3262
|
+
const out = {};
|
|
3263
|
+
if (!extra || typeof extra !== "object") return out;
|
|
3264
|
+
for (const [key, value] of Object.entries(extra)) {
|
|
3265
|
+
const cleanKey = cleanString(key);
|
|
3266
|
+
if (!cleanKey) continue;
|
|
3267
|
+
if (!isWireScalar(value)) continue;
|
|
3268
|
+
out[`${EXTRA_KEY_PREFIX}${cleanKey}`] = value;
|
|
3269
|
+
}
|
|
3270
|
+
return out;
|
|
3271
|
+
};
|
|
3272
|
+
var resolveUserContext = (ctx = {}, opts = {}) => {
|
|
3273
|
+
var _a;
|
|
3274
|
+
const result = {};
|
|
3275
|
+
const bucket = {};
|
|
3276
|
+
const userId = sanitizeUserId(ctx.userId);
|
|
3277
|
+
if (userId) result.userId = userId;
|
|
3278
|
+
const deviceKey = cleanString(ctx.deviceKey);
|
|
3279
|
+
if (deviceKey) {
|
|
3280
|
+
result.deviceKey = deviceKey;
|
|
3281
|
+
bucket.device_key = deviceKey;
|
|
3282
|
+
}
|
|
3283
|
+
const appVersion = (_a = cleanString(ctx.appVersion)) != null ? _a : cleanString(opts.autoAppVersion);
|
|
3284
|
+
if (appVersion) {
|
|
3285
|
+
result.appVersion = appVersion;
|
|
3286
|
+
bucket.app_version = appVersion;
|
|
3287
|
+
}
|
|
3288
|
+
const email = cleanString(ctx.userEmail);
|
|
3289
|
+
if (email) {
|
|
3290
|
+
if (ctx.hashEmail) {
|
|
3291
|
+
bucket.user_email = hashEmailFnv1a(email);
|
|
3292
|
+
bucket.user_email_hashed = true;
|
|
3293
|
+
} else {
|
|
3294
|
+
bucket.user_email = email;
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
Object.assign(bucket, namespaceExtra(ctx.extra));
|
|
3298
|
+
if (Object.keys(bucket).length > 0) result.userContext = bucket;
|
|
3299
|
+
return result;
|
|
3300
|
+
};
|
|
3301
|
+
|
|
3158
3302
|
// src/session-analytics/reportSessionStart.ts
|
|
3159
3303
|
var SESSION_STARTED_EVENT = "app.session_started";
|
|
3160
3304
|
var _emitted = /* @__PURE__ */ new Set();
|
|
@@ -3167,6 +3311,7 @@ var reportSessionStart = (opts) => {
|
|
|
3167
3311
|
const target = opts.target;
|
|
3168
3312
|
if (!opts.sink && !(target == null ? void 0 : target.serverUrl)) return;
|
|
3169
3313
|
const sessionId = (_a = opts.sessionId) != null ? _a : makeSessionId();
|
|
3314
|
+
setCurrentSessionId(sessionId);
|
|
3170
3315
|
if (opts.once !== false) {
|
|
3171
3316
|
if (_emitted.has(sessionId)) return;
|
|
3172
3317
|
if (_emitted.size >= _GUARD_MAX) {
|
|
@@ -3223,7 +3368,7 @@ var useSessionStart = (config, options = {}) => {
|
|
|
3223
3368
|
if (opts.enabled === false) return;
|
|
3224
3369
|
const target = { serverUrl: cfg.serverUrl, apiKey: (_a = cfg.apiKey) != null ? _a : "" };
|
|
3225
3370
|
const device = collectDeviceContext();
|
|
3226
|
-
if (cfg.appVersion
|
|
3371
|
+
if (cfg.appVersion) device.appVersion = cfg.appVersion;
|
|
3227
3372
|
reportSessionStart({
|
|
3228
3373
|
target,
|
|
3229
3374
|
// A fresh per-open id each fire; the emitter's once-guard dedupes within the open.
|
|
@@ -3597,7 +3742,7 @@ var useLifecycleEvents = (config, options = {}) => {
|
|
|
3597
3742
|
const { config: cfg, options: opts } = latest.current;
|
|
3598
3743
|
if (opts.enabled !== false) {
|
|
3599
3744
|
const device = collectDeviceContext();
|
|
3600
|
-
if (
|
|
3745
|
+
if (cfg == null ? void 0 : cfg.appVersion) device.appVersion = cfg.appVersion;
|
|
3601
3746
|
reportFirstOpen({
|
|
3602
3747
|
target: targetOf(cfg),
|
|
3603
3748
|
sink: resolveSink(),
|
|
@@ -3619,7 +3764,7 @@ var useLifecycleEvents = (config, options = {}) => {
|
|
|
3619
3764
|
if (opts.enabled === false) return;
|
|
3620
3765
|
if (!(cfg == null ? void 0 : cfg.serverUrl) && !opts.sink) return;
|
|
3621
3766
|
const device = collectDeviceContext();
|
|
3622
|
-
if (
|
|
3767
|
+
if (cfg == null ? void 0 : cfg.appVersion) device.appVersion = cfg.appVersion;
|
|
3623
3768
|
reportSessionStart({
|
|
3624
3769
|
target: targetOf(cfg),
|
|
3625
3770
|
sink: resolveSink(),
|
|
@@ -3663,6 +3808,7 @@ exports.DEFAULT_FEATURES_TTL_MS = DEFAULT_FEATURES_TTL_MS;
|
|
|
3663
3808
|
exports.DEFAULT_SESSION_TTL_MS = DEFAULT_SESSION_TTL_MS;
|
|
3664
3809
|
exports.DemoOnboarding = DemoOnboarding;
|
|
3665
3810
|
exports.DoneBlock = DoneBlock;
|
|
3811
|
+
exports.EXTRA_KEY_PREFIX = EXTRA_KEY_PREFIX;
|
|
3666
3812
|
exports.ErrorBlock = ErrorBlock;
|
|
3667
3813
|
exports.FIRST_OPEN_EVENT = FIRST_OPEN_EVENT;
|
|
3668
3814
|
exports.IllustrationProvider = IllustrationProvider;
|
|
@@ -3674,6 +3820,7 @@ exports.OnboardingButton = Button;
|
|
|
3674
3820
|
exports.OnboardingFlow = OnboardingFlow;
|
|
3675
3821
|
exports.OnboardingScaffold = OnboardingScaffold;
|
|
3676
3822
|
exports.OnboardingThemeProvider = OnboardingThemeProvider;
|
|
3823
|
+
exports.RESERVED_USER_CONTEXT_KEYS = RESERVED_USER_CONTEXT_KEYS;
|
|
3677
3824
|
exports.SESSION_STARTED_EVENT = SESSION_STARTED_EVENT;
|
|
3678
3825
|
exports.SelectionCard = SelectionCard;
|
|
3679
3826
|
exports.StatusCard = StatusCard;
|
|
@@ -3690,17 +3837,22 @@ exports.defaultIllustrations = defaultIllustrations;
|
|
|
3690
3837
|
exports.defaultOnboardingTheme = defaultOnboardingTheme;
|
|
3691
3838
|
exports.defaultWireFeatures = defaultWireFeatures;
|
|
3692
3839
|
exports.deriveAnswers = deriveAnswers;
|
|
3840
|
+
exports.detectAppVersion = detectAppVersion;
|
|
3693
3841
|
exports.featuresCacheKey = featuresCacheKey;
|
|
3694
3842
|
exports.featuresEqual = featuresEqual;
|
|
3695
3843
|
exports.fetchWireFeatures = fetchWireFeatures;
|
|
3696
3844
|
exports.firstOpenStorageKey = firstOpenStorageKey;
|
|
3845
|
+
exports.getCurrentSessionId = getCurrentSessionId;
|
|
3846
|
+
exports.hashEmailFnv1a = hashEmailFnv1a;
|
|
3697
3847
|
exports.identifyOnboarding = identifyOnboarding;
|
|
3698
3848
|
exports.isFeaturesFresh = isFeaturesFresh;
|
|
3699
3849
|
exports.isOnboardingEnabled = isOnboardingEnabled;
|
|
3850
|
+
exports.isWireScalar = isWireScalar;
|
|
3700
3851
|
exports.loadPersistedSession = loadPersistedSession;
|
|
3701
3852
|
exports.makeSessionId = makeSessionId;
|
|
3702
3853
|
exports.mergeTheme = mergeTheme;
|
|
3703
3854
|
exports.motionSpec = motionSpec_exports;
|
|
3855
|
+
exports.namespaceExtra = namespaceExtra;
|
|
3704
3856
|
exports.onboardingComponents = onboardingComponents;
|
|
3705
3857
|
exports.parseWireFeatures = parseWireFeatures;
|
|
3706
3858
|
exports.peekPersistedSession = peekPersistedSession;
|
|
@@ -3710,11 +3862,14 @@ exports.reportClientEvent = reportClientEvent;
|
|
|
3710
3862
|
exports.reportClientEvents = reportClientEvents;
|
|
3711
3863
|
exports.reportFirstOpen = reportFirstOpen;
|
|
3712
3864
|
exports.reportSessionStart = reportSessionStart;
|
|
3865
|
+
exports.resetCurrentSessionId = resetCurrentSessionId;
|
|
3713
3866
|
exports.resetFirstOpenLatch = resetFirstOpenLatch;
|
|
3714
3867
|
exports.resetSessionStartGuard = resetSessionStartGuard;
|
|
3868
|
+
exports.resolveUserContext = resolveUserContext;
|
|
3715
3869
|
exports.sanitizeUserId = sanitizeUserId;
|
|
3716
3870
|
exports.savePersistedSession = savePersistedSession;
|
|
3717
3871
|
exports.sessionStorageKey = sessionStorageKey;
|
|
3872
|
+
exports.setCurrentSessionId = setCurrentSessionId;
|
|
3718
3873
|
exports.themeFromBrand = themeFromBrand;
|
|
3719
3874
|
exports.toAnalyticsEvent = toAnalyticsEvent;
|
|
3720
3875
|
exports.useIllustration = useIllustration;
|