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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@felipelealdefaria/tracker-service

v0.1.0

Published

Tracking service to map user interactions using the Amplitude library

Downloads

2

Readme

Tracker Service

Tracking service to map user interactions using the Amplitude library.

Development aid tool

Amplitude Chrome Extension here.

Installation

yarn add @felipelealdefaria/tracker-service
# or
npm i @felipelealdefaria/tracker-service

Usage

import track from '@felipelealdefaria/tracker-service'

1) Initialize:

This is required before any other methods can be called.

track.init(params: InitParams): { success?: boolean | error?: boolean }
InitParams:
- apiKey: string
- userId?: string
- options?: {}
- callback?: () => unknown

See more options here.

2) Log Event:

Log event in Amplitude Dashboard.

track.log(params: LogParams): { success?: boolean | error?: boolean }
LogParams:
- eventName: string
- eventProperties?: {}
- timestamp?: number
- callback?: () => unknown

3) Set User Identification:

Identify current user:

track.setUserId(userId: string): { success?: boolean | error?: boolean }

4) Set User Properties:

Identify current user properties:

track.setUserProperties(userProperties: {}): { success?: boolean | error?: boolean }

5) Get Session Id:

Get current session id:

track.getSessionId(): { (success?: boolean | error?: boolean), sessionId: number | null }

6) New Session:

Verify if new session was created:

track.isNewSession(): { (success?: boolean | error?: boolean), isNewSession: boolean | null }

7) Clear User Properties:

Clear current user properties:

track.clearUserProperties(): { success?: boolean | error?: boolean }

8) Set Domain:

Sets a customer domain for the amplitude cookie. Useful if you want to support cross-subdomain tracking.

track.setDomain(domain: string): { success?: boolean | error?: boolean }

9) Set Track Off:

Sets whether to opt current user out of tracking.

track.setTrackOff(enable: boolean): { success?: boolean | error?: boolean }

10) Set Device Id:

Sets a custom deviceId for current user. Note: this is not recommended unless you know what you are doing (like if you have your own system for managing deviceIds). Make sure the deviceId you set is sufficiently unique (we recommend something like a UUID - see src/uuid.js for an example of how to generate) to prevent conflicts with other devices in our system.

track.setDeviceId(deviceId: string): { success?: boolean | error?: boolean }

11) Set Group:

Add user to a group or groups. You need to specify a groupType and groupName(s).

For example you can group people by their organization. In that case, groupType is "orgId" and groupName would be the actual ID(s). groupName can be a string or an array of strings to indicate a user in multiple gruups. You can also call setGroup multiple times with different groupTypes to track multiple types of groups (up to 5 per app).

track.setGroup(params: GroupParams): { success?: boolean | error?: boolean }
GroupParams:
- groupType: string
- groupName: string | string[]

12) Log Group:

Log an event with eventType, eventProperties, and groups. Use this to set event-level groups. Note: the group(s) set only apply for the specific event type being logged and does not persist on the user (unless you explicitly set it with setGroup).

track.logGroup(params: LogGroupParams): { success?: boolean | error?: boolean }
LogGroupParams:
- eventName: string
- eventProperties?: {}
- group?: {}
- callback?: () => unknown

Service's Architecture

Service created using the principles of Clean Architecture with the intention of facilitating maintenance and a possible exchange of lib used to trackers.

image