Skip to content

feat(analytics-react-native): add dependency tests and unpin analytics-core#1735

Draft
Mercy811 wants to merge 2 commits intomainfrom
cursor/add-rn-dependency-tests-c0d7
Draft

feat(analytics-react-native): add dependency tests and unpin analytics-core#1735
Mercy811 wants to merge 2 commits intomainfrom
cursor/add-rn-dependency-tests-c0d7

Conversation

@Mercy811
Copy link
Copy Markdown
Contributor

@Mercy811 Mercy811 commented May 6, 2026

Summary

This PR adds comprehensive dependency compatibility tests for @amplitude/analytics-react-native to prevent breaking changes from @amplitude/analytics-core upgrades, specifically addressing the issue reported in #181.

Changes:

  1. Added dependency compatibility tests (test/dependency-compatibility.test.ts) that verify:

    • All required functions and classes from @amplitude/analytics-core are exported
    • Type exports are available for TypeScript compilation
    • getGlobalScope works correctly when document is undefined (React Native environment)
    • CookieStorage handles missing document gracefully without throwing errors
    • Core utilities like MemoryStorage, FetchTransport, UUID, Revenue, and Identify work correctly
    • Specific regression test for issue fix: add callable queue when init is pending #181 (getGlobalScope/document.cookie crash in Expo)
  2. Unpinned @amplitude/analytics-core from 2.41.5 back to workspace:* - now that dependency testing is in place, breaking changes will be caught in CI before they can affect React Native users

Context:

Previously, a breaking change in analytics-core caused crashes in Expo/React Native apps due to CookieStorage attempting to access document.cookie when document was undefined. The fix was implemented in PR #1594, and analytics-core was pinned in PR #1596 as a temporary measure.

This PR allows us to safely unpin analytics-core by ensuring that similar issues will be caught in CI going forward.

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?: No

Slack Thread

Open in Web Open in Cursor 

…s-core

- Add comprehensive dependency compatibility tests for @amplitude/analytics-core
- Tests verify core exports, React Native environment compatibility, and critical bug regressions
- Specifically prevents issues like #181 (getGlobalScope/document.cookie crash in Expo)
- Unpin @amplitude/analytics-core from 2.41.5 to workspace:* now that tests catch breaking changes
- Tests run in both web and mobile environments to ensure compatibility
- Related to Linear ticket SDKRN-2
Use type assertion instead of non-null assertion to satisfy TypeScript
strict null checking in dependency-compatibility tests.
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.

2 participants