Code Monkey home page Code Monkey logo

Comments (5)

bcaudan avatar bcaudan commented on September 24, 2024 1

Could you handle your use case by having a setup like:

if (env.DATADOG_CLIENT_TOKEN) {
  DD_LOGS.init({ clientToken: env.DATADOG_CLIENT_TOKEN, ...})
}

or is there something more to it?

from browser-sdk.

bcaudan avatar bcaudan commented on September 24, 2024

Hi @thaim,

What about not initialize browser logs when you don't want to use it?

from browser-sdk.

bcaudan avatar bcaudan commented on September 24, 2024

Feel free to reopen if needed.

from browser-sdk.

cloudworkpro-dave avatar cloudworkpro-dave commented on September 24, 2024

Hey @bcaudan. Thanks for your work on this. I agree with @thaim on this I really don't think this should be throwing an error in the console. In our company, we have some people that have the environment variables set locally because they use the tool, and many other developers that don't, and even the developers that don't use the tool see this error warning. In either case, it's a configuration, people don't have it set on purpose so would this be an easy update to just change this console.error to console.warn. Would really appreciate it. Thank you!

from browser-sdk.

alan-ps avatar alan-ps commented on September 24, 2024

Hi @bcaudan,

The thing is validation happen (validateAndBuildConfiguration) before we decide which handler gonna be used. This means we should always specify clientToken (it's mandatory) to be able to use logger, even if we need console handler (e.g for dev environment), which does not require it.

The suggestion above does not work for such case, since we want to use logger (console handler), however - it's not possible w/o clientToken.

We can specify some random string (e.g 'empty') and everything works fine. However, I didn't find this in documentation so not sure it's correct.

// env.DATADOG_CLIENT_TOKEN is set for production only.

datadogLogs.init({
  clientToken: env.DATADOG_CLIENT_TOKEN || 'empty',
  ...
})

datadogLogs.logger.setHandler(env.DATADOG_CLIENT_TOKEN ? 'http' : 'console')
datadogLogs.logger.setLevel(env.LOGGER_LEVEL)

In summary, it would be great to not specify clientToken for console handler if it's not used. Or maybe add a workaround with 'empty' string to the documentation. Does it make sense?

from browser-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.