Setting up product analytics in Snowflake

Overview

This topic explains how to set up LaunchDarkly product analytics in Snowflake.

To set up product analytics, you must first connect LaunchDarkly’s Snowflake Native Product Analytics integration to import event and other data to LaunchDarkly. To do this, you provide some information to LaunchDarkly, and LaunchDarkly generates a SQL script that you use to connect your Snowflake account to LaunchDarkly. You do not need to change anything in the script, which includes comments to explain each step of what it does.

Prerequisites

Before completing this procedure, you must have the following:

  • Events populating LaunchDarkly’s event stream
  • An active Snowflake account with the SECURITYADMIN and SYSADMIN privileges
  • Access to a Snowflake Native data warehouse

Set up product analytics with Snowflake

There are two ways to set up product analytics with Snowflake:

  • Using the Snowflake Data Export destination
  • Using a third-party customer data platform (CDP) to import your own events

Using the Snowflake Data Export destination

To use LaunchDarkly product analytics, you must first enable LaunchDarkly’s Snowflake Native Product Analytics integration. Here’s how:

  1. Click Product analytics in the left navigation, or find it by searching “Snowflake product analytics” on the Integrations page.
  2. Click Configure. The “Configure Snowflake Product Analytics” menu opens.
  3. Click Manage integration. The “Configure Snowflake Native Product Analytics” menu opens.

The Configure Snowflake Product Analytics menu.

The Configure Snowflake Product Analytics menu.
  1. Choose Using LaunchDarkly SDK and click Next step. If you have not yet configured Data Export, you will be prompted to do so. Then, the “Configure Snowflake Native Product Analytics” menu opens.
  2. Enter a human-readable Name.
  3. Enter your Snowflake account URL. You can find this in Snowflake’s “Account” menu, in the “Account/Server URL” field.

After you complete the steps above, LaunchDarkly generates a SQL script to connect your Snowflake account to LaunchDarkly. In the “Configure Snowflake Native Product Analytics” menu:

  1. Copy the script and paste it into a new worksheet in your Snowflake account.
  2. Run the script in Snowflake. When it completes, return to LaunchDarkly.
  3. Read the “Integration Terms and Conditions,” and then select the checkbox to acknowledge them.
  4. Click Save configuration. A confirmation message appears at the top of the screen when configuration completes successfully.

Using a third-party customer data platform (CDP) to import your own events

To use LaunchDarkly product analytics, you can also import your own events from a third-party customer data platform (CDP). Here’s how:

  1. Click Product analytics in the left navigation, or find it by searching “Snowflake product analytics” on the Integrations page.
  2. Click Configure. The “Configure Snowflake Product Analytics” menu opens.
  3. Click Manage integration. The “Configure Snowflake Native Product Analytics” menu opens.

The Configure Snowflake Product Analytics menu.

The Configure Snowflake Product Analytics menu.
  1. Choose Use CDP/Custom SDK and click Next step. The “Configure Snowflake Warehouse” menu opens.

Now, use the code below to configure your CDP or custom SDK to connect to LaunchDarkly product analytics.

