feat: lifecycle storage + bundle metadata foundation [1/4]#30
Open
choudlet wants to merge 2 commits into
Open
Conversation
Foundational types for the application-lifecycle events feature. Pure additions; no behavior change to MetaRouterAnalyticsClient yet. - LifecycleStorage: SharedPreferences wrapper for (version, build) under com.metarouter.analytics.lifecycle, separate from identity prefs so reset() does not wipe install/update state - IdentityStorage.hasAnyValue(): identifies users that pre-date the lifecycle SDK (existing identity, no lifecycle keys) so the tracker can emit Application Updated instead of Application Installed - IdentityManager.hasAnyValue(): forwarder - AppContext.fromContext(): single-source-of-truth factory that reads PackageManager once. The lifecycle subsystem and DeviceContextProvider will share the cached snapshot so per-event enrichment never re-reads the manifest - LifecycleEventNames / LifecycleEventProperties: extracted constants used by the tracker and (later) the coordinator Refs: sc-38233
This was referenced Apr 27, 2026
choudlet
commented
Apr 27, 2026
| val packageInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { | ||
| packageManager.getPackageInfo(packageName, PackageManager.PackageInfoFlags.of(0)) | ||
| } else { | ||
| @Suppress("DEPRECATION") |
Collaborator
Author
There was a problem hiding this comment.
these are legacy overloads that are required for previous sdk versions and our need to support 23 as our min SDK version
Two small follow-ups from code review on slice 1. - AppContext.fromContext: when the outer PackageManager read fails entirely, derive a best-effort `name` from the last segment of the package id rather than returning literal 'unknown'. Better attribution on ingest dashboards in the rare case the read throws (corrupted install / instrumentation contexts) and matches what most launchers show when applicationLabel resolution fails. - AppContextTest: direct Robolectric coverage for the factory. Slice 1 introduces fromContext standalone — it had no direct tests until now, only transitive coverage via DeviceContextProvider. Refs: sc-38233
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Shortcut: sc-38233
Parent: sc-36799 — Application Lifecycle Events (Android)
iOS reference: sc-38228
Slice 1 of 4 — pure additions, no behavior change yet.
Summary
Foundational types for the lifecycle-events feature. Lands safely on
mainimmediately because nothing references the new types yet — slices 2–4 build on this.LifecycleStorage—SharedPreferenceswrapper for(version, build)undercom.metarouter.analytics.lifecycle, separate from identity prefs soreset()does not wipe install/update state.IdentityStorage.hasAnyValue()— distinguishes a fresh install from a user upgrading from a pre-lifecycle SDK build (existing identity, no lifecycle keys → "Updated unknown→unknown" rather than "Installed").IdentityManager.hasAnyValue()— forwarder used by the tracker (slice 2).AppContext.fromContext(Context)— single-source-of-truth factory that readsPackageManageronce. Slice 3 stopsDeviceContextProviderfrom re-reading the manifest on every event.LifecycleEventNames/LifecycleEventProperties— extracted constants the tracker (slice 2) and coordinator (slice 3) reference.LifecycleStorageTest— round-trip + namespace-isolation coverage.Stack
LifecycleEventTrackeralgorithm + testsMetaRouterAnalyticsClientwiring +openURLpublic APITest plan
./gradlew :metarouter-sdk:testpassesLifecycleStorageTestexercises round-trip + namespace isolationIdentityStorage.clear()does not affect lifecycle prefs (covered in test)AppContext.fromContext(...)returns sane values on a Robolectric application context