Skip to main content

Configuration

Causal client APIs use environment variables (or initialization calls) to determine where the impression sever is running. The previous chapter had you start the impression server locally, meaning that the impression server is running on http://localhost:3004/iserver. This is the default place where the API looks for the Impression Server. If you start your impression sever elsewhere, you'll need to update these environment variables.

Causal uses two different environment variables to identify where the impression server is running. It uses one for processes running inside your cluster (ie for server side rendering), and one for browser/client side rendering. It uses two different variables because often times your internal addresses will not match your external ones.

For SSR, set the following: CAUSAL_ISERVER

For browser / client side rendering, set any of the following:

  • NEXT_PUBLIC_CAUSAL_BROWSER_ISERVER if you are using Next.js
  • REACT_APP_CAUSAL_BROWSER_ISERVER if you are using Create React App
  • VAGRANT_CAUSAL_BROWSER_ISERVER if you are using Vagrant
  • RAZZLE_CAUSAL_BROWSER_ISERVER if you are using Razzle
  • CAUSAL_BROWSER_ISERVER other/custom

Please consult with your platform documentation for details on setting environment variables. For browser / client side rending the variables must show up to the code running in the browser. Typically this is done by compiling them in to the JavaScript.

For illustration, our example project (written in Next.js) has the variables are configured in a root level .env file:

getting-started/.env
# The impression server address to use when rending in the browser
# This will be the external facing address of your impression server
# If you are using a hosted impression server it will be "https://tools.causallabs.io/iserver"
# If you are self hosting, it will be whatever the external address of your impression server is
#
NEXT_PUBLIC_CAUSAL_BROWSER_ISERVER=https://tools.causallabs.io/sandbox-iserver

# The impression server address to use when rendering server side
# This will be the internal address of your iserver
# If you are using a hosted impression server it will be "https://tools.causallabs.io/iserver"
# If you are self hosting, it will be whatever the internal address of your impression server is
#
# For demo purposes, running locally
CAUSAL_ISERVER=https://tools.causallabs.io/sandbox-iserver

At this point you have set up Causal end to end. Your front-end code will be log data to the impression server, the impresion server will upload the data to the S3 bucket you created earlier, and the ETL will automatically create your data tables.