### Example Test Structure Source: https://docs.dittofeed.com/guide/testing This example demonstrates a typical test structure using `describe`, `it`, and `afterEach` blocks for organizing tests. It includes setup and teardown logic. ```javascript describe("identify", () => { it("Emails the clicking user", async () => { // Test logic here }); afterEach(async () => { await df.teardown(); }); }); ``` -------------------------------- ### Installation Source: https://docs.dittofeed.com/integrations/sdks/web Install the Web SDK using either Yarn or NPM. ```APIDOC ## Installation ```bash # Using Yarn yarn add @dittofeed/sdk-web # Using NPM npm install --save @dittofeed/sdk-web ``` ``` -------------------------------- ### Testing SDK Example Source: https://docs.dittofeed.com/llms-full.txt This example demonstrates how to use the Dittofeed testing SDK to simulate user actions and verify message delivery. It includes setup, event simulation, and message assertion. ```javascript describe("When the bookmark button is clicked", () => { let df: DittofeedTestEnv; beforeEach(async () => { df = await Dittofeed.setupTestEnv(); ... }) it("Emails the clicking user", async () => { render() fireEvent.click(screen.getByText(/bookmark/i)) // Using simulated time. await df.sleep("1 week"); const messages = await df.fetchMessages(); expect(messages).toEqual([ expect.objectContaining({ to: "test@email.com", type: "Email", body: expect.stringContaining("https://app.com/user-1/bookmarks") ... }); ]); }); }); ``` -------------------------------- ### Install Web SDK with NPM Source: https://docs.dittofeed.com/integrations/sdks/web Install the Web SDK using NPM. This command adds the SDK as a dependency to your project. ```shellscript # Using NPM npm install --save @dittofeed/sdk-web ``` -------------------------------- ### Example Broadcast Configuration Source: https://docs.dittofeed.com/embedded/getting-started This example demonstrates how to create a configuration for the Broadcast component. Ensure the 'name' field matches the component type. ```json { "name": "Broadcast", "description": "Configure the Broadcast component.", "config": { "originUriTemplate": "/app/campaigns/{originId}", "hideOptions": [ "schedule", "rateLimit" ] } } ``` -------------------------------- ### Install Web SDK Source: https://docs.dittofeed.com/integrations/sdks/web Install the Dittofeed Web SDK using npm. This command saves the package to your project dependencies. ```bash npm install --save @dittofeed/sdk-web ``` -------------------------------- ### Install Node.js SDK Source: https://docs.dittofeed.com/llms-full.txt Install the Node.js SDK using Yarn or NPM. This is the first step to integrating your Node.js application with Dittofeed. ```bash # Using Yarn yarn add @dittofeed/sdk-node # Using NPM npm install --save @dittofeed/sdk-node ``` -------------------------------- ### Kafka Configuration Example Source: https://docs.dittofeed.com/deployment/self-hosted/write-modes/kafka This snippet shows an example of Kafka configuration, including security protocol, SASL mechanism, username, and password. ```xml sasl_ssl PLAIN your-kafka-username your-kafka-password ``` -------------------------------- ### Install Web SDK with Yarn Source: https://docs.dittofeed.com/integrations/sdks/web Install the Web SDK using Yarn. This command adds the SDK as a dependency to your project. ```shellscript # Using Yarn yarn add @dittofeed/sdk-web ``` -------------------------------- ### Kafka Configuration Example Source: https://docs.dittofeed.com/deployment/self-hosted/write-modes/kafka Example configuration for writing data to Kafka. This includes broker addresses, security protocols, SASL mechanisms, and credentials. ```xml sasl_ssl PLAIN your-kafka-username ``` -------------------------------- ### Create Journey Example Source: https://docs.dittofeed.com/guide/testing Example of how to create a journey with specific entry and node configurations. This snippet demonstrates defining segments, delays, and child nodes. ```javascript children: \" df\"\ }), \n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \".\"\n }), \n_jsx(_components.span, {\n style: {\n color: \"#8250DF\",\n \"--shiki-dark\": \"#DCDCAA\"\n },\n children: \"createJourney\"\n }), \n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \"({\"\ })\]\ }), \n\"\\\n\", \n_jsxs(_components.span, {\n className: \"line\",\n children: [\n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \" entry:\"\n }), \n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \" {\"\ })\n]\n}), \n\"\\\n\", \n_jsxs(_components.span, {\n className: \"line\",\n children: [\n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \" segmentId:\"\n }), \n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \" segment\"\n }), \n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \".\"\n }), \n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \"id\"\n }), \n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \",\"\n })\n]\n}), \n\"\\\n\", \n_jsxs(_components.span, {\n className: \"line\",\n children: [\n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \" childId:\"\n }), \n_jsx(_components.span, {\n style: {\n color: \"#0A3069\",\n \"--shiki-dark\": \"#CE9178\"\n },\n children: \" \\\\"1\\\\"\"\n })\n]\n}), \n\"\\\n\", \n_jsx(_components.span, {\n className: \"line\",\n children: \n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \" },\"\n })\n}), \n\"\\\n\", \n_jsxs(_components.span, {\n className: \"line\",\n children: [\n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \" nodes:\"\n }), \n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \" \[\"\ })\n]\n}), \n\"\\\n\", \n_jsx(_components.span, {\n className: \"line\",\n children: \n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \" {\"\ })\n}), \n\"\\\n\", \n_jsxs(_components.span, {\n className: \"line\",\n children: [\n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \" id:\"\n }), \n_jsx(_components.span, {\n style: {\n color: \"#0A3069\",\n \"--shiki-dark\": \"#CE9178\"\n },\n children: \" \\\\"1\\\\"\"\n }), \n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \",\"\n })\n]\n}), \n\"\\\n\", \n_jsxs(_components.span, {\n className: \"line\",\n children: [\n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \" type:\"\n }), \n_jsx(_components.span, {\n style: {\n color: \"#0A3069\",\n \"--shiki-dark\": \"#CE9178\"\n },\n children: \" \\\\"Delay\\\\"\"\n }), \n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \",\"\n })\n]\n}), \n\"\\\n\", \n_jsx(_components.span, {\n className: \"line\",\n children: \n_jsx(_components.span, {\n style: {\n color: \"#6E7781\",\n \"--shiki-dark\": \"#6A9955\"\n },\n children: \" // 1 week\"\n })\n}), \n\"\\\n\", \n_jsxs(_components.span, {\n className: \"line\",\n children: [\n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \" seconds:\"\n }), \n_jsx(_components.span, {\n style: {\n color: \"#0A3069\",\n \"--shiki-dark\": \"#CE9178\"\n },\n children: \" \\\\"604800\\\\"\"\n }), \n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \",\"\n })\n]\n}), \n\"\\\n\", \n_jsxs(_components.span, {\n className: \"line\",\n children: [\n_jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \" childId:\"\n }), \n_jsx(_components.span, {\n style: {\n color: \"#0A3069\",\n \"--shiki-dark\": \"#CE9178\"\n },\n children: \" \\\\"2\\\\"\"\n })\n]\n}), \n\"\\\n\", \n ``` -------------------------------- ### Example Subscription Page URL Source: https://docs.dittofeed.com/guide/custom-subscription-page This is an example URL for accessing the subscription management page. It includes parameters for workspace ID, email, and authentication hash. ```text /api/public/subscription-management/page?w=workspace-id&[email protected]&ik=email&h=hash-value ``` -------------------------------- ### Node.js SDK Usage Examples Source: https://docs.dittofeed.com/llms-full.txt Examples demonstrating how to initialize the SDK, identify users with traits, track user events, record screen views, and flush events to Dittofeed's API. ```javascript import { DittofeedSdk } from '@dittofeed/sdk-node'; // Initialize the sdk with a writeKey, which is used to identify your // workspace. This key can be found at // https://app.dittofeed.com/dashboard/settings await DittofeedSdk.init({ writeKey: "Basic abcdefg...", }); // Lets you tie a user to their actions and record traits about them. It // includes a unique User ID and any optional traits you know about the // user, like their email, name, and more. DittofeedSdk.identify({ userId: "123", traits: { email: "john@email.com", firstName: "John" }, }); // The track call is how you record any actions your users perform, along // with any properties that describe the action. DittofeedSdk.track({ userId: "123", event: "Made Purchase", properties: { itemId: "abc", }, }); // Lets you record whenever a user sees a screen, the mobile equivalent of // page, in your mobile app, along with any properties about the screen. DittofeedSdk.screen({ userId: "123", name: "Recipe Screen", properties: { recipeType: "Soup", }, }); // Ensures that asynchronously submitted events are flushed synchronously // to Dittofeed's API. await DittofeedSdk.flush(); ``` -------------------------------- ### Run Local Docs Development Server Source: https://docs.dittofeed.com/llms-full.txt Starts the Mintlify development server to preview the documentation locally. Ensure you are in the `packages/docs` directory. ```bash mintlify dev ``` -------------------------------- ### Create Email Template Source: https://docs.dittofeed.com/resources/journey-nodes/message This section guides you to create an email template that consumes user properties. The provided image illustrates an example of such a template. ```html
 
