Debugging & troubleshooting
Debug mode
js
Moderok.init({
appKey: "mk_...",
debug: true,
});Logs are prefixed with [moderok]: enqueue, flush, transport results, dropped properties, oversized events, and more.
Common issues
| What you see | What to check |
|---|---|
No __install / __update | Call Moderok.init() synchronously at top level in the background service worker (Initialization). |
| Events from popup but not background | Call init() in each context where you track(), or send messages to the background (Patterns). |
| CORS or network errors | Confirm the endpoint (if you override it) and that the API is reachable (Manifest). |
chrome.runtime.lastError not in reports | Use captureLastError() in the callback (Error tracking). |
| Properties missing | Only string / number / boolean; nested values are dropped (Events). |
| Queue grows | Offline or server errors can keep batches for retry. Fix connectivity or endpoint; use debug: true to see status codes. |
| Too many duplicate errors | The SDK deduplicates bursts; captureConsoleErrors adds noise. Enable it only if you need it. |
Graceful shutdown (rare)
If your extension has a dedicated shutdown path:
js
await Moderok.shutdown();This stops timers, flushes, and tears down error listeners. Most MV3 extensions do not need this.