Skip to Content
v1.36.0 · shipped One-screen report · Looks like your app Read the changelog →
SDK reference@mushi-mushi/wasm-classifier

@mushi-mushi/wasm-classifier

Optional on-device junk filter for bug reports. It stops empty or nonsense reports (“hi”, “asdf”) in the browser, before they are sent. The default backend is a heuristic with no dependencies; an optional ONNX backend runs a model you host, through onnxruntime-web.

pnpm add @mushi-mushi/wasm-classifier # Optional, only for the ONNX backend: pnpm add onnxruntime-web

Use it with the web SDK

The web SDK does not load the classifier on its own. Pass it in preFilter.wasmClassifier:

import { Mushi } from 'mushi-mushi' import { createHeuristicClassifier } from '@mushi-mushi/wasm-classifier' Mushi.init({ projectId: 'YOUR_PROJECT_ID', apiKey: 'mushi_...', preFilter: { wasmClassifier: createHeuristicClassifier() }, })

It runs after the SDK’s built-in pattern filter. A block verdict stops the report on the device; pass and unsure send it, and the server does the full classification.

Call it directly

import { createHeuristicClassifier } from '@mushi-mushi/wasm-classifier' const classifier = createHeuristicClassifier({ blockThreshold: 0.2, passThreshold: 0.55 }) const result = await classifier.classify({ description: 'asdf qwer' }) // → { verdict: 'pass' | 'block' | 'unsure', confidence, reason, modelId: 'heuristic-v1', durationMs }

classify() also takes the signals the web SDK passes: category, url, hasScreenshot, hasSelectedElement, hasNetworkErrors, hasConsoleErrors and proactiveTrigger.

ONNX backend (experimental)

import { createOnnxClassifier } from '@mushi-mushi/wasm-classifier' const classifier = await createOnnxClassifier({ modelUrl: 'https://cdn.your-app.com/mushi/model.onnx', cacheKey: 'model-v1', preload: true, classifyTimeoutMs: 750, })

If onnxruntime-web is missing, the model fetch fails, or a call exceeds classifyTimeoutMs, it falls back to the heuristic backend. The package does not ship a model.

Model inference is not implemented yet. The ONNX backend loads the runtime and downloads your model, then still returns heuristic verdicts (modelId: 'heuristic-fallback', a reason starting “ONNX inference is not implemented yet”, and one console warning). Use createHeuristicClassifier() until that changes.

Last updated on