@webticks/core
v0.1.2
Published
Lightweight analytics library for modern web applications with seamless event tracking and page view monitoring
Downloads
67
Readme
@webticks/core
Lightweight analytics library for modern web applications.
Installation
npm install @webticks/coreQuick Start
import inject from '@webticks/core';
// Initialize analytics with explicit config
inject({
serverUrl: 'https://your-api.com/track',
appId: 'your-app-id'
});Best Practices: Environment Variables
For security and flexibility, it is highly recommended to source your configuration from environment variables rather than hardcoding them in your source code.
// Example using Vite or other modern bundlers
inject({
serverUrl: import.meta.env.VITE_WEBTICKS_SERVER_URL,
appId: import.meta.env.VITE_WEBTICKS_APP_ID
});
// Example using Node.js / Webpack
inject({
serverUrl: process.env.WEBTICKS_SERVER_URL,
appId: process.env.WEBTICKS_APP_ID
});Exports
| Export | Description |
|--------|-------------|
| @webticks/core | Injector function (default) |
| @webticks/core/tracker | AnalyticsTracker class for manual tracking |
API
inject(config)
| Option | Type | Description |
|--------|------|-------------|
| serverUrl | string | Recommended. URL to send analytics data to. Defaults to /api/track. |
| appId | string | Required. Your application ID. |
| debug | boolean | Optional. Enable console logging for debugging. Defaults to false. |
[!NOTE]
appIdandserverUrlare typically provided by the webticks-api project, which you can self-host. Alternatively, you can use any backend that implements the WebTicks ingestion API.
