DEM 여정 변형 생성

POST https://api.ap1.datadoghq.com/api/v2/dem/journeys/{journey_id}/variantshttps://api.ap2.datadoghq.com/api/v2/dem/journeys/{journey_id}/variantshttps://api.datadoghq.eu/api/v2/dem/journeys/{journey_id}/variantshttps://api.ddog-gov.com/api/v2/dem/journeys/{journey_id}/variantshttps://api.us2.ddog-gov.com/api/v2/dem/journeys/{journey_id}/variantshttps://api.uk1.datadoghq.com/api/v2/dem/journeys/{journey_id}/variantshttps://api.datadoghq.com/api/v2/dem/journeys/{journey_id}/variantshttps://api.us3.datadoghq.com/api/v2/dem/journeys/{journey_id}/variantshttps://api.us5.datadoghq.com/api/v2/dem/journeys/{journey_id}/variants

개요

DEM 여정에 대한 변형을 생성합니다. This endpoint requires the synthetics_write permission.

인수

경로 파라미터

이름

유형

설명

journey_id [required]

string

The unique identifier of the journey that owns the variant.

요청

Body Data (required)

Expand All

항목

유형

설명

data [required]

object

Data object for a DEM journey variant request.

attributes [required]

object

Attributes of a DEM journey variant.

filter

string

An optional RUM query filter to scope this variant.

name [required]

string

The name of the variant.

rum_steps [required]

[object]

List of RUM journey steps.

nodes [required]

[object]

List of RUM nodes within a journey step.

app_id

string

The application ID associated with this node.

id

string

The ID of the RUM node element.

query [required]

string

The RUM query for matching this node.

type [required]

enum

The type of a RUM journey step. Allowed enum values: start,stop,step

type [required]

enum

The type identifier for DEM journey variants. Allowed enum values: variants

{
  "data": {
    "attributes": {
      "filter": "device.type:mobile",
      "name": "Mobile checkout",
      "rum_steps": [
        {
          "nodes": [
            {
              "app_id": "app-xyz789",
              "id": "element-id-123",
              "query": "action.name:'checkout'"
            }
          ],
          "type": "start"
        }
      ]
    },
    "type": "variants"
  }
}

응답

OK

Response containing a DEM journey variant.

Expand All

항목

유형

설명

data [required]

object

Data object returned for a DEM journey variant.

attributes [required]

object

Attributes of a DEM journey variant.

filter

string

An optional RUM query filter to scope this variant.

name [required]

string

The name of the variant.

rum_steps [required]

[object]

List of RUM journey steps.

nodes [required]

[object]

List of RUM nodes within a journey step.

app_id

string

The application ID associated with this node.

id

string

The ID of the RUM node element.

query [required]

string

The RUM query for matching this node.

type [required]

enum

The type of a RUM journey step. Allowed enum values: start,stop,step

id [required]

string

The unique identifier of the variant.

type [required]

enum

The type identifier for DEM journey variants. Allowed enum values: variants

{
  "data": {
    "attributes": {
      "filter": "device.type:mobile",
      "name": "Mobile checkout",
      "rum_steps": [
        {
          "nodes": [
            {
              "app_id": "app-xyz789",
              "id": "element-id-123",
              "query": "action.name:'checkout'"
            }
          ],
          "type": "start"
        }
      ]
    },
    "id": "variant-001",
    "type": "variants"
  }
}

Bad Request

API error response.

Expand All

항목

유형

설명

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short human-readable summary of the error.

{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}

Not Found

API error response.

Expand All

항목

유형

설명

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short human-readable summary of the error.

{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}

Too many requests

API error response.

Expand All

항목

유형

설명

errors [required]

[string]

A list of errors.

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

코드 예시

                  ## default
# 

# Path parameters
export journey_id="journey-abc123"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

