Skip to content

Commit 02eb0e2

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

45 files changed

Lines changed: 4930 additions & 2 deletions

File tree

Some content is hidden

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

.generator/schemas/v2/openapi.yaml

Lines changed: 562 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Compute scalar analytics returns "OK" response
2+
3+
require "datadog_api_client"
4+
api_instance = DatadogAPIClient::V2::ProductAnalyticsAPI.new
5+
6+
body = DatadogAPIClient::V2::ProductAnalyticsAnalyticsRequest.new({
7+
data: DatadogAPIClient::V2::ProductAnalyticsAnalyticsRequestData.new({
8+
attributes: DatadogAPIClient::V2::ProductAnalyticsAnalyticsRequestAttributes.new({
9+
from: 1771232048460,
10+
query: DatadogAPIClient::V2::ProductAnalyticsAnalyticsQuery.new({
11+
compute: DatadogAPIClient::V2::ProductAnalyticsCompute.new({
12+
aggregation: "count",
13+
}),
14+
query: DatadogAPIClient::V2::ProductAnalyticsEventQuery.new({
15+
data_source: DatadogAPIClient::V2::ProductAnalyticsEventQueryDataSource::PRODUCT_ANALYTICS,
16+
search: DatadogAPIClient::V2::ProductAnalyticsEventSearch.new({
17+
query: "@type:view",
18+
}),
19+
}),
20+
}),
21+
to: 1771836848262,
22+
}),
23+
type: DatadogAPIClient::V2::ProductAnalyticsAnalyticsRequestType::FORMULA_ANALYTICS_EXTENDED_REQUEST,
24+
}),
25+
})
26+
p api_instance.query_product_analytics_scalar(body)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Compute timeseries analytics returns "OK" response
2+
3+
require "datadog_api_client"
4+
api_instance = DatadogAPIClient::V2::ProductAnalyticsAPI.new
5+
6+
body = DatadogAPIClient::V2::ProductAnalyticsAnalyticsRequest.new({
7+
data: DatadogAPIClient::V2::ProductAnalyticsAnalyticsRequestData.new({
8+
attributes: DatadogAPIClient::V2::ProductAnalyticsAnalyticsRequestAttributes.new({
9+
from: 1771232048460,
10+
query: DatadogAPIClient::V2::ProductAnalyticsAnalyticsQuery.new({
11+
compute: DatadogAPIClient::V2::ProductAnalyticsCompute.new({
12+
aggregation: "count",
13+
}),
14+
query: DatadogAPIClient::V2::ProductAnalyticsEventQuery.new({
15+
data_source: DatadogAPIClient::V2::ProductAnalyticsEventQueryDataSource::PRODUCT_ANALYTICS,
16+
search: DatadogAPIClient::V2::ProductAnalyticsEventSearch.new({
17+
query: "@type:view",
18+
}),
19+
}),
20+
}),
21+
to: 1771836848262,
22+
}),
23+
type: DatadogAPIClient::V2::ProductAnalyticsAnalyticsRequestType::FORMULA_ANALYTICS_EXTENDED_REQUEST,
24+
}),
25+
})
26+
p api_instance.query_product_analytics_timeseries(body)

features/scenarios_model_mapping.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3114,6 +3114,12 @@
31143114
"v2.SubmitProductAnalyticsEvent" => {
31153115
"body" => "ProductAnalyticsServerSideEventItem",
31163116
},
3117+
"v2.QueryProductAnalyticsScalar" => {
3118+
"body" => "ProductAnalyticsAnalyticsRequest",
3119+
},
3120+
"v2.QueryProductAnalyticsTimeseries" => {
3121+
"body" => "ProductAnalyticsAnalyticsRequest",
3122+
},
31173123
"v2.GetAccountFacetInfo" => {
31183124
"body" => "FacetInfoRequest",
31193125
},

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": {

