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? #455

Open
QuanGao-osmind opened this issue May 2, 2024 · 8 comments
Open

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

QuanGao-osmind opened this issue May 2, 2024 · 8 comments
Labels
feature Label for feature requests package: sdk/react-native Issues that affect the react native SDK. waiting for feedback Indicates LaunchDarkly is waiting for customer feedback before issue is closed due to staleness.

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, looks like Platform.constants is undefined.

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!

@QuanGao-osmind QuanGao-osmind added bug Something isn't working package: sdk/react-native Issues that affect the react native SDK. labels May 2, 2024
@louis-launchdarkly
Copy link
Contributor

@QuanGao-osmind Thank you so much - for other people who see this: LaunchDarkly team filed internally as 242760 for the investigation of disabling the web autoEnv, and @QuanGao-osmind also found out that once disabling this, there is also browser CORS security that we need to be concern about when we put a fix for this.

@QuanGao-osmind
Copy link
Author

@louis-launchdarkly Thank you for the reply!

We are able to apply a patch to the package to get around the issue in autoEnv.

Do you have any suggestions in getting around the CORS issue?

@yusinto
Copy link
Contributor

yusinto commented May 9, 2024

@QuanGao-osmind the react-native SDK is designed, built and tested for iOS and Android only. Other platforms are not supported. Web is not supported. The cors issue is due to http requests made to the LaunchDarkly mobile endpoints from a browser. We use different endpoints for these platforms and these are also coupled tightly with the use of mobile keys and client side ids.

@yusinto yusinto added the waiting for feedback Indicates LaunchDarkly is waiting for customer feedback before issue is closed due to staleness. label May 9, 2024
@louis-launchdarkly
Copy link
Contributor

Based on the investigation so far, while we have the feature request captured in the internal ticket I mentioned above, currently there is no ETA of when our RN SDK can support expo web. Trying to use the Client ID and the endpoints for the browser could be a thing to try.

@louis-launchdarkly louis-launchdarkly added feature Label for feature requests and removed bug Something isn't working labels May 9, 2024
@QuanGao-osmind
Copy link
Author

@louis-launchdarkly @yusinto Thank you for the updates!

I thought react-native SDK is fully compatible with Expo because of the documentation here
Screenshot 2024-05-10 at 8 45 59 AM

If there's no immediate plan to support Expo web, could LD team update this documentation to reflect that?

FWIW we tested LD in Expo web in a security-disabled browser and it seems to work fine (with a patch to fix the above issue). It could be very close to get LD fully compatible with all platforms Expo support.

@QuanGao-osmind
Copy link
Author

@yusinto @louis-launchdarkly Followup question, which SDK would you recommend us to use for Expo web?

In the documentation for React Web SDK, I see

The React Web SDK does not work in React Native projects
If you want to add LaunchDarkly to your React Native codebase, use the React Native SDK instead.

Do we need to resort to JavaScript SDK?

@retronouns
Copy link

retronouns commented May 10, 2024

My team just ran into this issue as well! ❤️

It's very useful to be able to run our apps in expo web during local development, so I am happy to see there is a ticket to address it, even if there is no ETA yet. 😄

@retronouns
Copy link

retronouns commented Jun 17, 2024

@QuanGao-osmind We ended up needing to use both the RN SDK and the JS SDK and have 2 implementations using platform specific modules: abcd.tsx that uses the RN SDK, and abcd.web.tsx that uses the JS SDK.

Definitely not ideal, but it appears to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Label for feature requests package: sdk/react-native Issues that affect the react native SDK. waiting for feedback Indicates LaunchDarkly is waiting for customer feedback before issue is closed due to staleness.
Projects
None yet
Development

No branches or pull requests

4 participants