Analytics
/

Debug mode

Debug in local development mode


A huge focus of the analytics project is an improved developer experience.

The library comes with a powerful suite of debug tools for local development.

This includes time travel debugging so devs can walk through call chains & debug how different plugins are making remote calls & effecting the lifecycle.

During development you can turn on debug mode. This will connect dev tools for devs to visually see the analytics events passing through the application.

analytics-debug-tools

Enabling debug mode

By default, debug is off.

To enable debug mode, pass in the debug option to analytics.

import Analytics from 'analytics'

const analytics = Analytics({
  app: 'my-app',
  // enable debug mode
  debug: true
})

Disabling debug in production

To disable debug set to false or omit from the options.

import Analytics from 'analytics'

const analytics = Analytics({
  app: 'my-app',
  // disable debug mode
  debug: false
})

Running debug in local dev only

To disable debug set to false.

Below is a handy snippet to run in debug mode only in local dev.

import Analytics from 'analytics'

const analytics = Analytics({
  app: 'my-app',
  // enable debug mode
  debug: process.env.NODE_ENV === 'development'
})