Skip to main content
Version: 1.3.0

Toggle analytics events

In order to determine if analytics should be enabled, GX Core checks two sources:

  • The environment variable GX_ANALYTICS_ENABLED
  • The Data Context variable analytics_enabled

If either variable is set to False, analytics collection will be disabled. If the variables are not explicitly set to False, they are assumed to be True.

Methods for toggling analytics collection

Select one of the following methods for toggling analytics collection:

The environment variable GX_ANALYTICS_ENABLED can be used to toggle the collection of analytics information. This is particularly useful when using an Ephemeral Data Context because an Ephemeral Data Context does not persist between Python sessions and therefore won't persist configuration changes made using context.variables in Python.

GX_ANALYTICS_ENABLED will also work to toggle analytics collection when using a GX Cloud Data Context or a File Data Context.

Prerequisites

Procedure

  1. Set the environment variable GX_ANALYTICS_ENABLED.

    You can set environment variables through terminal commands or by adding the equivalent commands to your ~/.bashrc file. If you set the environment variable directly from the terminal, the environment variable will not persist beyond the current session. If you add them to the ~/.bashrc file, the variable will be exported each time you log in.

    To set the GX_ANALYTICS_ENABLED environment variable, use the command:

    Terminal or ~/.bashrc
    export GX_ANALYTICS_ENABLED=False

    or:

    Terminal or ~/.bashrc
    export GX_ANALYTICS_ENABLED=True
  2. Initialize a Data Context in Python.

    Analytics settings are checked when a Data Context is initialized. Therefore, for a change to GX_ANALYTICS_ENABLED to take effect, the Data Context must be initialized after the environment variable has been set.

    If you already have a Data Context in a Python environment when you make a change to GX_ANALYTICS_ENABLED, you can re-initialize it by updating the value of my_mode with ephemeral, file, or cloud and executing the following code:

    Python
    my_mode = "file"
    context = gx.get_context(mode=my_mode)

    For more information on initializing a Data Context, see Create a Data Context.