0.32.1 • Published 5 months ago

@vyro-x/react-insights-client v0.32.1

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

@vyro-x/react-insights-client

Client-side insights system integration for React & Next.js

Usage

Install

npm i @vyro-x/react-insights-client

or

pnpm i @vyro-x/react-insights-client

InsightsProvider

Wrap your app with the InsightsProvider

import { InsightsProvider, CollectorApi } from '@vyro-x/react-insights-client';
import { authService } from '@vyro-x/react-auth';
import * as React from 'react';
import * as ReactDOM from 'react-dom/client';
import { App } from './App';

const container = document.getElementById('root');
if (!container) throw new Error('Failed to find the root element');
const root = ReactDOM.createRoot(container);

const collectorApi = new CollectorApi({
  endpoint: process.env.REACT_APP_COLLECTOR_API_URL,
  getAccessToken: authService.tokens.getAccessToken,
});

root.render(
  <React.StrictMode>
    <InsightsProvider collectorApi={collectorApi}>
      <App />
    </InsightsProvider>
  </React.StrictMode>,
);

Track

Track events using the useInsights hook.

import { useInsights, EventInput } from '@vyro-x/react-insights-client';

export default function Page() {
  const { trackEvent } = useInsights();

  return (
    <button
      onClick={() =>
        trackEvent({
          type: EventInput.type.CLICK,
          // ...
        })
      }
    >
      My button
    </button>
  );
}

Config

The collector-api is deployed to the following URLs:

REACT_APP_COLLECTOR_API_URL=http://127.0.0.1:3020

For the dev env these are:

REACT_APP_COLLECTOR_API_URL=https://collector-api.vyrolabs.net

And in production they are:

REACT_APP_COLLECTOR_API_URL=https://collector-api.vyro.com.au
0.32.1

5 months ago

0.32.0

5 months ago

0.31.1

5 months ago

0.31.0

7 months ago

0.21.0

9 months ago

0.20.0

9 months ago

0.19.0

9 months ago

0.11.0

9 months ago

0.12.0

9 months ago

0.13.0

9 months ago

0.14.0

9 months ago

0.15.0

9 months ago

0.16.0

9 months ago

0.17.0

9 months ago

0.18.0

9 months ago

0.10.0

9 months ago

0.30.0

9 months ago

0.29.0

9 months ago

0.28.0

9 months ago

0.27.0

9 months ago

0.26.0

9 months ago

0.25.0

9 months ago

0.24.0

9 months ago

0.23.0

9 months ago

0.22.0

9 months ago

0.9.3

12 months ago

0.9.2

12 months ago

0.8.0

1 year ago

0.9.1

1 year ago

0.4.0

1 year ago

0.7.0

1 year ago

0.6.0

1 year ago

0.2.3

1 year ago

0.1.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.2.2

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago