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

event-tracker-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

event-tracker-wrapper

provide unified interface for event tracking

  • 1.0.5
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

event-tracker-wrapper

English | 中文

API

Methods

Please note that types are for reference only. They are not the actual types.

createEventTracker
function createEventTracker<Events, StartOptions, EventOptions>(
  options: EventTrackerOptions<Events, StartOptions, EventOptions>
): EventTracker<Events, StartOptions, EventOptions>;

type EventTrackerOptions<Events, StartOptions, EventOptions> = {
  autostart?: boolean;
  onEvent?: (arg: {
    level: "debug" | "info" | "warn" | "error";
    name: string;
    message: string;
    payload: unknown;
    options: EventOptions;
    startOptions: StartOptions;
  }) => void;
};

type EventTracker<Events, StartOptions, EventOptions> = {
  start: () => void;
  debug: (event: {
    name: string;
    message: string;
    payload: unknown;
    options: EventOptions;
  }) => void;
  info: Function; // same as debug
  warn: Function; // same as debug
  error: Function; // same as debug
};

FAQ

  1. event-tracker-wrapper seems only work for event track. How to deal with normal log?

Normal log can be viewed as event, you can do like this:

import { createEventTracker } from "event-tracker-wrapper";

type Events = {
  debug: {
    LOG: undefined;
  };
  info: {
    LOG: undefined;
  };
  warn: {
    LOG: undefined;
  };
  error: {
    LOG: undefined;
  };
};

const tracker = createEventTracker<Events>();

tracker.info({
  name: "LOG",
  message: "info log",
});
  1. How to delay event tracking?
import { createEventTracker } from "event-tracker-wrapper";
import type { Reporter } from "takes-long-time-to-import-reporter";

// in package-a
export const tracker = createEventTracker<Events, Reporter>({
  autostart: false,
});

// in package-b
import { tracker } from "package-a";

// after TTI
{
  import("takes-long-time-to-import-reporter").then((reporter) => {
    tracker.start(reporter);
  });
}

FAQs

Package last updated on 15 Jan 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