Skip to content

Patterns

One app key everywhere

Keep your Moderok app key in one module or constant and import it in the background, popup, options, and content scripts. Mismatched keys across contexts split analytics.

Track only from the background

The SDK does not include a message bus. If you want a single place that calls Moderok.track(), use chrome.runtime.sendMessage (or your framework’s wrapper) from UI or content scripts and call Moderok.track() in the background handler.

You still need Moderok.init() in the service worker at top level so install/update and queue behavior work as designed. UI scripts that do not call Moderok at all do not need init() unless you track from them directly.

WXT

If you use WXT with @wxt-dev/analytics, see the dedicated WXT page for setup, options, and error-tracking limits in that stack.

Moderok: analytics for browser extensions