Repository navigation
feat(react-native): add setAppLanguage() for $app_language - #5601
turnipdabeets wants to merge 6 commits into
Conversation
Stamp the language the app displays on JS events and forward it to @posthog/react-native-plugin when the method exists, so native events agree.
Coherence📄 0 spec file errors · ⛔ 0 broken rules · 🚪 2 unchecked inputs · 🐛 0 bugs that came back What is Coherence?Coherence compares the code with its spec files ( This check read 44 parts of the code and 7 rules. Note These findings do not make this check fail. None of these findings are in files that this pull request changes. You do not need to fix them in this pull request. 🚪 Unchecked inputs (2)
What this means and how to fix itInput from outside this code comes in at these places. The spec does not say what checks that input. 10 more places were already like this when Coherence was added. This list does not show them. To close one of these, find the place by its name in the
To get the line to add, run |
SDK performance: posthog-nodeBenchmarks completed. No changes flagged for review. Flags require at least a 5% change in the median and all six pairs agreeing on direction. This is a noise filter, not proof of a performance change or a CI gate. View all results
Values are medians of paired measurements. Not flagged does not mean unchanged. Unavailable means a measurement could not be provided, not zero. Estimated allocation measurements retain their instrumentation uncertainty. RSS measures the whole process, not just SDK allocations; observed peaks are sampled checkpoints. Paired ranges in the diagnostics describe variability, not confidence intervals. Each shard uses its own runner; compare Before PR against With PR within a row, not across shards. Compared 102 metric rows; 102 rows shown in all results. Omitted or shortened data remain in |
There was a problem hiding this comment.
PostHog Review · Standard · reviewed b20440d: 4 Should fix.
See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.
…old-start push opens carry it
Problem
React Native events send no
$app_language, and there's no way to set it. posthog-ios, posthog-android and posthog-flutter all havesetAppLanguage(). RN apps usually translate in JavaScript (i18next and similar), so the SDK can't detect the language on screen; the app has to tell us.The app tells us the language it displays, usually from its i18n library:
Changes
setAppLanguage(language: string | null)to the RN client, matching the native SDKs: trims, replaces_with-, blank ornullclears it, kept in memory only, survivesreset(). Aregister()ed,registerForSession()ed or per-event$app_languagewins over it, like on iOS/Android. Without a call, events carry no$app_language(unchanged).@posthog/react-native-pluginso native events (crashes, push opens) agree. Changes go through the existing ordered native command queue. The current value (ornull) also goes in the nativesetup()options, which the plugin applies before setup, so the push open that cold-launches the app carries it and a value an earlier client left is cleared.plugin.setAppLanguage?.()); JS events are still stamped. Covered by a test. They ignore the extraappLanguagesetup option.PostHogReactNativePluginExtendedas optional, so this ships frommainindependently of the plugin PR.references/posthog-react-native-references-latest.json.Native side (turns off native detection, adds the bridge method): #5602 against
chore/rn-plugin-v3.Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
setAppLanguage(feat!: report the device language as $locale and add $app_language posthog-flutter#699) and the nativesetAppLanguagein posthog-ios / posthog-android 4.0.test/app-language.spec.ts(normalization, clear, survivesreset(),register()andregisterForSession()win, sent in the native setup options includingnull, cross-project isolation, plugin without the method). Mutation-checked: dropping theregister()orregisterForSession()check each fail a test. Full RN suite, lint andcheck-typespass.🤖 Generated with Claude Code