Configuration script
-- Setting up the warehouse, database, schema, roles, user and such.
-- the events table schema we expect
begin;
-- Enter project environment key
set project_env_key = 'EXAMPLE_PROJECT_ENV_KEY';
-- ===== System Setup Variables (Do not modify) =====
set warehouse_name = 'LD_PRODUCT_ANALYTICS_WH'; -- Uppercase required
set database_name = 'LD_PRODUCT_ANALYTICS'; -- Uppercase required
set role_name = 'LD_PRODUCT_ANALYTICS_ROLE'; -- Uppercase required
set schema_name = 'PRODUCT_ANALYTICS_'|| $project_env_key;
set user_name = 'LD_PRODUCT_ANALYTICS_USER_'|| $project_env_key;
-- ===== Warehouse Setup =====
use role sysadmin;
create warehouse if not exists identifier($warehouse_name)
warehouse_size = medium
warehouse_type = standard
auto_suspend = 60
auto_resume = true
initially_suspended = true;
-- ===== Database Setup =====
create database if not exists identifier($database_name);
-- ===== Role Setup =====
use role securityadmin;
create role if not exists identifier($role_name);
grant role identifier($role_name) to role SYSADMIN;
-- ===== Permissions: Warehouse & Database =====
use role sysadmin;
grant usage, operate
on warehouse identifier($warehouse_name)
to role identifier($role_name);
grant monitor, usage
on database identifier($database_name)
to role identifier($role_name);
grant create schema
on database identifier($database_name)
to role identifier($role_name);
grant usage
on all schemas in database identifier($database_name)
to role identifier($role_name);
grant usage
on future schemas in database identifier($database_name)
to role identifier($role_name);
grant create table
on all schemas in database identifier($database_name)
to role identifier($role_name);
grant create table
on future schemas in database identifier($database_name)
to role identifier($role_name);
grant select
on all tables in database identifier($database_name)
to role identifier($role_name);
grant select
on future tables in database identifier($database_name)
to role identifier($role_name);
grant select
on all views in database identifier($database_name)
to role identifier($role_name);
grant select
on future views in database identifier($database_name)
to role identifier($role_name);
-- ===== Schema Setup =====
use database identifier($database_name);
create schema if not exists identifier($schema_name);
grant usage, create table, create view
on schema identifier($schema_name)
to role identifier($role_name);
grant create procedure, create task, create stream, create function
on schema identifier($schema_name)
to role identifier($role_name);
grant operate
on future tasks in schema identifier($schema_name)
to role identifier($role_name);
grant execute task on account
to role identifier($role_name);
-- ===== User Setup =====
use role securityadmin;
create user if not exists identifier($user_name);
alter user identifier($user_name)
set default_role = $role_name,
default_warehouse = $warehouse_name,
QUOTED_IDENTIFIERS_IGNORE_CASE = false;
grant role identifier($role_name)
to user identifier($user_name);
-- ===== Set Public Key =====
alter user identifier($user_name)
set rsa_public_key=$$
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoSIgCMLA5k5Cwifb0xkOlkrlOnd35+fYCOttX7O2l2VHocIFV964CjCYo9iRC9Vih11zzduOPGGb73RyD1g8/HnTbQK44PgTZc9YdPwxvrmlWL/lbAUj9+gr9KkhfYiY2y2GMMQgwc8nbckPAgLhgqiTqVTBIdhrKktNoCdsupkHB1awa1y6c2W/HvfZHTJWeNOArZM+d1WdQu0SuSewTTJR2deHxBYG74SRsJcAVZ1YMuxavQ0+gTeU6qz0u3FdKW73bAXMyvgbWUNcylAju/5IebmWuFCzGg7tCy/2rNcLaFnzm1XEQUpsYi/SggyyP4NYl2Nfzgdq25azsHSKYwIDAQAB
$$;
commit;
-- ==== Run this only after creating the ALLEVENTS table in the schema ==== --
-- ==== Change role to LD_PRODUCT_ANALYTICS_ROLE to run this ==== --
-- ===== Enable Change Tracking on Events Table ===== --
-- This assumes the ALLEVENTS table already exists --
use role identifier($role_name);
begin;
alter table ALLEVENTS set change_tracking = true;
commit;

After you complete the steps above, LaunchDarkly generates a SQL script to connect your Snowflake account to LaunchDarkly. In the “Configure Snowflake warehouse” menu:

  1. Enter a human-readable Name.
  2. Enter your Snowflake account URL. You can find this in Snowflake’s “Account” menu, in the “Account/Server URL” field.
  3. Copy the script and paste it into a new worksheet in your Snowflake account.
  4. Run the script in Snowflake. When it completes, return to LaunchDarkly.
  5. Read the “Integration Terms and Conditions,” and then select the checkbox to acknowledge them.
  6. Click Save configuration. A confirmation message appears at the top of the screen when configuration completes successfully.

After you complete the setup steps, the landing page on the Product analytics screen in LaunchDarkly will update to show a “Waiting for data…” status. Events and other information will begin to populate the screen within 15 minutes. Events from the last 30 days will be available within an hour. Load time varies based on the volume of data you’re importing from Snowflake.

To verify that data is loading, refresh the page. The Dashboards tab will not have any information in it until you create a dashboard, but you can confirm that setup was successful by checking the Events and Attributes tabs. After the import completes, both of those tabs display pre-populated data.

After the event data appears, you will be able to access different aspects of the product analytics UI.

To learn more, read Dashboards, Events, Cohorts, and Attributes.