Skip to content

Commit efb1a36

Browse files
feat(source-maps): real React Native test apps (bare + Expo) (#2960)
* feat(source-maps): real React Native test apps (bare + Expo) The wizard is flipping react-native to automatable in the error-tracking-upload-source-maps program, so the stub fixture that existed to exercise the unsupported-platform path is replaced with two real apps, mirroring the ios-pod/ios-spm two-flavour pattern: - react-native/: bare RN 0.86 scaffold (android/ + ios/ projects) with posthog-react-native installed and initialised in App.tsx - react-native-expo/: Expo SDK 57 blank scaffold with posthog-react-native installed and initialised in App.js Both pre-seed .env with the POSTHOG_CLI_* trio like the android and ios-spm apps. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * chore(source-maps): strip RN test apps to minimal shells Drop scaffold extras (README, Gemfile, jest/eslint/prettier configs, tests, Expo assets/LICENSE/AGENTS.md/CLAUDE.md/.claude) and trim package.json to what the upload flow needs: PostHog installed, native projects intact, no source maps configured. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * docs(source-maps): run/build instructions for the RN fixtures Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: reade * fix: readme * fix: package locks * fix: expo prebuilds * fix: dotenvs ignore * fix(source-maps): drop mismatched expo-file-system from Expo fixture ~19.0.7 is the SDK 54 line; the app is Expo SDK 57, so the Release build failed compiling FileSystemLegacyModule.swift against the newer expo-modules-core Promise API. The fixture doesn't need the package — posthog-react-native only uses it opportunistically. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: regenerate prebuild * feat(apps): add native crash triggers to react-native source-map fixtures Both RN fixtures get a 'Trigger native crash' button backed by a tiny native module (RuntimeException on Android, NSException on iOS) so native crash autocapture + symbolication can be verified end to end after a wizard run. Expo uses a local expo-module (autolinked at prebuild); bare RN registers a classic bridge module in both native projects. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent f07c9f4 commit efb1a36

61 files changed

Lines changed: 14208 additions & 4 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
2+
3+
# dependencies
4+
node_modules/
5+
6+
# Expo
7+
.expo/
8+
dist/
9+
web-build/
10+
expo-env.d.ts
11+
12+
# Native
13+
.kotlin/
14+
*.orig.*
15+
*.jks
16+
*.p8
17+
*.p12
18+
*.key
19+
*.mobileprovision
20+
21+
# Metro
22+
.metro-health-check*
23+
24+
# debug
25+
npm-debug.*
26+
yarn-debug.*
27+
yarn-error.*
28+
29+
# macOS
30+
.DS_Store
31+
*.pem
32+
33+
# local env files
34+
.env*.local
35+
36+
# typescript
37+
*.tsbuildinfo
38+
39+
# generated native folders
40+
/ios
41+
/android
42+
43+
.env
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { StatusBar } from 'expo-status-bar';
2+
import { PostHogProvider } from 'posthog-react-native';
3+
import { Button, StyleSheet, Text, View } from 'react-native';
4+
import NativeCrashTest from './modules/native-crash-test';
5+
6+
export default function App() {
7+
return (
8+
<PostHogProvider
9+
apiKey="phc_raG2H9V246hkNZk6K89DZGG98qQyPrKKlicifGlpOXA"
10+
options={{ host: 'https://internal-c.posthog.com' }}
11+
>
12+
<View style={styles.container}>
13+
<Text>Open up App.js to start working on your app!</Text>
14+
{/* Crashes the app natively (not a JS error). Only shows up in PostHog
15+
error tracking when native crash autocapture is enabled; the crash
16+
report uploads on the NEXT app launch. */}
17+
<Button title="Trigger native crash" onPress={() => NativeCrashTest.crash()} />
18+
<StatusBar style="auto" />
19+
</View>
20+
</PostHogProvider>
21+
);
22+
}
23+
24+
const styles = StyleSheet.create({
25+
container: {
26+
flex: 1,
27+
backgroundColor: '#fff',
28+
alignItems: 'center',
29+
justifyContent: 'center',
30+
},
31+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Expo source-maps fixture
2+
3+
PostHog SDK installed, no source-map upload configured — run the wizard's
4+
`upload-source-maps` against this app
5+
6+
## Setup
7+
8+
```bash
9+
npm install
10+
```
11+
12+
## Run (dev)
13+
14+
```bash
15+
npx expo start # or: npm run android / npm run ios
16+
```
17+
18+
## Build Release (uploads only fire on Release native builds)
19+
20+
```bash
21+
npx expo prebuild # generates android/ and ios/
22+
23+
npx expo run:android --variant release
24+
npx expo run:ios --configuration Release
25+
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"expo": {
3+
"name": "react-native-expo",
4+
"slug": "react-native-expo",
5+
"version": "1.0.0",
6+
"orientation": "portrait",
7+
"userInterfaceStyle": "light",
8+
"ios": {
9+
"supportsTablet": true,
10+
"bundleIdentifier": "com.ablaszkiewicz.reactnativeexpo"
11+
},
12+
"android": {
13+
"package": "com.ablaszkiewicz.reactnativeexpo"
14+
}
15+
}
16+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { registerRootComponent } from 'expo';
2+
3+
import App from './App';
4+
5+
// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
6+
// It also ensures that whether you load the app in Expo Go or in a native build,
7+
// the environment is set up appropriately
8+
registerRootComponent(App);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
plugins {
2+
id 'com.android.library'
3+
id 'expo-module-gradle-plugin'
4+
}
5+
6+
group = 'expo.modules.nativecrashtest'
7+
version = '1.0.0'
8+
9+
android {
10+
namespace "expo.modules.nativecrashtest"
11+
defaultConfig {
12+
versionCode 1
13+
versionName '1.0.0'
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package expo.modules.nativecrashtest
2+
3+
import android.os.Handler
4+
import android.os.Looper
5+
import expo.modules.kotlin.modules.Module
6+
import expo.modules.kotlin.modules.ModuleDefinition
7+
8+
class NativeCrashTestModule : Module() {
9+
override fun definition() = ModuleDefinition {
10+
Name("NativeCrashTest")
11+
12+
// Posts to the main thread so the exception escapes React Native's
13+
// native-module call guards and crashes the app as a real uncaught
14+
// JVM exception (what PostHog's native crash autocapture records).
15+
Function("crash") {
16+
Handler(Looper.getMainLooper()).post {
17+
throw RuntimeException("PostHog native crash test (Android)")
18+
}
19+
}
20+
}
21+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"platforms": ["ios", "android"],
3+
"ios": {
4+
"modules": ["NativeCrashTestModule"]
5+
},
6+
"android": {
7+
"modules": ["expo.modules.nativecrashtest.NativeCrashTestModule"]
8+
}
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { requireNativeModule } from 'expo-modules-core';
2+
3+
export default requireNativeModule('NativeCrashTest');
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Pod::Spec.new do |s|
2+
s.name = 'NativeCrashTest'
3+
s.version = '1.0.0'
4+
s.summary = 'Throws a native crash to verify PostHog symbolication'
5+
s.description = 'Test-only local Expo module: crashes the app natively on demand'
6+
s.author = ''
7+
s.homepage = 'https://docs.expo.dev/modules/'
8+
s.platforms = { :ios => '15.1' }
9+
s.source = { git: '' }
10+
s.static_framework = true
11+
12+
s.dependency 'ExpoModulesCore'
13+
14+
s.pod_target_xcconfig = {
15+
'DEFINES_MODULE' => 'YES',
16+
}
17+
18+
s.source_files = '**/*.{h,m,mm,swift,hpp,cpp}'
19+
end

0 commit comments

Comments
 (0)