Skip to content

CDI를 사용하여 계정 데이터를 동기화합니다

CDI를 사용하여 Braze 계정 데이터를 동기화하는 방법을 배우십시오.

필수 조건

CDI를 사용하여 계정 데이터를 동기화하기 전에 계정 스키마를 구성해야 합니다.

동기화 작동 방식

  • 각 동기화는 UPDATED_AT이 마지막 동기화된 타임스탬프보다 늦은 행을 가져옵니다.
  • 통합에서 가져온 데이터는 제공된 id에 따라 계정을 생성하거나 업데이트합니다.
  • DELETEDtrue인 경우 계정이 삭제됩니다.
  • 동기화는 데이터 포인트를 기록하지 않지만, 모든 동기화된 데이터는 총 저장 데이터로 측정되는 총 계정 사용량에 포함됩니다. 변경된 데이터만 제한할 필요는 없습니다.
  • 계정 스키마에 없는 필드는 삭제됩니다. 새 필드를 동기화하기 전에 스키마를 업데이트하십시오.
  • 동기화 이름 위에 마우스를 올리고 관련 작업을 선택하여 동기화를 새로 고치거나, 재개하거나, 일시 중지할 수 있습니다.

계정 데이터를 동기화하십시오.

데이터 웨어하우스 또는 파일 저장소를 통해 CDI를 사용하여 계정 데이터를 동기화할 수 있습니다.

