app-tracker
v2.2.2
Published
App Tracker for Web-Applications
Maintainers
Readme
App Tracker for Web & Node.js
App Tracker is a TypeScript/JavaScript library for logging and tracking events in web and Node.js applications. It supports batching, flexible configuration, and sending logs to a central endpoint.
Installation
npm i app-trackerRegistration & API Key
- Register at App Tracker and create an application to get your API key.
Quick Start
import { AppTracker, AppTrackerService } from "app-tracker";
const config = {
userAgentOrOs: typeof window !== 'undefined' ? navigator.userAgent : require('os'),
logInConsole: true,
sendLogsInDevelopment: true,
// more options below
};
const tracker: AppTrackerService = AppTracker.init("API_KEY", config);
tracker.debug("Debug message", { foo: "bar" });
tracker.error("An error occurred", errorObj);Configuration
| Property | Type | Default | Description | |-----------------------------|--------------|--------------------------------|-------------| | sendLogsInDevelopment | boolean | false | Send logs during development | | logInConsole | boolean | false | Also log to the console | | endpointUrl | string | https://app-tracker-api.azurewebsites.net/ | Target endpoint for logs | | maxSendTries | number | 5 | Max. send attempts on error | | maxLogsCount | number | 10 | Batch size for sending logs | | logLevel | LogType[] | [LogType.error] | Which log types are sent | | sendLogsByTypesImmediately | LogType[] | [LogType.error, LogType.critical] | Types sent immediately | | userAgentOrOs | any | | Browser: navigator.userAgent, Node: require('os') |
LogType: debug, info, log, warn, error, critical
Architecture & Features
- Singleton Service: Always access via
AppTracker.init()orAppTracker.getService() - Batching: Logs are collected and sent after
maxLogsCountor immediately for critical errors - Environment Awareness: Automatically adapts for browser/Node.js
- Secure Sending: API key required, retry mechanism on errors
- External Dependency: Uses
cross-fetchfor HTTP requests
Build & Development
- Build:
npm run build(TypeScript compile & copy tolib/) - Minify:
npm run terser(Terser minification of JS files) - Lint:
npm run lint(TSLint) - Format:
npm run format(Prettier)
FAQ
Where do I get my API key?
Register at https://www.app-tracker.cloud/ and create an application.
How can I suppress logs in development?
Set
sendLogsInDevelopment: falsein the configuration.
How do I send custom log types?
Use the
debug,info,warn,error,criticalmethods of the service object.
Further Information
- See
src/app-tracker.service.tsfor service logic - See
src/log.tsfor configuration and log types - See
.github/copilot-instructions.mdfor developer guidelines
