diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index abac03b8a8..1d7a005fe3 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -41237,6 +41237,114 @@ components: type: string x-enum-varnames: - PROCESS + ProductAnalyticsServerSideEventError: + description: Error details. + properties: + detail: + description: Error message. + example: Malformed payload + type: string + status: + description: Error code. + example: '400' + type: string + title: + description: Error title. + example: Bad Request + type: string + type: object + ProductAnalyticsServerSideEventErrors: + description: Error response. + properties: + errors: + description: Structured errors. + items: + $ref: '#/components/schemas/ProductAnalyticsServerSideEventError' + type: array + type: object + ProductAnalyticsServerSideEventItem: + description: A Product Analytics server-side event. + properties: + account: + $ref: '#/components/schemas/ProductAnalyticsServerSideEventItemAccount' + application: + $ref: '#/components/schemas/ProductAnalyticsServerSideEventItemApplication' + event: + $ref: '#/components/schemas/ProductAnalyticsServerSideEventItemEvent' + session: + $ref: '#/components/schemas/ProductAnalyticsServerSideEventItemSession' + type: + $ref: '#/components/schemas/ProductAnalyticsServerSideEventItemType' + usr: + $ref: '#/components/schemas/ProductAnalyticsServerSideEventItemUsr' + required: + - application + - event + - type + type: object + ProductAnalyticsServerSideEventItemAccount: + description: The account linked to your event. + properties: + id: + description: The account ID used in Datadog. + example: account-67890 + type: string + required: + - id + type: object + ProductAnalyticsServerSideEventItemApplication: + description: The application in which you want to send your events. + properties: + id: + description: 'The application ID of your application. It can be found in + your + + [application management page](https://app.datadoghq.com/rum/list).' + example: 123abcde-123a-123b-1234-123456789abc + type: string + required: + - id + type: object + ProductAnalyticsServerSideEventItemEvent: + description: Fields used for the event. + properties: + name: + description: The name of your event, which is used for search in the same + way as view or action names. + example: payment.processed + type: string + required: + - name + type: object + ProductAnalyticsServerSideEventItemSession: + description: The session linked to your event. + properties: + id: + description: The session ID captured by the SDK. + example: session-abcdef + type: string + required: + - id + type: object + ProductAnalyticsServerSideEventItemType: + description: The type of Product Analytics event. Must be `server` for server-side + events. + enum: + - server + example: server + type: string + x-enum-varnames: + - SERVER + ProductAnalyticsServerSideEventItemUsr: + description: The user linked to your event. + properties: + id: + description: The user ID used in Datadog. + example: user-12345 + type: string + required: + - id + type: object Project: description: A Project properties: @@ -78009,6 +78117,218 @@ paths: x-permission: operator: OPEN permissions: [] + /api/v2/prodlytics: + post: + description: 'Send server-side events to Product Analytics. Server-side events + are retained for 15 months. + + + Server-Side events in Product Analytics are helpful for tracking events that + occur on the server, + + as opposed to client-side events, which are captured by Real User Monitoring + (RUM) SDKs. + + This allows for a more comprehensive view of the user journey by including + actions that happen on the server. + + Typical examples could be `checkout.completed` or `payment.processed`. + + + Ingested server-side events are integrated into Product Analytics to allow + users to select and filter + + these events in the event picker, similar to how views or actions are handled. + + + **Requirements:** + + - At least one of `usr`, `account`, or `session` must be provided with a valid + ID. + + - The `application.id` must reference a Product Analytics-enabled application. + + + **Custom Attributes:** + + Any additional fields in the payload are flattened and searchable as facets. + + For example, a payload with `{"customer": {"tier": "premium"}}` is searchable + with + + the syntax `@customer.tier:premium` in Datadog. + + + The status codes answered by the HTTP API are: + + - 202: Accepted: The request has been accepted for processing + + - 400: Bad request (likely an issue in the payload formatting) + + - 401: Unauthorized (likely a missing API Key) + + - 403: Permission issue (likely using an invalid API Key) + + - 408: Request Timeout, request should be retried after some time + + - 413: Payload too large (batch is above 5MB uncompressed) + + - 429: Too Many Requests, request should be retried after some time + + - 500: Internal Server Error, the server encountered an unexpected condition + that prevented it from fulfilling the request, request should be retried after + some time + + - 503: Service Unavailable, the server is not ready to handle the request + probably because it is overloaded, request should be retried after some time' + operationId: SubmitProductAnalyticsEvent + requestBody: + content: + application/json: + examples: + event-with-account: + description: Send a server-side event linked to an account. + summary: Event with account ID + value: + account: + id: account-456 + application: + id: 123abcde-123a-123b-1234-123456789abc + event: + name: checkout.completed + type: server + event-with-custom-attributes: + description: Send a server-side event with additional custom attributes. + summary: Event with custom attributes + value: + application: + id: 123abcde-123a-123b-1234-123456789abc + customer: + tier: premium + event: + name: payment.processed + type: server + usr: + id: '123' + event-with-session: + description: Send a server-side event linked to a session. + summary: Event with session ID + value: + application: + id: 123abcde-123a-123b-1234-123456789abc + event: + name: form.submitted + session: + id: session-789 + type: server + simple-event-with-user: + description: Send a server-side event linked to a user. + summary: Simple event with user ID + value: + application: + id: 123abcde-123a-123b-1234-123456789abc + event: + name: payment.processed + type: server + usr: + id: '123' + schema: + $ref: '#/components/schemas/ProductAnalyticsServerSideEventItem' + description: Server-side event to send (JSON format). + required: true + responses: + '202': + content: + application/json: + schema: + type: object + description: Request accepted for processing (always 202 empty JSON). + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/ProductAnalyticsServerSideEventErrors' + description: Bad Request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/ProductAnalyticsServerSideEventErrors' + description: Unauthorized + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/ProductAnalyticsServerSideEventErrors' + description: Forbidden + '408': + content: + application/json: + schema: + $ref: '#/components/schemas/ProductAnalyticsServerSideEventErrors' + description: Request Timeout + '413': + content: + application/json: + schema: + $ref: '#/components/schemas/ProductAnalyticsServerSideEventErrors' + description: Payload Too Large + '429': + content: + application/json: + schema: + $ref: '#/components/schemas/ProductAnalyticsServerSideEventErrors' + description: Too Many Requests + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/ProductAnalyticsServerSideEventErrors' + description: Internal Server Error + '503': + content: + application/json: + schema: + $ref: '#/components/schemas/ProductAnalyticsServerSideEventErrors' + description: Service Unavailable + security: + - apiKeyAuth: [] + servers: + - url: https://{subdomain}.{site} + variables: + site: + default: datadoghq.com + description: The regional site for customers. + enum: + - datadoghq.com + - us3.datadoghq.com + - us5.datadoghq.com + - ap1.datadoghq.com + - ap2.datadoghq.com + - datadoghq.eu + subdomain: + default: browser-intake + description: The subdomain where the API is deployed. + - url: '{protocol}://{name}' + variables: + name: + default: browser-intake-datadoghq.com + description: Full site DNS name. + protocol: + default: https + description: The protocol for accessing the API. + - url: https://{subdomain}.{site} + variables: + site: + default: datadoghq.com + description: Any Datadog deployment. + subdomain: + default: browser-intake + description: The subdomain where the API is deployed. + summary: Send server-side events + tags: + - Product Analytics + x-codegen-request-body-name: body /api/v2/product-analytics/accounts/facet_info: post: description: Get facet information for account attributes including possible @@ -90205,6 +90525,18 @@ tags: See the [Live Processes page](https://docs.datadoghq.com/infrastructure/process/) for more information. name: Processes +- description: 'Send server-side events to Product Analytics. Server-Side Events Ingestion + allows you to collect custom events + + from any server-side source, and retains events for 15 months. Server-side events + are helpful for understanding + + causes of a funnel drop-off which are external to the client-side (for example, + payment processing error). + + See the [Product Analytics page](https://docs.datadoghq.com/product_analytics/) + for more information.' + name: Product Analytics - description: Manage your Real User Monitoring (RUM) applications, and search or aggregate your RUM events over HTTP. See the [RUM & Session Replay page](https://docs.datadoghq.com/real_user_monitoring/) for more information diff --git a/docs/datadog_api_client.v2.api.rst b/docs/datadog_api_client.v2.api.rst index 89ac91c28c..ef7c7e17c8 100644 --- a/docs/datadog_api_client.v2.api.rst +++ b/docs/datadog_api_client.v2.api.rst @@ -431,6 +431,13 @@ datadog\_api\_client.v2.api.processes\_api module :members: :show-inheritance: +datadog\_api\_client.v2.api.product\_analytics\_api module +---------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.api.product_analytics_api + :members: + :show-inheritance: + datadog\_api\_client.v2.api.reference\_tables\_api module --------------------------------------------------------- diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index 831f388abf..a0147235bd 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -18050,6 +18050,69 @@ datadog\_api\_client.v2.model.process\_summary\_type module :members: :show-inheritance: +datadog\_api\_client.v2.model.product\_analytics\_server\_side\_event\_error module +----------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.product_analytics_server_side_event_error + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.product\_analytics\_server\_side\_event\_errors module +------------------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.product_analytics_server_side_event_errors + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.product\_analytics\_server\_side\_event\_item module +---------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.product_analytics_server_side_event_item + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.product\_analytics\_server\_side\_event\_item\_account module +------------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.product_analytics_server_side_event_item_account + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.product\_analytics\_server\_side\_event\_item\_application module +----------------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.product_analytics_server_side_event_item_application + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.product\_analytics\_server\_side\_event\_item\_event module +----------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.product_analytics_server_side_event_item_event + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.product\_analytics\_server\_side\_event\_item\_session module +------------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.product_analytics_server_side_event_item_session + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.product\_analytics\_server\_side\_event\_item\_type module +---------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.product_analytics_server_side_event_item_type + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.product\_analytics\_server\_side\_event\_item\_usr module +--------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.product_analytics_server_side_event_item_usr + :members: + :show-inheritance: + datadog\_api\_client.v2.model.project module -------------------------------------------- diff --git a/examples/v2/product-analytics/SubmitProductAnalyticsEvent.py b/examples/v2/product-analytics/SubmitProductAnalyticsEvent.py new file mode 100644 index 0000000000..1e9c5e8f33 --- /dev/null +++ b/examples/v2/product-analytics/SubmitProductAnalyticsEvent.py @@ -0,0 +1,51 @@ +""" +Send server-side events returns "Request accepted for processing (always 202 empty JSON)." 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_server_side_event_item import ProductAnalyticsServerSideEventItem +from datadog_api_client.v2.model.product_analytics_server_side_event_item_account import ( + ProductAnalyticsServerSideEventItemAccount, +) +from datadog_api_client.v2.model.product_analytics_server_side_event_item_application import ( + ProductAnalyticsServerSideEventItemApplication, +) +from datadog_api_client.v2.model.product_analytics_server_side_event_item_event import ( + ProductAnalyticsServerSideEventItemEvent, +) +from datadog_api_client.v2.model.product_analytics_server_side_event_item_session import ( + ProductAnalyticsServerSideEventItemSession, +) +from datadog_api_client.v2.model.product_analytics_server_side_event_item_type import ( + ProductAnalyticsServerSideEventItemType, +) +from datadog_api_client.v2.model.product_analytics_server_side_event_item_usr import ( + ProductAnalyticsServerSideEventItemUsr, +) + +body = ProductAnalyticsServerSideEventItem( + account=ProductAnalyticsServerSideEventItemAccount( + id="account-67890", + ), + application=ProductAnalyticsServerSideEventItemApplication( + id="123abcde-123a-123b-1234-123456789abc", + ), + event=ProductAnalyticsServerSideEventItemEvent( + name="payment.processed", + ), + session=ProductAnalyticsServerSideEventItemSession( + id="session-abcdef", + ), + type=ProductAnalyticsServerSideEventItemType.SERVER, + usr=ProductAnalyticsServerSideEventItemUsr( + id="user-12345", + ), +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = ProductAnalyticsApi(api_client) + response = api_instance.submit_product_analytics_event(body=body) + + print(response) diff --git a/src/datadog_api_client/v2/api/product_analytics_api.py b/src/datadog_api_client/v2/api/product_analytics_api.py new file mode 100644 index 0000000000..4731973b92 --- /dev/null +++ b/src/datadog_api_client/v2/api/product_analytics_api.py @@ -0,0 +1,140 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Any, Dict + +from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint +from datadog_api_client.configuration import Configuration +from datadog_api_client.v2.model.product_analytics_server_side_event_item import ProductAnalyticsServerSideEventItem + + +class ProductAnalyticsApi: + """ + Send server-side events to Product Analytics. Server-Side Events Ingestion allows you to collect custom events + from any server-side source, and retains events for 15 months. Server-side events are helpful for understanding + causes of a funnel drop-off which are external to the client-side (for example, payment processing error). + See the `Product Analytics page `_ for more information. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient(Configuration()) + self.api_client = api_client + + self._submit_product_analytics_event_endpoint = _Endpoint( + settings={ + "response_type": (dict,), + "auth": ["apiKeyAuth"], + "endpoint_path": "/api/v2/prodlytics", + "operation_id": "submit_product_analytics_event", + "http_method": "POST", + "version": "v2", + "servers": [ + { + "url": "https://{subdomain}.{site}", + "variables": { + "site": { + "description": "The regional site for customers.", + "default_value": "datadoghq.com", + "enum_values": [ + "datadoghq.com", + "us3.datadoghq.com", + "us5.datadoghq.com", + "ap1.datadoghq.com", + "ap2.datadoghq.com", + "datadoghq.eu", + ], + }, + "subdomain": { + "description": "The subdomain where the API is deployed.", + "default_value": "browser-intake", + }, + }, + }, + { + "url": "{protocol}://{name}", + "variables": { + "name": { + "description": "Full site DNS name.", + "default_value": "browser-intake-datadoghq.com", + }, + "protocol": { + "description": "The protocol for accessing the API.", + "default_value": "https", + }, + }, + }, + { + "url": "https://{subdomain}.{site}", + "variables": { + "site": { + "description": "Any Datadog deployment.", + "default_value": "datadoghq.com", + }, + "subdomain": { + "description": "The subdomain where the API is deployed.", + "default_value": "browser-intake", + }, + }, + }, + ], + }, + params_map={ + "body": { + "required": True, + "openapi_types": (ProductAnalyticsServerSideEventItem,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + + def submit_product_analytics_event( + self, + body: ProductAnalyticsServerSideEventItem, + ) -> dict: + """Send server-side events. + + Send server-side events to Product Analytics. Server-side events are retained for 15 months. + + Server-Side events in Product Analytics are helpful for tracking events that occur on the server, + as opposed to client-side events, which are captured by Real User Monitoring (RUM) SDKs. + This allows for a more comprehensive view of the user journey by including actions that happen on the server. + Typical examples could be ``checkout.completed`` or ``payment.processed``. + + Ingested server-side events are integrated into Product Analytics to allow users to select and filter + these events in the event picker, similar to how views or actions are handled. + + **Requirements:** + + * At least one of ``usr`` , ``account`` , or ``session`` must be provided with a valid ID. + * The ``application.id`` must reference a Product Analytics-enabled application. + + **Custom Attributes:** + Any additional fields in the payload are flattened and searchable as facets. + For example, a payload with ``{"customer": {"tier": "premium"}}`` is searchable with + the syntax ``@customer.tier:premium`` in Datadog. + + The status codes answered by the HTTP API are: + + * 202: Accepted: The request has been accepted for processing + * 400: Bad request (likely an issue in the payload formatting) + * 401: Unauthorized (likely a missing API Key) + * 403: Permission issue (likely using an invalid API Key) + * 408: Request Timeout, request should be retried after some time + * 413: Payload too large (batch is above 5MB uncompressed) + * 429: Too Many Requests, request should be retried after some time + * 500: Internal Server Error, the server encountered an unexpected condition that prevented it from fulfilling the request, request should be retried after some time + * 503: Service Unavailable, the server is not ready to handle the request probably because it is overloaded, request should be retried after some time + + :param body: Server-side event to send (JSON format). + :type body: ProductAnalyticsServerSideEventItem + :rtype: dict + """ + kwargs: Dict[str, Any] = {} + kwargs["body"] = body + + return self._submit_product_analytics_event_endpoint.call_with_http_info(**kwargs) diff --git a/src/datadog_api_client/v2/apis/__init__.py b/src/datadog_api_client/v2/apis/__init__.py index 45c303f79e..35ab810c4a 100644 --- a/src/datadog_api_client/v2/apis/__init__.py +++ b/src/datadog_api_client/v2/apis/__init__.py @@ -59,6 +59,7 @@ from datadog_api_client.v2.api.organizations_api import OrganizationsApi from datadog_api_client.v2.api.powerpack_api import PowerpackApi from datadog_api_client.v2.api.processes_api import ProcessesApi +from datadog_api_client.v2.api.product_analytics_api import ProductAnalyticsApi from datadog_api_client.v2.api.rum_api import RUMApi from datadog_api_client.v2.api.reference_tables_api import ReferenceTablesApi from datadog_api_client.v2.api.restriction_policies_api import RestrictionPoliciesApi @@ -147,6 +148,7 @@ "OrganizationsApi", "PowerpackApi", "ProcessesApi", + "ProductAnalyticsApi", "RUMApi", "ReferenceTablesApi", "RestrictionPoliciesApi", diff --git a/src/datadog_api_client/v2/model/product_analytics_server_side_event_error.py b/src/datadog_api_client/v2/model/product_analytics_server_side_event_error.py new file mode 100644 index 0000000000..536050f2bc --- /dev/null +++ b/src/datadog_api_client/v2/model/product_analytics_server_side_event_error.py @@ -0,0 +1,56 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class ProductAnalyticsServerSideEventError(ModelNormal): + @cached_property + def openapi_types(_): + return { + "detail": (str,), + "status": (str,), + "title": (str,), + } + + attribute_map = { + "detail": "detail", + "status": "status", + "title": "title", + } + + def __init__( + self_, + detail: Union[str, UnsetType] = unset, + status: Union[str, UnsetType] = unset, + title: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + Error details. + + :param detail: Error message. + :type detail: str, optional + + :param status: Error code. + :type status: str, optional + + :param title: Error title. + :type title: str, optional + """ + if detail is not unset: + kwargs["detail"] = detail + if status is not unset: + kwargs["status"] = status + if title is not unset: + kwargs["title"] = title + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/product_analytics_server_side_event_errors.py b/src/datadog_api_client/v2/model/product_analytics_server_side_event_errors.py new file mode 100644 index 0000000000..6ebc94ebee --- /dev/null +++ b/src/datadog_api_client/v2/model/product_analytics_server_side_event_errors.py @@ -0,0 +1,46 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.product_analytics_server_side_event_error import ( + ProductAnalyticsServerSideEventError, + ) + + +class ProductAnalyticsServerSideEventErrors(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.product_analytics_server_side_event_error import ( + ProductAnalyticsServerSideEventError, + ) + + return { + "errors": ([ProductAnalyticsServerSideEventError],), + } + + attribute_map = { + "errors": "errors", + } + + def __init__(self_, errors: Union[List[ProductAnalyticsServerSideEventError], UnsetType] = unset, **kwargs): + """ + Error response. + + :param errors: Structured errors. + :type errors: [ProductAnalyticsServerSideEventError], optional + """ + if errors is not unset: + kwargs["errors"] = errors + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/product_analytics_server_side_event_item.py b/src/datadog_api_client/v2/model/product_analytics_server_side_event_item.py new file mode 100644 index 0000000000..be1bac46e1 --- /dev/null +++ b/src/datadog_api_client/v2/model/product_analytics_server_side_event_item.py @@ -0,0 +1,118 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.product_analytics_server_side_event_item_account import ( + ProductAnalyticsServerSideEventItemAccount, + ) + from datadog_api_client.v2.model.product_analytics_server_side_event_item_application import ( + ProductAnalyticsServerSideEventItemApplication, + ) + from datadog_api_client.v2.model.product_analytics_server_side_event_item_event import ( + ProductAnalyticsServerSideEventItemEvent, + ) + from datadog_api_client.v2.model.product_analytics_server_side_event_item_session import ( + ProductAnalyticsServerSideEventItemSession, + ) + from datadog_api_client.v2.model.product_analytics_server_side_event_item_type import ( + ProductAnalyticsServerSideEventItemType, + ) + from datadog_api_client.v2.model.product_analytics_server_side_event_item_usr import ( + ProductAnalyticsServerSideEventItemUsr, + ) + + +class ProductAnalyticsServerSideEventItem(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.product_analytics_server_side_event_item_account import ( + ProductAnalyticsServerSideEventItemAccount, + ) + from datadog_api_client.v2.model.product_analytics_server_side_event_item_application import ( + ProductAnalyticsServerSideEventItemApplication, + ) + from datadog_api_client.v2.model.product_analytics_server_side_event_item_event import ( + ProductAnalyticsServerSideEventItemEvent, + ) + from datadog_api_client.v2.model.product_analytics_server_side_event_item_session import ( + ProductAnalyticsServerSideEventItemSession, + ) + from datadog_api_client.v2.model.product_analytics_server_side_event_item_type import ( + ProductAnalyticsServerSideEventItemType, + ) + from datadog_api_client.v2.model.product_analytics_server_side_event_item_usr import ( + ProductAnalyticsServerSideEventItemUsr, + ) + + return { + "account": (ProductAnalyticsServerSideEventItemAccount,), + "application": (ProductAnalyticsServerSideEventItemApplication,), + "event": (ProductAnalyticsServerSideEventItemEvent,), + "session": (ProductAnalyticsServerSideEventItemSession,), + "type": (ProductAnalyticsServerSideEventItemType,), + "usr": (ProductAnalyticsServerSideEventItemUsr,), + } + + attribute_map = { + "account": "account", + "application": "application", + "event": "event", + "session": "session", + "type": "type", + "usr": "usr", + } + + def __init__( + self_, + application: ProductAnalyticsServerSideEventItemApplication, + event: ProductAnalyticsServerSideEventItemEvent, + type: ProductAnalyticsServerSideEventItemType, + account: Union[ProductAnalyticsServerSideEventItemAccount, UnsetType] = unset, + session: Union[ProductAnalyticsServerSideEventItemSession, UnsetType] = unset, + usr: Union[ProductAnalyticsServerSideEventItemUsr, UnsetType] = unset, + **kwargs, + ): + """ + A Product Analytics server-side event. + + :param account: The account linked to your event. + :type account: ProductAnalyticsServerSideEventItemAccount, optional + + :param application: The application in which you want to send your events. + :type application: ProductAnalyticsServerSideEventItemApplication + + :param event: Fields used for the event. + :type event: ProductAnalyticsServerSideEventItemEvent + + :param session: The session linked to your event. + :type session: ProductAnalyticsServerSideEventItemSession, optional + + :param type: The type of Product Analytics event. Must be ``server`` for server-side events. + :type type: ProductAnalyticsServerSideEventItemType + + :param usr: The user linked to your event. + :type usr: ProductAnalyticsServerSideEventItemUsr, optional + """ + if account is not unset: + kwargs["account"] = account + if session is not unset: + kwargs["session"] = session + if usr is not unset: + kwargs["usr"] = usr + super().__init__(kwargs) + + self_.application = application + self_.event = event + self_.type = type diff --git a/src/datadog_api_client/v2/model/product_analytics_server_side_event_item_account.py b/src/datadog_api_client/v2/model/product_analytics_server_side_event_item_account.py new file mode 100644 index 0000000000..ad14647ae0 --- /dev/null +++ b/src/datadog_api_client/v2/model/product_analytics_server_side_event_item_account.py @@ -0,0 +1,33 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class ProductAnalyticsServerSideEventItemAccount(ModelNormal): + @cached_property + def openapi_types(_): + return { + "id": (str,), + } + + attribute_map = { + "id": "id", + } + + def __init__(self_, id: str, **kwargs): + """ + The account linked to your event. + + :param id: The account ID used in Datadog. + :type id: str + """ + super().__init__(kwargs) + + self_.id = id diff --git a/src/datadog_api_client/v2/model/product_analytics_server_side_event_item_application.py b/src/datadog_api_client/v2/model/product_analytics_server_side_event_item_application.py new file mode 100644 index 0000000000..07b747f973 --- /dev/null +++ b/src/datadog_api_client/v2/model/product_analytics_server_side_event_item_application.py @@ -0,0 +1,34 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class ProductAnalyticsServerSideEventItemApplication(ModelNormal): + @cached_property + def openapi_types(_): + return { + "id": (str,), + } + + attribute_map = { + "id": "id", + } + + def __init__(self_, id: str, **kwargs): + """ + The application in which you want to send your events. + + :param id: The application ID of your application. It can be found in your + `application management page `_. + :type id: str + """ + super().__init__(kwargs) + + self_.id = id diff --git a/src/datadog_api_client/v2/model/product_analytics_server_side_event_item_event.py b/src/datadog_api_client/v2/model/product_analytics_server_side_event_item_event.py new file mode 100644 index 0000000000..96f35f574e --- /dev/null +++ b/src/datadog_api_client/v2/model/product_analytics_server_side_event_item_event.py @@ -0,0 +1,33 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class ProductAnalyticsServerSideEventItemEvent(ModelNormal): + @cached_property + def openapi_types(_): + return { + "name": (str,), + } + + attribute_map = { + "name": "name", + } + + def __init__(self_, name: str, **kwargs): + """ + Fields used for the event. + + :param name: The name of your event, which is used for search in the same way as view or action names. + :type name: str + """ + super().__init__(kwargs) + + self_.name = name diff --git a/src/datadog_api_client/v2/model/product_analytics_server_side_event_item_session.py b/src/datadog_api_client/v2/model/product_analytics_server_side_event_item_session.py new file mode 100644 index 0000000000..b9c146b17a --- /dev/null +++ b/src/datadog_api_client/v2/model/product_analytics_server_side_event_item_session.py @@ -0,0 +1,33 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class ProductAnalyticsServerSideEventItemSession(ModelNormal): + @cached_property + def openapi_types(_): + return { + "id": (str,), + } + + attribute_map = { + "id": "id", + } + + def __init__(self_, id: str, **kwargs): + """ + The session linked to your event. + + :param id: The session ID captured by the SDK. + :type id: str + """ + super().__init__(kwargs) + + self_.id = id diff --git a/src/datadog_api_client/v2/model/product_analytics_server_side_event_item_type.py b/src/datadog_api_client/v2/model/product_analytics_server_side_event_item_type.py new file mode 100644 index 0000000000..0a01db01f9 --- /dev/null +++ b/src/datadog_api_client/v2/model/product_analytics_server_side_event_item_type.py @@ -0,0 +1,35 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class ProductAnalyticsServerSideEventItemType(ModelSimple): + """ + The type of Product Analytics event. Must be `server` for server-side events. + + :param value: If omitted defaults to "server". Must be one of ["server"]. + :type value: str + """ + + allowed_values = { + "server", + } + SERVER: ClassVar["ProductAnalyticsServerSideEventItemType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +ProductAnalyticsServerSideEventItemType.SERVER = ProductAnalyticsServerSideEventItemType("server") diff --git a/src/datadog_api_client/v2/model/product_analytics_server_side_event_item_usr.py b/src/datadog_api_client/v2/model/product_analytics_server_side_event_item_usr.py new file mode 100644 index 0000000000..0b4c41202b --- /dev/null +++ b/src/datadog_api_client/v2/model/product_analytics_server_side_event_item_usr.py @@ -0,0 +1,33 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class ProductAnalyticsServerSideEventItemUsr(ModelNormal): + @cached_property + def openapi_types(_): + return { + "id": (str,), + } + + attribute_map = { + "id": "id", + } + + def __init__(self_, id: str, **kwargs): + """ + The user linked to your event. + + :param id: The user ID used in Datadog. + :type id: str + """ + super().__init__(kwargs) + + self_.id = id diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 56c30e6ed7..35866835bc 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -3650,6 +3650,27 @@ from datadog_api_client.v2.model.process_summary import ProcessSummary from datadog_api_client.v2.model.process_summary_attributes import ProcessSummaryAttributes from datadog_api_client.v2.model.process_summary_type import ProcessSummaryType +from datadog_api_client.v2.model.product_analytics_server_side_event_error import ProductAnalyticsServerSideEventError +from datadog_api_client.v2.model.product_analytics_server_side_event_errors import ProductAnalyticsServerSideEventErrors +from datadog_api_client.v2.model.product_analytics_server_side_event_item import ProductAnalyticsServerSideEventItem +from datadog_api_client.v2.model.product_analytics_server_side_event_item_account import ( + ProductAnalyticsServerSideEventItemAccount, +) +from datadog_api_client.v2.model.product_analytics_server_side_event_item_application import ( + ProductAnalyticsServerSideEventItemApplication, +) +from datadog_api_client.v2.model.product_analytics_server_side_event_item_event import ( + ProductAnalyticsServerSideEventItemEvent, +) +from datadog_api_client.v2.model.product_analytics_server_side_event_item_session import ( + ProductAnalyticsServerSideEventItemSession, +) +from datadog_api_client.v2.model.product_analytics_server_side_event_item_type import ( + ProductAnalyticsServerSideEventItemType, +) +from datadog_api_client.v2.model.product_analytics_server_side_event_item_usr import ( + ProductAnalyticsServerSideEventItemUsr, +) from datadog_api_client.v2.model.project import Project from datadog_api_client.v2.model.project_attributes import ProjectAttributes from datadog_api_client.v2.model.project_create import ProjectCreate @@ -7755,6 +7776,15 @@ "ProcessSummary", "ProcessSummaryAttributes", "ProcessSummaryType", + "ProductAnalyticsServerSideEventError", + "ProductAnalyticsServerSideEventErrors", + "ProductAnalyticsServerSideEventItem", + "ProductAnalyticsServerSideEventItemAccount", + "ProductAnalyticsServerSideEventItemApplication", + "ProductAnalyticsServerSideEventItemEvent", + "ProductAnalyticsServerSideEventItemSession", + "ProductAnalyticsServerSideEventItemType", + "ProductAnalyticsServerSideEventItemUsr", "Project", "ProjectAttributes", "ProjectCreate", diff --git a/tests/v2/features/product_analytics.feature b/tests/v2/features/product_analytics.feature new file mode 100644 index 0000000000..a915c21304 --- /dev/null +++ b/tests/v2/features/product_analytics.feature @@ -0,0 +1,35 @@ +@endpoint(product-analytics) @endpoint(product-analytics-v2) +Feature: Product Analytics + Send server-side events to Product Analytics. Server-Side Events Ingestion + allows you to collect custom events from any server-side source, and + retains events for 15 months. Server-side events are helpful for + understanding causes of a funnel drop-off which are external to the + client-side (for example, payment processing error). See the [Product + Analytics page](https://docs.datadoghq.com/product_analytics/) for more + information. + + Background: + Given a valid "apiKeyAuth" key in the system + And an instance of "ProductAnalytics" API + And new "SubmitProductAnalyticsEvent" request + And body with value {"account": {"id": "account-67890"}, "application": {"id": "123abcde-123a-123b-1234-123456789abc"}, "event": {"name": "payment.processed"}, "session": {"id": "session-abcdef"}, "type": "server", "usr": {"id": "user-12345"}} + + @generated @skip @team:DataDog/product-analytics-backend + Scenario: Send server-side events returns "Bad Request" response + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/product-analytics-backend + Scenario: Send server-side events returns "Payload Too Large" response + When the request is sent + Then the response status is 413 Payload Too Large + + @generated @skip @team:DataDog/product-analytics-backend + Scenario: Send server-side events returns "Request Timeout" response + When the request is sent + Then the response status is 408 Request Timeout + + @generated @skip @team:DataDog/product-analytics-backend + Scenario: Send server-side events returns "Request accepted for processing (always 202 empty JSON)." response + When the request is sent + Then the response status is 202 Request accepted for processing (always 202 empty JSON). diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index eb43f26dbe..0867c10cd7 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -3133,6 +3133,12 @@ "type": "safe" } }, + "SubmitProductAnalyticsEvent": { + "tag": "Product Analytics", + "undo": { + "type": "safe" + } + }, "GetAccountFacetInfo": { "tag": "Rum Audience Management", "undo": {