npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@comparaonline/event-tracker

v8.3.3

Published

This library it's an interface between any frontend application and some event tracking platforms, currently Snowplow and Tag Manager.

Readme

@comparaonline/event-tracker

npm code style: prettier

This library is an interface between any frontend application and event tracking platforms.

There's more documentation available for the library in compara's notion

Documentation

Installation

To install the library in your application use

yarn add @comparaonline/event-tracker

or

npm install @comparaonline/event-tracker

Usage example

After installing the package you can send an event using the function track. For example:

import { track, BUSINESS_UNIT, COUNTRY_CODE } from '@comparaonline/event-tracker';

// Example of form step render event
track({
  name: 'form_step_render',
  data: {
    app_name: 'my-app',
    app_version: '1.0.0',
    country_code: COUNTRY_CODE.CL,
    business_unit: BUSINESS_UNIT.CAR_INSURANCE,
    user_type: 'anonymous',
    quote_id: '12345',
    accordion_index: '0',
    accordion_name: 'personal-information'
  }
});

// Example of transaction event
track({
  name: 'transaction',
  data: {
    app_name: 'my-app',
    app_version: '1.0.0',
    country_code: COUNTRY_CODE.CL,
    business_unit: BUSINESS_UNIT.CAR_INSURANCE,
    user_type: 'registered',
    user_id: 'user-123',
    transaction_id: 'trans-456',
    amount: 15000,
    currency: 'CLP'
  }
});

// Example of one-click checkout modal open event
track({
  name: 'one_click_checkout_modal_open',
  data: {
    app_name: 'my-app',
    app_version: '1.0.0',
    country_code: COUNTRY_CODE.CL,
    business_unit: BUSINESS_UNIT.CAR_INSURANCE,
    user_type: 'registered',
    user_id: 'user-123',
    offer_id: 'offer-789',
    quote_id: 'quote-456'
  }
});

The library will automatically send the event to all enabled trackers (currently ABTasty and Heap).

Trackers

The trackers currently supported by the library are:

  • ABTasty: Used for A/B testing and analytics.
  • Heap: Used for user behavior analytics.

The library is configured to use both trackers by default. The events are automatically sent to both trackers when you use the track function.

Event Types

The library supports various event types:

  • attached_policy_to_user: Track when a policy is attached to a user
  • cancel_policy_requested: Track when a user requests a policy cancellation
  • cep_autocompleted: Track when a postal code is autocompleted
  • form_step_render: Track when a form step is rendered
  • one_click_checkout_completed: Track when a one-click checkout is completed
  • one_click_checkout_modal_open: Track when a one-click checkout modal is opened
  • otp_error: Track when an OTP error occurs
  • payment_method_updated: Track when a payment method is updated
  • person_autocompleted: Track when person information is autocompleted
  • transaction: Track a transaction
  • tutorial_begin: Track when a tutorial begins
  • tutorial_complete: Track when a tutorial is completed
  • user_account_onboarding_completed: Track when user onboarding is completed
  • user_multi_travel_selected: Track when user selects multi-travel
  • vehicle_autocompleted: Track when vehicle information is autocompleted
  • profile_updated: Track when user profile information is updated
  • travel_companion_upserted: Track when a user's travel companion information is upserted
  • travel_companion_removed: Track when a user's travel companion information is removed
  • emergency_contact_upserted: Track when a user's emergency contact information is upserted
  • emergency_contact_removed: Track when a user's emergency contact information is removed
  • successful_payment: Track when user payment is completed

Each event type requires specific data. You can import the type definitions to ensure you're providing the correct data:

import { track, BUSINESS_UNIT, COUNTRY_CODE } from '@comparaonline/event-tracker';
import type { FormStepRenderData } from '@comparaonline/event-tracker';

const eventData: FormStepRenderData = {
  app_name: 'my-app',
  app_version: '1.0.0',
  country_code: COUNTRY_CODE.CL,
  business_unit: BUSINESS_UNIT.CAR_INSURANCE,
  user_type: 'anonymous',
  quote_id: '12345',
  accordion_index: '0',
  accordion_name: 'personal-information'
};

track({
  name: 'form_step_render',
  data: eventData
});

Migrating from previous versions

If you're migrating from version 6.x or earlier, there are significant changes to the API. The main changes are:

  1. The sendEvent function has been replaced with track
  2. Event types and constants are now exported directly from the main module
  3. There are no longer separate endpoints like SNOWPLOW_APP or TAG_MANAGER_APP
  4. Event tracking is handled automatically to all enabled trackers

To migrate, update your imports and replace your event sending code:

Old code:

import { endpoints, sendEvent, types } from '@comparaonline/event-tracker/';
import {
  carInsuranceGenerators,
  FormSubmitParams,
} from '@comparaonline/event-tracker/eventGenerators/carInsurance';

const rawFormSubmit: FormSubmitParams = {
  appVersion: '1.0',
  appName: 'test-module',
  countryCode: types.CountryCodeTypes.chile,
  formId: 'asdf',
  formType: types.FormTypes.wizard,
  formSubmitStatus: types.FormStatusTypes.successful,
  funnelType: types.FormRelatedTypes.FunnelTypes.quote,
  formValues: { a: 'asdf', b: 'sdf' },
};
const formSubmit = carInsuranceGenerators.generateFormSubmit(rawFormSubmit);
sendEvent(endpoints.SNOWPLOW_APP, formSubmit);

New code:

import { track, BUSINESS_UNIT, COUNTRY_CODE } from '@comparaonline/event-tracker';

track({
  name: 'form_step_render',
  data: {
    app_name: 'test-module',
    app_version: '1.0',
    country_code: COUNTRY_CODE.CL,
    business_unit: BUSINESS_UNIT.CAR_INSURANCE,
    user_type: 'anonymous',
    quote_id: 'asdf',
    accordion_index: '0',
    accordion_name: 'form-step'
  }
});