Skip to content

chore(react-native-plugin): leave out posthog-ios's Surveys trait - #5238

Closed
turnipdabeets wants to merge 1 commit into
chore/rn-plugin-posthog-ios-4-pinfrom
chore/rn-plugin-posthog-ios-traits
Closed

turnipdabeets wants to merge 1 commit into
chore/rn-plugin-posthog-ios-4-pinfrom
chore/rn-plugin-posthog-ios-traits

Conversation

@turnipdabeets

Copy link
Copy Markdown
Contributor

Problem

posthog-ios 4.0 adds Swift package traits so apps can leave out features they don't use (PostHog/posthog-ios#916 for SessionReplay and CrashReporting, PostHog/posthog-ios#918 for Surveys). All three are on by default.

The plugin never uses posthog-ios's native surveys: it sets config.surveys = false, and React Native surveys are rendered in JS. Today every React Native app still compiles and ships them.

Optional, and only if the traits land in posthog-ios 4.0. Stacked on #5237 (the 4.0 pin). If #916/#918 don't ship, close this: naming traits that don't exist makes package resolution fail.

Changes

  • ios/Package.swift depends on posthog-ios with traits: ["SessionReplay", "CrashReporting"], leaving out Surveys. The plugin needs the other two: React Native replay is the native replay engine, and native crash autocapture comes from CrashReporting.
  • ios/Package.swift moves from tools 6.0 to 6.2. Traits need 6.1+, and posthog-ios 4.0 already requires Xcode 26 (Swift 6.2), so this adds no new requirement.
Install path Gets native surveys?
React Native full SwiftPM (ios/Package.swift) No
CocoaPods (default) Yes. CocoaPods has no traits, so it always gets the full SDK
posthog.useSpm (React Native's spm_dependency helper) Yes. The helper takes no traits, so Xcode uses the defaults

SwiftPM turns a trait on if any package in the app asks for it. If another package or the app depends on posthog-ios with the defaults, Surveys comes back on. Nothing breaks either way; the code just isn't dropped.

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 (no new behavior; manifest check passes)
  • 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)

Made with Claude Code; split out of #5237 so the optional traits change can't block the 4.0 pin. The original change (then in #5226) was checked with examples/example-rn-spm (React Native 0.87.1 full SwiftPM), Debug simulator build on Xcode 26.4.1 against a local 4.0 stack (#873 + #916 + #918): the app contains the replay engine and PLCrashReporter and none of the survey engine or UI types. Not tested: Release builds, running the app.

🤖 Generated with Claude Code

Surveys are rendered in JS; traits need swift-tools 6.1+, and posthog-ios 4.0 already requires Xcode 26.
@turnipdabeets turnipdabeets self-assigned this Oct 7, 2026
@turnipdabeets
turnipdabeets marked this pull request as ready for review October 7, 2026 20:10
@turnipdabeets
turnipdabeets requested a review from a team as a code owner October 7, 2026 20:10
@turnipdabeets

Copy link
Copy Markdown
Contributor Author

Folded into #5237 (cherry-picked as 690bd16).

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