Plugin Options
The trackerPlugin() function accepts a single configuration object. Only appId is required — everything else has sensible defaults.
import { trackerPlugin } from '@ndriadev/vite-plugin-monitor'
trackerPlugin(options: TrackerPluginOptions)2
3
Top-Level Options
appId required
Type: string
Unique identifier for your application. Attached to every TrackerEvent as event.appId. Throws at startup if missing.
trackerPlugin({ appId: 'my-app' })Used in two ways:
- Stamped on every event — allows a single backend to distinguish events from multiple frontend apps.
- Used as the HMAC key when hashing dashboard credentials (
dashboard.auth).
enabled
Type: boolean · Default: true
Master switch. When false, the plugin is a complete no-op: no scripts are injected, no server is started, no logs are written, no event proxies are installed.
trackerPlugin({
appId: 'my-app',
enabled: process.env.NODE_ENV !== 'test',
})2
3
4
autoInit
Type: boolean · Default: true
Controls whether tracker.init() is automatically called at page load.
| Value | Behavior |
|---|---|
true | Plugin injects both the setup script (proxies) and the auto-init script. Everything starts immediately. |
false | Only the setup script (proxies) is injected. You must call tracker.init() manually from your application code. |
When to use autoInit: false
- After a cookie consent banner
- After user authentication
- Only in specific environments (e.g. staging but not production)
Proxies are always installed
Even with autoInit: false, the setup script that installs fetch, XHR, console, and history proxies is always injected at head-prepend. This is intentional — proxies must run before any application code to capture all events. autoInit: false only delays the call to tracker.init().
See Manual Initialization for a complete guide.
track
Type: TrackOptions
Controls which browser interactions to track. See Trackers for all options.
trackerPlugin({
appId: 'my-app',
track: {
clicks: true,
http: true,
errors: true,
navigation: true,
console: { methods: ['error', 'warn'] },
},
})2
3
4
5
6
7
8
9
10
storage
Type: StorageOptions
Controls how events are transported and stored. See Storage for all modes and options.
trackerPlugin({
appId: 'my-app',
storage: {
mode: 'http',
writeEndpoint: 'https://api.myapp.com/tracker/ingest',
},
})2
3
4
5
6
7
logging
Type: LoggingOptions
Controls server-side log file output. See Logging for all options.
trackerPlugin({
appId: 'my-app',
logging: {
level: 'warn',
transports: [
{ format: 'json', path: './logs/monitor.jsonl' },
],
},
})2
3
4
5
6
7
8
9
dashboard
Type: DashboardOptions
Controls the built-in dashboard SPA. See Dashboard for all options.
trackerPlugin({
appId: 'my-app',
dashboard: {
enabled: true,
route: '/_dashboard',
},
})2
3
4
5
6
7
overlay
Type: OverlayOptions
Controls the floating debug overlay. See Overlay for all options.
trackerPlugin({
appId: 'my-app',
overlay: {
enabled: true,
position: 'bottom-right',
},
})2
3
4
5
6
7
Full Example
// vite.config.ts
import { defineConfig } from 'vite'
import { trackerPlugin } from '@ndriadev/vite-plugin-monitor'
export default defineConfig({
plugins: [
trackerPlugin({
// Required
appId: 'my-app',
// Optional — defaults shown
enabled: true,
autoInit: true,
track: {
clicks: false,
http: false,
errors: false,
navigation: false,
console: true,
level: 'info',
ignoreUrls: [],
},
storage: {
mode: 'auto',
batchSize: 25,
flushInterval: 3000,
maxBufferSize: 500000,
port: 4242,
},
logging: {
level: 'info',
transports: [
{
format: 'json',
path: './logs/my-app.log',
rotation: {
strategy: 'daily',
maxFiles: 30,
compress: false,
},
},
],
},
dashboard: {
enabled: false,
route: '/_dashboard',
auth: false,
includeInBuild: false,
pollInterval: 3000,
},
overlay: {
enabled: false,
position: 'bottom-right',
},
}),
],
})2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
