Draft
Conversation
* Add a new response structure: a separate `comparison_results` field, used only when comparing in a time-dimensional query. * Add `meta.time_label_result_indices` to response (exclusive to internal API). Makes it easier for FE to find buckets for time labels.
This is currently only used by the main graph, which is going to move to a new endpoint in this PR. * The CSV export is currently ignoring comparisons * the `&compare=previous_period` option in Stats API v1 is ignored by the timeseries endpoint
13 tasks
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.
Changes
This PR gets rid of the/main-graph endpoint in favor of the new API v2 based /query endpoint. Doing so, a few gaps needed to be filled in the query API. See below.
NOTE: This PR will be kept as draft until #6159 (new main graph FE) gets merged into it.
1. Change the result format of comparison results (when time dimension breakdown)
With this PR, the query API starts returning
comparison_resultsas a separate response field ifdimensions == [time:*], while breakdown and aggregate responses keepcomparisonsnested for each row in the originalresultslist.In hindsight, the new comparison results format could have been avoided by filling in all the missing buckets instead. This would have let us avoid returning a bunch of meta fields (
time_labels,comparison_time_labels,time_label_indices,comparison_time_label_indices, andempty_metrics).The main reason I went with this approach was to prepare comparisons for a public API release (playing well with time_labels), but since it’s still far from perfect (a noisy query.include + meta; difficult for the client to read the data), we’ll still need to re-evaluate this. We should also carefully consider what to do with
include.total_rowsand multi-dimensional (time + non-time) breakdowns, where zipping comparison <> main results gets tricky.2. Add new
response.metaandquery.includefieldsNote: all these flags are internal-use only. Nothing gets released into the public API
meta.comparison_time_labelsmeta.time_labelsbut for generating the comparison plotinclude.time_labels && include.comparemeta.present_indexinclude.present_indexmeta.time_label_result_indicesmeta.time_labels) of indices where each item corresponds to an index in theresultslist ornullwhen there is no result for that bucket. Makes it much easier for the frontend to understand the data.include.time_label_result_indicesmeta.comparison_time_label_result_indicesmeta.time_label_result_indicesbut for comparison resultsinclude.time_label_result_indices && include.comparemeta.partial_time_labelsinclude.partial_time_labelsmeta.comparison_partial_time_labelsmeta.partial_time_labelsbut for comparison resultsinclude.partial_time_labels && include.comparemeta.empty_metricsquery.metrics = ['visitors', 'time_on_page'], thenmeta.empty_metrics = [0, null]. Makes it possible for the frontend to fill in missing buckets without re-defining empty metrics.include.empty_metrics && "event:goal" not in query.dimensions- there shouldn't be any need to ask for empty metrics in the goal breakdown, but this makes it clear that there's a conflict (possibly multiple revenue currencies).3. Remove old code
4. Transform main_graph_test.exs
A major rewrite of main_graph_test.exs - populate_stats and other tests setup remained the same, but the request is now made against the new endpoint and the assertions on the returned data structures have changed significantly.
Tests
Changelog
Documentation
Dark mode