Skip to content

Use a react-native-get-random-values polyfill instead of expo-crypto - #294

Merged
jaredmixpanel merged 2 commits into
masterfrom
jared-polyfill-uuid
Jun 5, 2025
Merged

Use a react-native-get-random-values polyfill instead of expo-crypto#294
jaredmixpanel merged 2 commits into
masterfrom
jared-polyfill-uuid

Conversation

@jaredmixpanel

@jaredmixpanel jaredmixpanel commented Jun 5, 2025

Copy link
Copy Markdown
Collaborator

Remove all references to expo-crypto and instead polyfill crypto.getRandomValues with react-native-get-random-values to avoid uuid.v4() crashing in Expo apps... without breaking non-Expo React Native apps.

Also adds a new sample/demo app, MixpanelExample in the Samples/ folder.

@jaredmixpanel
jaredmixpanel requested a review from Copilot June 5, 2025 00:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new React Native sample project demonstrating Mixpanel integration, replacing the previous expo-crypto setup with a standalone example.

  • Adds Android project configuration and resources
  • Implements a simple Mixpanel-powered UI in App.tsx
  • Includes testing, linting, formatting, and README documentation

Reviewed Changes

Copilot reviewed 59 out of 59 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Samples/MixpanelExample/android/gradle.properties Configures Gradle JVM args and AndroidX settings
Samples/MixpanelExample/android/build.gradle Defines buildscript repositories and plugin dependencies
Samples/MixpanelExample/android/app/src/main/res/values/styles.xml Adds the app theme style
Samples/MixpanelExample/android/app/src/main/res/values/strings.xml Defines app_name resource
Samples/MixpanelExample/android/app/src/main/res/drawable/rn_edit_text_material.xml Supplies safe EditText drawable variant
Samples/MixpanelExample/android/app/src/main/java/com/mixpanelexample/MainApplication.kt Initializes React Native host and SoLoader
Samples/MixpanelExample/android/app/src/main/java/com/mixpanelexample/MainActivity.kt Sets up React activity delegate
Samples/MixpanelExample/android/app/src/main/AndroidManifest.xml Declares application and activity settings
Samples/MixpanelExample/android/app/src/debug/AndroidManifest.xml Enables cleartext traffic for debug builds
Samples/MixpanelExample/android/app/proguard-rules.pro Placeholder for ProGuard rules
Samples/MixpanelExample/android/app/build.gradle Configures app module, dependencies, and build types
Samples/MixpanelExample/tests/App.test.tsx Adds a basic render test for the App component
Samples/MixpanelExample/README.md Provides setup and usage instructions
Samples/MixpanelExample/Gemfile Specifies Ruby gems for iOS CocoaPods environment
Samples/MixpanelExample/App.tsx Implements Mixpanel example UI and event handlers
Samples/MixpanelExample/.watchmanconfig Adds an empty Watchman configuration
Samples/MixpanelExample/.prettierrc.js Defines Prettier formatting rules
Samples/MixpanelExample/.gitignore Lists files and directories to ignore in version control
Samples/MixpanelExample/.eslintrc.js Sets up ESLint base configuration
Samples/MixpanelExample/.bundle/config Configures Bundler installation path
Comments suppressed due to low confidence (1)

Samples/MixpanelExample/App.tsx:15

  • Calling mixpanel.init() without awaiting its promise may lead to tracking calls occurring before initialization completes. Consider moving initialization into a useEffect and awaiting the result before rendering or tracking events.
mixpanel.init();
Comment thread Samples/MixpanelExample/android/build.gradle Outdated
…lExample

- Add version 8.7.2 to Android Gradle plugin coordinate in build.gradle
- Move mixpanel.init() to useEffect with proper async/await handling
- Add initialization state management to prevent tracking before init completes
- Add UI status indicators and disable buttons during initialization
- Add error handling for initialization failures
@arelstone

Copy link
Copy Markdown

Please ship this asap @jaredmixpanel

And please make sure that an expo module is not being added again

@jaredmixpanel jaredmixpanel added the bug Something isn't working label Jun 5, 2025
@jaredmixpanel
jaredmixpanel merged commit a3e62e5 into master Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

3 participants