Skip to content

Commit bf4c613

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
feat(product-analytics): add analytics scalar and timeseries endpoints (#3535)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 75d55a3 commit bf4c613

File tree

46 files changed

+3084
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3084
-2
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 562 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Compute scalar analytics returns "OK" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v2.ProductAnalyticsApi(configuration);
9+
10+
const params: v2.ProductAnalyticsApiQueryProductAnalyticsScalarRequest = {
11+
body: {
12+
data: {
13+
attributes: {
14+
from: 1771232048460,
15+
query: {
16+
compute: {
17+
aggregation: "count",
18+
},
19+
query: {
20+
dataSource: "product_analytics",
21+
search: {
22+
query: "@type:view",
23+
},
24+
},
25+
},
26+
to: 1771836848262,
27+
},
28+
type: "formula_analytics_extended_request",
29+
},
30+
},
31+
};
32+
33+
apiInstance
34+
.queryProductAnalyticsScalar(params)
35+
.then((data: v2.ProductAnalyticsScalarResponse) => {
36+
console.log(
37+
"API called successfully. Returned data: " + JSON.stringify(data)
38+
);
39+
})
40+
.catch((error: any) => console.error(error));
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Compute timeseries analytics returns "OK" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v2.ProductAnalyticsApi(configuration);
9+
10+
const params: v2.ProductAnalyticsApiQueryProductAnalyticsTimeseriesRequest = {
11+
body: {
12+
data: {
13+
attributes: {
14+
from: 1771232048460,
15+
query: {
16+
compute: {
17+
aggregation: "count",
18+
},
19+
query: {
20+
dataSource: "product_analytics",
21+
search: {
22+
query: "@type:view",
23+
},
24+
},
25+
},
26+
to: 1771836848262,
27+
},
28+
type: "formula_analytics_extended_request",
29+
},
30+
},
31+
};
32+
33+
apiInstance
34+
.queryProductAnalyticsTimeseries(params)
35+
.then((data: v2.ProductAnalyticsTimeseriesResponse) => {
36+
console.log(
37+
"API called successfully. Returned data: " + JSON.stringify(data)
38+
);
39+
})
40+
.catch((error: any) => console.error(error));

features/support/scenarios_model_mapping.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8787,6 +8787,20 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
87878787
},
87888788
"operationResponseType": "any",
87898789
},
8790+
"v2.QueryProductAnalyticsScalar": {
8791+
"body": {
8792+
"type": "ProductAnalyticsAnalyticsRequest",
8793+
"format": "",
8794+
},
8795+
"operationResponseType": "ProductAnalyticsScalarResponse",
8796+
},
8797+
"v2.QueryProductAnalyticsTimeseries": {
8798+
"body": {
8799+
"type": "ProductAnalyticsAnalyticsRequest",
8800+
"format": "",
8801+
},
8802+
"operationResponseType": "ProductAnalyticsTimeseriesResponse",
8803+
},
87908804
"v2.GetAccountFacetInfo": {
87918805
"body": {
87928806
"type": "FacetInfoRequest",

features/v2/product_analytics.feature

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,63 @@ Feature: Product Analytics
1111
Background:
1212
Given a valid "apiKeyAuth" key in the system
1313
And an instance of "ProductAnalytics" API
14-
And new "SubmitProductAnalyticsEvent" request
15-
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"}}
14+
15+
@generated @skip @team:DataDog/product-analytics-backend
16+
Scenario: Compute scalar analytics returns "Bad Request" response
17+
Given a valid "appKeyAuth" key in the system
18+
And new "QueryProductAnalyticsScalar" request
19+
And body with value {"data": {"attributes": {"from": 1771232048460, "query": {"compute": {"aggregation": "count"}, "query": {"data_source": "product_analytics", "search": {"query": "@type:view"}}}, "to": 1771836848262}, "type": "formula_analytics_extended_request"}}
20+
When the request is sent
21+
Then the response status is 400 Bad Request
22+
23+
@generated @skip @team:DataDog/product-analytics-backend
24+
Scenario: Compute scalar analytics returns "OK" response
25+
Given a valid "appKeyAuth" key in the system
26+
And new "QueryProductAnalyticsScalar" request
27+
And body with value {"data": {"attributes": {"from": 1771232048460, "query": {"compute": {"aggregation": "count"}, "query": {"data_source": "product_analytics", "search": {"query": "@type:view"}}}, "to": 1771836848262}, "type": "formula_analytics_extended_request"}}
28+
When the request is sent
29+
Then the response status is 200 OK
30+
31+
@generated @skip @team:DataDog/product-analytics-backend
32+
Scenario: Compute timeseries analytics returns "Bad Request" response
33+
Given a valid "appKeyAuth" key in the system
34+
And new "QueryProductAnalyticsTimeseries" request
35+
And body with value {"data": {"attributes": {"from": 1771232048460, "query": {"compute": {"aggregation": "count"}, "query": {"data_source": "product_analytics", "search": {"query": "@type:view"}}}, "to": 1771836848262}, "type": "formula_analytics_extended_request"}}
36+
When the request is sent
37+
Then the response status is 400 Bad Request
38+
39+
@generated @skip @team:DataDog/product-analytics-backend
40+
Scenario: Compute timeseries analytics returns "OK" response
41+
Given a valid "appKeyAuth" key in the system
42+
And new "QueryProductAnalyticsTimeseries" request
43+
And body with value {"data": {"attributes": {"from": 1771232048460, "query": {"compute": {"aggregation": "count"}, "query": {"data_source": "product_analytics", "search": {"query": "@type:view"}}}, "to": 1771836848262}, "type": "formula_analytics_extended_request"}}
44+
When the request is sent
45+
Then the response status is 200 OK
1646

1747
@generated @skip @team:DataDog/product-analytics-backend
1848
Scenario: Send server-side events returns "Bad Request" response
49+
Given new "SubmitProductAnalyticsEvent" request
50+
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"}}
1951
When the request is sent
2052
Then the response status is 400 Bad Request
2153

2254
@generated @skip @team:DataDog/product-analytics-backend
2355
Scenario: Send server-side events returns "Payload Too Large" response
56+
Given new "SubmitProductAnalyticsEvent" request
57+
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"}}
2458
When the request is sent
2559
Then the response status is 413 Payload Too Large
2660

2761
@generated @skip @team:DataDog/product-analytics-backend
2862
Scenario: Send server-side events returns "Request Timeout" response
63+
Given new "SubmitProductAnalyticsEvent" request
64+
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"}}
2965
When the request is sent
3066
Then the response status is 408 Request Timeout
3167

3268
@generated @skip @team:DataDog/product-analytics-backend
3369
Scenario: Send server-side events returns "Request accepted for processing (always 202 empty JSON)." response
70+
Given new "SubmitProductAnalyticsEvent" request
71+
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"}}
3472
When the request is sent
3573
Then the response status is 202 Request accepted for processing (always 202 empty JSON).

features/v2/undo.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3719,6 +3719,18 @@
37193719
"type": "unsafe"
37203720
}
37213721
},
3722+
"QueryProductAnalyticsScalar": {
3723+
"tag": "Product Analytics",
3724+
"undo": {
3725+
"type": "safe"
3726+
}
3727+
},
3728+
"QueryProductAnalyticsTimeseries": {
3729+
"tag": "Product Analytics",
3730+
"undo": {
3731+
"type": "safe"
3732+
}
3733+
},
37223734
"QueryEventFilteredUsers": {
37233735
"tag": "Rum Audience Management",
37243736
"undo": {

0 commit comments

Comments
 (0)