launchdarkly / react-client-sdk

LaunchDarkly Client-side SDK for React.js
Other
86 stars 68 forks source link

Large amount of CustomEvent: {"isTrusted": false} #219

Open emileturcotte opened 1 year ago

emileturcotte commented 1 year ago

Is this a support request? Yes

Describe the bug I am working on a React WebApp which uses both LaunchDarkly and AppInsights. Both seem to have a concept of Custom Events.

We started having large amounts of exceptions logged in our AppInsights regarding "untrusted Custom Events", and it always seems to happen next to LaunchDarkly analytic events calls. I have yet to find anything regarding untrusted custom events in both LaunchDarkly and AppInsights documentation. I have already opened the following issue with AppInsights.

screenshot

The errorSrc being window.onerror hints at the error coming from an external script, but I cannot know for sure whether it comes from LaunchDarkly or ApplicationInsights.

To reproduce Combine the use of launchdarkly-react-client-sdk: 2.29.4 and microsoft/applicationinsights-web: 3.0.2. When LaunchDarkly sends Analytic Events, notice if errors are logged in the browser or in AppInsights.

Expected behavior Exceptions should not happen.

Logs n/a

SDK version Using launchdarkly-react-client-sdk: 2.29.4. Using microsoft/applicationinsights-web: 3.0.2

Language version, developer tools Using react: 18.2.0

OS/platform OS: Windows, Linux, MacOS Browsers: Chrome 116.0+, Edge 116.0+, Firefox 116.0+

Additional context Add any other context about the problem here.

louis-launchdarkly commented 1 year ago

Hello @emileturcotte, Thank you for reporting. I have both searched isTrusted and the LaunchDarkly track event, but nothing matches that shape (don't see isTrusted in code search, LaunchDarkly custom event has "kind": "custom" inside JSON body instead of a top-level key).

https://github.com/search?q=repo%3Alaunchdarkly%2Fjs-sdk-common+isTrusted&type=code https://github.com/search?q=repo%3Alaunchdarkly%2Freact-client-sdk+isTrusted&type=code

We will follow the AppInsights issue.

If you don't mind digging deeper, can you search your code for any call to the LaunchDarkly client's track method and report back? https://github.com/launchdarkly/js-sdk-common/blob/5.0.3/src/index.js#L363

emileturcotte commented 1 year ago

Hi @louis-launchdarkly, thank you for the quick reply.

As was suggested in the other issue, this CustomEvent exception seems to refer to native browser Custom Events. However the fact that it is obfuscated by the browser seems to indicate that it comes from an external script. Does LaunchDarkly use native browser events when it comes to analytics?

As for your request, I have scouted the code and did not find any instance of us using LaunchDarkly's track method.