mixpanel-react-native 3.1.1 → 3.2.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/.claude/settings.local.json +12 -1
  2. package/.github/dependabot.yml +7 -0
  3. package/.github/workflows/node.js.yml +24 -1
  4. package/.vscode/settings.json +4 -0
  5. package/CHANGELOG.md +11 -0
  6. package/MixpanelReactNative.podspec +1 -1
  7. package/Samples/MixpanelExample/.bundle/config +2 -0
  8. package/Samples/MixpanelExample/.eslintrc.js +4 -0
  9. package/Samples/MixpanelExample/.prettierrc.js +7 -0
  10. package/Samples/MixpanelExample/.watchmanconfig +1 -0
  11. package/Samples/MixpanelExample/App.tsx +143 -0
  12. package/Samples/MixpanelExample/Gemfile +16 -0
  13. package/Samples/MixpanelExample/README.md +97 -0
  14. package/Samples/MixpanelExample/__tests__/App.test.tsx +13 -0
  15. package/Samples/MixpanelExample/android/app/build.gradle +119 -0
  16. package/Samples/MixpanelExample/android/app/debug.keystore +0 -0
  17. package/Samples/MixpanelExample/android/app/proguard-rules.pro +10 -0
  18. package/Samples/MixpanelExample/android/app/src/debug/AndroidManifest.xml +9 -0
  19. package/Samples/MixpanelExample/android/app/src/main/AndroidManifest.xml +26 -0
  20. package/Samples/MixpanelExample/android/app/src/main/java/com/mixpanelexample/MainActivity.kt +22 -0
  21. package/Samples/MixpanelExample/android/app/src/main/java/com/mixpanelexample/MainApplication.kt +44 -0
  22. package/Samples/MixpanelExample/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
  23. package/Samples/MixpanelExample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  24. package/Samples/MixpanelExample/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  25. package/Samples/MixpanelExample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  26. package/Samples/MixpanelExample/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  27. package/Samples/MixpanelExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  28. package/Samples/MixpanelExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  29. package/Samples/MixpanelExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  30. package/Samples/MixpanelExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  31. package/Samples/MixpanelExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  32. package/Samples/MixpanelExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  33. package/Samples/MixpanelExample/android/app/src/main/res/values/strings.xml +3 -0
  34. package/Samples/MixpanelExample/android/app/src/main/res/values/styles.xml +9 -0
  35. package/Samples/MixpanelExample/android/build.gradle +21 -0
  36. package/Samples/MixpanelExample/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  37. package/Samples/MixpanelExample/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  38. package/Samples/MixpanelExample/android/gradle.properties +39 -0
  39. package/Samples/MixpanelExample/android/gradlew +251 -0
  40. package/Samples/MixpanelExample/android/gradlew.bat +94 -0
  41. package/Samples/MixpanelExample/android/settings.gradle +6 -0
  42. package/Samples/MixpanelExample/app.json +4 -0
  43. package/Samples/MixpanelExample/babel.config.js +3 -0
  44. package/Samples/MixpanelExample/index.js +9 -0
  45. package/Samples/MixpanelExample/ios/.xcode.env +11 -0
  46. package/Samples/MixpanelExample/ios/MixpanelExample/AppDelegate.swift +48 -0
  47. package/Samples/MixpanelExample/ios/MixpanelExample/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  48. package/Samples/MixpanelExample/ios/MixpanelExample/Images.xcassets/Contents.json +6 -0
  49. package/Samples/MixpanelExample/ios/MixpanelExample/Info.plist +52 -0
  50. package/Samples/MixpanelExample/ios/MixpanelExample/LaunchScreen.storyboard +47 -0
  51. package/Samples/MixpanelExample/ios/MixpanelExample/PrivacyInfo.xcprivacy +37 -0
  52. package/Samples/MixpanelExample/ios/MixpanelExample.xcodeproj/project.pbxproj +505 -0
  53. package/Samples/MixpanelExample/ios/MixpanelExample.xcodeproj/xcshareddata/xcschemes/MixpanelExample.xcscheme +88 -0
  54. package/Samples/MixpanelExample/ios/MixpanelExample.xcworkspace/contents.xcworkspacedata +10 -0
  55. package/Samples/MixpanelExample/ios/Podfile +35 -0
  56. package/Samples/MixpanelExample/ios/Podfile.lock +1996 -0
  57. package/Samples/MixpanelExample/jest.config.js +3 -0
  58. package/Samples/MixpanelExample/metro.config.js +22 -0
  59. package/Samples/MixpanelExample/package-lock.json +12456 -0
  60. package/Samples/MixpanelExample/package.json +42 -0
  61. package/Samples/MixpanelExample/tsconfig.json +3 -0
  62. package/Samples/MixpanelStarter/.bundle/config +2 -0
  63. package/Samples/MixpanelStarter/.env.example +4 -0
  64. package/Samples/MixpanelStarter/.eslintrc.js +4 -0
  65. package/Samples/MixpanelStarter/.prettierrc.js +5 -0
  66. package/Samples/MixpanelStarter/.watchmanconfig +1 -0
  67. package/Samples/MixpanelStarter/App.tsx +10 -0
  68. package/Samples/MixpanelStarter/CLAUDE.md +538 -0
  69. package/Samples/MixpanelStarter/Gemfile +16 -0
  70. package/Samples/MixpanelStarter/INTEGRATION_GUIDE.md +606 -0
  71. package/Samples/MixpanelStarter/README.md +406 -0
  72. package/Samples/MixpanelStarter/__tests__/MixpanelContext.test.tsx +63 -0
  73. package/Samples/MixpanelStarter/android/app/build.gradle +119 -0
  74. package/Samples/MixpanelStarter/android/app/debug.keystore +0 -0
  75. package/Samples/MixpanelStarter/android/app/proguard-rules.pro +10 -0
  76. package/Samples/MixpanelStarter/android/app/src/main/AndroidManifest.xml +27 -0
  77. package/Samples/MixpanelStarter/android/app/src/main/java/com/mixpanelstarter/MainActivity.kt +22 -0
  78. package/Samples/MixpanelStarter/android/app/src/main/java/com/mixpanelstarter/MainApplication.kt +27 -0
  79. package/Samples/MixpanelStarter/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
  80. package/Samples/MixpanelStarter/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  81. package/Samples/MixpanelStarter/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  82. package/Samples/MixpanelStarter/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  83. package/Samples/MixpanelStarter/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  84. package/Samples/MixpanelStarter/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  85. package/Samples/MixpanelStarter/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  86. package/Samples/MixpanelStarter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  87. package/Samples/MixpanelStarter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  88. package/Samples/MixpanelStarter/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  89. package/Samples/MixpanelStarter/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  90. package/Samples/MixpanelStarter/android/app/src/main/res/values/strings.xml +3 -0
  91. package/Samples/MixpanelStarter/android/app/src/main/res/values/styles.xml +9 -0
  92. package/Samples/MixpanelStarter/android/build.gradle +21 -0
  93. package/Samples/MixpanelStarter/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  94. package/Samples/MixpanelStarter/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  95. package/Samples/MixpanelStarter/android/gradle.properties +44 -0
  96. package/Samples/MixpanelStarter/android/gradlew +251 -0
  97. package/Samples/MixpanelStarter/android/gradlew.bat +99 -0
  98. package/Samples/MixpanelStarter/android/settings.gradle +6 -0
  99. package/Samples/MixpanelStarter/app.json +4 -0
  100. package/Samples/MixpanelStarter/babel.config.js +14 -0
  101. package/Samples/MixpanelStarter/index.js +9 -0
  102. package/Samples/MixpanelStarter/ios/.xcode.env +11 -0
  103. package/Samples/MixpanelStarter/ios/MixpanelStarter/AppDelegate.swift +48 -0
  104. package/Samples/MixpanelStarter/ios/MixpanelStarter/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  105. package/Samples/MixpanelStarter/ios/MixpanelStarter/Images.xcassets/Contents.json +6 -0
  106. package/Samples/MixpanelStarter/ios/MixpanelStarter/Info.plist +55 -0
  107. package/Samples/MixpanelStarter/ios/MixpanelStarter/LaunchScreen.storyboard +47 -0
  108. package/Samples/MixpanelStarter/ios/MixpanelStarter/PrivacyInfo.xcprivacy +38 -0
  109. package/Samples/MixpanelStarter/ios/MixpanelStarter.xcodeproj/project.pbxproj +482 -0
  110. package/Samples/MixpanelStarter/ios/MixpanelStarter.xcodeproj/xcshareddata/xcschemes/MixpanelStarter.xcscheme +88 -0
  111. package/Samples/MixpanelStarter/ios/MixpanelStarter.xcworkspace/contents.xcworkspacedata +10 -0
  112. package/Samples/MixpanelStarter/ios/Podfile +34 -0
  113. package/Samples/MixpanelStarter/ios/Podfile.lock +2839 -0
  114. package/Samples/MixpanelStarter/jest.config.js +3 -0
  115. package/Samples/MixpanelStarter/metro.config.js +42 -0
  116. package/Samples/MixpanelStarter/package-lock.json +12141 -0
  117. package/Samples/MixpanelStarter/package.json +51 -0
  118. package/Samples/MixpanelStarter/src/@types/env.d.ts +3 -0
  119. package/Samples/MixpanelStarter/src/App.tsx +83 -0
  120. package/Samples/MixpanelStarter/src/components/ActionButton.tsx +92 -0
  121. package/Samples/MixpanelStarter/src/components/ErrorBoundary.tsx +81 -0
  122. package/Samples/MixpanelStarter/src/components/EventTrackingLog.tsx +163 -0
  123. package/Samples/MixpanelStarter/src/components/FlagCard.tsx +199 -0
  124. package/Samples/MixpanelStarter/src/components/InfoCard.tsx +77 -0
  125. package/Samples/MixpanelStarter/src/components/TestResultDisplay.tsx +181 -0
  126. package/Samples/MixpanelStarter/src/constants/tracking.ts +77 -0
  127. package/Samples/MixpanelStarter/src/contexts/MixpanelContext.tsx +159 -0
  128. package/Samples/MixpanelStarter/src/screens/FeatureFlagsScreen.tsx +1011 -0
  129. package/Samples/MixpanelStarter/src/screens/HomeScreen.tsx +307 -0
  130. package/Samples/MixpanelStarter/src/screens/OnboardingScreen.tsx +253 -0
  131. package/Samples/MixpanelStarter/src/screens/SettingsScreen.tsx +316 -0
  132. package/Samples/MixpanelStarter/src/types/flags.types.ts +42 -0
  133. package/Samples/MixpanelStarter/src/types/mixpanel.types.ts +26 -0
  134. package/Samples/MixpanelStarter/tsconfig.json +13 -0
  135. package/__tests__/flags.test.js +730 -0
  136. package/__tests__/index.test.js +7 -3
  137. package/__tests__/jest_setup.js +23 -5
  138. package/__tests__/persistent.test.js +6 -55
  139. package/android/build.gradle +1 -1
  140. package/android/src/main/java/com/mixpanel/reactnative/MixpanelReactNativeModule.java +272 -2
  141. package/index.d.ts +64 -1
  142. package/index.js +42 -3
  143. package/ios/MixpanelReactNative.m +19 -1
  144. package/ios/MixpanelReactNative.swift +183 -5
  145. package/javascript/mixpanel-flags-js.js +463 -0
  146. package/javascript/mixpanel-flags.js +290 -0
  147. package/javascript/mixpanel-main.js +13 -1
  148. package/javascript/mixpanel-persistent.js +3 -10
  149. package/package.json +3 -5
