> ## Documentation Index
> Fetch the complete documentation index at: https://www.dataframer.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Import Events from Warehouse

> Use the events your analytics tool already records, without the browser SDK

If you already send product events to Segment, PostHog or Amplitude, DataFramer can use those instead of the [browser SDK](https://www.dataframer.ai/docs/user-signals/browser-events.md). There are two ways in: a Databricks, Amazon Redshift or Snowflake table your tool already writes to, or Segment's webhook. Neither needs a code change in your app, and you can add as many as you need. To place imported events on the right journeys, set the [linking rule](https://www.dataframer.ai/docs/user-signals/fields-and-linking.md#linking-rule). When imported events carry a value at another path than your other events, add that path to the [field](https://www.dataframer.ai/docs/user-signals/fields-and-linking.md#fields).

## From a warehouse table

Segment, PostHog and Amplitude can each copy every event into a table in Databricks, Amazon Redshift or Snowflake:

* **Segment**: add the [Databricks destination](https://www.twilio.com/docs/segment/connections/storage/catalog/databricks), with the workspace host starting `https://`, the [Redshift destination](https://www.twilio.com/docs/segment/connections/storage/catalog/redshift), which needs a provisioned cluster, not Redshift Serverless, or the [Snowflake destination](https://www.twilio.com/docs/segment/connections/storage/catalog/snowflake). It writes one table per event name, plus `identifies` for user traits, on Segment's sync schedule (once a day on the free plan).
* **PostHog**: create a [Databricks batch export](https://posthog.com/docs/cdp/batch-exports/databricks), with the workspace host without `https://`, a [Redshift batch export](https://posthog.com/docs/cdp/batch-exports/redshift) or a [Snowflake batch export](https://posthog.com/docs/cdp/batch-exports/snowflake). It writes one events table. DataFramer reads PostHog's Snowflake table by event time, as it reads its Redshift table. If every row of the table has `snowflake_ingested_timestamp`, you can name it as the load-time column instead: PostHog fills it only on rows it exports after the column exists, and never on the rows before.
* **Amplitude**: add the [Databricks destination](https://amplitude.com/docs/data/destination-catalog/databricks), the [Redshift destination](https://amplitude.com/docs/data/destination-catalog/amazon-redshift) or the [Snowflake destination](https://amplitude.com/docs/data/destination-catalog/snowflake). It writes one events table.

DataFramer reads that table:

* **Databricks**: with a service principal. Give the principal `USE CATALOG`, `USE SCHEMA` and `SELECT` on the tables, and **Can use** on a SQL warehouse.
* **Amazon Redshift**: with a database user that has `USAGE` on the schema and `SELECT` on the tables. The tool creates its tables itself, Segment one per new event name, so grant `SELECT` on future tables too, with `ALTER DEFAULT PRIVILEGES` for the tool's user. As for the tools' own Redshift exports, the endpoint must be publicly accessible, and its security group must allow DataFramer's address `35.83.1.227` on the port. In a [customer-hosted deployment](https://www.dataframer.ai/docs/deployment.md#user-signals-in-a-customer-hosted-deployment) your data plane connects instead: allow your data plane's network, and the endpoint need not be public.
* **Snowflake**: with a `SERVICE` user that signs in with a key pair. Its role needs `USAGE` on a warehouse, the database and the schema, and `SELECT` on the tables, including future ones. Imports run every few minutes, and each one that finds the warehouse suspended starts it, so give DataFramer its own X-Small warehouse with `AUTO_SUSPEND = 60` to keep the cost low. If your account or the user has a network policy, it must allow DataFramer's address `35.83.1.227`, or, in a customer-hosted deployment, your data plane's outbound address.

To set up the Snowflake login, first create a key pair. Paste the contents of `dataframer_key.p8` into DataFramer as the private key, and keep it out of version control:

```bash theme={null}
openssl genrsa 2048 | openssl pkcs8 -topk8 -nocrypt -out dataframer_key.p8
openssl rsa -in dataframer_key.p8 -pubout -out dataframer_key.pub
```

Then, as an administrator, run the following, with the public key's contents between its `BEGIN` and `END` lines as `RSA_PUBLIC_KEY`, and your own database and schema names:

```sql theme={null}
CREATE WAREHOUSE DATAFRAMER_WH WAREHOUSE_SIZE = XSMALL AUTO_SUSPEND = 60 AUTO_RESUME = TRUE INITIALLY_SUSPENDED = TRUE;
CREATE ROLE DATAFRAMER_READER;
GRANT USAGE ON WAREHOUSE DATAFRAMER_WH TO ROLE DATAFRAMER_READER;
GRANT USAGE ON DATABASE ANALYTICS TO ROLE DATAFRAMER_READER;
GRANT USAGE ON SCHEMA ANALYTICS.SEGMENT TO ROLE DATAFRAMER_READER;
GRANT SELECT ON ALL TABLES IN SCHEMA ANALYTICS.SEGMENT TO ROLE DATAFRAMER_READER;
GRANT SELECT ON FUTURE TABLES IN SCHEMA ANALYTICS.SEGMENT TO ROLE DATAFRAMER_READER;
CREATE USER DATAFRAMER TYPE = SERVICE DEFAULT_ROLE = DATAFRAMER_READER DEFAULT_WAREHOUSE = DATAFRAMER_WH RSA_PUBLIC_KEY = 'MIIBIjANBgkqh...';
GRANT ROLE DATAFRAMER_READER TO USER DATAFRAMER;
```

In DataFramer, the account identifier is `orgname-account_name`, as **Account details** in Snowsight shows it, without `https://` or `.snowflakecomputing.com`. Instead of the private key, you can paste a [programmatic access token](https://docs.snowflake.com/en/user-guide/programmatic-access-tokens) for the user.

Then, in DataFramer, open **Sources**, select **Add a warehouse table**, and follow its steps. Four things to know:

* Choose **Other table** for an events table of your own; you then name its columns.
* One login has one secret: a new secret saved on one import is also saved on every import that uses the same login.
* For Segment, list the event tables, not `tracks`, which has no properties.
* An empty **Only these events** imports every event, which for PostHog includes its automatic events such as `$pageview` and `$autocapture`.

When the preview looks right, select **Start importing**. DataFramer then imports new rows every few minutes, each event once, so a table you re-export does not create duplicates. From a table that does not record when each row arrived, such as PostHog's Redshift or Snowflake table, an event that arrives more than 7 days late is not imported. Edit an import to read more, with an earlier or empty **Import events from** or more events in **Only these events**, and its next runs read its tables again from the start, so the events the old settings left out arrive too. **Delete** stops an import; the events it imported stay, with its name.

## From Segment's webhook

Segment can also send DataFramer a copy of each event as it arrives. This needs no warehouse, but only events from then on arrive. Add one webhook for each Segment source:

1. In **Sources**, select **Add Segment webhook**, give it a name, such as the name of the Segment source, and copy its address and shared secret. The name shows as the source of its events, such as "Segment webhook · web app".
2. In Segment, add a **Webhooks (Actions)** destination to your source. In its **Settings**, paste the secret into **Shared Secret** and turn on **Enable Destination**.
3. In its **Mappings**, add a **Send** mapping for the event types you want, with the address as **URL** and **POST** as **Method**. Keep the default **Data**, the whole event. Batching can be on.

## Next steps

> [card] [Fields and Linking](https://www.dataframer.ai/docs/user-signals/fields-and-linking.md)
>
> Choose how imported events link to your AI traces.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.