Core / Node.js SDK
Use @flash-analytics/sdk for Node.js services, backend jobs, and custom JavaScript integrations.
The Core SDK is the shared base SDK used by the browser wrappers and by custom Node or JavaScript integrations.
Install
npm install @flash-analytics/sdk@2.1.8pnpm add @flash-analytics/sdk@2.1.8Initialize
import { FlashAnalytics } from '@flash-analytics/sdk';
const analytics = new FlashAnalytics({
appId: process.env.FLASH_ANALYTICS_CLIENT_ID!,
secretKey: process.env.FLASH_ANALYTICS_SECRET_KEY!,
endpoint: 'https://api.flashanalytics.app',
platform: 'node',
appVersion: '1.2.3',
buildNumber: '120',
captureVariants: true,
});Core APIs
await analytics.identify({
profileId: 'user-123',
email: 'user@example.com',
});
await analytics.track('job_completed', { queue: 'imports' });
analytics.setGlobalProperties({ plan: 'pro' });
const session = analytics.getSession();
const assignments = await analytics.autoAssignExperiments();
const variant = await analytics.assignExperiment('checkout-cta');Remote config
const config = await analytics.fetchRemoteConfig({
country: 'IN',
});
const featureFlag = config.getBoolean('feature_flag', false);
const welcomeText = config.getString('welcome_text', 'Welcome');
const maxItems = config.getNumber('max_items', 10);
const theme = config.getJson('theme_config', {});Remote config automatically includes platform, app version, build number, identified profile ID, primitive global properties, language, country, and a random seed where available.