lib/datadog_api_client/inflector.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3940,6 +3940,38 @@ def overrides
39403940
"v2.process_summary" => "ProcessSummary",
39413941
"v2.process_summary_attributes" => "ProcessSummaryAttributes",
39423942
"v2.process_summary_type" => "ProcessSummaryType",
3943+
"v2.product_analytics_analytics_query" => "ProductAnalyticsAnalyticsQuery",
3944+
"v2.product_analytics_analytics_request" => "ProductAnalyticsAnalyticsRequest",
3945+
"v2.product_analytics_analytics_request_attributes" => "ProductAnalyticsAnalyticsRequestAttributes",
3946+
"v2.product_analytics_analytics_request_data" => "ProductAnalyticsAnalyticsRequestData",
3947+
"v2.product_analytics_analytics_request_type" => "ProductAnalyticsAnalyticsRequestType",
3948+
"v2.product_analytics_audience_account_subquery" => "ProductAnalyticsAudienceAccountSubquery",
3949+
"v2.product_analytics_audience_filters" => "ProductAnalyticsAudienceFilters",
3950+
"v2.product_analytics_audience_segment_subquery" => "ProductAnalyticsAudienceSegmentSubquery",
3951+
"v2.product_analytics_audience_user_subquery" => "ProductAnalyticsAudienceUserSubquery",
3952+
"v2.product_analytics_base_query" => "ProductAnalyticsBaseQuery",
3953+
"v2.product_analytics_compute" => "ProductAnalyticsCompute",
3954+
"v2.product_analytics_event_query" => "ProductAnalyticsEventQuery",
3955+
"v2.product_analytics_event_query_data_source" => "ProductAnalyticsEventQueryDataSource",
3956+
"v2.product_analytics_event_search" => "ProductAnalyticsEventSearch",
3957+
"v2.product_analytics_execution_type" => "ProductAnalyticsExecutionType",
3958+
"v2.product_analytics_group_by" => "ProductAnalyticsGroupBy",
3959+
"v2.product_analytics_group_by_sort" => "ProductAnalyticsGroupBySort",
3960+
"v2.product_analytics_interval" => "ProductAnalyticsInterval",
3961+
"v2.product_analytics_occurrence_filter" => "ProductAnalyticsOccurrenceFilter",
3962+
"v2.product_analytics_occurrence_query" => "ProductAnalyticsOccurrenceQuery",
3963+
"v2.product_analytics_occurrence_query_data_source" => "ProductAnalyticsOccurrenceQueryDataSource",
3964+
"v2.product_analytics_occurrence_search" => "ProductAnalyticsOccurrenceSearch",
3965+
"v2.product_analytics_response_meta" => "ProductAnalyticsResponseMeta",
3966+
"v2.product_analytics_response_meta_status" => "ProductAnalyticsResponseMetaStatus",
3967+
"v2.product_analytics_scalar_column" => "ProductAnalyticsScalarColumn",
3968+
"v2.product_analytics_scalar_column_meta" => "ProductAnalyticsScalarColumnMeta",
3969+
"v2.product_analytics_scalar_column_type" => "ProductAnalyticsScalarColumnType",
3970+
"v2.product_analytics_scalar_response" => "ProductAnalyticsScalarResponse",
3971+
"v2.product_analytics_scalar_response_attributes" => "ProductAnalyticsScalarResponseAttributes",
3972+
"v2.product_analytics_scalar_response_data" => "ProductAnalyticsScalarResponseData",
3973+
"v2.product_analytics_scalar_response_type" => "ProductAnalyticsScalarResponseType",
3974+
"v2.product_analytics_serie" => "ProductAnalyticsSerie",
39433975
"v2.product_analytics_server_side_event_error" => "ProductAnalyticsServerSideEventError",
39443976
"v2.product_analytics_server_side_event_errors" => "ProductAnalyticsServerSideEventErrors",
39453977
"v2.product_analytics_server_side_event_item" => "ProductAnalyticsServerSideEventItem",
@@ -3949,6 +3981,11 @@ def overrides
39493981
"v2.product_analytics_server_side_event_item_session" => "ProductAnalyticsServerSideEventItemSession",
39503982
"v2.product_analytics_server_side_event_item_type" => "ProductAnalyticsServerSideEventItemType",
39513983
"v2.product_analytics_server_side_event_item_usr" => "ProductAnalyticsServerSideEventItemUsr",
3984+
"v2.product_analytics_timeseries_response" => "ProductAnalyticsTimeseriesResponse",
3985+
"v2.product_analytics_timeseries_response_attributes" => "ProductAnalyticsTimeseriesResponseAttributes",
3986+
"v2.product_analytics_timeseries_response_data" => "ProductAnalyticsTimeseriesResponseData",
3987+
"v2.product_analytics_timeseries_response_type" => "ProductAnalyticsTimeseriesResponseType",
3988+
"v2.product_analytics_unit" => "ProductAnalyticsUnit",
39523989
"v2.project" => "Project",
39533990
"v2.project_attributes" => "ProjectAttributes",
39543991
"v2.project_columns_config" => "ProjectColumnsConfig",

lib/datadog_api_client/v2/api/product_analytics_api.rb

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,143 @@ def initialize(api_client = DatadogAPIClient::APIClient.default)
2323
@api_client = api_client
2424
end
2525