데이터 소스를 데이터 웨어하우스와 통합하려면:

  1. Snowflake에서 소스 테이블을 생성합니다. 예제의 이름을 사용하거나 자신의 데이터베이스, 스키마 및 테이블 이름을 선택하십시오. 테이블 대신 뷰 또는 물리적 뷰를 사용할 수도 있습니다.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
     CREATE DATABASE BRAZE_CLOUD_PRODUCTION;
     CREATE SCHEMA BRAZE_CLOUD_PRODUCTION.INGESTION;
     CREATE OR REPLACE TABLE BRAZE_CLOUD_PRODUCTION.INGESTION.ACCOUNTS_SYNC (
          UPDATED_AT TIMESTAMP_NTZ(9) NOT NULL DEFAULT SYSDATE(),
          --ID of the account to be created or updated
          ID VARCHAR(16777216) NOT NULL,
          --Name of the account to be created or updated
          NAME VARCHAR(16777216) NOT NULL,
          --Account fields and values that should be added or updated
          PAYLOAD VARCHAR(16777216) NOT NULL,
          --The account associated with this ID should be deleted
          DELETED BOOLEAN
     );
    
  2. Create a role, warehouse, and user, and grant permissions. If you already have credentials from another sync, you can reuse them—make sure they have access to the accounts table.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
     CREATE ROLE BRAZE_INGESTION_ROLE;
    
     GRANT USAGE ON DATABASE BRAZE_CLOUD_PRODUCTION TO ROLE BRAZE_INGESTION_ROLE;
     GRANT USAGE ON SCHEMA BRAZE_CLOUD_PRODUCTION.INGESTION TO ROLE BRAZE_INGESTION_ROLE;
     GRANT SELECT ON TABLE BRAZE_CLOUD_PRODUCTION.INGESTION.ACCOUNTS_SYNC TO ROLE BRAZE_INGESTION_ROLE;
    
     CREATE WAREHOUSE BRAZE_INGESTION_WAREHOUSE;
     GRANT USAGE ON WAREHOUSE BRAZE_INGESTION_WAREHOUSE TO ROLE BRAZE_INGESTION_ROLE;
    
     CREATE USER BRAZE_INGESTION_USER;
     GRANT ROLE BRAZE_INGESTION_ROLE TO USER BRAZE_INGESTION_USER;
    
  3. If you use network policies, allowlist the Braze IPs so the CDI service can connect. For the list of IPs, see Cloud Data Ingestion.
  4. In the Braze dashboard, go to Data Settings > Cloud Data Ingestion and create a new sync.
  5. Enter connection details (or reuse existing ones), then add the source table.
  6. Select the Accounts sync type, then enter the integration name and schedule.
  7. Choose the sync frequency.
  8. Add the public key from the dashboard to the user you created. This requires a user with SECURITYADMIN access or higher in Snowflake.
  9. Select Test Connection to confirm the setup.
  10. When you’re finished, save the sync.
  1. Create a source table in Redshift. Use the names in the example or choose your own database, schema, and table names. You can also use a view or materialized view instead of a table.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
     CREATE DATABASE BRAZE_CLOUD_PRODUCTION;
     CREATE SCHEMA BRAZE_CLOUD_PRODUCTION.INGESTION;
     CREATE TABLE BRAZE_CLOUD_PRODUCTION.INGESTION.ACCOUNTS_SYNC (
        updated_at timestamptz default sysdate not null,
        --ID of the account to be created or updated
        id varchar not null,
        --Name of the account to be created or updated
        name varchar not null,
        --Account fields and values that should be added or updated
        payload varchar(max),
        --The account associated with this ID should be deleted
        deleted boolean
     )
    
  2. Create a user and grant permissions. If you already have credentials from another sync, you can reuse them—make sure they have access to the accounts table.

    1
    2
    3
    
     CREATE USER braze_user PASSWORD '{password}';
     GRANT USAGE ON SCHEMA BRAZE_CLOUD_PRODUCTION.INGESTION to braze_user;
     GRANT SELECT ON TABLE ACCOUNTS_SYNC TO braze_user;
    
  3. If you have a firewall or network policies, allow Braze access to your Redshift instance. For the list of IPs, see Cloud Data Ingestion.
  1. (Optional) Create a new project or dataset for your source table.
    1
    
     CREATE SCHEMA BRAZE-CLOUD-PRODUCTION.INGESTION;
    
  2. Create the source table for your CDI integration:
    1
    2
    3
    4
    5
    6
    7
    8
    
     CREATE TABLE `BRAZE-CLOUD-PRODUCTION.INGESTION.ACCOUNTS_SYNC`
     (
       updated_at TIMESTAMP DEFAULT current_timestamp,
       id STRING,
       name STRING,
       payload JSON,
       deleted BOOLEAN
     );
    

    Refer to the following when creating your source table:

  1. Create a user and grant permissions. If you already have credentials from another sync, you can reuse them as long as they have access to the accounts table.

    After granting permissions, generate a JSON key. See Keys create and delete for instructions. You’ll upload it in the Braze dashboard later.

  1. If you use network policies, allow Braze IPs to access your BigQuery instance. For the list of IPs, see Cloud Data Ingestion.
  1. Create a catalog or schema for your source table.
    1
    
     CREATE SCHEMA BRAZE-CLOUD-PRODUCTION.INGESTION;
    
  2. Create the source table for your CDI integration:
    1
    2
    3
    4
    5
    6
    7
    8
    
     CREATE TABLE `BRAZE-CLOUD-PRODUCTION.INGESTION.ACCOUNTS_SYNC`
     (
       updated_at TIMESTAMP DEFAULT current_timestamp(),
       id STRING,
       name STRING,
       payload STRING, STRUCT, or MAP,
       deleted BOOLEAN
     );
    

    Refer to the following when creating your source table:

  1. Create a personal access token in Databricks:
    1. Select your username, then select User Settings.
    2. On the Access tokens tab, select Generate new token.
    3. Add a comment to identify the token, such as “Braze CDI”.
    4. Leave Lifetime (days) blank for no expiration, then select Generate.
    5. Copy and save the token securely for use in the Braze dashboard.
  1. If you use network policies, allow Braze IPs to access your Databricks instance. For the list of IPs, see Cloud Data Ingestion.
  1. Create one or more tables for your CDI integration with these fields:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    
     CREATE OR ALTER TABLE [warehouse].[schema].[CDI_table_name] 
     (
       UPDATED_AT DATETIME2(6) NOT NULL,
       PAYLOAD VARCHAR NOT NULL,
       ID VARCHAR NOT NULL,
       NAME VARCHAR NOT NULL,
       DELETED BIT
     )
     GO
    
  1. Create a service principal and grant permissions. If you already have credentials from another sync, you can reuse them—make sure they have access to the accounts table.
  1. If you use network policies, allow Braze IPs to access your Microsoft Fabric instance. For the list of IPs, see Cloud Data Ingestion.

To sync account data from file storage, create a source file with the following fields.

The following examples show valid JSON and CSV formats for syncing account data from file storage.

