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

Does react-native-client-sdk (v10) support expo web? #263

Open
QuanGao-osmind opened this issue May 1, 2024 · 3 comments
Open

Does react-native-client-sdk (v10) support expo web? #263

QuanGao-osmind opened this issue May 1, 2024 · 3 comments

Comments

@QuanGao-osmind
Copy link

Describe the bug
We have an expo project that we are targeting both mobile and web platforms. The react-native-client-sdk works well on mobile but crashes in web.

This is the error I see:

autoEnv.js:24 Uncaught TypeError: Cannot read properties of undefined (reading 'Manufacturer')

which traces to this code in autoEnv, seems like Platform.constants is undefined somehow.

export const ldDevice = {
    // key is populated by common/client-sdk
    key: '',
    envAttributesVersion: '1.0',
    manufacturer: Platform.select({
        ios: 'apple',
        android: Platform.constants.Manufacturer,
    }),
    model: Platform.select({
        // ios: model n/a from PlatformIOSStatic
        android: Platform.constants.Model,
    }),
    os: {
        family: Platform.select({
            ios: 'apple',
            default: Platform.OS,
        }),
        name: Platform.OS,
        version: (_a = Platform.Version) === null || _a === void 0 ? void 0 : _a.toString(),
    },
};

To reproduce
Follow the SDK doc to initialize LD client and identify user.

Expected behavior
Expect react-native-client-sdk to work on all platforms expo support (Android, IOS, web)

SDK version
10.1.3

OS/platform
Web browser: Chrome Version 124.0.6367.62

Any insights are greatly appreciated, thank you!

@louis-launchdarkly
Copy link
Contributor

Hello @QuanGao-osmind, we will look into turning off autoEnv for the web (Filed internally as 242760). In the meantime, while it is extra effort and trouble for you, I wonder if disabling autoEnv when you build for the web platform could work?

@louis-launchdarkly
Copy link
Contributor

Also, if you don't mind, could you post this to https://github.com/launchdarkly/js-core? That is where the RN SDK v10 (and beyond) lives.

@QuanGao-osmind
Copy link
Author

QuanGao-osmind commented May 2, 2024

Hello @louis-launchdarkly thank you for the reply!
We end up adding a patch for the package to prevent it from crashing on web. Now we are seeing a CORS issue since there's no CORS headers served on mobile endpoint. (After disabling browser security, it works as expected)

I will post issues related to react-native-client-sdk to the other repo you suggested!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants