linq-analytics-client
v1.3.5
Published
## Overview
Downloads
6
Readme
LinqAnalytics Library
Overview
LinqAnalytics
is a comprehensive library designed to facilitate interaction with the Linq analytics platform. It provides seamless event tracking and user identification, offering developers an intuitive API.
Install
$ npm install linq-analytics-client
// or
$ yarn add linq-analytics-client
Initial Setup
First, ensure you've imported the necessary types and modules:
import {
LinqAnalyticsConfig,
ProductType,
EventUserProps,
TrackProps,
LinqAnalytics,
} from 'linq-analytics-client'
Initialization
Before using the library, you need to initialize LinqAnalytics
with your configuration:
const config: LinqAnalyticsConfig = {
product: 'linq_app', // or 'linq_chat'
}
LinqAnalytics.initialize(config)
Note: The product
can be either 'linq_app'
or 'linq_chat'
, depending on your application's context.
Using the useLinqAnalytics
Hook
- Import the Hook:
import { useLinqAnalytics } from 'linq-analytics-client'
- Initialize the Hook:
const { track } = useLinqAnalytics(organizationId, userProps)
- organizationId: (Optional) Your organization's unique identifier.
- userProps: (Optional) Object containing user properties like user_id, email, name, and so on.
- Track Events:
const someEventHandler = () => {
// ... your event handling logic
// Track the event
const eventProps: TrackProps = {
eventType: 'ButtonClick',
eventName: 'Submit Button Clicked',
properties: {
someProperty: 'propertyValue',
anotherProperty: 'anotherValue',
},
}
track(eventProps)
}
The track function accepts a TrackProps object which consists of:
- eventType: Type of the event ('PageView', 'ButtonClick', etc.).
- eventName: Descriptive name for the event.
- properties: (Optional) Additional properties or metadata related to the event.
Conclusion:
LinqAnalytics provides a straightforward way to integrate with the Linq analytics platform. By following the simple initialization step and leveraging the provided hook, developers can effortlessly track events and identify users in their applications. Happy coding!