braze-inc / braze-web-sdk

Public repo for the Braze Web SDK
https://www.braze.com
Other
70 stars 25 forks source link

[Bug]: Error when trying to use requestContentCardsRefresh method #129

Closed ionutgrad09 closed 1 year ago

ionutgrad09 commented 1 year ago

Braze Web SDK Version

4.2.1

Integration Method

Other (please specify)

Browser

Chrome

Steps To Reproduce

Hello, I am trying to use @braze/web-sdk for my app, to get the content cards.

I followed these steps to initialize braze: https://www.braze.com/docs/developer_guide/platform_integration_guides/web/initial_sdk_setup/

I get the following error when I try to invoke requestContentCardsRefresh() method, any idea why? Am I missing something?

Screenshot 2022-08-22 at 01 11 13
wesleyorbin commented 1 year ago

Hi @ionutgrad09. Can you provide more details about your integration (e.g. code examples, how you're bundling your code, etc) so we can try to reproduce?

ionutgrad09 commented 1 year ago

Hello @wesleyorbin,

Here is a snippet with the code I am using to initialize braze. The problem is thrown at line 20 (when I try to use requestContentCardsRefresh). Actually, I can't use any methods from SDK (except from initialize and openSession, these 2 methods seem to work fine).

I tried to add the same code in a new react-app application, and everything works fine, so I guess it's something on our platform that make braze SDK to throw that error, but I can't find what. Any idea?

Screenshot 2022-08-24 at 10 05 15
wesleyorbin commented 1 year ago

@ionutgrad09 Based on the stack trace and error message, it would seem that some code in the SDK is being incorrectly removed by your build process. Are you able to share more code snippets? The only thing that sticks out to me in the provided code sample is that initialize and openSession are exported by this file and are the only methods that work.

ionutgrad09 commented 1 year ago

Hello, I tried to use Braze CDN and everything works fine (the only problem is that we can't keep the unsafe-eval enabled). We are using esbuild for building the problem, do you know if braze SDK doesn't work well with esbuild?

wesleyorbin commented 1 year ago

Closing since this was routed through our support team