@@ -2,7 +2,18 @@
2
2
  "permissions": {
3
3
  "allow": [
4
4
  "Bash(find:*)",
5
- "Bash(ls:*)"
5
+ "Bash(ls:*)",
6
+ "mcp__github__list_dependabot_alerts",
7
+ "Bash(npm ls:*)",
8
+ "Bash(npm test)",
9
+ "Bash(npm test:*)",
10
+ "mcp__github__get_pull_request",
11
+ "mcp__github__get_issue",
12
+ "mcp__vscode__get_diagnostics_code",
13
+ "mcp__vscode__search_symbols_code",
14
+ "mcp__vscode__get_document_symbols_code",
15
+ "mcp__vscode__get_symbol_definition_code",
16
+ "WebFetch(domain:docs.anthropic.com)"
6
17
  ]
7
18
  },
8
19
  "enableAllProjectMcpServers": false
@@ -0,0 +1,7 @@
1
+ # .github/dependabot.yml
2
+ version: 2
3
+ updates:
4
+ - package-ecosystem: "npm" # Or "yarn"
5
+ directory: "/" # Tells Dependabot to scan root directory only
6
+ schedule:
7
+ interval: "daily"
@@ -27,7 +27,7 @@ jobs:
27
27
  - run: npm test
28
28
 
