amplitude / Amplitude-TypeScript

TypeScript Amplitude Analytics SDK
https://amplitude.github.io/Amplitude-TypeScript/
MIT License
123 stars 33 forks source link

React Native "Amplitude Logger [Error]: Failed to set cookie for key: AMP_TEST. Error: Property 'btoa' doesn't exist" #800

Open hohoaisan opened 5 days ago

hohoaisan commented 5 days ago

Expected Behavior

No error was shown when initialize amplitude with @amplitude/analytics-react-native module in React Native

Current Behavior

The following error log was pushed into console, there is no documentation about polyfilling or disable cookies?

 ERROR  Amplitude Logger [Error]: Failed to set cookie for key: AMP_TEST. Error: Property 'btoa' doesn't exist
    at apply (native)
    at apply (native)
    at App
    at doResolve (/Users/distiller/react-native/packages/react-native/sdks/hermes/build_iphoneos/lib/InternalBytecode/InternalBytecode.js:216:25)
    at apply (native)
    at ErrorOverlay
    at RCTView
    at apply (native)
    at RCTView
    at apply (native)
    at Promise (/Users/distiller/react-native/packages/react-native/sdks/hermes/build_iphoneos/lib/InternalBytecode/InternalBytecode.js:82:14)
    at apply (native)
 ERROR  Amplitude Logger [Error]: Failed to set cookie for key: AMP_TEST. Error: Property 'btoa' doesn't exist
 ERROR  Amplitude Logger [Error]: Failed to set cookie for key: AMP_TEST. Error: Property 'btoa' doesn't exist
 ERROR  Amplitude Logger [Error]: Failed to set cookie for key: AMP_TEST. Error: Property 'btoa' doesn't exist
 ERROR  Amplitude Logger [Error]: Failed to set cookie for key: AMP_TEST. Error: Property 'btoa' doesn't exist
 ERROR  Amplitude Logger [Error]: Failed to set cookie for key: AMP_TEST. Error: Property 'btoa' doesn't exist
 ERROR  Amplitude Logger [Error]: Failed to set cookie for key: AMP_TEST. Error: Property 'btoa' doesn't exist
 ERROR  Amplitude Logger [Error]: Failed to set cookie for key: AMP_TEST. Error: Property 'btoa' doesn't exist

Steps to Reproduce

  1. Install @amplitude/analytics-react-native by using yarn expo install @amplitude/analytics-react-native
  2. Import import * as amplitude from '@amplitude/analytics-react-native' in App.tsx
  3. Observe the Metro console

Environment

hohoaisan commented 5 days ago

After polyfilling btoa, following error log:

 ERROR  Amplitude Logger [Error]: Failed to set cookie for key: AMP_TEST. Error: Cannot set property 'cookie' of undefined
    at apply (native)
    at apply (native)
    at App
    at doResolve (/Users/distiller/react-native/packages/react-native/sdks/hermes/build_iphoneos/lib/InternalBytecode/InternalBytecode.js:216:25)
    at apply (native)
    at ErrorOverlay
    at RCTView
    at apply (native)
    at RCTView
    at apply (native)
    at Promise (/Users/distiller/react-native/packages/react-native/sdks/hermes/build_iphoneos/lib/InternalBytecode/InternalBytecode.js:82:14)
    at apply (native)
 ERROR  Amplitude Logger [Error]: Failed to set cookie for key: AMP_TEST. Error: Cannot set property 'cookie' of undefined
 ERROR  Amplitude Logger [Error]: Failed to set cookie for key: AMP_TEST. Error: Cannot set property 'cookie' of undefined
 ERROR  Amplitude Logger [Error]: Failed to set cookie for key: AMP_TEST. Error: Cannot set property 'cookie' of undefined
 ERROR  Amplitude Logger [Error]: Failed to set cookie for key: AMP_TEST. Error: Cannot set property 'cookie' of undefined
 ERROR  Amplitude Logger [Error]: Failed to set cookie for key: AMP_TEST. Error: Cannot set property 'cookie' of undefined
 ERROR  Amplitude Logger [Error]: Failed to set cookie for key: AMP_TEST. Error: Cannot set property 'cookie' of undefined
 ERROR  Amplitude Logger [Error]: Failed to set cookie for key: AMP_TEST. Error: Cannot set property 'cookie' of undefined