@@ -564,8 +564,9 @@ def retrieve_analytics(
564564 self ,
565565 project_id : str ,
566566 * ,
567- end : int | Omit = omit ,
568- start : int | Omit = omit ,
567+ end : Optional [int ] | Omit = omit ,
568+ metadata_filters : Optional [str ] | Omit = omit ,
569+ start : Optional [int ] | Omit = omit ,
569570 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
570571 # The extra values given here take precedence over values defined on the client or passed to this method.
571572 extra_headers : Headers | None = None ,
@@ -574,12 +575,46 @@ def retrieve_analytics(
574575 timeout : float | httpx .Timeout | None | NotGiven = not_given ,
575576 ) -> ProjectRetrieveAnalyticsResponse :
576577 """
577- Get Project Analytics Route
578+ Retrieve analytics data for a project including queries, bad responses, and
579+ answers published.
580+
581+ **Metadata Filtering:**
582+ - Filter by custom metadata fields using key-value pairs
583+ - Supports single values: `{"department": "Engineering"}`
584+ - Supports multiple values: `{"priority": ["high", "medium"]}`
585+ - Supports null/missing values: `{"department": []}` or `{"department": [null]}`
586+
587+ **Available Metadata Fields:**
588+ - Only metadata keys that exist on query logs are returned in `metadata_fields`
589+ - Fields with ≤12 unique values show as "select" type with checkbox options
590+ - Fields with >12 unique values show as "input" type for text search
591+ - Fields with no data are excluded from the response entirely
592+
593+ **Null Value Behavior:**
594+ - Empty arrays `[]` are automatically converted to `[null]` to filter for records where the metadata field is missing or null
595+ - Use `[null]` explicitly to filter for records where the field is missing or null
596+ - Use `["value1", null, "value2"]` to include both specific values and null values
597+ - Records match if the metadata field is null, missing from custom_metadata, or custom_metadata itself is null
598+
599+ **Date Filtering:**
600+ - Provide `start` only: filter logs created at or after this timestamp
601+ - Provide `end` only: filter logs created at or before this timestamp
602+ - Provide both: filter logs created within the time range
603+ - Provide neither: include all logs regardless of creation time
578604
579605 Args:
580- end: End timestamp in seconds since epoch
606+ end: Filter logs created at or before this timestamp (epoch seconds). Can be used
607+ alone for upper-bound filtering.
581608
582- start: Start timestamp in seconds since epoch
609+ metadata_filters:
610+ Metadata filters as JSON string. Examples:
611+ - Single value: '{"department": "Engineering"}'
612+ - Multiple values: '{"priority": ["high", "medium"]}'
613+ - Null/missing values: '{"department": []}' or '{"department": [null]}'
614+ - Mixed values: '{"status": ["active", null, "pending"]}'
615+
616+ start: Filter logs created at or after this timestamp (epoch seconds). Can be used
617+ alone for lower-bound filtering.
583618
584619 extra_headers: Send extra headers
585620
@@ -601,6 +636,7 @@ def retrieve_analytics(
601636 query = maybe_transform (
602637 {
603638 "end" : end ,
639+ "metadata_filters" : metadata_filters ,
604640 "start" : start ,
605641 },
606642 project_retrieve_analytics_params .ProjectRetrieveAnalyticsParams ,
@@ -1301,8 +1337,9 @@ async def retrieve_analytics(
13011337 self ,
13021338 project_id : str ,
13031339 * ,
1304- end : int | Omit = omit ,
1305- start : int | Omit = omit ,
1340+ end : Optional [int ] | Omit = omit ,
1341+ metadata_filters : Optional [str ] | Omit = omit ,
1342+ start : Optional [int ] | Omit = omit ,
13061343 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
13071344 # The extra values given here take precedence over values defined on the client or passed to this method.
13081345 extra_headers : Headers | None = None ,
@@ -1311,12 +1348,46 @@ async def retrieve_analytics(
13111348 timeout : float | httpx .Timeout | None | NotGiven = not_given ,
13121349 ) -> ProjectRetrieveAnalyticsResponse :
13131350 """
1314- Get Project Analytics Route
1351+ Retrieve analytics data for a project including queries, bad responses, and
1352+ answers published.
1353+
1354+ **Metadata Filtering:**
1355+ - Filter by custom metadata fields using key-value pairs
1356+ - Supports single values: `{"department": "Engineering"}`
1357+ - Supports multiple values: `{"priority": ["high", "medium"]}`
1358+ - Supports null/missing values: `{"department": []}` or `{"department": [null]}`
1359+
1360+ **Available Metadata Fields:**
1361+ - Only metadata keys that exist on query logs are returned in `metadata_fields`
1362+ - Fields with ≤12 unique values show as "select" type with checkbox options
1363+ - Fields with >12 unique values show as "input" type for text search
1364+ - Fields with no data are excluded from the response entirely
1365+
1366+ **Null Value Behavior:**
1367+ - Empty arrays `[]` are automatically converted to `[null]` to filter for records where the metadata field is missing or null
1368+ - Use `[null]` explicitly to filter for records where the field is missing or null
1369+ - Use `["value1", null, "value2"]` to include both specific values and null values
1370+ - Records match if the metadata field is null, missing from custom_metadata, or custom_metadata itself is null
1371+
1372+ **Date Filtering:**
1373+ - Provide `start` only: filter logs created at or after this timestamp
1374+ - Provide `end` only: filter logs created at or before this timestamp
1375+ - Provide both: filter logs created within the time range
1376+ - Provide neither: include all logs regardless of creation time
13151377
13161378 Args:
1317- end: End timestamp in seconds since epoch
1379+ end: Filter logs created at or before this timestamp (epoch seconds). Can be used
1380+ alone for upper-bound filtering.
1381+
1382+ metadata_filters:
1383+ Metadata filters as JSON string. Examples:
1384+ - Single value: '{"department": "Engineering"}'
1385+ - Multiple values: '{"priority": ["high", "medium"]}'
1386+ - Null/missing values: '{"department": []}' or '{"department": [null]}'
1387+ - Mixed values: '{"status": ["active", null, "pending"]}'
13181388
1319- start: Start timestamp in seconds since epoch
1389+ start: Filter logs created at or after this timestamp (epoch seconds). Can be used
1390+ alone for lower-bound filtering.
13201391
13211392 extra_headers: Send extra headers
13221393
@@ -1338,6 +1409,7 @@ async def retrieve_analytics(
13381409 query = await async_maybe_transform (
13391410 {
13401411 "end" : end ,
1412+ "metadata_filters" : metadata_filters ,
13411413 "start" : start ,
13421414 },
13431415 project_retrieve_analytics_params .ProjectRetrieveAnalyticsParams ,
0 commit comments