Commit Graph

1829 Commits

Author SHA1 Message Date
RobertJoonas
bd0de97521
Fix returning more pageviews with a visit property filter (#2612)
* fix subquery for sessions in base_event_query/2

As the 'sessions' table is using the CollapsingMergeTree engine, we have
to select session_id's distinctively. Otherwise we will get multiple rows
(with sign -1 and 1) as long as the background merge hasn't happened.

* update changelog

* use GROUP BY instead of SELECT DISTINCT

* remove comma
2023-01-23 12:14:27 +02:00
ruslandoga
8640ba499f
fix clickhouse-ci rule in Makefile (#2614) 2023-01-20 10:52:39 -03:00
ruslandoga
e3f095ade7
fix class name typo and include it in safelist (#2610) 2023-01-20 10:41:04 -03:00
Adam Rutkowski
1a4b65c36c
Communicate site creation edge cases to the users (#2605)
* Fingerprint DBConnection.ConnectionError in Sentry

* Check events before creating a site

* Enable sites limit screen

* Remove debugging remnant

* Fix buggy assertions

This wasn't doing what expected:

  iex(1)> Repo.exists?(Plausible.Site, domain: "foo")
  [debug] QUERY OK source="sites" db=0.6ms idle=1906.2ms
  SELECT TRUE FROM "sites" AS s0 LIMIT 1 []

* Encapsulate check to satisfy credo

* Use less technically involved error message

* Bring back e-mail to the limit error message
2023-01-19 15:03:18 +01:00
Vini Brasil
86d5098b31
Stop logging invalid_address errors from Locus (#2604)
This commit stops logging `{:invalid_address, "ip"}` errors. This
reduces noise on Sentry, that is capturing error logs. Other errors are
still logged.
2023-01-18 12:39:54 -03:00
RobertJoonas
c4b8bf8c32
Fix metric undefined (#2589)
* extract maybeUpdateMetric function

* reset graph metric after fetching top stats

* fix bug

Also make sure we do not allow 'metric' to become undefined anymore

* keep graph hidden when empty metric saved

* reset metric in setState callback

* pass function not call
2023-01-18 16:37:03 +02:00
Uku Taht
818d4404a8
Support custom events and props in mix send_pageview (#2606) 2023-01-18 16:35:37 +02:00
ruslandoga
166748dcf2
Replace Geolix with Locus (#2362)
This PR replaces geolix with locus to simplify self-hosted setup. locus can auto-update maxmind dbs which are recommended for self-hosters if they want city-level geolocation. locus is also a bit faster.

This PR also uses a test mmdb file from https://github.com/maxmind/MaxMind-DB for e2e geolocation tests without stubs.
2023-01-17 12:05:09 -03:00
Uku Taht
2a4061de8c
Make checkly alert after 5 minutes of downtime (#2599) 2023-01-17 11:58:01 +02:00
Adam Rutkowski
5ba8697c31
Fingerprint DBConnection.ConnectionError in Sentry (#2597) 2023-01-16 13:05:56 +01:00
Vini Brasil
cb5d8a0d25
Make warning notices responsive (#2591)
Closes #2528
2023-01-16 08:23:09 -03:00
RobertJoonas
3999f282a5
Last updated tooltip (#2576)
* extract blinkingDot function

* position pulsating-circle with tailwind instead

* remove unused function

* extract renderStatName function

* display seconds since last realtime update

Adds a 'Last updated X seconds ago' label to the Current Visitors tooltip.

* small refactor: avoid duplication of this.props and this.state

* show the 'last updated ...' tooltip in historical

* changelog update

* use className utility function
2023-01-16 10:30:22 +02:00
David Janda
b6349df475
Display pageviews in details modal for top pages when filtering by a source (#2585) 2023-01-13 14:10:20 -03:00
Adam Rutkowski
61bf624761
Sentry cleanup (#2590)
* Filter DBConnection logs for clickhouse in Sentry

Removing the never matching clause btw

* Exclude Plug.CSRFProtection.InvalidCSRFTokenError from Sentry

* Turn common Sentry captures into logged warnings

* Exclude fonts from static conf and InvalidPathError from Sentry
2023-01-13 14:04:09 -03:00
Adam Rutkowski
97a3ce72e4
Update clickhousex & fingerprint sentry errors (#2587)
* Revert "Revert "Fingerprint Clickhousex.Error exceptions in Sentry (#2578)" (#2586)"

This reverts commit a78e07236a.

* Bump clickhousex to include https://github.com/plausible/clickhousex/pull/20
2023-01-12 17:22:45 +01:00
Cenk Kücük
d9011e4189
unmute checkly (#2588) 2023-01-12 16:24:25 +01:00
Adam Rutkowski
a78e07236a
Revert "Fingerprint Clickhousex.Error exceptions in Sentry (#2578)" (#2586)
This reverts commit 2428a2bf36.
2023-01-12 06:49:41 +01:00
Adam Rutkowski
2428a2bf36
Fingerprint Clickhousex.Error exceptions in Sentry (#2578)
* Fingerprint Clickhousex.Error exceptions in Sentry

* Update clickhousex
2023-01-11 15:19:07 +01:00
Marko Saric
934c3c323e
Some changes to the 'dashboard locked' email copy (#2584) 2023-01-11 09:18:41 -03:00
Marko Saric
5ba446e87c
Some changes to the 'over limit' email copy (#2583) 2023-01-11 08:51:27 -03:00
Adam Rutkowski
4bde884da8
Self-host Sentry user feedback script (#2579)
* Add static, minified sentry bundle

OG source: https://browser.sentry-cdn.com/5.9.1/bundle.min.js

* On 500s, load our self-hosted sentry bundle
2023-01-10 16:51:46 +02:00
ruslandoga
a6e75ada7b
update ecto to include db url scheme (#2570)
* update ecto to include db url scheme

* update clickhousex

* update changelog
2023-01-10 13:02:28 +01:00
Uku Taht
256e8263c0 Add Hetzner load balancer to health checks 2023-01-09 18:02:38 +02:00
Uku Taht
f10c67e0e7 Add custom.plausible.io to checkly monitoring 2023-01-09 17:59:44 +02:00
RobertJoonas
13a05b4e1e
Change metric labels for realtime with goal filter (#2560)
* change metric labels for realtime with goal filter

* changelog

* fix formatting
2023-01-09 09:31:55 +02:00
Uku Taht
1772ddff17
Add Checkly (#2520)
* Add Checkly Terraform config

* add deployment workflow

* use pagerduty instead of email for notifications

* use terraform cloud backend

* update variable declaration

* rename checkly check group

* update syntax

* test trigger

* Revert "test trigger"

This reverts commit 333e82beac.

* run a single job at a time

Co-authored-by: Cenk Kücük <c@cenk.me>
2023-01-05 20:25:54 +01:00
Uku Taht
51fc9c0945
Refine parallel application-side joins (#2564)
* Consolidate task timeouts, incrase to 15s

* Use Task.async_stream for parallel Clickhouse queries

* Propagate Opentelemetry context to child Task process
2023-01-05 12:34:01 +01:00
David Janda
f949278d39
Convert list elements to button elements for stats tabs in order to enable keyboard navigation (#2526) 2023-01-05 11:45:19 +02:00
Adam Rutkowski
89da676215
Update clickhousex (start using Mint and proper pool management) (#2502)
* Pin clickhousex to @ruslandoga's rebase branch

* Bump lockfile

* Use HTTP pings

* Update lockfile

* Pin to master
2023-01-05 09:38:52 +01:00
Vini Brasil
4503895d0a
Fix breakdown API pagination when using event metrics (#2562)
* Fix breakdown API pagination when using event metrics

This commit fixes a bug where the subsequent breakdown API pages had
the same items as the first page. The fix sorts the underlying
ClickHouse query by timestamp, keeping the same order between requests,
as we use OFFSET/LIMIT pagination.

* Fix repeated results assertion

* Add different ORDER BY to each breakdown property
2023-01-04 22:14:40 -03:00
Adam Rutkowski
44afbaa2f9
Wrap paddle actions with DB transactions (#2558)
* Wrap paddle actions with DB transactions

* Bow to credo

* Make the paddle transactions crash when applicable

* s/changeset/details
2023-01-03 16:14:50 +01:00
Uku Taht
1785653b1e
Ignore unknown countries (#2556)
* Ignore XX and T1 countries

* Add fallback if country_code=nil

* Lookup city overrides directly in CityOverrides module

* Changelog

* Add empty moduledoc

* Remove redundant comment
2023-01-03 10:35:23 -03:00
RobertJoonas
47e21121db
Realtime dashboard improvements (#2445)
* add a new realtime-update-timer module

* hook to the new 'tick' event in ListReport for auto-updates

This commit fixes the bug where all reports using the `ListReport` component did not
auto-update in realtime mode. Those reports are:

- Pages (Top / Entry / Exit)
- Locations (Countries / Regions / Cities)
- Devices (Screen Sizes / Browsers + versions / OS-s + versions)

* fetch data for ListReports only when scrolled into view

* refactor fetching data in ListReport

* refer to one source of truth for utm tags

* make the 'All' tab in Sources auto-update

* make all UTM tabs in Sources auto-update

* fetch UTM data only when scrolled into view

* auto-update Referrers with the new timer

* auto-update google search terms

* auto-update Conversions

* make countries map auto-update

* auto-update visitor-graph and top stats with new timer

* use new tick event for current visitors (in Historical)

* remove the old timer class

* update changelog

* Visual improvements to automatic realtime updates (#2532)

* minor consistency fix for text color in dark mode

* use FlipMove in goal conversions report

* use FlipMove in ListReports

* set main graph and top stats loading state correctly

* refactor isIntervalValid function

* enforce intervals are valid when set and stored

* remove duplicate data fetching on interval change

Fetching new data is handled by the `fetchGraphData` callback in `updateInterval`

* refactor updateMetric function

* make it clearer why 'metric' can be a faulty value

* extract 'query' and 'site' variables from 'this.props'

* reset interval state only when period is changed

The 'maybeRollbackInterval' function was also used to fetch data. This commit replaces
all those function calls with 'fetchGraphData' which better describes the actual behavior.
We should only worry about rolling back the interval if 'query.period' has changed.

This commit also stops the graph from flickering when it is updated in realtime.

* update names of two variables

* remove unnecessary negation

* make collapsed graph state more explicit

* consider stored invalid intervals when graph mounts

* fix not showing loading spinner regression

* remove interval state from VisitorGraph (#2540)

* Realtime prop breakdown (#2535)

* disable load more in realtime mode

* extract doFetch function

* separate fetchPropBreakdown and fetchNextPage functions

* subscribe for auto-updates in realtime

* improve readability with function name changes
2023-01-02 17:42:57 +02:00
Vini Brasil
22e2ae1844
Add OTEL tracing to breakdown functions (#2544)
Co-authored-by: Robert Joonas <robertjoonas16@gmail.com>

Co-authored-by: Robert Joonas <robertjoonas16@gmail.com>
2023-01-02 11:53:02 -03:00
Vini Brasil
b6d30019ef
Cascade delete sent_renewal_notifications table when user is deleted (#2549)
* Cascade delete sent_renewal_notifications table when user is deleted

This commit fixes a bug when deleting a user would trigger a constraint
error.

* Update CHANGELOG.md
2023-01-02 11:46:18 -03:00
Vini Brasil
10a9767912
Remove ingestion requests and Oban queries from OTEL (#2543) 2022-12-27 11:14:36 +01:00
Adam Rutkowski
5de43b758d
Run tests in async mode where applicable (#2542)
* Set pg pool size for MIX_ENV=test

* Include slow tests in CI run

* Exclude slow tests by default

* Mark tests slow/async where applicable

* Restructure captcha mocks

* Revert async where env is relied upon

* Add --max-failures=1 to CI run

* Set warnings as errors

* Disable async where various mocks are used

* Revert "Disable async where various mocks are used"

This reverts commit 2446b72a29.

* Disable async for test using vcr
2022-12-26 10:20:29 -03:00
Vini Brasil
5152e8d416
Reject events with long URIs and data URIs (#2536)
* Reject events with data URIs

* Reject events with URIs longer than 2,000 characters

* Update CHANGELOG.md
2022-12-21 15:53:04 +02:00
Marko Saric
ecd3ff276b
Some changes to the copy to keep it consistent with the main site 2022-12-21 12:32:48 +01:00
Vini Brasil
0e87b489f6
Return empty list when breaking down by event:page without events (#2530)
* Return empty list when breaking down by event:page without events

This commit fixes a bug with pagination where breaking down by event:page
would always return results despite pagination.

Closes #2255

* Update CHANGELOG.md
2022-12-19 13:49:03 +01:00
Uku Taht
a37b3433d7
Always show direct traffic in sources reports (#2531)
* Remove show_noref behaviour

Removes query param show_noref which was used from React to control
whether to show Direct / None traffic or not. The show_noref behaviour
was untested previously.

Closes #2523

* Add changelog entry

* Fix tests

* Removed files I did not mean to check in :)
2022-12-19 13:40:21 +01:00
Uku Taht
8f20bf0ab2
Add metric ID to HTML (#2518) 2022-12-19 12:21:15 +01:00
Vini Brasil
478e0c6990
Handle GA authentication errors (#2505) 2022-12-07 23:32:14 -03:00
ruslandoga
f95e67bec8
Release v1.5.1 (#2504)
### Changes

Preparations for `v1.5.1` release.

### Tests
- [x] This PR does not require tests

### Changelog
- [x] Entry has been added to changelog

### Documentation
- [x] This change does not need a documentation update

### Dark mode
- [x] This PR does not change the UI
2022-12-06 15:39:09 +02:00
ruslandoga
138e7c06d6
add BUILD_METADATA fallback when parsing (#2503)
### Changes

This PR adds a fallback to empty build metadata when BUILD_METADATA
contains invalid JSON.

Example `warning` log for `BUILD_METADATA={...}`:

```
20:57:57.872 [warning] failed to parse $BUILD_METADATA, reason: ** (Jason.DecodeError) unexpected byte at position 1: 0x2E (".")
```

Fixes https://github.com/plausible/analytics/issues/2491

### Tests
- [x] This PR does not require tests

### Changelog
- [ ] Entry has been added to changelog

### Documentation
- [x] This change does not need a documentation update

### Dark mode
- [x] This PR does not change the UI
2022-12-05 17:59:16 +02:00
ruslandoga
f9ab2650b3
Release v1.5.0 (#2490)
### Changes

Preparing for `v1.5.0` release.

### Tests
- [x] This PR does not require tests

### Changelog
- [x] Entry has been added to changelog

### Documentation
- [ ] [Docs](https://github.com/plausible/docs) have been updated

### Dark mode
- [x] This PR does not change the UI
2022-12-02 16:57:59 +02:00
Vini Brasil
9b32dace3e
Add Content-Security-Policy to favicon Plug (#2489) 2022-12-02 06:33:24 -03:00
Serafeim Papastefanos
fd6ebf7598
Trim the value in case it contains newlines (#2480)
### Changes

Hello friends, I'm trying to self-host plausible on my server and have
observed that if I add a file named (for example) `secrets/LISTEN_IP` to
configure the bind IP I'll get the following error:

```
Compiling 1 file (.ex)
** (RuntimeError) Invalid LISTEN_IP '172.19.130.83
' error: :einval
    /home/serafeim/plausible/config/runtime.exs:20: (file)
```

(notice that I get the same error when configuring the DATABASE_URL or
whatever comes first)

It seems that for whatever reason the File.read! will insert a newline
at the end of the file. Notice that I have double checked the file with
vim and *it does not contain a newline at the end* or at least I don't
know *how* to make the file not have a newline at the end.

Thus I'm adding a `String.trim()` there to fix that thing; even if I am
doing something wrong and my files *do* contain a newline at the end,
adding a `String.trim()` there definite won't hurt :)

Below you'll find a checklist. For each item on the list, check one
option and delete the other.

### Tests
- [ ] Automated tests have been added
- [x] This PR does not require tests

### Changelog
- [ ] Entry has been added to changelog
- [x] This PR does not make a user-facing change

### Documentation
- [ ] [Docs](https://github.com/plausible/docs) have been updated
- [x] This change does not need a documentation update

### Dark mode
- [ ] The UI has been tested both in dark and light mode
- [x] This PR does not change the UI
2022-11-30 10:12:48 -03:00
Vini Brasil
96182da57d
Update bamboo_postmark to fork repository (#2477)
This commit updates mix.exs to resolve bamboo_postmark to our fork. The
fork encodes names with quotes when building e-mails, adding support for
special names with commas and quotes. Related to
plausible/bamboo_postmark#1.

Closes #1885
2022-11-29 17:48:44 +02:00
Vini Brasil
90786cb3bc
Remove intervals feature flag (#2474)
This commit removes the intervals feature flag, as this feature has
already been released to 100% of the users.
2022-11-29 10:12:36 -03:00