Skip to content
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

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

Closed
hohoaisan opened this issue Jul 3, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@hohoaisan
Copy link

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

  • @amplitude/analytics-react-native version: ^1.4.9
  • Installation Method: yarn
  • "react-native": "0.72.6
  • "expo": "^49.0.0",
@hohoaisan hohoaisan added the bug Something isn't working label Jul 3, 2024
@hohoaisan
Copy link
Author

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

@yuhao900914
Copy link
Contributor

Thanks for choosing amplitude.
Did you also install the async storage at the same time?

# npm
npm install @amplitude/analytics-react-native
npm install @react-native-async-storage/async-storage

# yarn
yarn add @amplitude/analytics-react-native
yarn add @react-native-async-storage/async-storage

This is the instruction on how to use amplitude. There is more for the developer doc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants