1.0.1 • Published 2 years ago

next-speedcurve v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

next-speedcurve

npm version

SpeedCurve integration for Next.js applications.

Installation

yarn add next-speedcurve

Usage

The SpeedCurve component will inject the SpeedCurve scripts into the document head and initialize RUM at the beginning of each SPA "page view".

The following example shows this being done via the Next.js App component:

import { SpeedCurve } from 'next-speedcurve';

const MyApp = ({ Component, pageProps }) => (
  <>
    <SpeedCurve
      luxId="123"
    />
    <Component
      {...pageProps}
    />
  </>
);

export default MyApp;

RUM API

The useSpeedCurveLUX() hook can be used to interact with the SpeedCurve RUM JS API, for example:

import { useSpeedCurveLUX } from 'next-speedcurve';

useSpeedCurveLUX({
  data: {
    'cart size': 128,
    'experiment A': 'control',
  },
  label: 'my-page',
  samplerate: 20,
});

The following properties are available:

PropertyDescription
autoIf set to false, the beacon is not sent at the window load event.
dataAn object containing key value pairs to be added to the beacon.
debugIf set to true, debug messages are written to the browser console.
forceSampleCalling LUX.forceSample() changes your session cookie so that on all subsequent page views you will be sampled and should see RUM data being generated.
labelThis is the “page label” used to group RUM data by page type.
samplerateThis is the sample rate for determining whether the beacon is sent.

See the SpeedCurve RUM JS API docs for more details about these properties.