Skip to content

feat(device-utils): add synchronous first-launch tracking API - #331

Merged
huhuanming merged 8 commits into
mainfrom
codex/device-utils-first-launch
Nov 26, 2026
Merged

huhuanming merged 8 commits into
mainfrom
codex/device-utils-first-launch

Conversation

@huhuanming

@huhuanming huhuanming commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds synchronous first-launch tracking to @onekeyfe/react-native-device-utils across iOS, Android, and shared Web/Desktop/Extension (@onekeyfe/react-native-device-utils/first-launch).

Design

  • Fixed 3-field persistence (hasLaunched, highestAppVersion, highestBundleVersion) in a single JSON file on native (onekey-device-utils-first-launch.json) and a single localStorage key on web (onekey:device-utils:first-launch). Storage size is constant and requires no cleanup API.
  • Stable per-launch results: Startup performs a single read disk → freeze current-launch booleans in memory → advance persisted fields pass. Subsequent getter calls within the same process/document read only from memory and stay consistent across main and bg runtimes.
  • Consistent version comparison across Swift, Kotlin, and TypeScript (numeric dot-separated segments + SemVer pre-release ordering); rolling back to a lower version returns false and preserves the higher recorded version.
  • Clean host/library boundary: No app-specific legacy storage paths or auto-startup hooks inside app-modules.
    • iOS: Pure native @objc(OneKeyDeviceUtilsFirstLaunch) singleton (hasPersistedState() + initializeWithOptions(_ options: NSDictionary?)) callable dynamically via NSClassFromString + perform in AppDelegate without importing Nitro C++ headers.
    • Android: Pure Kotlin DeviceUtilsFirstLaunch singleton (hasPersistedState(context) + initialize(context, isLegacyInstall = { ... }, legacyAppVersion = { ... })) for Application.onCreate(), with lazy NitroModules.applicationContext fallback if uninitialized.
    • Web / Desktop / Extension: initFirstLaunch({ appVersion, bundleVersion, isLegacyInstall, legacyAppVersion }) plus zero-arg synchronous getters (isFirstLaunch(), isFirstLaunchForCurrentAppVersion(), isFirstLaunchForCurrentBundle()).

Verification

  • yarn prepare (Nitrogen codegen + ESM + TypeScript declarations)
  • yarn typecheck
  • yarn test (5/5 Jest tests passing)
  • node tests/in-memory-store.cjs --swift (passed)
  • node tests/in-memory-store.cjs --kotlin (passed)

Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

3 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

@sidmorizon

Copy link
Copy Markdown
Contributor

@codex review

@sidmorizon

Copy link
Copy Markdown
Contributor

@codex security review

@sidmorizon

Copy link
Copy Markdown
Contributor

Cursor review failed.

Remote error: cursor_permission_denied: HTTP 403 Forbidden: Cloud Agent is not available for free users. Please upgrade to Pro.

@cursor

cursor Bot commented Nov 26, 2026

Copy link
Copy Markdown

Skipping Bugbot: Bugbot is disabled for this repository. Visit the Bugbot dashboard to update your settings.

@sidmorizon

Copy link
Copy Markdown
Contributor

Devin Cloud review ↗

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T06:22:50.930577Z 6c4fed9 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c4fed9d52

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 6c4fed9d52

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@sidmorizon

Copy link
Copy Markdown
Contributor

@huhuanming
huhuanming enabled auto-merge (squash) November 26, 2026 08:24
@huhuanming
huhuanming merged commit a57f1e2 into main Nov 26, 2026
15 checks passed
@huhuanming
huhuanming deleted the codex/device-utils-first-launch branch November 26, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants