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

[RUM-6160] Added errorSource property in LogEvent for mapping #727

Merged

Conversation

marco-saia-datadog
Copy link
Contributor

What does this PR do?

Adds Error Source property to Log Events, so that it can be used in custom Log Event Mappers.

Example

configuration.logEventMapper = logEvent => {
    if (logEvent.source === ErrorSource.CONSOLE) {
        return null;
    }

    return logEvent;
};

To be discussed

This PR adds an extra parameter source to the public API DdLogs.error():

  • message: string
  • errorKind?: string
  • errorMessage?: string
  • stacktrace?: string
  • context?: object
  • fingerprint?: string
  • source?: ErrorSource

Another option would be to add a custom Datadog attribute to the context and parse it internally (perhaps removing it before making the native call.

Finally, another option would be to refactor the implementation to hide the parameter from the public API.

Please let me know what you think about this.

Context

Currently, when trackErrors is set to true, we attach our error-reporting logic to:

  • Console Errors (via console.error)

  • React Native Global Error Handler (via ErrorUtils.setGlobalHandler)

In some cases, users might not want to report console errors, and we currently don’t have a way to disable this behaviour.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)
  • If this PR is auto-generated, please make sure also to manually update the code related to the change

@marco-saia-datadog marco-saia-datadog requested a review from a team as a code owner October 9, 2024 13:45
// WHEN
await DdSdkReactNative.initialize(configuration);

console.error('console-error-message');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Code Quality Violation

Unexpected console statement. (...read more)

Debugging with console is not considered a bad practice, but it's easy to forget about console statements and leave them in production code. There is no need to pollute production builds with debugging statements.

View in Datadog  Leave us feedback  Documentation

@marco-saia-datadog marco-saia-datadog merged commit c76b044 into develop Oct 9, 2024
6 checks passed
@marco-saia-datadog marco-saia-datadog deleted the marcosaia/RUM-6160/additional-error-config branch October 9, 2024 14:41
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

Successfully merging this pull request may close these issues.

2 participants