Skip to content

Web SDK - Configuration

import { FunnelMob, FunnelMobConfiguration } from '@funnelmob/sdk';
const config = new FunnelMobConfiguration({
appId: 'com.example.myapp',
apiKey: 'fm_live_abc123',
});
FunnelMob.shared.initialize(config);
import { FunnelMobConfiguration, Environment, LogLevel } from '@funnelmob/sdk';
const config = new FunnelMobConfiguration({
appId: 'com.example.myapp', // Required: Your app identifier
apiKey: 'fm_live_abc123', // Required: Your API key
environment: Environment.Production, // Production (default) or Sandbox
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)
});
EnvironmentBase URL
Environment.Productionhttps://api.funnelmob.com/v1
Environment.Sandboxhttps://sandbox.funnelmob.com/v1
import { useEffect } from 'react';
import { FunnelMob, FunnelMobConfiguration } from '@funnelmob/sdk';
function App() {
useEffect(() => {
const config = new FunnelMobConfiguration({
appId: 'com.example.myapp',
apiKey: 'fm_live_abc123',
});
FunnelMob.shared.initialize(config);
return () => {
FunnelMob.shared.destroy();
};
}, []);
return <div>...</div>;
}
main.ts
import { FunnelMob, FunnelMobConfiguration } from '@funnelmob/sdk';
const config = new FunnelMobConfiguration({
appId: 'com.example.myapp',
apiKey: 'fm_live_abc123',
});
FunnelMob.shared.initialize(config);
// In components
FunnelMob.shared.trackEvent('page_view');
// Disable tracking (e.g., for GDPR compliance)
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();

Full TypeScript definitions are included:

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

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

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