Summary
The queryExploreEventsInTableFormat SDK function wraps GET /api/0/organizations/{org}/events/, but its OpenAPI spec has two gaps that prevent the Sentry CLI from using it for the sentry explore command. The CLI currently drops down to raw HTTP via apiRequestToRegion() in src/lib/api/discover.ts to work around both issues.
Gap 1: metricsEnhanced missing from dataset enum
The spec declares the dataset query parameter as:
'discover' | 'errors' | 'logs' | 'profile_functions' | 'spans' | 'transactions' | 'uptime_results'
The Sentry backend also accepts metricsEnhanced (used by the Explore Metrics UI for tracemetrics queries — sum(value, metric_name, metric_type, unit) format). The CLI maps --dataset metrics to metricsEnhanced at the API level.
Passing dataset: "metricsEnhanced" to the SDK function is a type error, so the CLI can't use the SDK for metrics queries.
replays may also be missing — the CLI uses it for --dataset replays on the same endpoint.
Gap 2: meta.units missing from response type
The actual API response includes meta.units — a Record<string, string | null> mapping field names to their unit (e.g., "millisecond", "none"). The SDK's OrganizationEventsResponseDict type does not include it:
SDK type:
meta: {
fields: { [key: string]: string };
datasetReason?: string;
isMetricsData?: boolean;
isMetricsExtractedData?: boolean;
};
Actual API response also includes:
meta: {
// ...above fields...
units?: { [key: string]: string | null };
};
The CLI uses meta.units for dashboard widget formatting and metric metadata extraction. Without it in the SDK type, callers need manual type augmentation or a separate Zod schema.
Impact
The CLI's src/lib/api/discover.ts uses raw apiRequestToRegion() with a hand-written EventsTableResponseSchema instead of the SDK's queryExploreEventsInTableFormat. This is inconsistent with other API modules (logs.ts, issues.ts, events.ts, etc.) that already use the SDK.
Similarly, src/lib/api/dashboards.ts uses raw requests for the same endpoint for widget table/timeseries queries.
Expected behavior
- Add
metricsEnhanced (and replays if valid) to the dataset enum for queryExploreEventsInTableFormat and queryExploreEventsInTimeseriesFormat
- Add
units?: { [key: string]: string | null } to the meta object in OrganizationEventsResponseDict
Workaround
The CLI maintains a custom Zod schema EventsTableResponseSchema in src/types/dashboard.ts and calls the API directly: https://github.com/getsentry/cli/blob/main/src/lib/api/discover.ts
Summary
The
queryExploreEventsInTableFormatSDK function wrapsGET /api/0/organizations/{org}/events/, but its OpenAPI spec has two gaps that prevent the Sentry CLI from using it for thesentry explorecommand. The CLI currently drops down to raw HTTP viaapiRequestToRegion()insrc/lib/api/discover.tsto work around both issues.Gap 1:
metricsEnhancedmissing fromdatasetenumThe spec declares the
datasetquery parameter as:The Sentry backend also accepts
metricsEnhanced(used by the Explore Metrics UI for tracemetrics queries —sum(value, metric_name, metric_type, unit)format). The CLI maps--dataset metricstometricsEnhancedat the API level.Passing
dataset: "metricsEnhanced"to the SDK function is a type error, so the CLI can't use the SDK for metrics queries.replaysmay also be missing — the CLI uses it for--dataset replayson the same endpoint.Gap 2:
meta.unitsmissing from response typeThe actual API response includes
meta.units— aRecord<string, string | null>mapping field names to their unit (e.g.,"millisecond","none"). The SDK'sOrganizationEventsResponseDicttype does not include it:SDK type:
Actual API response also includes:
The CLI uses
meta.unitsfor dashboard widget formatting and metric metadata extraction. Without it in the SDK type, callers need manual type augmentation or a separate Zod schema.Impact
The CLI's
src/lib/api/discover.tsuses rawapiRequestToRegion()with a hand-writtenEventsTableResponseSchemainstead of the SDK'squeryExploreEventsInTableFormat. This is inconsistent with other API modules (logs.ts,issues.ts,events.ts, etc.) that already use the SDK.Similarly,
src/lib/api/dashboards.tsuses raw requests for the same endpoint for widget table/timeseries queries.Expected behavior
metricsEnhanced(andreplaysif valid) to thedatasetenum forqueryExploreEventsInTableFormatandqueryExploreEventsInTimeseriesFormatunits?: { [key: string]: string | null }to themetaobject inOrganizationEventsResponseDictWorkaround
The CLI maintains a custom Zod schema
EventsTableResponseSchemainsrc/types/dashboard.tsand calls the API directly: https://github.com/getsentry/cli/blob/main/src/lib/api/discover.ts