1.0.3 • Published 9 months ago

@reservamos/browser-analytics v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

Reservamos Browser Analytics

This library is a lightweight and optimized solution for tracking user events and utilizing an identification system to build user preferences, designed to be used in any Single Page Application (SPA). It allows third-party websites to send predefined events with ease.

Features

  • Modular and maintainable TypeScript code
  • Functional programming approach
  • Strong type safety with TypeScript
  • Clear and concise error handling
  • Easy integration with minimal configuration
  • Comprehensive documentation and usage examples

Installation

To install the library, use npm or yarn

  npm install @reservamos/browser-analytics

Usage

// Import the tracker and the InitConfig interface if you want to use type safety
import analytics, { InitConfig } from '@reservamos/browser-analytics';

// Define the configuration for the tracker
const config: InitConfig = {
  mixpanelToken: 'YOUR_MIXPANEL_TOKEN',
  identificationKey: 'YOUR_IDENTIFICATION_KEY',
  debug: true,
};

// Initialize the tracker with the config
analytics.init(config);

// Listen for the "Tracker Ready" event
window.addEventListener('Tracker Ready', () => {
  console.log('Tracker Ready');

  // Track a test event
  analytics.track.test();
});

Identifying Users

The identify method accepts a main identifier and an object containing user information. The object has four predefined fields: email, firstName, lastName, and phone. In addition to these, you can include any custom fields to store additional user-specific information as needed.

import analytics from '@reservamos/browser-analytics';

// Identify the user with the main identifier and additional information

analytics.identify('main-identifier', {
  email: 'example',
  firstName: 'John',
  lastName: 'Doe',
  phone: '123456789',
  salesforceId: '123456789',
});
1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago

1.0.3

9 months ago

0.3.1-alpha.5

9 months ago

0.3.1-alpha.6

9 months ago

0.3.1-alpha.7

9 months ago

0.3.1-alpha.8

9 months ago

0.3.1-alpha.4

9 months ago

0.3.0

9 months ago

0.3.1-alpha.0

9 months ago

0.3.1-alpha.2

9 months ago

0.3.1-alpha.3

9 months ago

0.2.1

9 months ago

0.2.0

9 months ago

0.1.4-alpha.15

9 months ago

0.2.2

9 months ago

0.1.4-alpha.0

10 months ago

0.1.4-alpha.2

10 months ago

0.1.4-alpha.3

10 months ago

0.1.1

10 months ago

0.1.4-alpha.10

10 months ago

0.1.4-alpha.8

10 months ago

0.1.4-alpha.9

10 months ago

0.1.4-alpha.14

9 months ago

0.1.4-alpha.4

10 months ago

0.1.4-alpha.13

9 months ago

0.1.4-alpha.5

10 months ago

0.1.3

10 months ago

0.1.4-alpha.12

9 months ago

0.1.4-alpha.6

10 months ago

0.1.4-alpha.11

10 months ago

0.1.4-alpha.7

10 months ago

0.1.0

10 months ago