{"id":"s3-qa-0","name":"account0","payload":"{\"attribute_0\": \"GT896\", \"attribute_1\": 74, \"attribute_2\": true, \"retention\": {\"previous_purchases\": 21, \"vip\": false}, \"last_visit\": \"2023-08-08T16:03:26.600803\"}"}
{"id":"s3-qa-1","name":"account1","payload":"{\"attribute_0\": \"GT896\", \"attribute_1\": 74, \"attribute_2\": true, \"retention\": {\"previous_purchases\": 21, \"vip\": false}, \"last_visit\": \"2023-08-08T16:03:26.600803\"}","deleted":true}
{"id":"s3-qa-2","name":"account2","payload":"{\"attribute_0\": \"GT896\", \"attribute_1\": 74, \"attribute_2\": true, \"retention\": {\"previous_purchases\": 21, \"vip\": false}, \"last_visit\": \"2023-08-08T16:03:26.600803\"}","deleted":false}
{"id":"s3-qa-3","name":"account3","payload":"{\"attribute_0\": \"GT896\", \"attribute_1\": 74, \"attribute_2\": true, \"retention\": {\"previous_purchases\": 21, \"vip\": false}, \"last_visit\": \"2023-08-08T16:03:26.600803\"}"}
1
2
3
ID,NAME,PAYLOAD,DELETED
85,"ACCOUNT_1","{""region"": ""APAC"", ""employees"": 850}",TRUE 
1,"ACCOUNT_2","{""region"": ""EMEA"", ""employees"": 10000}",FALSE
1
2
3
ID,NAME,PAYLOAD
85,"ACCOUNT_1","{""region"": ""APAC"", ""employees"": 850}"
1,"ACCOUNT_2","{""region"": ""EMEA"", ""employees"": 10000}"

동기화 뷰 만들기

데이터 웨어하우스에서 동기화 뷰를 생성하면 소스가 추가 쿼리를 다시 작성할 필요 없이 자동으로 새로 고침됩니다.

예를 들어, account_details_1이라는 계정 데이터 테이블이 있고 account_id, account_name 및 세 개의 추가 속성이 있는 경우 다음과 같은 동기화 뷰를 만들 수 있습니다:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
CREATE VIEW BRAZE_CLOUD_PRODUCTION.INGESTION.ACCOUNTS_SYNC AS 
SELECT
    CURRENT_TIMESTAMP as UPDATED_AT,
    account_id as id,
    account_name as name,
    TO_JSON(
        OBJECT_CONSTRUCT (
            'attribute_1',
            attribute_1,
            'attribute_2',
            attribute_2,
            'attribute_3',
            attribute_3)
    )as PAYLOAD FROM "account_details_1";
1
2
3
4
5
6
7
8
9
10
11
12
13
14
CREATE TABLE BRAZE_CLOUD_PRODUCTION.INGESTION.ACCOUNTS_SYNC AS
SELECT
    CURRENT_TIMESTAMP as UPDATED_AT,
    account_id as id,
    account_name as name,
    JSON_SERIALIZE(
        OBJECT (
            'attribute_1',
            attribute_1,
            'attribute_2',
            attribute_2,
            'attribute_3',
            attribute_3)
    ) as PAYLOAD FROM "account_details_1";
1
2
3
4
5
6
7
8
9
10
11
12
CREATE view IF NOT EXISTS BRAZE_CLOUD_PRODUCTION.INGESTION.ACCOUNTS_SYNC AS (SELECT
    last_updated as UPDATED_AT,
    account_id as ID,
    account_name as NAME,
    TO_JSON(
      STRUCT(
      attribute_1,
      attribute_2,
      attribute_3,
      )
    ) as PAYLOAD 
  FROM `BRAZE_CLOUD_PRODUCTION.INGESTION.account_details_1`);
1
2
3
4
5
6
7
8
9
10
11
12
CREATE view IF NOT EXISTS BRAZE_CLOUD_PRODUCTION.INGESTION.ACCOUNTS_SYNC AS (SELECT
    last_updated as UPDATED_AT,
    account_id as ID,
    account_name as NAME,
    TO_JSON(
      STRUCT(
      attribute_1,
      attribute_2,
      attribute_3,
      )
    ) as PAYLOAD 
  FROM `BRAZE_CLOUD_PRODUCTION.INGESTION.account_details_1`);
1
2
3
4
5
6
7
8
CREATE VIEW [BRAZE_CLOUD_PRODUCTION].[INGESTION].[ACCOUNTS_SYNC]
AS SELECT 
    account_id as ID,
    account_name as NAME,
    CURRENT_TIMESTAMP as UPDATED_AT,
    JSON_OBJECT('attribute_1':attribute_1, 'attribute_2':attribute_2, 'attribute_3':attribute_3, 'attribute_4':attribute_4) as PAYLOAD

FROM [braze].[account_details_1] ;
New Stuff!