Is it possible to send explicitly logs to New Relic from browsers?

I have a react application that is doing the monitoring using new relic.
I would like to know if is possible to send logs in a explicit way to new relic and see this information on “logs” section
For instance:
newRelic.info(‘some information’)
newRelic.error(‘some error that was not thrown to the browser’ errorObject)

1 Like

Hi, @paulosv: No, the Browser agent API does not currently include functions to write to New Relic Logs, though that is a great feature idea.

I do not think it is possible to call the Log API directly from the user’s browser, and even if it were, your API or license key would be visible in the JavaScript code. As a workaround, you could create a backend service that you call from your React application, which in turn calls the Log API.

3 Likes

@philweber, the license is already exposed from the snippet code provided on the “Application settings” page for each browser app so it shouldn’t be a problem. Furthermore, there’s already a “Domain conditions” section that can be used to allow or deny data from different domains.
Having that said, would it make sense to have support for this?

Hi, @GDoCarmoNorte: I am not on the product team, so it doesn’t matter what I think. :slight_smile: I can only tell you how the product currently works.

I’m trying to figure this out as well.

We rely on logging on the front end, in your traditional sense, as what seq, application insights, elastic search, etc provides.

I don’t see how we can do this via the browser API.

What would be the alternative approach? Is this something interaction would help with (no idea what interaction is, just saw that word thrown around)

Any help or guidance (or even understanding) on how to get more observability through logging.

Hi @jonyeezy Welcome to the community! I’m happy to help.
Even though we do not have a direct approach to collect front-end logs, you can use our Browser agent APIs to forward data from your application.

Here’s a quick link to the list of APIs available.

Using these APIs, you can send custom data along with custom interactions from different points of your code execution which gets stored in the New Relic event data. All this info can be queried later from our query builder which can also be added to the custom dashboards for your quick reference. Hope this info helps.

So was there any change to this, from what i can tell Browser agent api still doesn’t support logging?

Hi, @oleg.maltsev: No, there has been no change. @harika’s reply above still applies.

the issue i have using browser api is that all the logs are in different areas (Javascript, PageAction, etc).
I would love to structure the logs how i want to view it into Logs with all my other API and mobile logs