26+
# Compute scalar analytics.
27+
#
28+
# @see #query_product_analytics_scalar_with_http_info
29+
def query_product_analytics_scalar(body, opts = {})
30+
data, _status_code, _headers = query_product_analytics_scalar_with_http_info(body, opts)
31+
data
32+
end
33+
34+
# Compute scalar analytics.
35+
#
36+
# Compute scalar analytics results for Product Analytics data.
37+
# Returns aggregated values (counts, averages, percentiles) optionally grouped by facets.
38+
#
39+
# @param body [ProductAnalyticsAnalyticsRequest]
40+
# @param opts [Hash] the optional parameters
41+
# @return [Array<(ProductAnalyticsScalarResponse, Integer, Hash)>] ProductAnalyticsScalarResponse data, response status code and response headers
42+
def query_product_analytics_scalar_with_http_info(body, opts = {})
43+
44+
if @api_client.config.debugging
45+
@api_client.config.logger.debug 'Calling API: ProductAnalyticsAPI.query_product_analytics_scalar ...'
46+
end
47+
# verify the required parameter 'body' is set
48+
if @api_client.config.client_side_validation && body.nil?
49+
fail ArgumentError, "Missing the required parameter 'body' when calling ProductAnalyticsAPI.query_product_analytics_scalar"
50+
end
51+
# resource path
52+
local_var_path = '/api/v2/product-analytics/analytics/scalar'
53+
54+
# query parameters
55+
query_params = opts[:query_params] || {}
56+
57+
# header parameters
58+
header_params = opts[:header_params] || {}
59+
# HTTP header 'Accept' (if needed)
60+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
61+
# HTTP header 'Content-Type'
62+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
63+
64+
# form parameters
65+
form_params = opts[:form_params] || {}
66+
67+
# http body (model)
68+
post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
69+
70+
# return_type
71+
return_type = opts[:debug_return_type] || 'ProductAnalyticsScalarResponse'
72+
73+
# auth_names
74+
auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]
75+
76+
new_options = opts.merge(
77+
:operation => :query_product_analytics_scalar,
78+
:header_params => header_params,
79+
:query_params => query_params,
80+
:form_params => form_params,
81+
:body => post_body,
82+
:auth_names => auth_names,
83+
:return_type => return_type,
84+
:api_version => "V2"
85+
)
86+
87+
data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options)
88+
if @api_client.config.debugging
89+
@api_client.config.logger.debug "API called: ProductAnalyticsAPI#query_product_analytics_scalar\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
90+
end
91+
return data, status_code, headers
92+
end
93+
94+
# Compute timeseries analytics.
95+
#
96+
# @see #query_product_analytics_timeseries_with_http_info
97+
def query_product_analytics_timeseries(body, opts = {})
98+
data, _status_code, _headers = query_product_analytics_timeseries_with_http_info(body, opts)
99+
data
100+
end
101+
102+
# Compute timeseries analytics.
103+
#
104+
# Compute timeseries analytics results for Product Analytics data.
105+
# Returns time-bucketed values for charts and trend analysis.
106+
# The `compute.interval` field (milliseconds) is required for time bucketing.
107+
#
108+
# @param body [ProductAnalyticsAnalyticsRequest]
109+
# @param opts [Hash] the optional parameters
110+
# @return [Array<(ProductAnalyticsTimeseriesResponse, Integer, Hash)>] ProductAnalyticsTimeseriesResponse data, response status code and response headers
111+
def query_product_analytics_timeseries_with_http_info(body, opts = {})
112+
113+
if @api_client.config.debugging
114+
@api_client.config.logger.debug 'Calling API: ProductAnalyticsAPI.query_product_analytics_timeseries ...'
115+
end
116+
# verify the required parameter 'body' is set
117+
if @api_client.config.client_side_validation && body.nil?
118+
fail ArgumentError, "Missing the required parameter 'body' when calling ProductAnalyticsAPI.query_product_analytics_timeseries"
119+
end
120+
# resource path
121+
local_var_path = '/api/v2/product-analytics/analytics/timeseries'
122+
123+
# query parameters
124+
query_params = opts[:query_params] || {}
125+
126+
# header parameters
127+
header_params = opts[:header_params] || {}
128+
# HTTP header 'Accept' (if needed)
129+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
130+
# HTTP header 'Content-Type'
131+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
132+
133+
# form parameters
134+
form_params = opts[:form_params] || {}
135+
136+
# http body (model)
137+
post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
138+
139+
# return_type
140+
return_type = opts[:debug_return_type] || 'ProductAnalyticsTimeseriesResponse'
141+
142+
# auth_names
143+
auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]
144+
145+
new_options = opts.merge(
146+
:operation => :query_product_analytics_timeseries,
147+
:header_params => header_params,
148+
:query_params => query_params,
149+
:form_params => form_params,
150+
:body => post_body,
151+
:auth_names => auth_names,
152+
:return_type => return_type,
153+
:api_version => "V2"
154+
)
155+
156+
data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options)
157+
if @api_client.config.debugging
158+
@api_client.config.logger.debug "API called: ProductAnalyticsAPI#query_product_analytics_timeseries\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
159+
end
160+
return data, status_code, headers
161+
end
162+
26163
# Send server-side events.
27164
#
28165
# @see #submit_product_analytics_event_with_http_info

0 commit comments

Comments
 (0)