0.1.16 • Published 4 years ago
@lightspeed/react-new-relic-script v0.1.16
@lightspeed/react-new-relic-script
Introduction
In serverside rendered React apps, this component renders to the browser timing header for clientside New Relic instrumentation.
Quick Start
- Install the dependency in your webapp.
yarn add newrelic @lightspeed/react-new-relic-scriptConfigure New Relic by either creating a
newrelic.jsconfiguration file at the root directory of your webapp, or setting environment variables as described here. You will at least need to set theapp_nameandlicense_keyconfigurations.Add
require('newrelic');as the first line of your application's entry point. Modules syncronously loaded New Relic will be instrumented appropriately.In your serverside rendered document component, render the
<NewRelicScript />component in the<head />of your document. For example, in aNext.jsapp with serverside rendering, use the component as follows:
// app/_document.tsx
import React from 'react';
import Document, { Head, Main, NextScript, NextDocumentContext } from 'next/document';
import NewRelicScript from '@lightspeed/react-new-relic-script';
export default class MyDocument extends Document {
render() {
return (
<html>
<Head nonce={this.props.nonce}>
<title>Lightspeed Retail - Cool Page</title>
<NewRelicScript />
</Head>
<body>
<Main />
<NextScript />
</body>
</html>
);
}
}