``` -------------------------------- ### Get User Groups Source: https://docs.dittofeed.com/api-reference/auto/groups/get-apiadmingroupsuser-groups Retrieves a list of groups for a specified user within a workspace. You can control the number of results and the starting point with limit and offset. ```APIDOC ## GET /api/admin/groups/user-groups ### Description Get list of groups for a specific user. ### Method GET ### Endpoint /api/admin/groups/user-groups ### Parameters #### Query Parameters - **workspaceId** (string) - Required - The ID of the workspace. - **userId** (string) - Required - The ID of the user. - **limit** (number) - Optional - The maximum number of groups to return. - **offset** (number) - Optional - The number of groups to skip before starting to collect the result set. ### Response #### Success Response (200) - **groups** (string[]) - A list of group IDs. #### Response Example ```json { "groups": [ "" ] } ``` #### Error Response (400) - **message** (string) - An error message indicating why the request failed. #### Response Example ```json { "message": "" } ``` ``` -------------------------------- ### Initialization Source: https://docs.dittofeed.com/integrations/sdks/web Initialize the SDK with your workspace's write key. ```APIDOC ## Initialization ```javascript import { DittofeedSdk } from '@dittofeed/sdk-web'; // Initialize the sdk with a writeKey, which is used to identify your // workspace. This key can be found at // https://dittofeed.com/dashboard/settings await DittofeedSdk.init({ writeKey: "Basic abcdefg...", }); ``` ``` -------------------------------- ### Example Custom Subscription Page Template Source: https://docs.dittofeed.com/guide/custom-subscription-page A starting point for creating a custom subscription page. This template includes basic HTML structure and placeholders for content. ```liquid Subscription

