Compute a Sankey diagram

Note: This endpoint is in preview and is subject to change. If you have any feedback, contact Datadog support.

POST https://api.ap1.datadoghq.com/api/v2/product-analytics/sankeyhttps://api.ap2.datadoghq.com/api/v2/product-analytics/sankeyhttps://api.datadoghq.eu/api/v2/product-analytics/sankeyhttps://api.ddog-gov.com/api/v2/product-analytics/sankeyhttps://api.us2.ddog-gov.com/api/v2/product-analytics/sankeyhttps://api.uk1.datadoghq.com/api/v2/product-analytics/sankeyhttps://api.datadoghq.com/api/v2/product-analytics/sankeyhttps://api.us3.datadoghq.com/api/v2/product-analytics/sankeyhttps://api.us5.datadoghq.com/api/v2/product-analytics/sankey

Overview

Compute a Sankey diagram of how sessions flow between the values of two facets, showing where users continue and where they drop off at each step. This endpoint requires the rum_apps_read permission.

Request

Body Data (required)

The Sankey diagram query.

Expand All

Field

Type

Description

data [required]

object

The single JSON:API resource carrying a Sankey query. Its attributes hold the time window to query, the search that selects the sessions, and the definition of the diagram to build.

attributes [required]

object

Attributes of a Sankey request.

definition [required]

object

The shape of the Sankey diagram, expressed as the facets to flow between and how many steps to show.

entries_per_step

int64

Maximum number of nodes to keep in each column. Remaining values are rolled up into an aggregated node. Omit it, or send 0, to use the default of 5.

number_of_steps

int64

Number of intermediate columns between the source and the target. Omit it, or send 0, to use the default of 5.

source [required]

string

Facet forming the first column of the diagram.

target [required]

string

Facet forming the last column of the diagram.

search [required]

object

Selects the sessions a Sankey diagram is built from.

audience_filters

object

Audience filter definitions for targeting specific user segments.

accounts

[object]

Account audience queries.

name [required]

string

Name of this query, referenced in the formula.

query

string

Search query for filtering accounts.

formula

string

Boolean formula combining audience queries by name.

segments

[object]

Segment audience queries.

name [required]

string

Name of this query, referenced in the formula.

segment_id [required]

uuid

UUID of the segment to filter by.

users

[object]

User audience queries.

name [required]

string

Name of this query, referenced in the formula.

query

string

Search query for filtering users.

join_keys

object

Identity join keys used to stitch events belonging to the same user or session.

primary

string

Primary identity join key. Defaults to @session.id.

secondary

[string]

Additional identity join keys.

query

string

Datadog search query restricting the events considered.

time [required]

object

The time window a Sankey query covers.

from [required]

int64

Start of the query window, in epoch milliseconds.

to [required]

int64

End of the query window, in epoch milliseconds.

type [required]

enum

The resource type identifier for a Sankey request. Allowed enum values: sankey_request

{
  "data": {
    "attributes": {
      "definition": {
        "entries_per_step": 10,
        "number_of_steps": 3,
        "source": "@view.name",
        "target": "@view.name"
      },
      "search": {
        "audience_filters": {
          "accounts": [
            {
              "name": "",
              "query": "string"
            }
          ],
          "formula": "u",
          "segments": [
            {
              "name": "",
              "segment_id": "00000000-0000-0000-0000-000000000000"
            }
          ],
          "users": [
            {
              "name": "u",
              "query": "*"
            }
          ]
        },
        "join_keys": {
          "primary": "@session.id",
          "secondary": []
        },
        "query": "@type:view"
      },
      "time": {
        "from": 1756425600000,
        "to": 1756857600000
      }
    },
    "type": "sankey_request"
  }
}

Response

OK

Response for a Sankey diagram query.

Expand All

Field

Type

Description

data [required]

object

The single JSON:API resource holding a computed Sankey diagram. Its attributes contain the nodes of every column and the links that carry sessions between them.

attributes [required]

object

Attributes of a Sankey response, containing the nodes and the links between them.

links

[object]

The links of the diagram, one per pair of connected nodes.

column

int64

Zero-based index of the column the link starts from.

id

string

Unique identifier for the link.

source

string

Identifier of the node the link starts at.

target

string

Identifier of the node the link ends at.

