Web SDK - Configuration
Basic Configuration
Section titled “Basic Configuration”import { FunnelMob, FunnelMobConfiguration } from '@funnelmob/sdk';
const config = new FunnelMobConfiguration({ appId: 'com.example.myapp', apiKey: 'fm_live_abc123',});
FunnelMob.shared.initialize(config);Full Configuration
Section titled “Full Configuration”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)});Environments
Section titled “Environments”| Environment | Base URL |
|---|---|
Environment.Production | https://api.funnelmob.com/v1 |
Environment.Sandbox | https://sandbox.funnelmob.com/v1 |
Framework Integration
Section titled “Framework Integration”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>;}import { FunnelMob, FunnelMobConfiguration } from '@funnelmob/sdk';
const config = new FunnelMobConfiguration({ appId: 'com.example.myapp', apiKey: 'fm_live_abc123',});FunnelMob.shared.initialize(config);
// In componentsFunnelMob.shared.trackEvent('page_view');SDK Control
Section titled “SDK Control”// Disable tracking (e.g., for GDPR compliance)FunnelMob.shared.setEnabled(false);
// Re-enable trackingFunnelMob.shared.setEnabled(true);
// Force send queued events immediatelyFunnelMob.shared.flush();
// Cleanup resources (stops flush timer, sends remaining events)FunnelMob.shared.destroy();TypeScript Support
Section titled “TypeScript Support”Full TypeScript definitions are included:
import type { StandardEventName } from '@funnelmob/sdk';
function trackCustomEvent(name: string | StandardEventName) { FunnelMob.shared.trackEvent(name);}Error Handling
Section titled “Error Handling”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,});