File tree Expand file tree Collapse file tree 4 files changed +353
-14
lines changed Expand file tree Collapse file tree 4 files changed +353
-14
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ import {
1212import { AsyncStorageAdapter } from "./mixpanel-storage" ;
1313import uuid from "uuid" ;
1414import { MixpanelLogger } from "mixpanel-react-native/javascript/mixpanel-logger" ;
15- import { randomUUID } from "expo-crypto" ;
1615
1716export class MixpanelPersistent {
1817 static instance ;
@@ -67,11 +66,16 @@ export class MixpanelPersistent {
6766 this . _identity [ token ] . deviceId = storageToken ;
6867
6968 if ( ! this . _identity [ token ] . deviceId ) {
69+ let newDeviceId ;
7070 try {
71- this . _identity [ token ] . deviceId = randomUUID ( ) ;
71+ // Try to use expo-crypto if available
72+ const expoCrypto = require ( "expo-crypto" ) ;
73+ newDeviceId = expoCrypto . randomUUID ( ) ;
7274 } catch ( e ) {
73- this . _identity [ token ] . deviceId = uuid . v4 ( ) ;
75+ // Fallback to uuid.v4() if expo-crypto is not available
76+ newDeviceId = uuid . v4 ( ) ;
7477 }
78+ this . _identity [ token ] . deviceId = newDeviceId ;
7579 await this . storageAdapter . setItem (
7680 getDeviceIdKey ( token ) ,
7781 this . _identity [ token ] . deviceId
You can’t perform that action at this time.
0 commit comments