Skip to content

Commit 2c84816

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add product analytics to FormulaAndFunctionEventsDataSource (#3354)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 0dd5e95 commit 2c84816

6 files changed

Lines changed: 144 additions & 0 deletions

File tree

.generator/schemas/v1/openapi.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2875,6 +2875,7 @@ components:
28752875
- ci_tests
28762876
- ci_pipelines
28772877
- incident_analytics
2878+
- product_analytics
28782879
example: logs
28792880
type: string
28802881
x-enum-varnames:
@@ -2889,6 +2890,7 @@ components:
28892890
- CI_TESTS
28902891
- CI_PIPELINES
28912892
- INCIDENT_ANALYTICS
2893+
- PRODUCT_ANALYTICS
28922894
FormulaAndFunctionMetricAggregation:
28932895
description: The aggregation methods available for metrics queries.
28942896
enum:

api/datadogV1/model_formula_and_function_events_data_source.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const (
2626
FORMULAANDFUNCTIONEVENTSDATASOURCE_CI_TESTS FormulaAndFunctionEventsDataSource = "ci_tests"
2727
FORMULAANDFUNCTIONEVENTSDATASOURCE_CI_PIPELINES FormulaAndFunctionEventsDataSource = "ci_pipelines"
2828
FORMULAANDFUNCTIONEVENTSDATASOURCE_INCIDENT_ANALYTICS FormulaAndFunctionEventsDataSource = "incident_analytics"
29+
FORMULAANDFUNCTIONEVENTSDATASOURCE_PRODUCT_ANALYTICS FormulaAndFunctionEventsDataSource = "product_analytics"
2930
)
3031

3132
var allowedFormulaAndFunctionEventsDataSourceEnumValues = []FormulaAndFunctionEventsDataSource{
@@ -40,6 +41,7 @@ var allowedFormulaAndFunctionEventsDataSourceEnumValues = []FormulaAndFunctionEv
4041
FORMULAANDFUNCTIONEVENTSDATASOURCE_CI_TESTS,
4142
FORMULAANDFUNCTIONEVENTSDATASOURCE_CI_PIPELINES,
4243
FORMULAANDFUNCTIONEVENTSDATASOURCE_INCIDENT_ANALYTICS,
44+
FORMULAANDFUNCTIONEVENTSDATASOURCE_PRODUCT_ANALYTICS,
4345
}
4446

4547
// GetAllowedValues reeturns the list of possible values.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Create a new timeseries widget with product_analytics data source
2+
3+
package main
4+
5+
import (
6+
"context"
7+
"encoding/json"
8+
"fmt"
9+
"os"
10+
11+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
12+
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
13+
)
14+
15+
func main() {
16+
body := datadogV1.Dashboard{
17+
Title: "Example-Dashboard with product_analytics datasource",
18+
Widgets: []datadogV1.Widget{
19+
{
20+
Definition: datadogV1.WidgetDefinition{
21+
TimeseriesWidgetDefinition: &datadogV1.TimeseriesWidgetDefinition{
22+
Title: datadog.PtrString(""),
23+
ShowLegend: datadog.PtrBool(true),
24+
LegendLayout: datadogV1.TIMESERIESWIDGETLEGENDLAYOUT_AUTO.Ptr(),
25+
LegendColumns: []datadogV1.TimeseriesWidgetLegendColumn{
26+
datadogV1.TIMESERIESWIDGETLEGENDCOLUMN_AVG,
27+
datadogV1.TIMESERIESWIDGETLEGENDCOLUMN_MIN,
28+
datadogV1.TIMESERIESWIDGETLEGENDCOLUMN_MAX,
29+
datadogV1.TIMESERIESWIDGETLEGENDCOLUMN_VALUE,
30+
datadogV1.TIMESERIESWIDGETLEGENDCOLUMN_SUM,
31+
},
32+
Time: &datadogV1.WidgetTime{
33+
WidgetLegacyLiveSpan: &datadogV1.WidgetLegacyLiveSpan{}},
34+
Type: datadogV1.TIMESERIESWIDGETDEFINITIONTYPE_TIMESERIES,
35+
Requests: []datadogV1.TimeseriesWidgetRequest{
36+
{
37+
Formulas: []datadogV1.WidgetFormula{
38+
{
39+
Formula: "query1",
40+
},
41+
},
42+
Queries: []datadogV1.FormulaAndFunctionQueryDefinition{
43+
datadogV1.FormulaAndFunctionQueryDefinition{
44+
FormulaAndFunctionEventQueryDefinition: &datadogV1.FormulaAndFunctionEventQueryDefinition{
45+
DataSource: datadogV1.FORMULAANDFUNCTIONEVENTSDATASOURCE_PRODUCT_ANALYTICS,
46+
Name: "query1",
47+
Search: &datadogV1.FormulaAndFunctionEventQueryDefinitionSearch{
48+
Query: "test_level:test",
49+
},
50+
Indexes: []string{
51+
"*",
52+
},
53+
Compute: datadogV1.FormulaAndFunctionEventQueryDefinitionCompute{
54+
Aggregation: datadogV1.FORMULAANDFUNCTIONEVENTAGGREGATION_COUNT,
55+
},
56+
GroupBy: []datadogV1.FormulaAndFunctionEventQueryGroupBy{},
57+
}},
58+
},
59+
ResponseFormat: datadogV1.FORMULAANDFUNCTIONRESPONSEFORMAT_TIMESERIES.Ptr(),
60+
Style: &datadogV1.WidgetRequestStyle{
61+
Palette: datadog.PtrString("dog_classic"),
62+
LineType: datadogV1.WIDGETLINETYPE_SOLID.Ptr(),
63+
LineWidth: datadogV1.WIDGETLINEWIDTH_NORMAL.Ptr(),
64+
},
65+
DisplayType: datadogV1.WIDGETDISPLAYTYPE_LINE.Ptr(),
66+
},
67+
},
68+
}},
69+
},
70+
},
71+
LayoutType: datadogV1.DASHBOARDLAYOUTTYPE_ORDERED,
72+
ReflowType: datadogV1.DASHBOARDREFLOWTYPE_AUTO.Ptr(),
73+
}
74+
ctx := datadog.NewDefaultContext(context.Background())
75+
configuration := datadog.NewConfiguration()
76+
apiClient := datadog.NewAPIClient(configuration)
77+
api := datadogV1.NewDashboardsApi(apiClient)
78+
resp, r, err := api.CreateDashboard(ctx, body)
79+
80+
if err != nil {
81+
fmt.Fprintf(os.Stderr, "Error when calling `DashboardsApi.CreateDashboard`: %v\n", err)
82+
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
83+
}
84+
85+
responseContent, _ := json.MarshalIndent(resp, "", " ")
86+
fmt.Fprintf(os.Stdout, "Response from `DashboardsApi.CreateDashboard`:\n%s\n", responseContent)
87+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-09-18T18:51:17.951Z
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
interactions:
2+
- request:
3+
body: |
4+
{"layout_type":"ordered","reflow_type":"auto","title":"Test-Create_a_new_timeseries_widget_with_product_analytics_data_source-1758221477 with product_analytics datasource","widgets":[{"definition":{"legend_columns":["avg","min","max","value","sum"],"legend_layout":"auto","requests":[{"display_type":"line","formulas":[{"formula":"query1"}],"queries":[{"compute":{"aggregation":"count"},"data_source":"product_analytics","group_by":[],"indexes":["*"],"name":"query1","search":{"query":"test_level:test"}}],"response_format":"timeseries","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"show_legend":true,"time":{},"title":"","type":"timeseries"}}]}
5+
form: {}
6+
headers:
7+
Accept:
8+
- application/json
9+
Content-Type:
10+
- application/json
11+
id: 0
12+
method: POST
13+
url: https://api.datadoghq.com/api/v1/dashboard
14+
response:
15+
body: '{"id":"zvr-td5-ppm","title":"Test-Create_a_new_timeseries_widget_with_product_analytics_data_source-1758221477
16+
with product_analytics datasource","description":null,"author_handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","author_name":"CI
17+
Account","layout_type":"ordered","url":"/dashboard/zvr-td5-ppm/test-createanewtimeserieswidgetwithproductanalyticsdatasource-1758221477-with-pr","template_variables":null,"widgets":[{"definition":{"legend_columns":["avg","min","max","value","sum"],"legend_layout":"auto","requests":[{"display_type":"line","formulas":[{"formula":"query1"}],"queries":[{"compute":{"aggregation":"count"},"data_source":"product_analytics","group_by":[],"indexes":["*"],"name":"query1","search":{"query":"test_level:test"}}],"response_format":"timeseries","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"show_legend":true,"time":{},"title":"","type":"timeseries"},"id":6058978575853641}],"notify_list":null,"created_at":"2025-09-18T18:51:18.107135+00:00","modified_at":"2025-09-18T18:51:18.107135+00:00","reflow_type":"auto","restricted_roles":[]}'
18+
code: 200
19+
duration: 0ms
20+
headers:
21+
Content-Type:
22+
- application/json
23+
status: 200 OK
24+
- request:
25+
body: ''
26+
form: {}
27+
headers:
28+
Accept:
29+
- application/json
30+
id: 1
31+
method: DELETE
32+
url: https://api.datadoghq.com/api/v1/dashboard/zvr-td5-ppm
33+
response:
34+
body: '{"deleted_dashboard_id":"zvr-td5-ppm"}
35+
36+
'
37+
code: 200
38+
duration: 0ms
39+
headers:
40+
Content-Type:
41+
- application/json
42+
status: 200 OK
43+
version: 2

tests/scenarios/features/v1/dashboards.feature

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,15 @@ Feature: Dashboards
950950
And the response "widgets[0].definition.time.value" is equal to 8
951951
And the response "widgets[0].definition.time.hide_incomplete_cost_data" is equal to true
952952

953+
@team:DataDog/dashboards-backend
954+
Scenario: Create a new timeseries widget with product_analytics data source
955+
Given new "CreateDashboard" request
956+
And body with value {"title":"{{ unique }} with product_analytics datasource","widgets":[{"definition":{"title":"","show_legend":true,"legend_layout":"auto","legend_columns":["avg","min","max","value","sum"],"time":{},"type":"timeseries","requests":[{"formulas":[{"formula":"query1"}],"queries":[{"data_source":"product_analytics","name":"query1","search":{"query":"test_level:test"},"indexes":["*"],"compute":{"aggregation":"count"},"group_by":[]}],"response_format":"timeseries","style":{"palette":"dog_classic","line_type":"solid","line_width":"normal"},"display_type":"line"}]}}],"layout_type":"ordered","reflow_type":"auto"}
957+
When the request is sent
958+
Then the response status is 200 OK
959+
And the response "widgets[0].definition.requests[0].queries[0].data_source" is equal to "product_analytics"
960+
And the response "widgets[0].definition.requests[0].queries[0].search.query" is equal to "test_level:test"
961+
953962
@generated @skip @team:DataDog/reporting-and-sharing
954963
Scenario: Create a shared dashboard returns "Bad Request" response
955964
Given new "CreatePublicDashboard" request

0 commit comments

Comments
 (0)