From d7b256d3b0c55de258c74e428462516b4afe13f0 Mon Sep 17 00:00:00 2001 From: Jordan Porter Date: Sat, 22 Jun 2024 17:07:41 -0600 Subject: [PATCH 01/10] add logs API docs --- .../introduction-browser-monitoring.mdx | 2 +- .../{addpageaction.mdx => addpageaction.md} | 0 .../new-relic-browser/browser-apis/log.mdx | 115 ++++++++++++++ .../browser-apis/using-browser-apis.mdx | 22 ++- .../browser-apis/wraplogger.mdx | 142 ++++++++++++++++++ 5 files changed, 279 insertions(+), 2 deletions(-) rename src/content/docs/browser/new-relic-browser/browser-apis/{addpageaction.mdx => addpageaction.md} (100%) create mode 100644 src/content/docs/browser/new-relic-browser/browser-apis/log.mdx create mode 100644 src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx diff --git a/src/content/docs/browser/browser-monitoring/getting-started/introduction-browser-monitoring.mdx b/src/content/docs/browser/browser-monitoring/getting-started/introduction-browser-monitoring.mdx index ae87f6bafb4..c2f7dcfe333 100644 --- a/src/content/docs/browser/browser-monitoring/getting-started/introduction-browser-monitoring.mdx +++ b/src/content/docs/browser/browser-monitoring/getting-started/introduction-browser-monitoring.mdx @@ -34,7 +34,7 @@ import browserDistributedTracing from 'images/browser_screenshot-crop_distribute Our provides a real user monitoring (RUM) solution. It measures speed and performance as your end users navigate to your site through different web browsers, devices, operating systems, and networks. But browser monitoring goes far beyond providing information about the initial page load. Use it to measure full page life cycle data and start getting the info you need to help ensure customer satisfaction. - New Relic lets you monitor the data from browser activity and optimize performance across your entire stack. Use browser monitoring to help ensure successful deployments and quickly troubleshoot customer-visible problems. Monitor your stack at a glance and make sure all your entities are operating as they should. Visualize application speed and performance, JavaScript errors, AJAX requests, and more. Spend less time trying to chase down issues and more time delivering a perfect digital experience to customers. + New Relic lets you monitor the data from browser activity and optimize performance across your entire stack. Use browser monitoring to help ensure successful deployments and quickly troubleshoot customer-visible problems. Monitor your stack at a glance and make sure all your entities are operating as they should. Visualize application speed and performance, JavaScript errors, AJAX requests, logs and more. Spend less time trying to chase down issues and more time delivering a perfect digital experience to customers. ) +``` + +Captures data as a single log event. + +## Requirements + +* Browser Pro, or Pro+SPA agent (v1.261.0 or higher) +* If you're using npm to install the browser agent and using a non-standard implementation, you must enable the `logging` feature when instantiating the `BrowserAgent` class. For example, add the following in the`features` array: + + ```js + import { Logging } from '@newrelic/browser-agent/features/logging' + + const options = { + info: { ... }, + loader_config: { ... }, + init: { ... }, + features: [ + Logging + ] + } + ``` + + For more information, see the [npm browser installation documentation](https://www.npmjs.com/package/@newrelic/browser-agent#new-relic-browser-agent). + +## Description + +Upon executing this function with a valid message and elective options, the browser agent records the data as a single `log` event. See the [Logs UI](https://docs.newrelic.com/docs/logs/ui-data/use-logs-ui/) for more information about log events. Any custom attributes supplied to the API call in the `options` argument (`options.customAttributes`) will be appended as top-level attributes on the log event. You can control the `logLevel` of the captured log by supplying a `level` to the `options` argument (`options.level`), which defaults to `info`. + +## Parameters + + + + + + + + + + + + + + + + + + + + + + +
+ Parameter + + Description +
+ `message` + + _string_ + + Required. A string value which will be set to the `message` value of the created log event. The `message` property of the log event is the most visible property exposed on the log event and is used across the UI platform when displaying logs. +
+ `options` + + _Object_ + + Optional. An object used for supplying optional configurations for the captured log. `options.customAttributes` is an object of key:val pairs that assigns a top-level property and value to the created log for each attribute supplied. `options.level` is an enum that assigns a log level to the created log event. The `level` must be one of: `debug | error | info | trace | warn`. The log level defaults to `info` if not supplied. +
+ +## Examples + +### Capturing a simple log item + +```js +newrelic.log('my log message') +// saves a log event with: +// a message of --> 'my log message' +// a logLevel of --> 'info' +``` + +### Capturing a log item with a specified logLevel + +```js +newrelic.setUserId('my log message', {level: 'debug'}) +// saves a log event with: +// a message of --> 'my log message' +// a logLevel of --> 'debug' +``` + +### Capturing a log item with custom attributes + +```js +newrelic.setUserId('my log message', {customAttributes: {myFavoriteApp: true}}) +// saves a log event with: +// a message of --> 'my log message' +// a logLevel of --> 'info' +// an attribute of --> 'myFavoriteApp: true' +``` diff --git a/src/content/docs/browser/new-relic-browser/browser-apis/using-browser-apis.mdx b/src/content/docs/browser/new-relic-browser/browser-apis/using-browser-apis.mdx index 39d06e54b21..6872bfe4143 100644 --- a/src/content/docs/browser/new-relic-browser/browser-apis/using-browser-apis.mdx +++ b/src/content/docs/browser/new-relic-browser/browser-apis/using-browser-apis.mdx @@ -104,6 +104,26 @@ To monitor traces and events, use these methods: [`newrelic.setUserId()`](/docs/browser/new-relic-browser/browser-apis/setuserid) + + + + Capture a single browser log event + + + + [`newrelic.log()`](/docs/browser/new-relic-browser/browser-apis/log) + + + + + + Automatically capture messages passing through your existing logger methods as log events + + + + [`newrelic.wrapLogger()`](/docs/browser/new-relic-browser/browser-apis/wraplogger) + + @@ -137,7 +157,7 @@ To report errors in your application, use these methods: - Log a caught or handled error, without disrupting your app's operation + Capture a caught or handled error, without disrupting your app's operation diff --git a/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx b/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx new file mode 100644 index 00000000000..02184df8bd7 --- /dev/null +++ b/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx @@ -0,0 +1,142 @@ +--- +title: wrapLogger +type: apiDoc +shortDescription: Automatically capture data passing through your existing logger methods as log events. +tags: + - Browser + - Browser monitoring + - Browser agent and SPA API +metaDescription: Automatically capture data passing through your existing logger methods as log events. +redirects: +freshnessValidatedDate: never +--- + +## Syntax + +```js +newrelic.wrapLogger(parent: Object, functionName: string, options?: Object<{ customAttributes?: Object, level?: 'debug|error|info|trace|warn'}>) +``` + +Captures data as a single log event. + +## Requirements + +* Browser Pro, or Pro+SPA agent (v1.261.0 or higher) +* If you're using npm to install the browser agent and using a non-standard implementation, you must enable the `logging` feature when instantiating the `BrowserAgent` class. For example, add the following in the`features` array: + + ```js + import { Logging } from '@newrelic/browser-agent/features/logging' + + const options = { + info: { ... }, + loader_config: { ... }, + init: { ... }, + features: [ + Logging + ] + } + ``` + + For more information, see the [npm browser installation documentation](https://www.npmjs.com/package/@newrelic/browser-agent#new-relic-browser-agent). + +## Description +Upon providing this method with a valid parent container and child function name, the browser agent will record a new `log` event every time the wrapped function is `invoked`, capturing the `first` argument passed to the invoked function as the log's `message`. See the [Logs UI](https://docs.newrelic.com/docs/logs/ui-data/use-logs-ui/) for more information about log events. Optional configurations can be passed along with these captured logs, by use of the `options` argument. Any custom attributes supplied to the API call in the `options` argument (`options.customAttributes`) will be appended as top-level attributes on every log event created by this wrapper. You can control the `logLevel` of the captured log by supplying a `level` to the `options` argument (`options.level`), which defaults to `info`. To `unset` the `options`, call the method again without supplying the options values. To `overwrite` existing `options`, call the method again with new `options` configurations. + +## Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Parameter + + Description +
+ `parent` + + _Object_ + + Required. An object which contains the target function to be wrapped. +
+ `functionName` + + _string_ + + Required. The name of the target function to be wrapped. This function must exist in the `parent` object and match the type of "function". +
+ `options` + + _Object_ + + Optional. An object used for supplying optional configurations for every log captured by the wrapper. `options.customAttributes` is an object of key:val pairs that assigns a top-level property and value to the created log for each attribute supplied. `options.level` is an enum that assigns a log level to the created log event. The `level` must be one of: `debug | error | info | trace | warn`. The log level defaults to `info` if not supplied. +
+ +## Examples + +### Capturing log items from the native console method(s) +```js +newrelic.wrapLogger(console, 'info') +// from this point forward, every time `console.info` is invoked, it will save a log event with: +// a message of --> +// a logLevel of --> 'info' +``` + +### Capturing log items from a custom logger + +```js +const myLoggers = { + myInfoLogger: function(){...} +} +newrelic.wrapLogger(myLoggers, 'myInfoLogger') +// from this point forward, every time `myLoggers.myInfoLogger` is invoked, it will save a log event with: +// a message of --> +// a logLevel of --> 'info' +``` + +### Capturing log items with a specified logLevel + +```js +const myLoggers = { + myInfoLogger: function(){...} +} +newrelic.wrapLogger(myLoggers, 'myInfoLogger') +// from this point forward, every time `myLoggers.myInfoLogger` is invoked, it will save a log event with: +// a message of --> +// a logLevel of --> 'debug' +``` + +### Capturing a log item with custom attributes + +```js +const myLoggers = { + myInfoLogger: function(){...} +} +newrelic.wrapLogger(myLoggers, 'myInfoLogger') +// from this point forward, every time `myLoggers.myInfoLogger` is invoked, it will save a log event with: +// a message of --> +// a logLevel of --> 'debug' +// an attribute of --> 'myFavoriteApp: true' +``` From f5a632cc5d45d770df315591fcb8a39175c3ab8d Mon Sep 17 00:00:00 2001 From: Jordan Porter Date: Sat, 22 Jun 2024 17:12:05 -0600 Subject: [PATCH 02/10] fix missed copypasta issues --- .../browser/new-relic-browser/browser-apis/log.mdx | 14 ++++++++++++-- .../new-relic-browser/browser-apis/wraplogger.mdx | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/content/docs/browser/new-relic-browser/browser-apis/log.mdx b/src/content/docs/browser/new-relic-browser/browser-apis/log.mdx index 21517cfc4c7..a7ae75a78e5 100644 --- a/src/content/docs/browser/new-relic-browser/browser-apis/log.mdx +++ b/src/content/docs/browser/new-relic-browser/browser-apis/log.mdx @@ -98,7 +98,7 @@ newrelic.log('my log message') ### Capturing a log item with a specified logLevel ```js -newrelic.setUserId('my log message', {level: 'debug'}) +newrelic.log('my log message', {level: 'debug'}) // saves a log event with: // a message of --> 'my log message' // a logLevel of --> 'debug' @@ -107,9 +107,19 @@ newrelic.setUserId('my log message', {level: 'debug'}) ### Capturing a log item with custom attributes ```js -newrelic.setUserId('my log message', {customAttributes: {myFavoriteApp: true}}) +newrelic.log('my log message', {customAttributes: {myFavoriteApp: true}}) // saves a log event with: // a message of --> 'my log message' // a logLevel of --> 'info' // an attribute of --> 'myFavoriteApp: true' ``` + +### Capturing a log item with a specified logLevel and custom attributes + +```js +newrelic.log('my log message', {level: 'debug', customAttributes: {myFavoriteApp: true}}) +// saves a log event with: +// a message of --> 'my log message' +// a logLevel of --> 'debug' +// an attribute of --> 'myFavoriteApp: true' +``` diff --git a/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx b/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx index 02184df8bd7..c681a2bf485 100644 --- a/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx +++ b/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx @@ -122,7 +122,7 @@ newrelic.wrapLogger(myLoggers, 'myInfoLogger') const myLoggers = { myInfoLogger: function(){...} } -newrelic.wrapLogger(myLoggers, 'myInfoLogger') +newrelic.wrapLogger(myLoggers, 'myInfoLogger', {level: 'debug'}) // from this point forward, every time `myLoggers.myInfoLogger` is invoked, it will save a log event with: // a message of --> // a logLevel of --> 'debug' @@ -134,7 +134,7 @@ newrelic.wrapLogger(myLoggers, 'myInfoLogger') const myLoggers = { myInfoLogger: function(){...} } -newrelic.wrapLogger(myLoggers, 'myInfoLogger') +newrelic.wrapLogger(myLoggers, 'myInfoLogger', {customAttributes: {myFavoriteApp: true}}) // from this point forward, every time `myLoggers.myInfoLogger` is invoked, it will save a log event with: // a message of --> // a logLevel of --> 'debug' From 76439815dc1d2a4a9a32ccf1d794703ada5b5d8f Mon Sep 17 00:00:00 2001 From: Jordan Porter Date: Sat, 22 Jun 2024 17:13:56 -0600 Subject: [PATCH 03/10] cleanup --- .../new-relic-browser/browser-apis/using-browser-apis.mdx | 2 +- .../browser/new-relic-browser/browser-apis/wraplogger.mdx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/content/docs/browser/new-relic-browser/browser-apis/using-browser-apis.mdx b/src/content/docs/browser/new-relic-browser/browser-apis/using-browser-apis.mdx index 6872bfe4143..77e7e22972f 100644 --- a/src/content/docs/browser/new-relic-browser/browser-apis/using-browser-apis.mdx +++ b/src/content/docs/browser/new-relic-browser/browser-apis/using-browser-apis.mdx @@ -121,7 +121,7 @@ To monitor traces and events, use these methods: - [`newrelic.wrapLogger()`](/docs/browser/new-relic-browser/browser-apis/wraplogger) + [`newrelic.wrapLogger()`](/docs/browser/new-relic-browser/browser-apis/wrapLogger) diff --git a/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx b/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx index c681a2bf485..c1e31fdf900 100644 --- a/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx +++ b/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx @@ -1,12 +1,12 @@ --- title: wrapLogger type: apiDoc -shortDescription: Automatically capture data passing through your existing logger methods as log events. +shortDescription: Wrap existing browser logging methods. tags: - Browser - Browser monitoring - Browser agent and SPA API -metaDescription: Automatically capture data passing through your existing logger methods as log events. +metaDescription: Automatically capture data passing through your existing browser logging methods as log events. redirects: freshnessValidatedDate: never --- From d99a03c68615bb36872a632d4d3660cb119f56e2 Mon Sep 17 00:00:00 2001 From: Jordan Porter Date: Sat, 22 Jun 2024 17:18:16 -0600 Subject: [PATCH 04/10] add another example --- .../browser-apis/wraplogger.mdx | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx b/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx index c1e31fdf900..48a16de0ff2 100644 --- a/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx +++ b/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx @@ -108,11 +108,11 @@ newrelic.wrapLogger(console, 'info') ```js const myLoggers = { - myInfoLogger: function(){...} + logger: function(){...} } -newrelic.wrapLogger(myLoggers, 'myInfoLogger') -// from this point forward, every time `myLoggers.myInfoLogger` is invoked, it will save a log event with: -// a message of --> +newrelic.wrapLogger(myLoggers, 'logger') +// from this point forward, every time `myLoggers.logger` is invoked, it will save a log event with: +// a message of --> // a logLevel of --> 'info' ``` @@ -120,11 +120,11 @@ newrelic.wrapLogger(myLoggers, 'myInfoLogger') ```js const myLoggers = { - myInfoLogger: function(){...} + logger: function(){...} } -newrelic.wrapLogger(myLoggers, 'myInfoLogger', {level: 'debug'}) -// from this point forward, every time `myLoggers.myInfoLogger` is invoked, it will save a log event with: -// a message of --> +newrelic.wrapLogger(myLoggers, 'logger', {level: 'debug'}) +// from this point forward, every time `myLoggers.logger` is invoked, it will save a log event with: +// a message of --> // a logLevel of --> 'debug' ``` @@ -132,11 +132,29 @@ newrelic.wrapLogger(myLoggers, 'myInfoLogger', {level: 'debug'}) ```js const myLoggers = { - myInfoLogger: function(){...} + logger: function(){...} } -newrelic.wrapLogger(myLoggers, 'myInfoLogger', {customAttributes: {myFavoriteApp: true}}) +newrelic.wrapLogger(myLoggers, 'logger', {customAttributes: {myFavoriteApp: true}}) +// from this point forward, every time `myLoggers.logger` is invoked, it will save a log event with: +// a message of --> +// a logLevel of --> 'info' +// an attribute of --> 'myFavoriteApp: true' +``` + +### Wrap multiple loggers + +```js +const myLoggers = { + myInfoLogger: function(){...}, + myDebugLogger: function(){...} +} +newrelic.wrapLogger(myLoggers, 'myInfoLogger', {level: 'info'}) +newrelic.wrapLogger(myLoggers, 'myDebugLogger', {level: 'debug'}) // from this point forward, every time `myLoggers.myInfoLogger` is invoked, it will save a log event with: // a message of --> +// a logLevel of --> 'info' + +// every time `myLoggers.myDebugLogger` is invoked, it will save a log event with: +// a message of --> // a logLevel of --> 'debug' -// an attribute of --> 'myFavoriteApp: true' ``` From a12d39f93fa14b39ab0df9f2d0fe429777289745 Mon Sep 17 00:00:00 2001 From: Jordan Porter Date: Sat, 22 Jun 2024 17:23:15 -0600 Subject: [PATCH 05/10] fix note --- .../docs/browser/new-relic-browser/browser-apis/wraplogger.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx b/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx index 48a16de0ff2..3edb89e1192 100644 --- a/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx +++ b/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx @@ -17,7 +17,7 @@ freshnessValidatedDate: never newrelic.wrapLogger(parent: Object, functionName: string, options?: Object<{ customAttributes?: Object, level?: 'debug|error|info|trace|warn'}>) ``` -Captures data as a single log event. +Automatically captures data passing through existing browser logging methods as log events. ## Requirements From d630e2664bfb9de13d9164e106ecf7860df6821a Mon Sep 17 00:00:00 2001 From: Jordan Porter Date: Mon, 24 Jun 2024 14:29:02 -0600 Subject: [PATCH 06/10] remove instruction after alignment with team --- .../new-relic-browser/browser-apis/log.mdx | 14 +++++++------- .../browser-apis/wraplogger.mdx | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/content/docs/browser/new-relic-browser/browser-apis/log.mdx b/src/content/docs/browser/new-relic-browser/browser-apis/log.mdx index a7ae75a78e5..0863e70899b 100644 --- a/src/content/docs/browser/new-relic-browser/browser-apis/log.mdx +++ b/src/content/docs/browser/new-relic-browser/browser-apis/log.mdx @@ -41,7 +41,7 @@ Captures data as a single log event. ## Description -Upon executing this function with a valid message and elective options, the browser agent records the data as a single `log` event. See the [Logs UI](https://docs.newrelic.com/docs/logs/ui-data/use-logs-ui/) for more information about log events. Any custom attributes supplied to the API call in the `options` argument (`options.customAttributes`) will be appended as top-level attributes on the log event. You can control the `logLevel` of the captured log by supplying a `level` to the `options` argument (`options.level`), which defaults to `info`. +Upon executing this function with a valid message and elective options, the browser agent records the data as a single `log` event. See the [Logs UI](https://docs.newrelic.com/docs/logs/ui-data/use-logs-ui/) for more information about log events. Any custom attributes supplied to the API call in the `options` argument (`options.customAttributes`) will be appended as top-level attributes on the log event. You can control the `logType` of the captured log by supplying a `level` to the `options` argument (`options.level`), which defaults to `info`. ## Parameters @@ -92,16 +92,16 @@ Upon executing this function with a valid message and elective options, the brow newrelic.log('my log message') // saves a log event with: // a message of --> 'my log message' -// a logLevel of --> 'info' +// a logType of --> 'info' ``` -### Capturing a log item with a specified logLevel +### Capturing a log item with a specified logType ```js newrelic.log('my log message', {level: 'debug'}) // saves a log event with: // a message of --> 'my log message' -// a logLevel of --> 'debug' +// a logType of --> 'debug' ``` ### Capturing a log item with custom attributes @@ -110,16 +110,16 @@ newrelic.log('my log message', {level: 'debug'}) newrelic.log('my log message', {customAttributes: {myFavoriteApp: true}}) // saves a log event with: // a message of --> 'my log message' -// a logLevel of --> 'info' +// a logType of --> 'info' // an attribute of --> 'myFavoriteApp: true' ``` -### Capturing a log item with a specified logLevel and custom attributes +### Capturing a log item with a specified logType and custom attributes ```js newrelic.log('my log message', {level: 'debug', customAttributes: {myFavoriteApp: true}}) // saves a log event with: // a message of --> 'my log message' -// a logLevel of --> 'debug' +// a logType of --> 'debug' // an attribute of --> 'myFavoriteApp: true' ``` diff --git a/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx b/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx index 3edb89e1192..b5841c3db08 100644 --- a/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx +++ b/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx @@ -40,7 +40,7 @@ Automatically captures data passing through existing browser logging methods as For more information, see the [npm browser installation documentation](https://www.npmjs.com/package/@newrelic/browser-agent#new-relic-browser-agent). ## Description -Upon providing this method with a valid parent container and child function name, the browser agent will record a new `log` event every time the wrapped function is `invoked`, capturing the `first` argument passed to the invoked function as the log's `message`. See the [Logs UI](https://docs.newrelic.com/docs/logs/ui-data/use-logs-ui/) for more information about log events. Optional configurations can be passed along with these captured logs, by use of the `options` argument. Any custom attributes supplied to the API call in the `options` argument (`options.customAttributes`) will be appended as top-level attributes on every log event created by this wrapper. You can control the `logLevel` of the captured log by supplying a `level` to the `options` argument (`options.level`), which defaults to `info`. To `unset` the `options`, call the method again without supplying the options values. To `overwrite` existing `options`, call the method again with new `options` configurations. +Upon providing this method with a valid parent container and child function name, the browser agent will record a new `log` event every time the wrapped function is `invoked`, capturing the `first` argument passed to the invoked function as the log's `message`. See the [Logs UI](https://docs.newrelic.com/docs/logs/ui-data/use-logs-ui/) for more information about log events. Optional configurations can be passed along with these captured logs, by use of the `options` argument. Any custom attributes supplied to the API call in the `options` argument (`options.customAttributes`) will be appended as top-level attributes on every log event created by this wrapper. You can control the `logType` of the captured log by supplying a `level` to the `options` argument (`options.level`), which defaults to `info`. **Note** once successfully wrapped, the function's logging detection will not be able to be altered. ## Parameters @@ -101,7 +101,7 @@ Upon providing this method with a valid parent container and child function name newrelic.wrapLogger(console, 'info') // from this point forward, every time `console.info` is invoked, it will save a log event with: // a message of --> -// a logLevel of --> 'info' +// a logType of --> 'info' ``` ### Capturing log items from a custom logger @@ -113,10 +113,10 @@ const myLoggers = { newrelic.wrapLogger(myLoggers, 'logger') // from this point forward, every time `myLoggers.logger` is invoked, it will save a log event with: // a message of --> -// a logLevel of --> 'info' +// a logType of --> 'info' ``` -### Capturing log items with a specified logLevel +### Capturing log items with a specified logType ```js const myLoggers = { @@ -125,7 +125,7 @@ const myLoggers = { newrelic.wrapLogger(myLoggers, 'logger', {level: 'debug'}) // from this point forward, every time `myLoggers.logger` is invoked, it will save a log event with: // a message of --> -// a logLevel of --> 'debug' +// a logType of --> 'debug' ``` ### Capturing a log item with custom attributes @@ -137,7 +137,7 @@ const myLoggers = { newrelic.wrapLogger(myLoggers, 'logger', {customAttributes: {myFavoriteApp: true}}) // from this point forward, every time `myLoggers.logger` is invoked, it will save a log event with: // a message of --> -// a logLevel of --> 'info' +// a logType of --> 'info' // an attribute of --> 'myFavoriteApp: true' ``` @@ -152,9 +152,9 @@ newrelic.wrapLogger(myLoggers, 'myInfoLogger', {level: 'info'}) newrelic.wrapLogger(myLoggers, 'myDebugLogger', {level: 'debug'}) // from this point forward, every time `myLoggers.myInfoLogger` is invoked, it will save a log event with: // a message of --> -// a logLevel of --> 'info' +// a logType of --> 'info' // every time `myLoggers.myDebugLogger` is invoked, it will save a log event with: // a message of --> -// a logLevel of --> 'debug' +// a logType of --> 'debug' ``` From 661a9e4b2811a1b4933fe228dada8d2300ac20d1 Mon Sep 17 00:00:00 2001 From: Rob Siebens Date: Tue, 25 Jun 2024 08:23:02 -0700 Subject: [PATCH 07/10] fix(browser): Add navigation links --- src/nav/browser.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/nav/browser.yml b/src/nav/browser.yml index e8661fed1b2..88ca6e7e857 100644 --- a/src/nav/browser.yml +++ b/src/nav/browser.yml @@ -120,6 +120,8 @@ pages: path: /docs/browser/new-relic-browser/browser-apis/addtotrace - title: finished path: /docs/browser/new-relic-browser/browser-apis/finished + - title: logs + path: /docs/browser/new-relic-browser/browser-apis/log - title: noticeError path: /docs/browser/new-relic-browser/browser-apis/noticeerror - title: setApplicationVersion @@ -160,6 +162,8 @@ pages: path: /docs/browser/new-relic-browser/browser-apis/setname - title: start path: /docs/browser/new-relic-browser/browser-apis/start + - title: wrapLogger + path: /docs/browser/new-relic-browser/browser-apis/wraplogger - title: Troubleshooting pages: - title: AJAX data collection From cc5b9cc8c954bfaf1746087b719d1196298a02d0 Mon Sep 17 00:00:00 2001 From: Sunny Zanchi Date: Tue, 25 Jun 2024 14:04:28 -0400 Subject: [PATCH 08/10] rename back to mdx --- .../browser-apis/{addpageaction.md => addpageaction.mdx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/content/docs/browser/new-relic-browser/browser-apis/{addpageaction.md => addpageaction.mdx} (100%) diff --git a/src/content/docs/browser/new-relic-browser/browser-apis/addpageaction.md b/src/content/docs/browser/new-relic-browser/browser-apis/addpageaction.mdx similarity index 100% rename from src/content/docs/browser/new-relic-browser/browser-apis/addpageaction.md rename to src/content/docs/browser/new-relic-browser/browser-apis/addpageaction.mdx From bddee8ec2f29b427e04a8bd68497f34a481a2980 Mon Sep 17 00:00:00 2001 From: Jordan Porter Date: Tue, 25 Jun 2024 13:11:42 -0600 Subject: [PATCH 09/10] address PR comments and align logType to level --- .../new-relic-browser/browser-apis/log.mdx | 16 +++++++-------- .../browser-apis/using-browser-apis.mdx | 2 +- .../browser-apis/wraplogger.mdx | 20 ++++++++++--------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/content/docs/browser/new-relic-browser/browser-apis/log.mdx b/src/content/docs/browser/new-relic-browser/browser-apis/log.mdx index 0863e70899b..88ad61bb1e3 100644 --- a/src/content/docs/browser/new-relic-browser/browser-apis/log.mdx +++ b/src/content/docs/browser/new-relic-browser/browser-apis/log.mdx @@ -41,7 +41,7 @@ Captures data as a single log event. ## Description -Upon executing this function with a valid message and elective options, the browser agent records the data as a single `log` event. See the [Logs UI](https://docs.newrelic.com/docs/logs/ui-data/use-logs-ui/) for more information about log events. Any custom attributes supplied to the API call in the `options` argument (`options.customAttributes`) will be appended as top-level attributes on the log event. You can control the `logType` of the captured log by supplying a `level` to the `options` argument (`options.level`), which defaults to `info`. +When you execute this function with a valid message and elective options, the browser agent records the data as a single `log` event. See the [Logs UI](https://docs.newrelic.com/docs/logs/ui-data/use-logs-ui/) for more information about log events. Any custom attributes supplied to the API call in the `options` argument (`options.customAttributes`) will be appended as top-level attributes on the log event. You can control the `level` of the captured log by supplying a `level` to the `options` argument (`options.level`), which defaults to `info`. ## Parameters @@ -78,7 +78,7 @@ Upon executing this function with a valid message and elective options, the brow - Optional. An object used for supplying optional configurations for the captured log. `options.customAttributes` is an object of key:val pairs that assigns a top-level property and value to the created log for each attribute supplied. `options.level` is an enum that assigns a log level to the created log event. The `level` must be one of: `debug | error | info | trace | warn`. The log level defaults to `info` if not supplied. + Optional. An object used for supplying optional configurations for the captured log. `options.customAttributes` is an object of key:val pairs that assigns a top-level property and value to the created log for each attribute supplied. The enum `options.level` assigns a log level to the created log event. The `level` must be one of: `debug | error | info | trace | warn`. The log level defaults to `info` if not supplied. @@ -92,16 +92,16 @@ Upon executing this function with a valid message and elective options, the brow newrelic.log('my log message') // saves a log event with: // a message of --> 'my log message' -// a logType of --> 'info' +// a level of --> 'info' ``` -### Capturing a log item with a specified logType +### Capturing a log item with a specified level ```js newrelic.log('my log message', {level: 'debug'}) // saves a log event with: // a message of --> 'my log message' -// a logType of --> 'debug' +// a level of --> 'debug' ``` ### Capturing a log item with custom attributes @@ -110,16 +110,16 @@ newrelic.log('my log message', {level: 'debug'}) newrelic.log('my log message', {customAttributes: {myFavoriteApp: true}}) // saves a log event with: // a message of --> 'my log message' -// a logType of --> 'info' +// a level of --> 'info' // an attribute of --> 'myFavoriteApp: true' ``` -### Capturing a log item with a specified logType and custom attributes +### Capturing a log item with a specified level and custom attributes ```js newrelic.log('my log message', {level: 'debug', customAttributes: {myFavoriteApp: true}}) // saves a log event with: // a message of --> 'my log message' -// a logType of --> 'debug' +// a level of --> 'debug' // an attribute of --> 'myFavoriteApp: true' ``` diff --git a/src/content/docs/browser/new-relic-browser/browser-apis/using-browser-apis.mdx b/src/content/docs/browser/new-relic-browser/browser-apis/using-browser-apis.mdx index 77e7e22972f..a2cdd9d5f35 100644 --- a/src/content/docs/browser/new-relic-browser/browser-apis/using-browser-apis.mdx +++ b/src/content/docs/browser/new-relic-browser/browser-apis/using-browser-apis.mdx @@ -157,7 +157,7 @@ To report errors in your application, use these methods: - Capture a caught or handled error, without disrupting your app's operation + Capture a caught or handled error without disrupting your app's operation diff --git a/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx b/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx index b5841c3db08..78cc0636418 100644 --- a/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx +++ b/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx @@ -40,7 +40,9 @@ Automatically captures data passing through existing browser logging methods as For more information, see the [npm browser installation documentation](https://www.npmjs.com/package/@newrelic/browser-agent#new-relic-browser-agent). ## Description -Upon providing this method with a valid parent container and child function name, the browser agent will record a new `log` event every time the wrapped function is `invoked`, capturing the `first` argument passed to the invoked function as the log's `message`. See the [Logs UI](https://docs.newrelic.com/docs/logs/ui-data/use-logs-ui/) for more information about log events. Optional configurations can be passed along with these captured logs, by use of the `options` argument. Any custom attributes supplied to the API call in the `options` argument (`options.customAttributes`) will be appended as top-level attributes on every log event created by this wrapper. You can control the `logType` of the captured log by supplying a `level` to the `options` argument (`options.level`), which defaults to `info`. **Note** once successfully wrapped, the function's logging detection will not be able to be altered. +After you provide this method with a valid parent container and child function name, the browser agent will record a new log event every time the wrapped function is invoked. The first argument is passed to the invoked function as the log's message. See the [Logs UI](https://docs.newrelic.com/docs/logs/ui-data/use-logs-ui/) for more information about log events. + +Optional configurations can be passed along with these captured logs with the `options` argument. Any custom attributes supplied to the API call in the `options` argument (`options.customAttributes`) will be appended as top-level attributes on every log event created by this wrapper. You can control the `level` of the captured log by supplying a `level` to the `options` argument (`options.level`), which defaults to `info`. Note that once successfully wrapped, the function's logging detection can't be altered. ## Parameters @@ -88,7 +90,7 @@ Upon providing this method with a valid parent container and child function name - Optional. An object used for supplying optional configurations for every log captured by the wrapper. `options.customAttributes` is an object of key:val pairs that assigns a top-level property and value to the created log for each attribute supplied. `options.level` is an enum that assigns a log level to the created log event. The `level` must be one of: `debug | error | info | trace | warn`. The log level defaults to `info` if not supplied. + Optional. An object used for supplying optional configurations for every log captured by the wrapper. `options.customAttributes` is an object of key:val pairs that assigns a top-level property and value to the created log for each attribute supplied. The enum `options.level` assigns a log level to the created log event. The `level` must be one of: `debug | error | info | trace | warn`. The log level defaults to `info` if not supplied. @@ -101,7 +103,7 @@ Upon providing this method with a valid parent container and child function name newrelic.wrapLogger(console, 'info') // from this point forward, every time `console.info` is invoked, it will save a log event with: // a message of --> -// a logType of --> 'info' +// a level of --> 'info' ``` ### Capturing log items from a custom logger @@ -113,10 +115,10 @@ const myLoggers = { newrelic.wrapLogger(myLoggers, 'logger') // from this point forward, every time `myLoggers.logger` is invoked, it will save a log event with: // a message of --> -// a logType of --> 'info' +// a level of --> 'info' ``` -### Capturing log items with a specified logType +### Capturing log items with a specified level ```js const myLoggers = { @@ -125,7 +127,7 @@ const myLoggers = { newrelic.wrapLogger(myLoggers, 'logger', {level: 'debug'}) // from this point forward, every time `myLoggers.logger` is invoked, it will save a log event with: // a message of --> -// a logType of --> 'debug' +// a level of --> 'debug' ``` ### Capturing a log item with custom attributes @@ -137,7 +139,7 @@ const myLoggers = { newrelic.wrapLogger(myLoggers, 'logger', {customAttributes: {myFavoriteApp: true}}) // from this point forward, every time `myLoggers.logger` is invoked, it will save a log event with: // a message of --> -// a logType of --> 'info' +// a level of --> 'info' // an attribute of --> 'myFavoriteApp: true' ``` @@ -152,9 +154,9 @@ newrelic.wrapLogger(myLoggers, 'myInfoLogger', {level: 'info'}) newrelic.wrapLogger(myLoggers, 'myDebugLogger', {level: 'debug'}) // from this point forward, every time `myLoggers.myInfoLogger` is invoked, it will save a log event with: // a message of --> -// a logType of --> 'info' +// a level of --> 'info' // every time `myLoggers.myDebugLogger` is invoked, it will save a log event with: // a message of --> -// a logType of --> 'debug' +// a level of --> 'debug' ``` From 7a0efd39d770596c006ddcbc337fa368b0e34d2a Mon Sep 17 00:00:00 2001 From: Rob Siebens Date: Tue, 25 Jun 2024 15:56:31 -0700 Subject: [PATCH 10/10] fix(browser): Fix indentation --- .../docs/browser/new-relic-browser/browser-apis/log.mdx | 3 ++- .../docs/browser/new-relic-browser/browser-apis/wraplogger.mdx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/content/docs/browser/new-relic-browser/browser-apis/log.mdx b/src/content/docs/browser/new-relic-browser/browser-apis/log.mdx index 88ad61bb1e3..83dcb991210 100644 --- a/src/content/docs/browser/new-relic-browser/browser-apis/log.mdx +++ b/src/content/docs/browser/new-relic-browser/browser-apis/log.mdx @@ -37,7 +37,8 @@ Captures data as a single log event. } ``` - For more information, see the [npm browser installation documentation](https://www.npmjs.com/package/@newrelic/browser-agent#new-relic-browser-agent). + +For more information, see the [npm browser installation documentation](https://www.npmjs.com/package/@newrelic/browser-agent#new-relic-browser-agent). ## Description diff --git a/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx b/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx index 78cc0636418..18d755ad455 100644 --- a/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx +++ b/src/content/docs/browser/new-relic-browser/browser-apis/wraplogger.mdx @@ -37,7 +37,7 @@ Automatically captures data passing through existing browser logging methods as } ``` - For more information, see the [npm browser installation documentation](https://www.npmjs.com/package/@newrelic/browser-agent#new-relic-browser-agent). +For more information, see the [npm browser installation documentation](https://www.npmjs.com/package/@newrelic/browser-agent#new-relic-browser-agent). ## Description After you provide this method with a valid parent container and child function name, the browser agent will record a new log event every time the wrapped function is invoked. The first argument is passed to the invoked function as the log's message. See the [Logs UI](https://docs.newrelic.com/docs/logs/ui-data/use-logs-ui/) for more information about log events.