29
29
  test_android:
30
- runs-on: macos-13
30
+ runs-on: macos-15-intel
31
31
  strategy:
32
32
  matrix:
33
33
  node-version: [18.x]
@@ -88,6 +88,29 @@ jobs:
88
88
  - name: Setup iOS
89
89
  working-directory: ./Samples/SimpleMixpanel/ios
90
90
  run: pod install --repo-update
91
+ - name: List available simulators
92
+ run: xcrun simctl list devices available
93
+ - name: Boot iOS Simulator
94
+ run: |
95
+ # Get list of available iPhone simulators
96
+ # Note: jq is pre-installed on macOS GitHub Actions runners
97
+ SIMULATOR_ID=$(xcrun simctl list devices available -j | jq -r '.devices | to_entries[] | .value[] | select(.name | contains("iPhone")) | .udid' | head -n 1)
98
+ if [ -z "$SIMULATOR_ID" ]; then
99
+ echo "Error: No iPhone simulator found"
100
+ exit 1
101
+ fi
102
+ echo "Found simulator: $SIMULATOR_ID"
103
+ # Check if simulator is already booted
104
+ DEVICE_LIST=$(xcrun simctl list devices)
105
+ if echo "$DEVICE_LIST" | grep -q "$SIMULATOR_ID.*Booted"; then
106
+ echo "Simulator already booted"
107
+ else
108
+ echo "Booting simulator..."
109
+ xcrun simctl boot "$SIMULATOR_ID"
110
+ fi
111
+ # Verify simulator is booted
112
+ echo "Booted simulators:"
113
+ xcrun simctl list devices | grep Booted
91
114
  - name: Test iOS
