Skip to content

refactor(react-native-plugin): drop unused setupNativeSdk method param, accept projectToken on Android - #5214

Merged
turnipdabeets merged 2 commits into
chore/rn-plugin-v3from
refactor/rn-plugin-setup-cleanup
Oct 6, 2026
Merged

turnipdabeets merged 2 commits into
chore/rn-plugin-v3from
refactor/rn-plugin-setup-cleanup

Conversation

@turnipdabeets

@turnipdabeets turnipdabeets commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Stacked on #5194. Two leftovers from removing start(), flagged in review:

  • setupNativeSdk still takes a method parameter, but setup is now its only caller.
  • iOS reads sdkOptions["projectToken"], which the RN SDK never sends. The RN SDK is meant to move from apiKey to projectToken, though, so the right fix is to accept both keys on both platforms rather than drop it. Android reads only apiKey.

Changes

  • Removed the method parameter from setupNativeSdk on iOS and Android. The Android error log now names "setup" directly.
  • Android reads projectToken first and falls back to apiKey, matching iOS. iOS is unchanged.

The RN SDK still sends apiKey, so nothing changes for apps and no changeset is needed. #5194 carries the major-bump changesets.

Follow-up: when the RN SDK switches to sending only projectToken, it also needs to raise its @posthog/react-native-plugin floor from >= 2.9.3 to >= 3.0.0, because plugin v2 on Android reads only apiKey.

Release info Sub-libraries affected

Libraries affected

  • All of them
  • posthog-js (web)
  • posthog-js-lite (web lite)
  • posthog-node
  • posthog-react-native
  • @posthog/react-native-plugin
  • @posthog/react
  • @posthog/ai
  • @posthog/convex
  • @posthog/next
  • @posthog/nextjs-config
  • @posthog/nuxt
  • @posthog/openfeature-node-provider
  • @posthog/openfeature-web-provider
  • @posthog/rollup-plugin
  • @posthog/webpack-plugin
  • @posthog/types
  • @posthog/browser-common

Checklist

  • Tests for new code
  • Accounted for the impact of any changes across different platforms
  • Accounted for backwards compatibility of any changes (no breaking changes!)
  • Took care not to unnecessarily increase the bundle size

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Claude Code applied the two review leftovers from #5194. It kept setupNativeSdk as a separate function and did not inline it into setup, which keeps the diff small. It first dropped the iOS projectToken fallback as dead, then restored it and added it on Android after the reviewer pointed out the RN SDK will move to projectToken. It did not compile or test anything locally, so CI is the check.

🤖 Generated with Claude Code

…m and projectToken key

Both were left over from removing start(); the JS layer only calls setup and only sends apiKey.
@turnipdabeets turnipdabeets self-assigned this Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor
⚠️ `@posthog/react-native-plugin` is modified but this PR has no changeset

This is informational — the PR is not blocked. Click the triangle above to collapse, or push a fix and this comment will auto-delete.

Modified in this PR but no changeset added:

  • @posthog/react-native-plugin

If this change should ship, run pnpm changeset and select a bump level.
If it isn't user-facing (refactor with no behavior change, internal tooling, generated files), no action needed.

@turnipdabeets turnipdabeets changed the title refactor(react-native-plugin): drop unused setupNativeSdk method param and projectToken key refactor(react-native-plugin): drop unused setupNativeSdk method param, accept projectToken on Android Oct 6, 2026
@turnipdabeets
turnipdabeets force-pushed the refactor/rn-plugin-setup-cleanup branch from a5abccc to 32e0db6 Compare October 6, 2026 14:15
Keeps the iOS fallback and adds it on Android, so a future RN SDK can send projectToken.
@turnipdabeets
turnipdabeets force-pushed the refactor/rn-plugin-setup-cleanup branch from 32e0db6 to 9689368 Compare October 6, 2026 14:16
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

📝 No Changeset Found

This PR doesn't include a changeset. A changeset is required to release a new version.

How to add a changeset

Run this command and follow the prompts:

pnpm changeset

Remember: Never use major version bumps for posthog-js as it's autoloaded by clients.

@turnipdabeets
turnipdabeets marked this pull request as ready for review October 6, 2026 14:18
@turnipdabeets
turnipdabeets requested a review from a team as a code owner October 6, 2026 14:18
@turnipdabeets
turnipdabeets merged commit 51ecdc8 into chore/rn-plugin-v3 Oct 6, 2026
69 of 71 checks passed
@turnipdabeets
turnipdabeets deleted the refactor/rn-plugin-setup-cleanup branch October 6, 2026 22:38
turnipdabeets added a commit that referenced this pull request Oct 20, 2026
…m, accept projectToken on Android (#5214)

* refactor(react-native-plugin): drop unused setupNativeSdk method param and projectToken key

Both were left over from removing start(); the JS layer only calls setup and only sends apiKey.

* refactor(react-native-plugin): accept projectToken on both platforms

Keeps the iOS fallback and adds it on Android, so a future RN SDK can send projectToken.
turnipdabeets added a commit that referenced this pull request Oct 26, 2026
…m, accept projectToken on Android (#5214)

* refactor(react-native-plugin): drop unused setupNativeSdk method param and projectToken key

Both were left over from removing start(); the JS layer only calls setup and only sends apiKey.

* refactor(react-native-plugin): accept projectToken on both platforms

Keeps the iOS fallback and adds it on Android, so a future RN SDK can send projectToken.
turnipdabeets added a commit that referenced this pull request Oct 31, 2026
…m, accept projectToken on Android (#5214)

* refactor(react-native-plugin): drop unused setupNativeSdk method param and projectToken key

Both were left over from removing start(); the JS layer only calls setup and only sends apiKey.

* refactor(react-native-plugin): accept projectToken on both platforms

Keeps the iOS fallback and adds it on Android, so a future RN SDK can send projectToken.
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