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/lib/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 `String.to_atom/1` is safe to do at compile-time (#3813) 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
event Flush Clickhouse buffers faster by encoding early (#3623) 3 years ago
funnel Add small build option (#3536) 3 years ago
goal Small build updates (#3546) 3 years ago
google Populate new columns in imports and exports (#3969) 3 years ago
helpers Small build updates (#3546) 3 years ago
imported Populate new columns in imports and exports (#3969) 3 years ago
ingestion Filter by hostnames (#3963) 3 years ago
open_telemetry Make OpenTelemetry sampler ratio configurable via env (#3514) 3 years ago
plugins/api Add `GET /capabilities` to Plugins API (#3808) 3 years ago
s3 Add csv importer (#3795) 3 years ago
sentry Update Sentry (#3843) 3 years ago
session Filter by hostnames (#3963) 3 years ago
shield Reapply 3918 (#3940) 3 years ago
shields 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
telemetry Add metrics to ingestion pipeline (#3927) 3 years ago
application.ex Reapply 3918 (#3940) 3 years ago
async_insert_repo.ex Switch to new clickhouse adapter (ch/chto) (#2733) 4 years ago
cache.ex Add metrics to ingestion pipeline (#3927) 3 years ago
cldr.ex Revenue tracking: Add currency field to goal creation (#2948) 4 years ago
clickhouse_event_v2.ex Filter by hostnames (#3963) 3 years ago
clickhouse_repo.ex Switch to new clickhouse adapter (ch/chto) (#2733) 4 years ago
clickhouse_session_v2.ex Filter by hostnames (#3963) 3 years ago
data_migration.ex Mutation to populate event session columns (#3844) 3 years ago
debug_replay_info.ex Add debug_replay_info context to Sentry Stats reports (#3189) 3 years ago
exports.ex Populate new columns in imports and exports (#3969) 3 years ago
geo.ex Dockerfile and co updates (#3811) 3 years ago
goals.ex Refactor VisitorGraph (#3936) 3 years ago
http_client.ex Use Phoenix LiveView for the upgrade page (#3382) 3 years ago
import_deletion_repo.ex Split clickhouse repos - making the main one read only (#2826) 4 years ago
imported.ex Improve import stats toggle and `with_imported` flag computation (#3960) 3 years ago
ingest_repo.ex Switch to new clickhouse adapter (ch/chto) (#2733) 4 years ago
mailer.ex Fix and refactor invitation logic (#3376) 3 years ago
migration_utils.ex Add data migration for moving sessions_v2 table to VersionedCollapsingMergeTree (#3802) 3 years ago
open_telemetry.ex Implement trace ID ratio-based sampling for OpenTelemetry (#3499) 3 years ago
pagination.ex Implement new sites view (#3463) 3 years ago
prom_ex.ex Implement new sites view (#3463) 3 years ago
props.ex Limit Custom Properties access in Stats API (#3670) 3 years ago
purge.ex Implement UI for multiple imports (#3727) 3 years ago
rate_limit.ex rm Hammer (#3571) 3 years ago
repo.ex Implement new sites view (#3463) 3 years ago
s3.ex Include domain and dates in zip archive filename (#3921) 3 years ago
shields.ex Reapply 3918 (#3940) 3 years ago
site.ex Improve import stats toggle and `with_imported` flag computation (#3960) 3 years ago
sites.ex Include domain and dates in zip archive filename (#3921) 3 years ago
stats.ex Add small build option (#3536) 3 years ago
themes.ex Adds dark mode to entire dashboard (#467) 6 years ago
timezones.ex Shield: Country Rules (#3828) 3 years ago
users.ex Bugfix: available features for expired trials, no subscriptions (#3740) 3 years ago