Error tracking
If you use WXT with the Moderok analytics provider, read WXT first. Automatic __error capture is limited to the background there.
Default behavior
On by default. In every context where you call Moderok.init(), the SDK records uncaught exceptions and unhandled promise rejections as __error events.
What is not automatic
chrome.runtime.lastErrorin callbacks — useModerok.captureLastError(apiName, lastError, props?)to record these.console.error— off by default. SetcaptureConsoleErrors: trueto mirrorconsole.errorcalls to__error(can be noisy). RequirestrackErrors: true(the default).
Handled errors
Inside try/catch, use Moderok.captureError(error, props?):
js
try {
await saveSettings();
} catch (error) {
Moderok.captureError(error, { action: "save_settings" });
}Callback-style APIs
js
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
if (chrome.runtime.lastError) {
Moderok.captureLastError("tabs.query", chrome.runtime.lastError, {
action: "load_active_tab",
});
return;
}
Moderok.track("active_tab_loaded", { count: tabs.length });
});Turn automatic capture off
Set trackErrors: false in Moderok.init() if you do not want global listeners in that context.