FunnelMob

Web SDK

Web SDK - Configuration

Configure the FunnelMob Web SDK.

Basic Configuration

import { FunnelMob, FunnelMobConfiguration } from '@funnelmob/sdk';
 
const config = new FunnelMobConfiguration({
  apiKey: 'fm_live_abc123',
});
 
FunnelMob.shared.initialize(config);

Full Configuration

import { FunnelMobConfiguration, LogLevel } from '@funnelmob/sdk';
 
const config = new FunnelMobConfiguration({
  apiKey: 'fm_live_abc123',              // Required: Your API key
  logLevel: LogLevel.None,               // None, Error, Warning, Info, Debug, Verbose
  flushIntervalMs: 30000,                // Auto-flush interval in ms (min: 1000, default: 30000)
  maxBatchSize: 100,                     // Events per batch (1-100, default: 100)
  autoStart: true,                       // false to defer all activity until start() — see Privacy & Consent
  autoCollectBrowserIds: true,           // false if your CMP / banner manages _fbp / _fbc cookies
});

Overriding the base URL (local development)

By default the SDK POSTs to https://api.funnelmob.com/v1. For local development against a dev backend, pass an explicit baseUrl:

const config = new FunnelMobConfiguration({
  apiKey: 'fm_live_abc123',
  baseUrl: 'http://localhost:3080/v1',
});

Framework Integration

React

import { useEffect } from 'react';
import { FunnelMob, FunnelMobConfiguration } from '@funnelmob/sdk';
 
function App() {
  useEffect(() => {
    const config = new FunnelMobConfiguration({
      apiKey: 'fm_live_abc123',
    });
    FunnelMob.shared.initialize(config);
 
    return () => {
      FunnelMob.shared.destroy();
    };
  }, []);
 
  return <div>...</div>;
}

Vue

// main.ts
import { FunnelMob, FunnelMobConfiguration } from '@funnelmob/sdk';
 
const config = new FunnelMobConfiguration({
  apiKey: 'fm_live_abc123',
});
FunnelMob.shared.initialize(config);
 
// In components
FunnelMob.shared.trackEvent('page_view');

SDK Control

// Disable tracking (kill switch — for QA / debug; for GDPR use setConsent)
FunnelMob.shared.setEnabled(false);
 
// Re-enable tracking
FunnelMob.shared.setEnabled(true);
 
// Force send queued events immediately
FunnelMob.shared.flush();
 
// Cleanup resources (stops flush timer, sends remaining events)
FunnelMob.shared.destroy();

For GDPR / DMA, see Privacy & ConsentsetConsent(...) is the right tool rather than the kill switch.

TypeScript Support

Full TypeScript definitions are included:

import type { StandardEventName } from '@funnelmob/sdk';
 
function trackCustomEvent(name: string | StandardEventName) {
  FunnelMob.shared.trackEvent(name);
}

Error Handling

Errors are logged to the console rather than thrown. Set logLevel to see validation errors:

const config = new FunnelMobConfiguration({
  apiKey: 'fm_live_abc123',
  logLevel: LogLevel.Debug,
});