Skip to main content

JavaScript SDK

Ensure you have completed the Prerequisites section before continuing.

Installation

If you're using npm:

npm install @dashx/browser

If you're using yarn:

yarn add @dashx/browser

Configuration

Configure the DashX client as early as possible in your application:

import DashX from '@dashx/browser'

DashX.configure({
publicKey: '<YOUR PUBLIC KEY>', // required
baseUri: '<YOUR BASE URI>', // optional
targetEnvironment: '<YOUR ENVIRONMENT>' // optional
})

Usage

Analytics

DashX.track('Button Clicked', {
label: 'Click here',
placement: 'top'
})

Learn more

Messaging

// Subscribe to Web Push Notifications

DashX.subscribe()

DashX.unsubscribe()

// Manage User Preferences

const preferencesData = await DashX.fetchStoredPreferences()

await DashX.saveStoredPreferences(preferencesData)

Learn more