Add stripe analytics query command#1735
Open
kamenrider-cyber wants to merge 3 commits into
Open
Conversation
benanthony-stripe
requested changes
Jul 3, 2026
benanthony-stripe
left a comment
There was a problem hiding this comment.
Great first pass, awesome work! A few small comments mostly about stuff you couldn't have possibly known.
One other small request, could you add some snippets of the output of this command in your PR description? I saw you have the actual CLI commands but would be really helpful to see the output too!
c75580e to
b7d5f4a
Compare
billmei-stripe
requested changes
Jul 9, 2026
| c.cmd.Flags().BoolVarP(&c.rb.DarkStyle, "dark-style", "", false, "Use a darker color scheme better suited for lighter command-lines") | ||
|
|
||
| c.cmd.Flags().StringVar(&c.rb.APIBaseURL, "api-base", stripe.DefaultAPIBaseURL, "Sets the API base URL") | ||
| c.cmd.Flags().MarkHidden("api-base") // #nosec G104 |
Contributor
Author
There was a problem hiding this comment.
Hi,
--api-base overrides the API host (used for local/dev testing), and i think it is in listen and login=D
There was a problem hiding this comment.
I meant, what does #nosec G104 mean?
billmei-stripe
approved these changes
Jul 14, 2026
|
|
||
| See the supported metrics at https://docs.stripe.com/data/analytics/supported-metrics | ||
| and the API reference at | ||
| https://docs.stripe.com/api/v2/data/analytics/metric-query-results/create?api-version=preview`, |
| c.cmd.Flags().BoolVarP(&c.rb.DarkStyle, "dark-style", "", false, "Use a darker color scheme better suited for lighter command-lines") | ||
|
|
||
| c.cmd.Flags().StringVar(&c.rb.APIBaseURL, "api-base", stripe.DefaultAPIBaseURL, "Sets the API base URL") | ||
| c.cmd.Flags().MarkHidden("api-base") // #nosec G104 |
There was a problem hiding this comment.
I meant, what does #nosec G104 mean?
| // the API so we don't duplicate logic that could drift out of sync. | ||
| if len(c.metrics) == 0 { | ||
| return fmt.Errorf("at least one --metric is required") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reviewers
r?
cc @stripe/developer-products
Summary
Add
stripe data metrics run, a new CLI command that wrapsPOST /v2/data/analytics/metric_query(a Private Preview API). The command sends the previewStripe-Versionheader automatically and supports querying one or more metrics bynamespace.metricname (e.g.revenue.mrr) or ID (e.g.metric_test_...), along with time range, granularity, currency, timezone, filters, group-by, and limit.The command (and its
data/data metricsparents) is hidden while the API is in Private Preview. Parameters are forwarded to the API for validation rather than duplicated client-side, so the CLI won't drift from the API's rules (metric namespaces, time ranges, group-by/filter cardinality, limit bounds, etc.).This is implemented as a bespoke command (not OpenAPI-generated) because the endpoint's
metricsarray-of-objects and dynamicfiltersmap aren't representable with the current resource-command codegen.Test plan
go test ./pkg/cmd/ -run 'MetricRef|BuildRequestBody|ParseMetricFilters|DataMetricsRun|NewDataCmd|NewDataMetricsRun'Baseline (equivalent curl request):