Subscribe to Our Newsletter

Get the latest updates delivered straight to your inbox.

{% if subscription_message %}
{{ subscription_message }}
{% endif %} {% if subscription_error %}
{{ subscription_error }}
{% endif %}
``` -------------------------------- ### Get Current Template API Endpoint Source: https://docs.dittofeed.com/guide/custom-subscription-page This code block shows an example of how to retrieve the current custom template for the subscription management page. It is part of the template management API. ```text GET /api/public/templates/subscription-management ``` -------------------------------- ### GET /api-l/admin/workspaces/ Source: https://docs.dittofeed.com/api-reference/endpoints/apps/identify Get a workspace. ```APIDOC ## GET /api-l/admin/workspaces/ ### Description Get a workspace. ### Method GET ### Endpoint /api-l/admin/workspaces/ ``` -------------------------------- ### Bookmark Button Test Example Source: https://docs.dittofeed.com/guide/testing This is a full example of a test file for the BookmarkButton component. It demonstrates how to import necessary testing utilities and the component itself, and then defines a test suite using `describe` and `it` blocks. ```javascript import { render, screen, fireEvent } from '@testing-library/react'; import BookmarkButton from './bookmarkButton'; describe('BookmarkButton', () => { it('renders correctly and toggles bookmark state', () => { // Mocking the onClick handler const handleClick = jest.fn(); render(); // Initial state check (assuming it's not bookmarked initially) const button = screen.getByRole('button', { name: /bookmark/i }); expect(button).toBeInTheDocument(); expect(button).not.toHaveClass('bookmarked'); // Assuming a 'bookmarked' class for active state // Simulate a click to bookmark fireEvent.click(button); expect(handleClick).toHaveBeenCalledTimes(1); // After click, the button should visually indicate it's bookmarked // Note: The actual state change logic is within the component, we are testing the interaction and handler call. // If the component itself updates its class, you'd check for that here after the click. // For this example, we'll assume the onClick handler is the primary interaction to test. // Simulate another click to unbookmark fireEvent.click(button); expect(handleClick).toHaveBeenCalledTimes(2); }); it('renders with initial bookmarked state', () => { const handleClick = jest.fn(); // Render the button assuming it's already bookmarked render(); const button = screen.getByRole('button', { name: /bookmark/i }); expect(button).toBeInTheDocument(); expect(button).toHaveClass('bookmarked'); // Check for the 'bookmarked' class }); }); ``` -------------------------------- ### GET /api/admin/component-configurations/ Source: https://docs.dittofeed.com/api-reference/endpoints/apps/identify Get all component configurations. ```APIDOC ## GET /api/admin/component-configurations/ ### Description Get all component configurations. ### Method GET ### Endpoint /api/admin/component-configurations/ ``` -------------------------------- ### Example Subscription Management Page URL Source: https://docs.dittofeed.com/llms-full.txt An example URL demonstrating how to access the subscription management page with required query parameters for workspace, user identification, and authentication. ```URL /api/public/subscription-management/page?w=workspace-id&i=user@example.com&ik=email&h=hash-value ``` -------------------------------- ### Initialize Dittofeed SDK Source: https://docs.dittofeed.com/deployment/self-hosted/render Initialize the Dittofeed SDK with your write key and instance host URL. Replace '...' with your actual write key and the Render deployment URL. ```javascript DittofeedSdk.init({ writeKey: '...', host: 'https://PLACEHOLDER.onrender.com' }); ``` -------------------------------- ### GET /api/admin/analysis/summary Source: https://docs.dittofeed.com/api-reference/endpoints/apps/identify Get summarized metrics for the analysis dashboard. ```APIDOC ## GET /api/admin/analysis/summary ### Description Get summarized metrics for analysis dashboard. ### Method GET ### Endpoint /api/admin/analysis/summary ``` -------------------------------- ### GET /api/admin/analysis/journey-stats Source: https://docs.dittofeed.com/api-reference/endpoints/apps/identify Get journey editor statistics for a specific journey. ```APIDOC ## GET /api/admin/analysis/journey-stats ### Description Get journey editor statistics for a specific journey. ### Method GET ### Endpoint /api/admin/analysis/journey-stats ``` -------------------------------- ### Identify API Endpoint Example Source: https://docs.dittofeed.com/api-reference/endpoints/apps/identify This snippet shows an example of the request body for the identify endpoint. ```APIDOC ## POST /apps/identify ### Description Sends user identification data to the application. ### Method POST ### Endpoint /apps/identify ### Request Body - **userId** (string) - Required - The unique identifier for the user. - **anonymousId** (string) - Required - The unique identifier for the anonymous user. - **traits** (object) - Optional - A JSON object containing user traits. - **traitName** (string) - Description of the trait. ### Request Example ```json { "userId": "user123", "anonymousId": "anon456", "traits": { "email": "test@example.com", "name": "Test User" } } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Segment Entry Node Example - Welcome Email Source: https://docs.dittofeed.com/resources/journey-nodes/entry This example illustrates a welcome email journey triggered by a 'New Users' segment. The segment includes users whose 'createdAt' date is within the last 30 minutes. This journey aims to encourage profile completion and inform users about new features. ```javascript const _jsxs = require("react/jsx-runtime").jsxs; const _jsx = require("react/jsx-runtime").jsx; const Heading = require("../components/Heading").default; const Frame = require("../components/Frame").default; const OptimizedImage = require("../components/OptimizedImage").default; Example Use Case - Welcome email