92
115
  working-directory: ./Samples/SimpleMixpanel
93
116
  run: react-native run-ios
@@ -0,0 +1,4 @@
1
+ {
2
+ "java.configuration.updateBuildConfiguration": "interactive",
3
+ "java.compile.nullAnalysis.mode": "automatic"
4
+ }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  #
2
2
 
3
+ ## [v3.1.2](https://github.com/mixpanel/mixpanel-react-native/tree/v3.1.2) (2025-06-05)
4
+
5
+ ### Fixes
6
+
7
+ - Expo dependencies are required for non-Expo apps [\#291](https://github.com/mixpanel/mixpanel-react-native/issues/291)
8
+ - Use a react-native-get-random-values polyfill instead of expo-crypto [\#294](https://github.com/mixpanel/mixpanel-react-native/pull/294)
9
+
10
+ #
11
+
3
12
  ## [v3.1.1](https://github.com/mixpanel/mixpanel-react-native/tree/v3.1.1) (2025-06-02)
4
13
 
5
14
  ### Enhancements
@@ -518,6 +527,8 @@ This major release removes all remaining calls to Mixpanel's `/decide` API endpo
518
527
 
519
528
 
520
529
 
530
+
531
+
521
532
 
522
533
 
523
534
 
@@ -19,5 +19,5 @@ Pod::Spec.new do |s|
19
19
  s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
20
20
 
21
21
  s.dependency "React-Core"
22
- s.dependency "Mixpanel-swift", '5.1.0'
22
+ s.dependency "Mixpanel-swift", '5.1.3'
23
23
  end
@@ -0,0 +1,2 @@
1
+ BUNDLE_PATH: "vendor/bundle"
2
+ BUNDLE_FORCE_RUBY_PLATFORM: 1
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ root: true,
3
+ extends: '@react-native',
4
+ };
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ arrowParens: 'avoid',
3
+ bracketSameLine: true,
4
+ bracketSpacing: false,
5
+ singleQuote: true,
6
+ trailingComma: 'all',
7
+ };
@@ -0,0 +1,143 @@
1
+ import React, {useEffect, useState} from 'react';
2
+ import {
3
+ Button,
4
+ SafeAreaView,
5
+ ScrollView,
6
+ StatusBar,
7
+ StyleSheet,
8
+ Text,
9
+ View,
10
+ } from 'react-native';
11
+ import {Mixpanel} from 'mixpanel-react-native';
12
+
13
+ const trackAutomaticEvents = true;
14
+ const mixpanel = new Mixpanel('Your Project Token', trackAutomaticEvents);
15
+
16
+ function App(): React.JSX.Element {
17
+ const [isInitialized, setIsInitialized] = useState(false);
18
+
19
+ useEffect(() => {
20
+ const initializeMixpanel = async () => {
21
+ try {
22
+ await mixpanel.init();
23
+ setIsInitialized(true);
24
+ } catch (error) {
25
+ console.error('Failed to initialize Mixpanel:', error);
26
+ }
27
+ };
28
+
29
+ initializeMixpanel();
30
+ }, []);
31
+ const trackEvent = () => {
32
+ if (!isInitialized) {
33
+ console.warn('Mixpanel not initialized yet');
34
+ return;
35
+ }
36
+ mixpanel.track('Button Pressed', {
37
+ source: 'MixpanelExample',
38
+ timestamp: new Date().toISOString(),
39
+ });
40
+ };
41
+
42
+ const identifyUser = () => {
43
+ if (!isInitialized) {
44
+ console.warn('Mixpanel not initialized yet');
45
+ return;
46
+ }
47
+ mixpanel.identify('test_user_123');
48
+ mixpanel.getPeople().set({
49
+ $name: 'Test User',
50
+ $email: 'test@example.com',
51
+ });
52
+ };
53
+
54
+ const resetUser = () => {
55
+ if (!isInitialized) {
56
+ console.warn('Mixpanel not initialized yet');
57
+ return;
58
+ }
59
+ mixpanel.reset();
60
+ };
61
+
62
+ return (
63
+ <SafeAreaView style={styles.container}>
64
+ <StatusBar barStyle="dark-content" />
65
+ <ScrollView contentInsetAdjustmentBehavior="automatic">
66
+ <View style={styles.header}>
67
+ <Text style={styles.title}>Mixpanel React Native Example</Text>
68
+ {!isInitialized && (
69
+ <Text style={styles.statusText}>Initializing Mixpanel...</Text>
70
+ )}
71
+ {isInitialized && (
72
+ <Text style={styles.statusText}>✓ Mixpanel Ready</Text>
73
+ )}
74
+ </View>
75
+
76
+ <View style={styles.buttonContainer}>
77
+ <Button
78
+ title="Track Event"
79
+ onPress={trackEvent}
80
+ disabled={!isInitialized}
81
+ />
82
+ <View style={styles.spacer} />
83
+ <Button
84
+ title="Identify User"
85
+ onPress={identifyUser}
86
+ disabled={!isInitialized}
87
+ />
88
+ <View style={styles.spacer} />
89
+ <Button
90
+ title="Reset User"
91
+ onPress={resetUser}
92
+ disabled={!isInitialized}
93
+ />
94
+ </View>
95
+
96
+ <View style={styles.info}>
97
+ <Text style={styles.infoText}>
98
+ Replace 'Your Project Token' with your actual Mixpanel project token.
99
+ </Text>
100
+ </View>
101
+ </ScrollView>
102
+ </SafeAreaView>
103
+ );
104
+ }
105
+
106
+ const styles = StyleSheet.create({
107
+ container: {
108
+ flex: 1,
109
+ backgroundColor: '#f5f5f5',
110
+ },
111
+ header: {
112
+ padding: 20,
113
+ alignItems: 'center',
114
+ },
115
+ title: {
116
+ fontSize: 24,
117
+ fontWeight: 'bold',
118
+ color: '#333',
119
+ },
120
+ statusText: {
121
+ fontSize: 16,
122
+ color: '#666',
123
+ marginTop: 8,
124
+ textAlign: 'center',
125
+ },
126
+ buttonContainer: {
127
+ padding: 20,
128
+ },
129
+ spacer: {
130
+ height: 10,
131
+ },
132
+ info: {
133
+ padding: 20,
134
+ alignItems: 'center',
135
+ },
136
+ infoText: {
137
+ fontSize: 14,
138
+ color: '#666',
139
+ textAlign: 'center',
140
+ },
141
+ });
142
+
143
+ export default App;
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4
+ ruby ">= 2.6.10"
5
+
6
+ # Exclude problematic versions of cocoapods and activesupport that causes build failures.
7
+ gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
8
+ gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
9
+ gem 'xcodeproj', '< 1.26.0'
10
+ gem 'concurrent-ruby', '< 1.3.4'
11
+
12
+ # Ruby 3.4.0 has removed some libraries from the standard library.
13
+ gem 'bigdecimal'
14
+ gem 'logger'
15
+ gem 'benchmark'
16
+ gem 'mutex_m'
@@ -0,0 +1,97 @@
1
+ This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).
2
+
3
+ # Getting Started
4
+
5
+ > **Note**: Make sure you have completed the [Set Up Your Environment](https://reactnative.dev/docs/set-up-your-environment) guide before proceeding.
6
+
7
+ ## Step 1: Start Metro
8
+
9
+ First, you will need to run **Metro**, the JavaScript build tool for React Native.
10
+
11
+ To start the Metro dev server, run the following command from the root of your React Native project:
12
+
13
+ ```sh
14
+ # Using npm
15
+ npm start
16
+
17
+ # OR using Yarn
18
+ yarn start
19
+ ```
20
+
21
+ ## Step 2: Build and run your app
22
+
23
+ With Metro running, open a new terminal window/pane from the root of your React Native project, and use one of the following commands to build and run your Android or iOS app:
24
+
25
+ ### Android
26
+
27
+ ```sh
28
+ # Using npm
29
+ npm run android
30
+
31
+ # OR using Yarn
32
+ yarn android
33
+ ```
34
+
35
+ ### iOS
36
+
37
+ For iOS, remember to install CocoaPods dependencies (this only needs to be run on first clone or after updating native deps).
38
+
39
+ The first time you create a new project, run the Ruby bundler to install CocoaPods itself:
40
+
41
+ ```sh
42
+ bundle install
43
+ ```
44
+
45
+ Then, and every time you update your native dependencies, run:
46
+
47
+ ```sh
48
+ bundle exec pod install
49
+ ```
50
+
51
+ For more information, please visit [CocoaPods Getting Started guide](https://guides.cocoapods.org/using/getting-started.html).
52
+
53
+ ```sh
54
+ # Using npm
55
+ npm run ios
56
+
57
+ # OR using Yarn
58
+ yarn ios
59
+ ```
60
+
61
+ If everything is set up correctly, you should see your new app running in the Android Emulator, iOS Simulator, or your connected device.
62
+
63
+ This is one way to run your app — you can also build it directly from Android Studio or Xcode.
64
+
65
+ ## Step 3: Modify your app
66
+
67
+ Now that you have successfully run the app, let's make changes!
68
+
69
+ Open `App.tsx` in your text editor of choice and make some changes. When you save, your app will automatically update and reflect these changes — this is powered by [Fast Refresh](https://reactnative.dev/docs/fast-refresh).
70
+
71
+ When you want to forcefully reload, for example to reset the state of your app, you can perform a full reload:
72
+
73
+ - **Android**: Press the <kbd>R</kbd> key twice or select **"Reload"** from the **Dev Menu**, accessed via <kbd>Ctrl</kbd> + <kbd>M</kbd> (Windows/Linux) or <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> (macOS).
74
+ - **iOS**: Press <kbd>R</kbd> in iOS Simulator.
75
+
76
+ ## Congratulations! :tada:
77
+
78
+ You've successfully run and modified your React Native App. :partying_face:
79
+
80
+ ### Now what?
81
+
82
+ - If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
83
+ - If you're curious to learn more about React Native, check out the [docs](https://reactnative.dev/docs/getting-started).
84
+
85
+ # Troubleshooting
86
+
87
+ If you're having issues getting the above steps to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.
88
+
89
+ # Learn More
90
+
91
+ To learn more about React Native, take a look at the following resources:
92
+
93
+ - [React Native Website](https://reactnative.dev) - learn more about React Native.
94
+ - [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
95
+ - [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
96
+ - [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
97
+ - [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @format
3
+ */
4
+
5
+ import React from 'react';
6
+ import ReactTestRenderer from 'react-test-renderer';
7
+ import App from '../App';
8
+
9
+ test('renders correctly', async () => {
10
+ await ReactTestRenderer.act(() => {
11
+ ReactTestRenderer.create(<App />);
12
+ });
13
+ });
@@ -0,0 +1,119 @@
1
+ apply plugin: "com.android.application"
2
+ apply plugin: "org.jetbrains.kotlin.android"
3
+ apply plugin: "com.facebook.react"
4
+
5
+ /**
6
+ * This is the configuration block to customize your React Native Android app.
7
+ * By default you don't need to apply any configuration, just uncomment the lines you need.
8
+ */
9
+ react {
10
+ /* Folders */
11
+ // The root of your project, i.e. where "package.json" lives. Default is '../..'
12
+ // root = file("../../")
13
+ // The folder where the react-native NPM package is. Default is ../../node_modules/react-native
14
+ // reactNativeDir = file("../../node_modules/react-native")
15
+ // The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
16
+ // codegenDir = file("../../node_modules/@react-native/codegen")
17
+ // The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
18
+ // cliFile = file("../../node_modules/react-native/cli.js")
19
+
20
+ /* Variants */
21
+ // The list of variants to that are debuggable. For those we're going to
22
+ // skip the bundling of the JS bundle and the assets. By default is just 'debug'.
23
+ // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
24
+ // debuggableVariants = ["liteDebug", "prodDebug"]
25
+
26
+ /* Bundling */
27
+ // A list containing the node command and its flags. Default is just 'node'.
28
+ // nodeExecutableAndArgs = ["node"]
29
+ //
30
+ // The command to run when bundling. By default is 'bundle'
31
+ // bundleCommand = "ram-bundle"
32
+ //
33
+ // The path to the CLI configuration file. Default is empty.
34
+ // bundleConfig = file(../rn-cli.config.js)
35
+ //
36
+ // The name of the generated asset file containing your JS bundle
37
+ // bundleAssetName = "MyApplication.android.bundle"
38
+ //
39
+ // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
40
+ // entryFile = file("../js/MyApplication.android.js")
41
+ //
42
+ // A list of extra flags to pass to the 'bundle' commands.
43
+ // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
44
+ // extraPackagerArgs = []
45
+
46
+ /* Hermes Commands */
47
+ // The hermes compiler command to run. By default it is 'hermesc'
48
+ // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
49
+ //
50
+ // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
51
+ // hermesFlags = ["-O", "-output-source-map"]
52
+
53
+ /* Autolinking */
54
+ autolinkLibrariesWithApp()
55
+ }
56
+
57
+ /**
58
+ * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
59
+ */
60
+ def enableProguardInReleaseBuilds = false
61
+
62
+ /**
63
+ * The preferred build flavor of JavaScriptCore (JSC)
64
+ *
65
+ * For example, to use the international variant, you can use:
66
+ * `def jscFlavor = io.github.react-native-community:jsc-android-intl:2026004.+`
67
+ *
68
+ * The international variant includes ICU i18n library and necessary data
69
+ * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
70
+ * give correct results when using with locales other than en-US. Note that
71
+ * this variant is about 6MiB larger per architecture than default.
72
+ */
73
+ def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+'
74
+
75
+ android {
76
+ ndkVersion rootProject.ext.ndkVersion
77
+ buildToolsVersion rootProject.ext.buildToolsVersion
78
+ compileSdk rootProject.ext.compileSdkVersion
79
+
80
+ namespace "com.mixpanelexample"
81
+ defaultConfig {
82
+ applicationId "com.mixpanelexample"
83
+ minSdkVersion rootProject.ext.minSdkVersion
84
+ targetSdkVersion rootProject.ext.targetSdkVersion
85
+ versionCode 1
86
+ versionName "1.0"
87
+ }
88
+ signingConfigs {
89
+ debug {
90
+ storeFile file('debug.keystore')
91
+ storePassword 'android'
92
+ keyAlias 'androiddebugkey'
93
+ keyPassword 'android'
94
+ }
95
+ }
96
+ buildTypes {
97
+ debug {
98
+ signingConfig signingConfigs.debug
99
+ }
100
+ release {
101
+ // Caution! In production, you need to generate your own keystore file.
102
+ // see https://reactnative.dev/docs/signed-apk-android.
103
+ signingConfig signingConfigs.debug
104
+ minifyEnabled enableProguardInReleaseBuilds
105
+ proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
106
+ }
107
+ }
108
+ }
109
+
110
+ dependencies {
111
+ // The version of react-native is set by the React Native Gradle Plugin
112
+ implementation("com.facebook.react:react-android")
113
+
114
+ if (hermesEnabled.toBoolean()) {
115
+ implementation("com.facebook.react:hermes-android")
116
+ } else {
117
+ implementation jscFlavor
118
+ }
119
+ }
@@ -0,0 +1,10 @@
1
+ # Add project specific ProGuard rules here.
2
+ # By default, the flags in this file are appended to flags specified
3
+ # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4
+ # You can edit the include path and order by changing the proguardFiles
5
+ # directive in build.gradle.
6
+ #
7
+ # For more details, see
8
+ # http://developer.android.com/guide/developing/tools/proguard.html
9
+
10
+ # Add any project specific keep options here:
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+ xmlns:tools="http://schemas.android.com/tools">
4
+
5
+ <application
6
+ android:usesCleartextTraffic="true"
7
+ tools:targetApi="28"
8
+ tools:ignore="GoogleAppIndexingWarning"/>
9
+ </manifest>
@@ -0,0 +1,26 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+
3
+ <uses-permission android:name="android.permission.INTERNET" />
4
+
5
+ <application
6
+ android:name=".MainApplication"
7
+ android:label="@string/app_name"
8
+ android:icon="@mipmap/ic_launcher"
9
+ android:roundIcon="@mipmap/ic_launcher_round"
10
+ android:allowBackup="false"
11
+ android:theme="@style/AppTheme"
12
+ android:supportsRtl="true">
13
+ <activity
14
+ android:name=".MainActivity"
15
+ android:label="@string/app_name"
16
+ android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
17
+ android:launchMode="singleTask"
18
+ android:windowSoftInputMode="adjustResize"
19
+ android:exported="true">
20
+ <intent-filter>
21
+ <action android:name="android.intent.action.MAIN" />
22
+ <category android:name="android.intent.category.LAUNCHER" />
23
+ </intent-filter>
24
+ </activity>
25
+ </application>
26
+ </manifest>
@@ -0,0 +1,22 @@
1
+ package com.mixpanelexample
2
+
3
+ import com.facebook.react.ReactActivity
4
+ import com.facebook.react.ReactActivityDelegate
5
+ import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
6
+ import com.facebook.react.defaults.DefaultReactActivityDelegate
7
+
8
+ class MainActivity : ReactActivity() {
9
+
10
+ /**
11
+ * Returns the name of the main component registered from JavaScript. This is used to schedule
12
+ * rendering of the component.
13
+ */
14
+ override fun getMainComponentName(): String = "MixpanelExample"
15
+
16
+ /**
17
+ * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
18
+ * which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
19
+ */
20
+ override fun createReactActivityDelegate(): ReactActivityDelegate =
21
+ DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
22
+ }
@@ -0,0 +1,44 @@
1
+ package com.mixpanelexample
2
+
3
+ import android.app.Application
4
+ import com.facebook.react.PackageList
5
+ import com.facebook.react.ReactApplication
6
+ import com.facebook.react.ReactHost
7
+ import com.facebook.react.ReactNativeHost
8
+ import com.facebook.react.ReactPackage
9
+ import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
10
+ import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
11
+ import com.facebook.react.defaults.DefaultReactNativeHost
12
+ import com.facebook.react.soloader.OpenSourceMergedSoMapping
13
+ import com.facebook.soloader.SoLoader
14
+
15
+ class MainApplication : Application(), ReactApplication {
16
+
17
+ override val reactNativeHost: ReactNativeHost =
18
+ object : DefaultReactNativeHost(this) {
19
+ override fun getPackages(): List<ReactPackage> =
20
+ PackageList(this).packages.apply {
21
+ // Packages that cannot be autolinked yet can be added manually here, for example:
22
+ // add(MyReactNativePackage())
23
+ }
24
+
25
+ override fun getJSMainModuleName(): String = "index"
26
+
27
+ override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
28
+
29
+ override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
30
+ override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
31
+ }
32
+
33
+ override val reactHost: ReactHost
34
+ get() = getDefaultReactHost(applicationContext, reactNativeHost)
35
+
36
+ override fun onCreate() {
37
+ super.onCreate()
38
+ SoLoader.init(this, OpenSourceMergedSoMapping)
39
+ if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
40
+ // If you opted-in for the New Architecture, we load the native entry point for this app.
41
+ load()
42
+ }
43
+ }
44
+ }