Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@brainfish-ai/web-tracker

Package Overview
Dependencies
Maintainers
0
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brainfish-ai/web-tracker

Brainfish Tracker for Web

  • 0.0.4-alpha.30
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
0
Weekly downloads
 
Created
Source

Web SDK

Installation

Steps to install the Brainfish Tracker SDK in your web application.

Install dependencies

npm install @brainfish-ai/web-tracker

Initialize

import { Tracker } from '@brainfish-ai/web-tracker';

const tracker = new Tracker({
  accessKey: '{accessKey}',
  trackScreenViews: true,
  // trackAttributes: true,
  // trackOutgoingLinks: true,
});
Config

Ready!

You're now ready to use the library.

// Sends an event with payload foo: bar
tracker.event('my_event', { foo: 'bar' });

// Identify with user id
tracker.setUserId('123');

// or with additional data
tracker.setUser({
  userId: '123',
  firstName: 'John',
  lastName: 'Doe',
  email: 'john.doe@brainfi.sh',
});

// Increment a property
tracker.increment('app_opened'); // increment by 1
tracker.increment('app_opened', 5); // increment by 5

// Decrement a property
tracker.decrement('app_opened'); // decrement by 1
tracker.decrement('app_opened', 5); // decrement by 5

Usage

Track event

tracker.event('my_event', { foo: 'bar' });

Identify

Set user Id

Keep track of your users by identifying them with a unique id. This is a good features if you have things behind a login and want to track user behavior.

const userId = '123';
tracker.setUserId(userId);
Additional data

This method does the same as setUserId but also allows you to update the user with additional data.

const userId = '123';
tracker.setUser({
  userId,
  // firstName?: string;
  // lastName?: string;
  // email?: string;
  // avatar?: string;
  // properties?: Record<string, unknown>;
});
Increment property

Increment a property on the user.

// Increment by 1
tracker.increment('app_opened');

// Increment by 5
tracker.increment('app_opened', 5);
Decrement property

Decrement a property on the user.

// Increment by 1
tracker.decrement('app_opened');

// Increment by 5
tracker.decrement('app_opened', 5);
Clear / Logout

Clear the user id and all the data.

tracker.clear();

Keywords

FAQs

Package last updated on 05 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc