-
Notifications
You must be signed in to change notification settings - Fork 52
Use expo-crypto for UUID on Expo, expose useGzipCompression option and fix JavaScript mode People flushing issue #288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
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 centralizes UUID generation with expo-crypto
, ensures proper default imports for AsyncStorage, synchronizes user identity fields in queues, and introduces a gzip compression flag across JS, iOS, and Android modules.
- Added
expo-crypto
to reliably generaterandomUUID()
and fall back touuid.v4()
. - Implemented
identifyUserQueue
in the queue manager and wired it through core, main, and persistent layers. - Exposed a
useGzipCompression
option in the JS API and native modules, and bumped native dependency versions.
Reviewed Changes
Copilot reviewed 20 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
package.json | Added expo-crypto dependency for UUID generation fallback. |
javascript/mixpanel-storage.js | Detect default exports from AsyncStorage require. |
javascript/mixpanel-queue.js | Imported MixpanelType , added identifyUserQueue , and guard. |
javascript/mixpanel-persistent.js | Use randomUUID() fallback, pass token to getInstance , add isIdentified . |
javascript/mixpanel-main.js | Pass token to persistent, invoke identifyUserQueue , update return values. |
javascript/mixpanel-core.js | Exposed identifyUserQueue method. |
ios/MixpanelReactNative.swift | Added useGzipCompression parameter with default. |
index.js | Updated init signature and JSDoc for useGzipCompression . |
android/src/.../MixpanelReactNativeModule.java | Extended initialize signature with gzip flag. |
android/build.gradle | Bumped mixpanel-android to 8.1.0. |
tests/queue.test.js | Mocked new persistent methods and added USER-type queue tests. |
tests/main.test.js | Added identifyUserQueue mock and new identify tests. |
tests/jest_setup.js | Mocked expo-crypto ’s randomUUID() . |
tests/index.test.js | Updated tests for gzip flag and formatting. |
Samples/MixpanelExpo/package.json | Reordered and added metro runtime dependency. |
Samples/MixpanelExpo/App.js | Changed placeholder token to a real token (to be reviewed). |
MixpanelReactNative.podspec | Bumped Mixpanel-swift to 5.0.0. |
Files not reviewed (1)
- Samples/MixpanelExpo/package-lock.json: Language not supported
Comments suppressed due to low confidence (2)
tests/main.test.js:371
- The test references
MixpanelType
but this constant is not imported in this file. Addimport { MixpanelType } from './mixpanel-constants';
(or correct path) at the top.
expect(mixpanelMain.core.addToMixpanelQueue).toHaveBeenCalledWith(token, MixpanelType.EVENTS, expect.any(Object));
Samples/MixpanelExpo/App.js:17
- [nitpick] Sample app is hardcoding a real Mixpanel token. Consider reverting to a placeholder (e.g.,
YOUR_MIXPANEL_TOKEN
) or using an environment variable.
"26d77caa3b67accd112d74ecfc0214a4",
There was a problem hiding this comment.
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 integrates Expo’s crypto API for UUID generation, exposes a new useGzipCompression
option across JS and native layers, and ensures user identity fields are correctly applied before flushing the USER queue.
- Use
expo-crypto.randomUUID()
with fallback touuid.v4()
for device IDs. - Add a
useGzipCompression
parameter to the JSinit
API and native iOS/Android modules. - Introduce
identifyUserQueue
to update USER‐type queue items with up-to-date identity fields.
Reviewed Changes
Copilot reviewed 21 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
package.json | Added expo-crypto dependency. |
javascript/mixpanel-storage.js | Handle .default export for AsyncStorage module. |
javascript/mixpanel-queue.js | Import MixpanelType ; update getQueue logic; add identifyUserQueue . |
javascript/mixpanel-persistent.js | Use expo-crypto.randomUUID with fallback; add isIdentified ; update getInstance . |
javascript/mixpanel-main.js | Pass token into getInstance ; call identifyUserQueue before identify; cleanup identity getters. |
javascript/mixpanel-core.js | Expose identifyUserQueue in core API. |
ios/MixpanelReactNative.swift | Expose useGzipCompression in native initializer. |
index.js | Add useGzipCompression parameter to public init signature. |
android/src/.../MixpanelReactNativeModule.java | Add useGzipCompression to init and enable gzip. |
android/build.gradle | Bump com.mixpanel.android to version 8.1.0. |
tests/queue.test.js | Add mocks and tests for the extended identifyUserQueue flow. |
tests/main.test.js | Mock and assert core.identifyUserQueue behavior in identify. |
tests/index.test.js | Update test to expect useGzipCompression argument. |
tests/jest_setup.js | Mock expo-crypto.randomUUID . |
Samples/MixpanelExpo/App.js | Replace placeholder token (note: uses a real token here). |
README.md | Update docs for useGzipCompression and formatting tweaks. |
MixpanelReactNative.podspec | Bump Mixpanel-swift dependency to 5.0.0. |
Files not reviewed (1)
- Samples/MixpanelExpo/package-lock.json: Language not supported
Comments suppressed due to low confidence (2)
javascript/mixpanel-queue.js:47
- The helper
getPersistent
is not defined in this module, causing a runtime error. Import or reference the persistent instance correctly (e.g., useMixpanelPersistent.getInstance()
or definegetPersistent
).
(type === MixpanelType.USER && !getPersistent().isIdentified(token))
Samples/MixpanelExpo/App.js:17
- A real Mixpanel project token is exposed in the sample app. Replace it with a placeholder (e.g.,
YOUR_MIXPANEL_TOKEN
) to avoid leaking credentials.
"26d77caa3b67accd112d74ecfc0214a4"
It won't work in applications running on bare react-native-cli, getting below error. Add a suitable fallback or handle both cases to support expo and react native cli. Additionally I have to install "expo-crypto": "^14.1.4" & "expo-modules-core": "^2.3.13" unnecessarily to make it work. <----------------------ERROR-LOG------------------->
|
@rajgupta027 |
No description provided.