Flowpatrol Documentation
Read more about XYZ in this section.
Installation
Install dependencies
pnpm install @flowpatrol/nextjs
Initialize
Add FlowpatrolProvider
to your root layout component.
import { FlowpatrolProvider } from '@flowpatrol/nextjs';
export default RootLayout({ children }) {
return (
<>
<FlowpatrolProvider
url="https://api.flowpatrol.dev"
clientId="your-client-id"
trackScreenViews={true}
// trackAttributes={true}
// trackOutgoingLinks={true}
// If you have a user id, you can pass it here to identify the user
// profileId={'123'}
/>
{children}
</>
)
}
Config
TODO
Ready!
You're now ready to use the library.
import {
decrement,
increment,
setProfile,
setProfileId,
trackEvent,
} from '@flowpatrol/nextjs';
// Sends an event with payload foo: bar
trackEvent('my_event', { foo: 'bar' });
// Identify with profile id
setProfileId('123');
// or with additional data
setProfile({
profileId: '123',
firstName: 'John',
lastName: 'Doe',
email: 'john.doe@flowpatrol.dev',
});
// Increment a property
increment('app_opened'); // increment by 1
increment('app_opened', 5); // increment by 5
// Decrement a property
decrement('app_opened'); // decrement by 1
decrement('app_opened', 5); // decrement by 5
Usage
Track event
import { trackEvent } from '@flowpatrol/nextjs';
trackEvent('my_event', { foo: 'bar' });