Құжаттама мәзірі

API Reference

Құжаттама ағылшын тілінде қолжетімді. Аударма дайындалуда.

Complete reference for the BugSpotter SDK public API.

BugSpotter.init(config)

Initialize the SDK. Returns a Promise<BugSpotter>. Singleton — calling init() multiple times returns the same instance.

const bugspotter = await BugSpotter.init({
  apiKey: 'bgs_your_api_key',
  endpoint: 'https://api.bugspotter.io',
  sampleRate: 1,
  showWidget: true,
  replay: { enabled: true, duration: 15 },
  sanitize: { patterns: 'all' },
});

BugSpotter.getInstance()

Returns the current instance or null if not initialized.

const instance = BugSpotter.getInstance();
if (instance) {
  console.log('SDK initialized, sampled:', instance.isSampled);
}

bugspotter.capture()

Captures all data (screenshot, replay, console, network, metadata). Returns a BugReport object.

const report = await bugspotter.capture();
// report.console — console log entries
// report.network — network request entries
// report.metadata — browser metadata
// report.replay — session replay events (if enabled)

bugspotter.submit(payload)

Submits a bug report to the BugSpotter API. Handles screenshot/replay upload via presigned URLs.

await bugspotter.submit({
  title: 'Checkout button not working',
  description: 'User clicks pay but nothing happens',
  priority: 'high',  // low | medium | high | critical
  report,             // from capture()
});

bugspotter.isSampled

Boolean getter. true if the current session is being captured, false if excluded by sampleRate.

bugspotter.getConfig()

Returns a readonly copy of the current configuration.

bugspotter.destroy()

Cleans up the SDK instance — stops replay recording, removes widget, detaches event listeners. Call before reinitializing with new config.

BugReport Type

interface BugReport {
  console: Array<{
    level: string;
    message: string;
    timestamp: number;
    stack?: string;
  }>;
  network: Array<{
    url: string;
    method: string;
    status: number;
    duration: number;
    timestamp: number;
    error?: string;
  }>;
  metadata: {
    userAgent: string;
    viewport: { width: number; height: number };
    browser: string;
    os: string;
    url: string;
    timestamp: number;
  };
  replay?: EventWithTime[];
}

Capture Modules

Individual capture modules are exported for advanced usage:

ModuleImportWhat it captures
ScreenshotCaptureimport { ScreenshotCapture } from '@bugspotter/sdk'CSP-safe screenshots via html-to-image
ConsoleCaptureimport { ConsoleCapture } from '@bugspotter/sdk'All console levels with stack traces
NetworkCaptureimport { NetworkCapture } from '@bugspotter/sdk'fetch/XHR with URL, status, duration
MetadataCaptureimport { MetadataCapture } from '@bugspotter/sdk'Browser, OS, viewport, URL
DOMCollectorimport { DOMCollector } from '@bugspotter/sdk'Session replay via rrweb

Links