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
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
..
auth Bugfix: available features for expired trials, no subscriptions (#3740) 3 years ago
billing Allow inviting users who are members already (#3797) 3 years ago
cache Reapply #3878 + bugfix hit rate tracking (#3891) 3 years ago
data_migration Fix dry run mode in `DataMigration.SiteImports` (#3965) 3 years ago
google Implement adjusting imported date range to actual and existing stats (#3943) 3 years ago
imported Populate new columns in imports and exports (#3969) 3 years ago
ingestion Reapply 3918 (#3940) 3 years ago
plugins/api Remove custom domains support + update build options (#3559) 3 years ago
session Filter by hostnames (#3963) 3 years ago
shield Reapply 3918 (#3940) 3 years ago
site Reapply #3878 + bugfix hit rate tracking (#3891) 3 years ago
stats Reducing JOINs in queries (#3966) 3 years ago
cache_test.exs Reapply #3878 + bugfix hit rate tracking (#3891) 3 years ago
config_test.exs CSV imports (no UI) (#3895) 3 years ago
debug_replay_info_test.exs Upgrade Erlang/Elixir stack (#3454) 3 years ago
exports_test.exs Include domain and dates in zip archive filename (#3921) 3 years ago
funnels_test.exs Add small build option (#3536) 3 years ago
goals_test.exs Refactor VisitorGraph (#3936) 3 years ago
http_client_test.exs Upgrade stack (deps, elixir 1.16, OTP 26.2.1) (#3678) 3 years ago
imported_test.exs Improve import stats toggle and `with_imported` flag computation (#3960) 3 years ago
mailer_test.exs add MAILER_NAME (#2937) 4 years ago
pagination_test.exs Generalize Cache/Warmers - extract only specifics to `Site.Cache` (#3716) 3 years ago
props_test.exs Update plans_v4.json with new plans IDs (#3436) 3 years ago
purge_test.exs Implement UI for multiple imports (#3727) 3 years ago
rate_limit_test.exs Fix flaky test: wait till ets is emptied (#3755) 3 years ago
release_test.exs Remove custom domains support + update build options (#3559) 3 years ago
s3_test.exs CSV imports (no UI) (#3895) 3 years ago
sentry_filter_test.exs derive jason encoder for request (#3182) 3 years ago
shields_test.exs Reapply 3918 (#3940) 3 years ago
timezones_test.exs Shield: Country Rules (#3828) 3 years ago