For example, an entry node might be assigned a “New Users” segment as described here , which includes all users who have a createdAt date within the last 30 minutes. This journey might encourage users to finishing setting up their prorfile, and inform them about new features.

``` -------------------------------- ### Get Group Users Source: https://docs.dittofeed.com/api-reference/auto/groups/get-apiadmingroupsusers Retrieves a list of users belonging to a specified group. This is a GET request to the /api/admin/groups/users endpoint. ```APIDOC ## GET /api/admin/groups/users ### Description Get a list of users for a specific group. ### Method GET ### Endpoint /api/admin/groups/users ### Parameters #### Query Parameters - **group_id** (string) - Required - The ID of the group to retrieve users for. ### Response #### Success Response (200) - **users** (array) - A list of user objects. - **user_id** (string) - The ID of the user. - **email** (string) - The email address of the user. - **name** (string) - The name of the user. - **created_at** (string) - The timestamp when the user was created. - **updated_at** (string) - The timestamp when the user was last updated. ### Response Example { "users": [ { "user_id": "usr_abc123", "email": "user1@example.com", "name": "User One", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" }, { "user_id": "usr_def456", "email": "user2@example.com", "name": "User Two", "created_at": "2023-10-27T10:05:00Z", "updated_at": "2023-10-27T10:05:00Z" } ] } ``` -------------------------------- ### Install Helm Chart Source: https://docs.dittofeed.com/deployment/self-hosted/dittofeed-ee Deploy Dittofeed using the Helm chart with your custom values.yaml file. ```bash helm install dittofeed dittofeed/dittofeed --values values.yaml ``` -------------------------------- ### JavaScript Code Snippet Example Source: https://docs.dittofeed.com/integrations/sdks/web A JavaScript code snippet demonstrating a specific functionality. This is part of a larger example. ```javascript var _df = _df || []; _df.push(method); _df.push(method.concat(Array.prototype.slice.call(arguments))); }; ``` -------------------------------- ### Example Track Event Body Source: https://docs.dittofeed.com/api-reference/endpoints/apps/track This is an example of a track event body. It includes common fields for event tracking. ```json { "event": "User Signed Up", "properties": { "plan": "Free", "method": "Google" } } ``` -------------------------------- ### Navigate to Docs Directory Source: https://docs.dittofeed.com/llms-full.txt Change the current directory to the `packages/docs` folder to run local development commands for the documentation. ```bash cd packages/docs ``` -------------------------------- ### Install Web SDK using Yarn or NPM Source: https://docs.dittofeed.com/llms-full.txt Use either Yarn or NPM to add the Dittofeed Web SDK to your project dependencies. ```bash # Using Yarn yarn add @dittofeed/sdk-web # Using NPM npm install --save @dittofeed/sdk-web ``` -------------------------------- ### Broadcast Configuration Example Source: https://docs.dittofeed.com/embedded/getting-started This TypeScript example demonstrates how to configure the broadcast editor to customize available steps, providers, and UI elements. It's a comprehensive configuration object. ```typescript const broadcastConfiguration = { // Configuration for the broadcast editor // This object allows customization of various aspects of the broadcast creation process. // For example, you can specify which steps are available, which providers can be used, // and which UI elements are visible to the user. // // Example properties: // steps: ['content', 'schedule', 'audience', 'review'], // Define the order and availability of steps // providers: { // email: { enabled: true, options: { /* email provider specific options */ } }, // sms: { enabled: false }, // push: { enabled: true, options: { /* push notification options */ } } // }, // ui: { // showSaveAsDraft: true, // showPublishNow: true, // showSchedule: true, // showAudienceSelector: true, // showContentEditor: true, // showPreview: true // }, // // Other configuration options can be added here as needed. // // For a full list of options, please refer to the Dittofeed documentation. }; // To use this configuration, you would typically pass it to the Dittofeed embeddable component: // ``` -------------------------------- ### Install Dittofeed EE Helm Chart Source: https://docs.dittofeed.com/deployment/self-hosted/dittofeed-ee Command to install the Dittofeed EE Helm chart. This is the primary command for deploying the application. ```shellscript helm install dittofeed-ee ./charts/dittofeed-ee ``` -------------------------------- ### Dittofeed EE Configuration Example Source: https://docs.dittofeed.com/deployment/self-hosted/dittofeed-ee Example configuration for Dittofeed EE, specifying image details and environment variables. This is used to enable specific features and set up integrations. ```yaml ee: enabled: true image: repository: dittofeed/dittofeed-ee tag: v0.23.0-ee.1 env: - name: ONBOARDING_URL value: "/dashboard-l/onboarding" - name: SIGNOUT_URL value: ``` -------------------------------- ### Setup Test Environment and Fetch Messages Source: https://docs.dittofeed.com/guide/testing Sets up a test environment using Dittofeed.setupTestEnv() and fetches messages after a simulated delay. This is useful for testing asynchronous operations and verifying message content. ```typescript describe("When the bookmark button is clicked", () => { let df: DittofeedTestEnv; beforeEach(async () => { df = await Dittofeed.setupTestEnv(); ... }) it("Emails the clicking user", async () => { render() fireEvent.click(screen.getByText(/bookmark/i)) // Using simulated time. await df.sleep("1 week"); const messages = await df.fetchMessages(); expect(messages).toEqual([ expect.objectContaining({ to: "[email protected]", type: "Email", body: expect.stringContaining("https://app.com/user-1/bookmarks") ... }); ]); }); }); ``` -------------------------------- ### Custom Recipient Property Example Source: https://docs.dittofeed.com/guide/custom-recipient-properties Example of creating a custom user property, such as 'managerEmail' or 'workPhone', to store recipient contact information. ```javascript _jsx(_components.code, { children: "managerEmail" }) ``` ```javascript _jsx(_components.code, { children: "workPhone" }) ``` -------------------------------- ### Initialize the Dittofeed SDK Source: https://docs.dittofeed.com/integrations/sdks/web Initialize the SDK with your write key. This is typically done once when your application loads. ```javascript await DittofeedSdk.init({ writeKey: "Basic abcdefg...", }); ``` -------------------------------- ### Setup Test Environment in JavaScript Source: https://docs.dittofeed.com/guide/testing Use this snippet to set up the test environment before running tests. It ensures all necessary configurations are in place. ```javascript _jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#569CD6" }, children: "=>" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " {" }) }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#569CD6" }, children: " let" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: " df" }), _jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#D4D4D4" }, children: ":" }), _jsx(_components.span, { style: { color: "#953800", "--shiki-dark": "#4EC9B0" }, children: " DittofeedTestEnv" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: ";" })] }), "\n", _jsx(_components.span, { className: "line" }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#8250DF", "--shiki-dark": "#DCDCAA" }, children: "beforeEach" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "(" }), _jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#569CD6" }, children: "async" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " () " }), _jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#569CD6" }, children: "=>" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " {" }) }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: " df" }), _jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#D4D4D4" }, children: " =" }), _jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#C586C0" }, children: " await" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: " Dittofeed" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "." }), _jsx(_components.span, { style: { color: "#8250DF", "--shiki-dark": "#DCDCAA" }, children: "setupTestEnv" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "();" })] }), "\n", _jsx(_components.span, { className: "line" }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#569CD6" }, children: " const" }), _jsx(_components.span, { style: { color: "#0550AE", "--shiki-dark": "#4FC1FF" }, children: " segment" }), _jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#D4D4D4" }, children: " =" }), _jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#C586C0" }, children: " await" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: " df" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "." }), _jsx(_components.span, { style: { color: "#8250DF", "--shiki-dark": "#DCDCAA" }, children: "createSegment" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "({" })] }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: " name:" }), _jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " \"Users who have bookmarked\"" })] }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": ``` -------------------------------- ### Identify API Request Body Example Source: https://docs.dittofeed.com/api-reference/endpoints/apps/identify This is an example of the JSON body structure for an identify request, including userId, traits, and messageId. ```json { "userId": "532", "traits": { "email": "[email protected]" }, "messageId": "6f5f436d-8534-4070-8023-d18f8b78ed39" } ``` -------------------------------- ### Start admin-cli service in Docker Compose Source: https://docs.dittofeed.com/llms-full.txt Command to start the admin-cli service using Docker Compose, enabling the 'admin-cli' profile. ```bash docker compose --profile admin-cli -f docker-compose.lite.yaml up admin-cli -d ```