Vanilla JS SDK
@shellapps/experience — the core SDK that works in any JavaScript environment (browser, React, Vue, vanilla).
Installation
npm install @shellapps/experienceInitialisation
import { Experience } from '@shellapps/experience';
const exp = Experience.init({
// Required
appId: 'my-app-id',
apiKey: 'exp_xxxxxxxxxxxx',
// Optional
endpoint: 'https://experience.shellapps.com', // default
enableTracking: true, // default true
enableErrorCapture: true, // default true
enableHeatmaps: false, // default false (high volume)
enableBreadcrumbs: true, // default true
sampleRate: 1.0, // 0.0-1.0, default 1.0
batchIntervalMs: 2000, // default 2000
maxBatchSize: 50, // default 50
debug: false, // default false (console logging)
});Event Tracking
// Manual tracking
exp.track('checkout_started', { cart_value: '99.99' });
exp.trackPageView(); // manual page view (auto by default)Events are batched and sent via protobuf. See Event Tracking for the full data-t system, batching, and heatmap details.
Error Capture
exp.captureError(new Error('Payment failed'), {
tags: { module: 'checkout' },
extra: { orderId: '12345' }
});
exp.captureMessage('Unusual cart value detected', 'warning');See Error Monitoring for automatic capture, breadcrumbs, and crash UI.
Feature Flags
const showNewUI = exp.getFlag('new-checkout-ui', false);
const checkoutLimit = exp.getFlag('checkout-limit', 100);See Feature Flags for rule evaluation, rollouts, and experiments.
Identity
// Link to ShellApps profile
exp.identify(profileId);Shutdown
// Flush pending events before page close
exp.shutdown();Configuration Reference
| Option | Type | Default | Description |
|---|---|---|---|
appId | string | required | Your app ID from registration |
apiKey | string | required | API key (exp_xxxxxxxxxxxx) |
endpoint | string | https://experience.shellapps.com | Service endpoint |
enableTracking | boolean | true | Enable event tracking |
enableErrorCapture | boolean | true | Enable automatic error capture |
enableHeatmaps | boolean | false | Enable heatmap data (high volume) |
enableBreadcrumbs | boolean | true | Enable breadcrumb collection |
sampleRate | number | 1.0 | Session sampling rate (0.0–1.0) |
batchIntervalMs | number | 2000 | Batch send interval in ms |
maxBatchSize | number | 50 | Max events per batch |
debug | boolean | false | Enable console logging |
Also see the React SDK for React-specific hooks and components.