Skip to main content

Browser Configuration

import { AnalyticsBrowser } from '@zixflow/analytics-browser'

const analytics = AnalyticsBrowser.load({
  // Required
  apiKey: 'YOUR_API_KEY',

  // Delivery strategy
  deliveryStrategy: {
    strategy: 'batching',  // or 'standard'
    config: {
      size: 10,       // Batch size
      timeout: 5000   // Batch timeout (ms)
    }
  },

  // Disable page views
  disablePageView: false,

  // Disable client-side persistence
  disableClientPersistence: false,

  // Plugins
  plugins: [
    // Custom plugins
  ],

  // Middleware
  addSourceMiddleware: (middleware) => {
    // Add source middleware
  },

  // Initial page view
  initialPageview: true,

  // Obfuscate
  obfuscate: false
})

Node.js Configuration

import { Analytics } from '@zixflow/analytics-node'

const analytics = new Analytics({
  // Required
  writeKey: 'YOUR_API_KEY',

  // API path (optional)
  path: '/v1/track',

  // Batching
  maxEventsInBatch: 15,      // Max events per batch
  flushInterval: 10000,      // Flush interval (ms)

  // Retries
  maxRetries: 3,             // Max retry attempts
  httpRequestTimeout: 10000, // Request timeout (ms)

  // Disable events
  disable: false,

  // Enable/disable specific features
  enable: true
})

Delivery Strategies (Browser)

Standard Delivery

Send each event immediately:
const analytics = AnalyticsBrowser.load({
  apiKey: 'YOUR_API_KEY',
  deliveryStrategy: {
    strategy: 'standard'
  }
})

Batched Delivery

Batch events for efficiency:
const analytics = AnalyticsBrowser.load({
  apiKey: 'YOUR_API_KEY',
  deliveryStrategy: {
    strategy: 'batching',
    config: {
      size: 10,        // Send after 10 events
      timeout: 5000    // Or after 5 seconds
    }
  }
})