Test your SDK connection by sending a test event and confirming the round-trip.

Verify

Connection verification utility for the Codmir SDK. Sends a test event through the full pipeline (init, send, flush, confirm) and reports the result with step-by-step progress.

npm install @codmir/sdk

Quick Start

import { verify, printVerifyResult } from '@codmir/sdk/verify';

const result = await verify({
  dsn: process.env.CODMIR_DSN,
  apiKey: process.env.OVERSEER_KEY,
  onProgress: (step) => console.log(`[${step.status}] ${step.message}`),
});

console.log(printVerifyResult(result));

Output:

Codmir SDK Verification
=======================
[OK]   Initialize SDK ........................... 12ms
[OK]   Send test event ......................... 3ms
[OK]   Flush events ............................ 45ms
[OK]   Connection verified

Event ID: evt_abc123
Total: 60ms

Your Codmir SDK is working! Events will appear in your dashboard shortly.

Quick Verify

One-liner boolean check — pass a client key or DSN:

import { quickVerify } from '@codmir/sdk/verify';

const ok = await quickVerify(process.env.NEXT_PUBLIC_CODMIR_CLIENT_KEY);
console.log(ok ? 'Connected!' : 'Failed to connect');

Accepts both key formats:

  • DSN: https://your-project.codmir.com/api/overseer
  • Client key: osk_... or csk_...

Full Verify

The verify() function runs four steps and provides detailed results:

import { verify } from '@codmir/sdk/verify';

const result = await verify({
  dsn: 'https://your-project.codmir.com/api/overseer',
  apiKey: 'osk_...',
  timeout: 5000,   // Optional: flush timeout in ms (default: 10000)
  onProgress: (step) => {
    // Called for each step: init → send → flush → confirm
    console.log(`${step.step}: ${step.status} — ${step.message}`);
  },
});

if (result.success) {
  console.log('Event ID:', result.eventId);
  console.log('Total time:', result.totalDuration, 'ms');
} else {
  console.error('Failed:', result.error);
}

Verification Steps

StepDescription
initInitialize the SDK with the provided config
sendSend a test message event
flushFlush all pending events to the server
confirmConfirm the connection was successful

Result Structure

interface VerifyResult {
  success: boolean;
  eventId?: string;      // The test event's ID
  steps: VerifyStep[];   // Detailed step results
  totalDuration: number; // Total time in ms
  error?: string;        // Error message if failed
}

interface VerifyStep {
  step: 'init' | 'send' | 'flush' | 'confirm';
  status: 'running' | 'success' | 'failed';
  message: string;
  duration?: number;     // Step duration in ms
}

Format a result for CLI output:

import { printVerifyResult } from '@codmir/sdk/verify';

const result = await verify({ dsn, apiKey });
console.log(printVerifyResult(result));

TypeScript Support

import type {
  VerifyConfig,
  VerifyStep,
  VerifyResult,
} from '@codmir/sdk/verify';