# 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/dem/journeys/${journey_id}/variants" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${DD_BEARER_TOKEN}" \ -d @- << EOF { "data": { "attributes": { "filter": "device.type:mobile", "name": "Mobile checkout", "rum_steps": [ { "nodes": [ { "query": "action.name:'checkout'" } ], "type": "start" }, { "nodes": [ { "query": "action.name:'confirmation'" } ], "type": "stop" } ] }, "type": "variants" } } EOF
"""
Create a DEM journey variant returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.dem_api import DEMApi
from datadog_api_client.v2.model.dem_rum_node import DemRumNode
from datadog_api_client.v2.model.dem_rum_step import DemRumStep
from datadog_api_client.v2.model.dem_rum_step_type import DemRumStepType
from datadog_api_client.v2.model.dem_variant_attributes import DemVariantAttributes
from datadog_api_client.v2.model.dem_variant_request import DemVariantRequest
from datadog_api_client.v2.model.dem_variant_request_data import DemVariantRequestData
from datadog_api_client.v2.model.dem_variant_type import DemVariantType

body = DemVariantRequest(
    data=DemVariantRequestData(
        attributes=DemVariantAttributes(
            filter="device.type:mobile",
            name="Mobile checkout",
            rum_steps=[
                DemRumStep(
                    nodes=[
                        DemRumNode(
                            query="action.name:'checkout'",
                        ),
                    ],
                    type=DemRumStepType.START,
                ),
                DemRumStep(
                    nodes=[
                        DemRumNode(
                            query="action.name:'confirmation'",
                        ),
                    ],
                    type=DemRumStepType.STOP,
                ),
            ],
        ),
        type=DemVariantType.VARIANTS,
    ),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
    api_instance = DEMApi(api_client)
    response = api_instance.create_journey_variant(journey_id="journey_id", 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_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"
# Create a DEM journey variant returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::DEMAPI.new

body = DatadogAPIClient::V2::DemVariantRequest.new({
  data: DatadogAPIClient::V2::DemVariantRequestData.new({
    attributes: DatadogAPIClient::V2::DemVariantAttributes.new({
      filter: "device.type:mobile",
      name: "Mobile checkout",
      rum_steps: [
        DatadogAPIClient::V2::DemRumStep.new({
          nodes: [
            DatadogAPIClient::V2::DemRumNode.new({
              query: "action.name:'checkout'",
            }),
          ],
          type: DatadogAPIClient::V2::DemRumStepType::START,
        }),
        DatadogAPIClient::V2::DemRumStep.new({
          nodes: [
            DatadogAPIClient::V2::DemRumNode.new({
              query: "action.name:'confirmation'",
            }),
          ],
          type: DatadogAPIClient::V2::DemRumStepType::STOP,
        }),
      ],
    }),
    type: DatadogAPIClient::V2::DemVariantType::VARIANTS,
  }),
})
p api_instance.create_journey_variant("journey_id", 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_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"
// Create a DEM journey variant 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"
)

func main() {
	body := datadogV2.DemVariantRequest{
		Data: datadogV2.DemVariantRequestData{
			Attributes: datadogV2.DemVariantAttributes{
				Filter: datadog.PtrString("device.type:mobile"),
				Name:   "Mobile checkout",
				RumSteps: []datadogV2.DemRumStep{
					{
						Nodes: []datadogV2.DemRumNode{
							{
								Query: "action.name:'checkout'",
							},
						},
						Type: datadogV2.DEMRUMSTEPTYPE_START,
					},
					{
						Nodes: []datadogV2.DemRumNode{
							{
								Query: "action.name:'confirmation'",
							},
						},
						Type: datadogV2.DEMRUMSTEPTYPE_STOP,
					},
				},
			},
			Type: datadogV2.DEMVARIANTTYPE_VARIANTS,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewDEMApi(apiClient)
	resp, r, err := api.CreateJourneyVariant(ctx, "journey_id", body)

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `DEMApi.CreateJourneyVariant`:\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_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"
// Create a DEM journey variant returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.DemApi;
import com.datadog.api.client.v2.model.DemRumNode;
import com.datadog.api.client.v2.model.DemRumStep;
import com.datadog.api.client.v2.model.DemRumStepType;
import com.datadog.api.client.v2.model.DemVariantAttributes;
import com.datadog.api.client.v2.model.DemVariantRequest;
import com.datadog.api.client.v2.model.DemVariantRequestData;
import com.datadog.api.client.v2.model.DemVariantResponse;
import com.datadog.api.client.v2.model.DemVariantType;
import java.util.Arrays;
import java.util.Collections;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
    DemApi apiInstance = new DemApi(defaultClient);

    DemVariantRequest body =
        new DemVariantRequest()
            .data(
                new DemVariantRequestData()
                    .attributes(
                        new DemVariantAttributes()
                            .filter("device.type:mobile")
                            .name("Mobile checkout")
                            .rumSteps(
                                Arrays.asList(
                                    new DemRumStep()
                                        .nodes(
                                            Collections.singletonList(
                                                new DemRumNode().query("action.name:'checkout'")))
                                        .type(DemRumStepType.START),
                                    new DemRumStep()
                                        .nodes(
                                            Collections.singletonList(
                                                new DemRumNode()
                                                    .query("action.name:'confirmation'")))
                                        .type(DemRumStepType.STOP))))
                    .type(DemVariantType.VARIANTS));

    try {
      DemVariantResponse result = apiInstance.createJourneyVariant("journey-abc123", body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DemApi#createJourneyVariant");
      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_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"
// Create a DEM journey variant returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_dem::DEMAPI;
use datadog_api_client::datadogV2::model::DemRumNode;
use datadog_api_client::datadogV2::model::DemRumStep;
use datadog_api_client::datadogV2::model::DemRumStepType;
use datadog_api_client::datadogV2::model::DemVariantAttributes;
use datadog_api_client::datadogV2::model::DemVariantRequest;
use datadog_api_client::datadogV2::model::DemVariantRequestData;
use datadog_api_client::datadogV2::model::DemVariantType;

#[tokio::main]
async fn main() {
    let body = DemVariantRequest::new(DemVariantRequestData::new(
        DemVariantAttributes::new(
            "Mobile checkout".to_string(),
            vec![
                DemRumStep::new(
                    vec![DemRumNode::new("action.name:'checkout'".to_string())],
                    DemRumStepType::START,
                ),
                DemRumStep::new(
                    vec![DemRumNode::new("action.name:'confirmation'".to_string())],
                    DemRumStepType::STOP,
                ),
            ],
        )
        .filter("device.type:mobile".to_string()),
        DemVariantType::VARIANTS,
    ));
    let configuration = datadog::Configuration::new();
    let api = DEMAPI::with_config(configuration);
    let resp = api
        .create_journey_variant("journey_id".to_string(), 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
/**
 * Create a DEM journey variant returns "OK" response
 */

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

const configuration = client.createConfiguration({
  authMethods: {
    AuthZ: {
      accessToken: process.env.DD_BEARER_TOKEN as string,
    },
  },
});
const apiInstance = new v2.DEMApi(configuration);

const params: v2.DEMApiCreateJourneyVariantRequest = {
  body: {
    data: {
      attributes: {
        filter: "device.type:mobile",
        name: "Mobile checkout",
        rumSteps: [
          {
            nodes: [
              {
                query: "action.name:'checkout'",
              },
            ],
            type: "start",
          },
          {
            nodes: [
              {
                query: "action.name:'confirmation'",
              },
            ],
            type: "stop",
          },
        ],
      },
      type: "variants",
    },
  },
  journeyId: "journey_id",
};

apiInstance
  .createJourneyVariant(params)
  .then((data: v2.DemVariantResponse) => {
    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_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"