Fix the package name and unblock running the RN example against a linked SDK - #42
Merged
Merged
Conversation
Three things stopped this example from building or testing against a local checkout of the SDK: - jest.setup.js mocked "@formo/react-native-analytics" — the package is "@formo/analytics-react-native". The mock therefore matched nothing and both suites failed to run: 0 tests. Now 11 pass. - The README had the same transposed name in its install snippet and import examples, which is almost certainly where the typo came from. - Metro could not resolve the SDK when linked. It honours the package `exports` map, which points at lib/commonjs/index.js, but sdk-react-native/.watchmanconfig lists "lib" in ignore_dirs — so Metro's crawler never sees that file and resolution fails with "none of these files exist" even when the build output is present. `exports` also takes precedence over the `react-native` field that would have avoided this. Resolved by pinning the package to its TypeScript source, which is what the rest of this resolver already assumes: the redirect below it keys on originModulePath being inside sdkPath, which only happens when the SDK is consumed as source. It also means SDK edits hot reload with no rebuild. Verified end to end: `expo start --web` now bundles (2827 modules, HTTP 200), the SDK initialises, and screen/track/lifecycle events reach the ingest API. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
yosriady
added a commit
that referenced
this pull request
Aug 2, 2026
Metro resolver: the redirect added in #42 fired unconditionally, so the package resolved to ../../sdk-react-native/src for ANYONE with a sibling checkout — silently running unreleased local code instead of the pinned version — and resolved to a non-existent path for anyone without one. Caught while verifying the example against the published SDK: it kept reporting unreleased behaviour. Now gated on the node_modules entry actually being a symlink, which is exactly what distinguishes `pnpm add link:` from an install. Verified both ways round: npm install emits app://Wallet (1.0.0), a link emits app://com.formo.analytics.demo/Wallet. Dependency: ^0.1.6 -> ^1.0.0. The caret meant 0.1.6 could never pick up 1.x, so the example was two majors behind. App identity now comes from app.json via expo-constants instead of a hardcoded copy. config/formo.ts claimed version 1.1.0 while app.json said 1.0.0 — and these reach Formo as `app_version` and as the mobile `origin`, so the drift meant every event reported a version the app never had. The test asserted the literal 1.1.0, which is how it went unnoticed; it now asserts the two agree. Kept the explicit app config rather than relying on auto-detection: in Expo Go the native modules report EXPO GO's bundle id and version, and on React Native Web nothing resolves a bundle id at all. README: screen() takes (name, category?, properties?) — the example passed an object where the category string goes, which would have sent [object Object]. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Three separate things stopped
with-react-nativefrom building or testing against a local checkout of the SDK. Found while verifying getformo/sdk-react-native#69 and #70.1. Transposed package name broke the whole test suite
jest.setup.jsmocked@formo/react-native-analytics; the package is@formo/analytics-react-native. The mock matched nothing, so both suites failed to run — 0 tests. Now 11 pass.The README carried the same transposed name in its install snippet and every import example, which is almost certainly where the typo came from. Fixed there too.
2. Metro could not resolve a linked SDK
Metro honours the package
exportsmap, which points atlib/commonjs/index.js— butsdk-react-native/.watchmanconfiglists"lib"inignore_dirs, so Metro's crawler never sees that file. Resolution fails with "none of these files exist" even when the build output is present, which makes it a confusing thing to debug.exportsalso takes precedence over thereact-nativefield that would otherwise have pointed atsrc.Resolved by pinning the package to its TypeScript source. That is what the rest of this resolver already assumes — the redirect immediately below keys on
originModulePathbeing insidesdkPath, which only happens when the SDK is consumed as source. It also means SDK edits hot reload with no rebuild, which is the point of linking.Verification
expo start --webbundles (2827 modules, HTTP 200), the SDK reports Initialized, and screen / track / lifecycle events reachevents.formo.so/v0/raw_events. Confirmed in Tinybird:pageevents withpage_url: app://Home/app://Wallet/app://Events, plusApplication Installed,Application OpenedandDeep Link Openedin spec order.Running it this way is also what surfaced a real bug in the Tinybird pipe (getformo/formono#2033): Expo web reports
os_name: "Mac OS"whenexpo-deviceis installed, not"web", so a Mac browser session was classifying as an iPhone.Not included
The
link:entry inpackage.jsonis intentionally not committed — it holds an absolute path. To run against a local SDK:pnpm add "@formo/analytics-react-native@link:../../sdk-react-native"🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.