bugsnag / bugsnag-expo

MIT License
10 stars 5 forks source link

v51's expo-secure-store dependecy breaks web compatibility #183

Open jypa opened 1 month ago

jypa commented 1 month ago

Describe the bug

expo-bugsnag v51.x added expo-secure-store as peer-depedency. This package doesn't work on the web platform and causes the app to crash on runtime.

A possible fix would be to use AsynStorage when running in the web platform.

Steps to reproduce

  1. Launch the app on the web

Environment

Error messages: ``` Uncaught TypeError: _ExpoSecureStore.default.getValueWithKeySync is not a function ```
toniewypada commented 1 month ago

Hi @jypa :wave: , Thanks for raising this issue. We're going to take a look at addressing this. We don't currently have an ETA we can share on when this will be available, but we will make sure to post any updates on this thread.

giaset commented 1 month ago

Ended up patching the package like this:

    let deviceId
    if (Platform.OS === 'web') {
      deviceId = localStorage.getItem(DEVICE_ID_KEY)
      if (!deviceId || !cuid.isCuid(deviceId)) {
        deviceId = cuid()
        localStorage.setItem(DEVICE_ID_KEY, deviceId)
      }
    } else {
      const storeOptions = {
        requireAuthentication: false,
        keychainAccessible: SecureStore.ALWAYS_THIS_DEVICE_ONLY
      }

      deviceId = SecureStore.getItem(DEVICE_ID_KEY, storeOptions)
      if (!deviceId || !cuid.isCuid(deviceId)) {
        deviceId = cuid()
        SecureStore.setItem(DEVICE_ID_KEY, deviceId, storeOptions)
      }
    }
yousif-bugsnag commented 4 weeks ago

Hi @giaset, thanks for sharing this - please see the comment on the linked PR: https://github.com/bugsnag/bugsnag-expo/pull/185#issuecomment-2161042749