diff --git a/types/new-relic-browser/index.d.ts b/types/new-relic-browser/index.d.ts index f580226118..eef1df2d4e 100644 --- a/types/new-relic-browser/index.d.ts +++ b/types/new-relic-browser/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for non-npm package NewRelicBrowser 0.1072 +// Type definitions for non-npm package NewRelicBrowser 0.1118 // Project: https://docs.newrelic.com/docs/browser/new-relic-browser/browser-agent-spa-api // Definitions by: Rene Hamburger , Piotr Kubisa // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -49,11 +49,12 @@ declare namespace NewRelic { /** * Identifies a browser error without disrupting your app's operations. * - * @param Provide a meaningful error message that you can use when analyzing data on + * @param error Provide a meaningful error message that you can use when analyzing data on * New Relic Browser's JavaScript errors page. + * @param customAttributes An object containing name/value pairs representing custom attributes. * @see https://docs.newrelic.com/docs/browser/new-relic-browser/browser-agent-spa-api/notice-error */ - noticeError(error: any): void; + noticeError(error: Error | string, customAttributes?: { [key: string]: string | number }): void; /** * Adds a user-defined attribute name and value to subsequent events on the page. @@ -65,7 +66,7 @@ declare namespace NewRelic { * values cannot be complex objects, only simple types such as strings and numbers. * @see https://docs.newrelic.com/docs/browser/new-relic-browser/browser-agent-spa-api/set-custom-attribute */ - setCustomAttribute(name: string, value: string): void; + setCustomAttribute(name: string, value: string | number): void; /** * Allows selective ignoring of known errors that the Browser agent captures. @@ -108,7 +109,7 @@ declare namespace NewRelic { * the default naming strategy. * @see https://docs.newrelic.com/docs/browser/new-relic-browser/browser-agent-spa-api/spa-set-current-route-name */ - setCurrentRouteName(name: string): void; + setCurrentRouteName(name: string | null): void; } interface EventObject { @@ -131,10 +132,12 @@ declare namespace NewRelic { * @param name This will be used as the name of the tracer. If you do not include a name, * New Relic Browser does not add a node to the interaction tree. The callback time will be * attributed to the parent node. + * @param callback A callback that contains the synchronous work to run at the end of the async work. + * To execute this callback, call the wrapper function returned using createTracer() * @returns This method ends the async time. It calls (and times) the callback that was passed into createTracer(). * @see https://docs.newrelic.com/docs/browser/new-relic-browser/browser-agent-spa-api/spa-create-tracer */ - createTracer(name: string, syncCallback?: () => void): () => void; + createTracer(name: string, callback?: () => void): () => void; /** * Ends the New Relic SPA interaction at the current time. diff --git a/types/new-relic-browser/new-relic-browser-tests.ts b/types/new-relic-browser/new-relic-browser-tests.ts index b593f335e1..8a889f4992 100644 --- a/types/new-relic-browser/new-relic-browser-tests.ts +++ b/types/new-relic-browser/new-relic-browser-tests.ts @@ -1,4 +1,4 @@ -import newrelic = require("new-relic-browser"); +import newrelic = require('new-relic-browser'); // The following tests are largely taken straight from the examples at https://docs.newrelic.com/docs/browser/new-relic-browser/browser-agent-spa-api @@ -34,9 +34,12 @@ try { newrelic.noticeError(err); } newrelic.noticeError(new Error('bar')); +newrelic.noticeError('bar'); +newrelic.noticeError('bar', { foo: 'bar', baz: 1}); // setCustomAttribute() newrelic.setCustomAttribute('nodeId', '123'); +newrelic.setCustomAttribute('nodeId', 123); // setErrorHandler() newrelic.setErrorHandler((err) => { @@ -52,6 +55,7 @@ newrelic.setPageViewName('/login', 'https://www.myapp.com'); // setCurrentRouteName() newrelic.setCurrentRouteName('/users/:id'); +newrelic.setCurrentRouteName(null); // --- NewRelic.BrowserInteraction methods -----------------------------------