UNPKG

@groww-tech/analytics

Version:

Analytics service exposes methods to send events to 3rd party analytics tools like Webengage and Gtm.

63 lines (61 loc) 2.35 kB
declare global { interface Window { webengage: any; dataLayer: any; } } /** * This function will send event to webengage and gtm as of now but any new analytics tool if integrated once added here will send event to that tool also * * @param category This is used to identify the category of the event * @param eventName The name of the event that needs to be sent to either webengage or gtm * @param properties Additional properties that need to be sent for analytics * * @returns void * * @example * ``` * const eventProperties = { * userName: 'John Doe' * } * * trackEvent('Dev', 'PageView'); * trackEvent('Dev', 'PageView', eventProperties); //If you need to send any custom event properties * * ``` */ declare function trackEvent(category: string, eventName: string, properties?: {}): void; /** * This function helps in identifying the attributes, events nd session info accumulated that are created associated to an anonymous user that is created by default. Once logged in all of this stored information is attributed to this identified user * * * @param name This is used to identify the name of the logged in user * @param emailId This is the emailId which tells the emailId of the logged in user * @param thirdPartyId This is the unique id which we send which maps it to a specific user * @param phoneNumber This is the phone number of the user * * @returns void * * * @example * ``` * identifyLoggedInUser('John Doe', 'johndoe@gmail.com', 'test123', '9876543210') * ``` */ declare function identifyLoggedInUser(name: string, emailId: string, thirdPartyId?: string, phoneNumber?: string): void; /** * This function provides setters for assigning values against each attribute for the users. These attributes can be used to segment users, configure campaign targeting and personalize messages sent through each channel of engagement. * * * @param attribute This is the string which sets the attribute that you want to set * @param value This is the string which sets the value against the attribute that you want to set * * @returns void * * @example * ``` * updateUserAttribute('first_name', 'John Doe'); * ``` */ declare function updateUserAttribute(attribute: string, value: string): void; export { identifyLoggedInUser, trackEvent, updateUserAttribute };