Skip to content

How to prevent sending logs from local environment? #4861

Answered by vladanpaunovic
stunaz asked this question in Q&A
Discussion options

You must be logged in to vote

A better way to go about this is to still send it, yet separate the environment. In Sentry.io you will be able to see only development or production logs.

You can do this by providing the environment option to Sentry.init();. You can find the docs on it here.

Example

Sentry.init({
  dsn: "YOUR_PROJECT_DSN",
  sampleRate: 1,
  environment: provess.env.NODE_ENV
});

Another way to do it (not recommended) is to conditionally load Sentry.

if (process.env.NODE_ENV === "production") {
  Sentry.init({
    dsn: "YOUR_PROJECT_DSN",
    sampleRate: 1,
    environment: "production"
  });
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by vladanpaunovic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants