This SDK is intended for collecting anonymous usage data for campaigns developed by rangoon.tech.
First, install the library by running the command
npm install @rangoon/analytics
If you're using yarn,
yarn add @rangoon/analytics
Initialize the SDK by calling the method Analytics.initialize
.
import { Analytics } from '@rangoon/analytics';
Analytics.initialize({
projectId: "<PROJECT_ID>",
});
That's it! The SDK will automatically collect usage information of the website's users.
If you want to collect custom events, you can do so with the function logEvent
.
import { logEvent } from '@rangoon/analytics';
// initialize the SDK first
Analytics.initialize({
projectId: "<PROJECT_ID>",
});
// custom event name with custom payload
logEvent('custom_event', { foo: 'bar' });
Before you log custom events, make sure analytics SDK is initialized first.