Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/07akioni/event-tracker-wrapper
Event tracker wrapper.
https://github.com/07akioni/event-tracker-wrapper
event-tracking
Last synced: 2 months ago
JSON representation
Event tracker wrapper.
- Host: GitHub
- URL: https://github.com/07akioni/event-tracker-wrapper
- Owner: 07akioni
- Created: 2022-02-07T17:59:23.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-15T11:57:28.000Z (11 months ago)
- Last Synced: 2024-04-14T00:37:46.580Z (8 months ago)
- Topics: event-tracking
- Language: TypeScript
- Homepage:
- Size: 64.5 KB
- Stars: 15
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# event-tracker-wrapper
[English](README.md) | 中文
## API
### Methods
Please note that types are for reference only. They are not the actual types.
#### `createEventTracker`
```ts
function createEventTracker(
options: EventTrackerOptions
): EventTracker;type EventTrackerOptions = {
autostart?: boolean;
onEvent?: (arg: {
level: "debug" | "info" | "warn" | "error";
name: string;
message: string;
payload: unknown;
options: EventOptions;
startOptions: StartOptions;
}) => void;
};type EventTracker = {
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:
```ts
import { createEventTracker } from "event-tracker-wrapper";type Events = {
debug: {
LOG: undefined;
};
info: {
LOG: undefined;
};
warn: {
LOG: undefined;
};
error: {
LOG: undefined;
};
};const tracker = createEventTracker();
tracker.info({
name: "LOG",
message: "info log",
});
```2. How to delay event tracking?
```ts
import { createEventTracker } from "event-tracker-wrapper";
import type { Reporter } from "takes-long-time-to-import-reporter";// in package-a
export const tracker = createEventTracker({
autostart: false,
});// in package-b
import { tracker } from "package-a";// after TTI
{
import("takes-long-time-to-import-reporter").then((reporter) => {
tracker.start(reporter);
});
}
```