value

int64

Number of sessions flowing along the link.

nodes

[object]

The nodes of the diagram, one per facet value and column.

aggregated_nodes

[object]

The nodes rolled up into this one, when the node is an aggregate.

id

string

Unique identifier for the node.

incoming_value

int64

Number of sessions entering the node.

name

string

The facet value the node represents.

outgoing_value

int64

Number of sessions leaving the node.

type

enum

The resource type identifier for a node rolled up into an aggregated node. Allowed enum values: aggregated

value

int64

Number of sessions passing through the node.

column

int64

Zero-based index of the column the node sits in.

dropoff_value

int64

Number of sessions that ended at the node.

id

string

Unique identifier for the node.

incoming_value

int64

Number of sessions entering the node.

name

string

The facet value the node represents.

outgoing_value

int64

Number of sessions leaving the node.

type

enum

The kind of node. regular is a single facet value, other rolls up the values that did not fit within entries_per_step, and dropoff collects the sessions that ended at this column. Allowed enum values: regular,other,dropoff

value

int64

Number of sessions passing through the node.

id [required]

string

Unique identifier for this response data object.

type [required]

enum

The resource type identifier for a Sankey response. Allowed enum values: sankey_response

{
  "data": {
    "attributes": {
      "links": [
        {
          "column": "integer",
          "id": "string",
          "source": "string",
          "target": "string",
          "value": "integer"
        }
      ],
      "nodes": [
        {
          "aggregated_nodes": [
            {
              "id": "string",
              "incoming_value": "integer",
              "name": "string",
              "outgoing_value": "integer",
              "type": "string",
              "value": "integer"
            }
          ],
          "column": "integer",
          "dropoff_value": "integer",
          "id": "string",
          "incoming_value": "integer",
          "name": "string",
          "outgoing_value": "integer",
          "type": "string",
          "value": "integer"
        }
      ]
    },
    "id": "00000000-0000-0000-0000-000000000000",
    "type": "sankey_response"
  }
}

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Not Authorized

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example

                  ## default
# 

# Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.uk1.datadoghq.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/product-analytics/sankey" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "data": { "attributes": { "definition": { "entries_per_step": 10, "number_of_steps": 3, "source": "@view.name", "target": "@view.name" }, "search": { "query": "@type:view" }, "time": { "from": 1756425600000, "to": 1756857600000 } }, "type": "sankey_request" } } EOF
"""
Compute a Sankey diagram returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.product_analytics_api import ProductAnalyticsApi
from datadog_api_client.v2.model.product_analytics_audience_account_subquery import (
    ProductAnalyticsAudienceAccountSubquery,
)
from datadog_api_client.v2.model.product_analytics_audience_filters import ProductAnalyticsAudienceFilters
from datadog_api_client.v2.model.product_analytics_audience_segment_subquery import (
    ProductAnalyticsAudienceSegmentSubquery,
)
from datadog_api_client.v2.model.product_analytics_audience_user_subquery import ProductAnalyticsAudienceUserSubquery
from datadog_api_client.v2.model.product_analytics_join_keys import ProductAnalyticsJoinKeys
from datadog_api_client.v2.model.product_analytics_sankey_definition import ProductAnalyticsSankeyDefinition
from datadog_api_client.v2.model.product_analytics_sankey_request import ProductAnalyticsSankeyRequest
from datadog_api_client.v2.model.product_analytics_sankey_request_attributes import (
    ProductAnalyticsSankeyRequestAttributes,
)
from datadog_api_client.v2.model.product_analytics_sankey_request_data import ProductAnalyticsSankeyRequestData
from datadog_api_client.v2.model.product_analytics_sankey_request_type import ProductAnalyticsSankeyRequestType
from datadog_api_client.v2.model.product_analytics_sankey_search import ProductAnalyticsSankeySearch
from datadog_api_client.v2.model.product_analytics_sankey_time import ProductAnalyticsSankeyTime
from uuid import UUID

body = ProductAnalyticsSankeyRequest(
    data=ProductAnalyticsSankeyRequestData(
        attributes=ProductAnalyticsSankeyRequestAttributes(
            definition=ProductAnalyticsSankeyDefinition(
                entries_per_step=10,
                number_of_steps=3,
                source="@view.name",
                target="@view.name",
            ),
            search=ProductAnalyticsSankeySearch(
                audience_filters=ProductAnalyticsAudienceFilters(
                    accounts=[
                        ProductAnalyticsAudienceAccountSubquery(
                            name="",
                        ),
                    ],
                    formula="u",
                    segments=[
                        ProductAnalyticsAudienceSegmentSubquery(
                            name="",
                            segment_id=UUID("00000000-0000-0000-0000-000000000000"),
                        ),
                    ],
                    users=[
                        ProductAnalyticsAudienceUserSubquery(
                            name="u",
                            query="*",
                        ),
                    ],
                ),
                join_keys=ProductAnalyticsJoinKeys(
                    primary="@session.id",
                    secondary=[],
                ),
                query="@type:view",
            ),
            time=ProductAnalyticsSankeyTime(
                _from=1756425600000,
                to=1756857600000,
            ),
        ),
        type=ProductAnalyticsSankeyRequestType.SANKEY_REQUEST,
    ),
)

configuration = Configuration()
configuration.unstable_operations["query_product_analytics_sankey"] = True
with ApiClient(configuration) as api_client:
    api_instance = ProductAnalyticsApi(api_client)
    response = api_instance.query_product_analytics_sankey(body=body)

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
# Compute a Sankey diagram returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.unstable_operations["v2.query_product_analytics_sankey".to_sym] = true
end
api_instance = DatadogAPIClient::V2::ProductAnalyticsAPI.new

body = DatadogAPIClient::V2::ProductAnalyticsSankeyRequest.new({
  data: DatadogAPIClient::V2::ProductAnalyticsSankeyRequestData.new({
    attributes: DatadogAPIClient::V2::ProductAnalyticsSankeyRequestAttributes.new({
      definition: DatadogAPIClient::V2::ProductAnalyticsSankeyDefinition.new({
        entries_per_step: 10,
        number_of_steps: 3,
        source: "@view.name",
        target: "@view.name",
      }),
      search: DatadogAPIClient::V2::ProductAnalyticsSankeySearch.new({
        audience_filters: DatadogAPIClient::V2::ProductAnalyticsAudienceFilters.new({
          accounts: [
            DatadogAPIClient::V2::ProductAnalyticsAudienceAccountSubquery.new({
              name: "",
            }),
          ],
          formula: "u",
          segments: [
            DatadogAPIClient::V2::ProductAnalyticsAudienceSegmentSubquery.new({
              name: "",
              segment_id: "00000000-0000-0000-0000-000000000000",
            }),
          ],
          users: [
            DatadogAPIClient::V2::ProductAnalyticsAudienceUserSubquery.new({
              name: "u",
              query: "*",
            }),
          ],
        }),
        join_keys: DatadogAPIClient::V2::ProductAnalyticsJoinKeys.new({
          primary: "@session.id",
          secondary: [],
        }),
        query: "@type:view",
      }),
      time: DatadogAPIClient::V2::ProductAnalyticsSankeyTime.new({
        from: 1756425600000,
        to: 1756857600000,
      }),
    }),
    type: DatadogAPIClient::V2::ProductAnalyticsSankeyRequestType::SANKEY_REQUEST,
  }),
})
p api_instance.query_product_analytics_sankey(body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
// Compute a Sankey diagram returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
	"github.com/google/uuid"
)

func main() {
	body := datadogV2.ProductAnalyticsSankeyRequest{
		Data: datadogV2.ProductAnalyticsSankeyRequestData{
			Attributes: datadogV2.ProductAnalyticsSankeyRequestAttributes{
				Definition: datadogV2.ProductAnalyticsSankeyDefinition{
					EntriesPerStep: datadog.PtrInt64(10),
					NumberOfSteps:  datadog.PtrInt64(3),
					Source:         "@view.name",
					Target:         "@view.name",
				},
				Search: datadogV2.ProductAnalyticsSankeySearch{
					AudienceFilters: &datadogV2.ProductAnalyticsAudienceFilters{
						Accounts: []datadogV2.ProductAnalyticsAudienceAccountSubquery{
							{
								Name: "",
							},
						},
						Formula: datadog.PtrString("u"),
						Segments: []datadogV2.ProductAnalyticsAudienceSegmentSubquery{
							{
								Name:      "",
								SegmentId: uuid.MustParse("00000000-0000-0000-0000-000000000000"),
							},
						},
						Users: []datadogV2.ProductAnalyticsAudienceUserSubquery{
							{
								Name:  "u",
								Query: datadog.PtrString("*"),
							},
						},
					},
					JoinKeys: &datadogV2.ProductAnalyticsJoinKeys{
						Primary:   datadog.PtrString("@session.id"),
						Secondary: []string{},
					},
					Query: datadog.PtrString("@type:view"),
				},
				Time: datadogV2.ProductAnalyticsSankeyTime{
					From: 1756425600000,
					To:   1756857600000,
				},
			},
			Type: datadogV2.PRODUCTANALYTICSSANKEYREQUESTTYPE_SANKEY_REQUEST,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.QueryProductAnalyticsSankey", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewProductAnalyticsApi(apiClient)
	resp, r, err := api.QueryProductAnalyticsSankey(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `ProductAnalyticsApi.QueryProductAnalyticsSankey`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `ProductAnalyticsApi.QueryProductAnalyticsSankey`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Compute a Sankey diagram returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.ProductAnalyticsApi;
import com.datadog.api.client.v2.model.ProductAnalyticsAudienceAccountSubquery;
import com.datadog.api.client.v2.model.ProductAnalyticsAudienceFilters;
import com.datadog.api.client.v2.model.ProductAnalyticsAudienceSegmentSubquery;
import com.datadog.api.client.v2.model.ProductAnalyticsAudienceUserSubquery;
import com.datadog.api.client.v2.model.ProductAnalyticsJoinKeys;
import com.datadog.api.client.v2.model.ProductAnalyticsSankeyDefinition;
import com.datadog.api.client.v2.model.ProductAnalyticsSankeyRequest;
import com.datadog.api.client.v2.model.ProductAnalyticsSankeyRequestAttributes;
import com.datadog.api.client.v2.model.ProductAnalyticsSankeyRequestData;
import com.datadog.api.client.v2.model.ProductAnalyticsSankeyRequestType;
import com.datadog.api.client.v2.model.ProductAnalyticsSankeyResponse;
import com.datadog.api.client.v2.model.ProductAnalyticsSankeySearch;
import com.datadog.api.client.v2.model.ProductAnalyticsSankeyTime;
import java.util.Collections;
import java.util.UUID;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setUnstableOperationEnabled("v2.queryProductAnalyticsSankey", true);
    ProductAnalyticsApi apiInstance = new ProductAnalyticsApi(defaultClient);

    ProductAnalyticsSankeyRequest body =
        new ProductAnalyticsSankeyRequest()
            .data(
                new ProductAnalyticsSankeyRequestData()
                    .attributes(
                        new ProductAnalyticsSankeyRequestAttributes()
                            .definition(
                                new ProductAnalyticsSankeyDefinition()
                                    .entriesPerStep(10L)
                                    .numberOfSteps(3L)
                                    .source("@view.name")
                                    .target("@view.name"))
                            .search(
                                new ProductAnalyticsSankeySearch()
                                    .audienceFilters(
                                        new ProductAnalyticsAudienceFilters()
                                            .accounts(
                                                Collections.singletonList(
                                                    new ProductAnalyticsAudienceAccountSubquery()
                                                        .name("")))
                                            .formula("u")
                                            .segments(
                                                Collections.singletonList(
                                                    new ProductAnalyticsAudienceSegmentSubquery()
                                                        .name("")
                                                        .segmentId(
                                                            UUID.fromString(
                                                                "00000000-0000-0000-0000-000000000000"))))
                                            .users(
                                                Collections.singletonList(
                                                    new ProductAnalyticsAudienceUserSubquery()
                                                        .name("u")
                                                        .query("*"))))
                                    .joinKeys(new ProductAnalyticsJoinKeys().primary("@session.id"))
                                    .query("@type:view"))
                            .time(
                                new ProductAnalyticsSankeyTime()
                                    .from(1756425600000L)
                                    .to(1756857600000L)))
                    .type(ProductAnalyticsSankeyRequestType.SANKEY_REQUEST));

    try {
      ProductAnalyticsSankeyResponse result = apiInstance.queryProductAnalyticsSankey(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling ProductAnalyticsApi#queryProductAnalyticsSankey");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
// Compute a Sankey diagram returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_product_analytics::ProductAnalyticsAPI;
use datadog_api_client::datadogV2::model::ProductAnalyticsAudienceAccountSubquery;
use datadog_api_client::datadogV2::model::ProductAnalyticsAudienceFilters;
use datadog_api_client::datadogV2::model::ProductAnalyticsAudienceSegmentSubquery;
use datadog_api_client::datadogV2::model::ProductAnalyticsAudienceUserSubquery;
use datadog_api_client::datadogV2::model::ProductAnalyticsJoinKeys;
use datadog_api_client::datadogV2::model::ProductAnalyticsSankeyDefinition;
use datadog_api_client::datadogV2::model::ProductAnalyticsSankeyRequest;
use datadog_api_client::datadogV2::model::ProductAnalyticsSankeyRequestAttributes;
use datadog_api_client::datadogV2::model::ProductAnalyticsSankeyRequestData;
use datadog_api_client::datadogV2::model::ProductAnalyticsSankeyRequestType;
use datadog_api_client::datadogV2::model::ProductAnalyticsSankeySearch;
use datadog_api_client::datadogV2::model::ProductAnalyticsSankeyTime;
use uuid::Uuid;

#[tokio::main]
async fn main() {
    let body = ProductAnalyticsSankeyRequest::new(ProductAnalyticsSankeyRequestData::new(
        ProductAnalyticsSankeyRequestAttributes::new(
            ProductAnalyticsSankeyDefinition::new(
                "@view.name".to_string(),
                "@view.name".to_string(),
            )
            .entries_per_step(10)
            .number_of_steps(3),
            ProductAnalyticsSankeySearch::new()
                .audience_filters(
                    ProductAnalyticsAudienceFilters::new()
                        .accounts(vec![ProductAnalyticsAudienceAccountSubquery::new(
                            "".to_string(),
                        )])
                        .formula("u".to_string())
                        .segments(vec![ProductAnalyticsAudienceSegmentSubquery::new(
                            "".to_string(),
                            Uuid::parse_str("00000000-0000-0000-0000-000000000000")
                                .expect("invalid UUID"),
                        )])
                        .users(vec![ProductAnalyticsAudienceUserSubquery::new(
                            "u".to_string(),
                        )
                        .query("*".to_string())]),
                )
                .join_keys(
                    ProductAnalyticsJoinKeys::new()
                        .primary("@session.id".to_string())
                        .secondary(vec![]),
                )
                .query("@type:view".to_string()),
            ProductAnalyticsSankeyTime::new(1756425600000, 1756857600000),
        ),
        ProductAnalyticsSankeyRequestType::SANKEY_REQUEST,
    ));
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.QueryProductAnalyticsSankey", true);
    let api = ProductAnalyticsAPI::with_config(configuration);
    let resp = api.query_product_analytics_sankey(body).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}

Instructions

First install the library and its dependencies and then save the example to src/main.rs and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
/**
 * Compute a Sankey diagram returns "OK" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
configuration.unstableOperations["v2.queryProductAnalyticsSankey"] = true;
const apiInstance = new v2.ProductAnalyticsApi(configuration);

const params: v2.ProductAnalyticsApiQueryProductAnalyticsSankeyRequest = {
  body: {
    data: {
      attributes: {
        definition: {
          entriesPerStep: 10,
          numberOfSteps: 3,
          source: "@view.name",
          target: "@view.name",
        },
        search: {
          audienceFilters: {
            accounts: [
              {
                name: "",
              },
            ],
            formula: "u",
            segments: [
              {
                name: "",
                segmentId: "00000000-0000-0000-0000-000000000000",
              },
            ],
            users: [
              {
                name: "u",
                query: "*",
              },
            ],
          },
          joinKeys: {
            primary: "@session.id",
            secondary: [],
          },
          query: "@type:view",
        },
        time: {
          from: 1756425600000,
          to: 1756857600000,
        },
      },
      type: "sankey_request",
    },
  },
};

apiInstance
  .queryProductAnalyticsSankey(params)
  .then((data: v2.ProductAnalyticsSankeyResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"