Synchronisation des données de compte à l’aide de CDI
Veuillez découvrir comment synchroniser les données de votre compte Braze à l’aide de CDI.
Les objets de compte sont en version bêta et sont nécessaires pour utiliser cette fonctionnalité. Contactez votre gestionnaire de compte Braze si vous souhaitez participer à la version bêta.
Conditions préalables
Avant de pouvoir synchroniser les données de votre compte à l’aide de CDI, il est nécessaire de configurer le schéma de vos comptes.
Veuillez effectuer les mises à jour de votre schéma de compte uniquement lorsque la synchronisation est suspendue ou non en phase de planification afin d’éviter tout conflit entre les données de votre entrepôt de données et le schéma dans Braze.
Fonctionnement de la synchronisation
- Chaque synchronisation importe les lignes dont la date
UPDATED_ATest postérieure à la dernière synchronisation. - Les données issues de l’intégration permettent de créer ou de mettre à jour des comptes en fonction des informations fournies
id. - Si
DELETEDesttrue, le compte est supprimé. - La synchronisation n’enregistre pas les points de données, mais toutes les données synchronisées sont prises en compte dans l’utilisation totale de vos comptes, mesurée par le total des données stockées. Il n’est pas nécessaire de se limiter aux seules données modifiées.
- Les champs qui ne figurent pas dans le schéma de vos comptes sont supprimés ; veuillez mettre à jour le schéma avant de synchroniser de nouveaux champs.
- Vous pouvez actualiser, reprendre ou suspendre une synchronisation en plaçant le curseur sur le nom de la synchronisation et en sélectionnant l’action appropriée.
Veuillez synchroniser les données de votre compte.
Vous pouvez synchroniser les données de votre compte à l’aide de CDI via un entrepôt de données ou un stockage de fichiers.
Pour réaliser l’intégration de votre source de données à votre entrepôt de données :
- Veuillez créer une table source dans Snowflake. Veuillez utiliser les noms fournis dans l’exemple ou sélectionner vos propres noms de base de données, de schéma et de table. Vous pouvez également utiliser une vue ou une vue matérialisée à la place d’une 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 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 );
- 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;
- If you use network policies, allowlist the Braze IPs so the CDI service can connect. For the list of IPs, see Cloud Data Ingestion.
- In the Braze dashboard, go to Data Settings > Cloud Data Ingestion and create a new sync.
- Enter connection details (or reuse existing ones), then add the source table.
- Select the Accounts sync type, then enter the integration name and schedule.
- Choose the sync frequency.
- Add the public key from the dashboard to the user you created. This requires a user with
SECURITYADMINaccess or higher in Snowflake. - Select Test Connection to confirm the setup.
- When you’re finished, save the sync.
- 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 )
-
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;
- If you have a firewall or network policies, allow Braze access to your Redshift instance. For the list of IPs, see Cloud Data Ingestion.
- (Optional) Create a new project or dataset for your source table.
1
CREATE SCHEMA BRAZE-CLOUD-PRODUCTION.INGESTION;
- 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:
Field Name Type Required? UPDATED_ATTimestamp Yes PAYLOADJSON Yes IDString Yes NAMEString Yes DELETEDBoolean Optional
-
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.
Permission Purpose BigQuery Connection User Allows Braze to connect. BigQuery User Allows Braze to run queries, read metadata, and list tables. BigQuery Data Viewer Allows Braze to view datasets and contents. BigQuery Job User Allows Braze to run jobs. After granting permissions, generate a JSON key. See Keys create and delete for instructions. You’ll upload it in the Braze dashboard later.
- If you use network policies, allow Braze IPs to access your BigQuery instance. For the list of IPs, see Cloud Data Ingestion.
- Create a catalog or schema for your source table.
1
CREATE SCHEMA BRAZE-CLOUD-PRODUCTION.INGESTION;
- 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:
Field Name Type Required? UPDATED_ATTimestamp Yes PAYLOADString, Struct, or Map Yes IDString Yes NAMEString Yes DELETEDBoolean Optional
- Create a personal access token in Databricks:
- Select your username, then select User Settings.
- On the Access tokens tab, select Generate new token.
- Add a comment to identify the token, such as “Braze CDI”.
- Leave Lifetime (days) blank for no expiration, then select Generate.
- Copy and save the token securely for use in the Braze dashboard.
- If you use network policies, allow Braze IPs to access your Databricks instance. For the list of IPs, see Cloud Data Ingestion.
- 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
- 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.
- 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.
| Field | Required? | Description |
|---|---|---|
ID |
Yes | ID of the Account to update or create |
NAME |
Yes | Name of the Account |
PAYLOAD |
Yes | JSON string of the fields to sync to the account in Braze |
DELETED |
Optional | Boolean indicating to delete the account from Braze |
UPDATED_AT |
*Unsupported | File storage doesn’t support UPDATED_AT columns |
Filenames must follow AWS rules and be unique. Append timestamps to help ensure uniqueness. For more on Amazon S3 syncing, see File Storage Integrations.
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\"}"}
Chaque ligne de votre fichier source doit contenir du JSON valide, sinon le fichier sera ignoré.
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}"
Créer une vue synchronisée
La création d’une vue synchronisée dans votre entrepôt de données permet à la source d’actualiser automatiquement sans qu’il soit nécessaire de réécrire des requêtes supplémentaires.
Par exemple, si vous disposez d’une table de données comptables intituléeaccount_details_1 avec account_id,account_name , et trois attributs supplémentaires, vous pouvez créer une vue de synchronisation comme suit :
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] ;
Modifier cette page sur GitHub