You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
analytics/test/plausible_web/controllers
RobertJoonas e5b56dbe62
Refactor VisitorGraph (#3936)
* Give a more semantic name to a function

* Make the LineGraph component thinner

* Move LineGraph into a separate file

* Move interval logic into interval-picker.js

This commit also fixes a bug where the interval name displayed inside
the picker component flickers the default interval when the graph is
loading.

The problem was that we were counting on graphData for returning us the
current interval: `let currentInterval = graphData?.interval`

We should always know the default interval before making the main-graph
request. Sending graphData to IntervalPicker component does not make
sense anyway.

* extract data fetching functions out of VisitorGraph component

* Return graph_metric key from Top Stats API

This commit introduces no behavioral changes - only starts returning an
additional field, allowing us to avoid the following logic in React:

1. Finding the metric names, given a stat display name. E.g.
   `Unique visitors (last 30 min) -> visitors`

2. Checking if a metric is graphable or not

* Move metric state into localStorage

This commit gets rid of the internal `metric` state in the VisitorGraph
component and starts using localStorage for that instead.

This commit also chains the main-graph request into the top-stats request
callback - meaning that we'll always fetch new graph data after top stats
are updated. And we do it all in a single function.

Doing so simplifies the loading state significantly, and also helps to
make it clear, that at all times, existing top stats are required before
we can fetch the graph. That's because the metric is determined by which
Top stats are returned (for example, we can't be sure whether revenue
metrics will be returned or not).

* Make sure graph tooltip says "Converted Visitors"

* Extract a StatsExport function component

Again, instead of relying on `graphData?.interval` we can read it from
localStorage, or default to the largest interval available. The export
should not be dependant on the graph.

* Extract SamplingNotice function component

* Extract WithImportedSwitch function component

* Stop "lazy-loading" the graph and top stats

Since the container is always on top on the page, it will be visible on
the first render in any case - no matter the screen size.

* Turn VisitorGraph into a function component

* Display empty container until everything has loaded

* Do not display loading spinner on realtime ticks

* Turn Top Stats into a fn component

* fetch top stats and graph async

* Make sure revenue metrics can remain on the graph

* Add an extra check to canMetricBeGraphed

* fix typo

* remove redundant double negation
3 years ago
..
CSVs Ignore sessions without entry/exit pages when breaking down entry/exit pages (#3933) 3 years ago
api Refactor VisitorGraph (#3936) 3 years ago
auth_controller Remove custom domains support + update build options (#3559) 3 years ago
site Allow inviting users who are members already (#3797) 3 years ago
admin_auth_controller_test.exs Remove custom domains support + update build options (#3559) 3 years ago
admin_controller_test.exs New admin route for displaying usage (#3577) 3 years ago
auth_controller_sync_test.exs Always enable e-mail verification on full build (#3666) 3 years ago
auth_controller_test.exs Implement UI for multiple imports (#3727) 3 years ago
avatar_controller_test.exs Remove custom domains support + update build options (#3559) 3 years ago
billing_controller_test.exs Make `hello@plausible.io` clickable (#3746) 3 years ago
error_report_controller_test.exs Remove custom domains support + update build options (#3559) 3 years ago
google_analytics_controller_test.exs Implement adjusting imported date range to actual and existing stats (#3943) 3 years ago
invitation_controller_test.exs Move limit enforcement to accepting site ownership transfer (#3612) 3 years ago
page_controller_test.exs Remove custom domains support + update build options (#3559) 3 years ago
site_controller_test.exs Use sessionStorage for "dashboard first launch" banner tracking (#3892) 3 years ago
stats_controller_test.exs Ensure all the react container attributes are strings (#3948) 3 years ago
unsubscribe_controller_test.exs Remove custom domains support + update build options (#3559) 3 years ago