Commit Graph

3101 Commits

Author SHA1 Message Date
Adrian Gruntkowski
bd93cf3b46
Refactor and consolidate user session logic (#4452)
* Extract session management from AuthController

* Don't explicitly pass `current_user_id` to `live_render`'s session

* Add ability to retrieve session and user from token via `UserAuth`

* Always fetch current user (or just id) via `UserAuth` API

* Introduce `UserSession` as an embedded schema for now

* Make `UserAuth.get_user/1` accept `UserSession` as an input

* Introduce LV auth context populating user data from session on mount

* Refactor `AuthPlug` and make it populate `current_user_session` as well

* Rely on authenticated user data provided by auth plug or LV context

* Make `Sites.get_for_user(!)` accept `User` struct as well

* Set `logged_in` cookie explicitly when it's out of sync with session

* Expand modules documentation a bit

* Improve and extend tests slightly
2024-08-23 10:53:33 +02:00
RobertJoonas
039790b82d
Prepare for graph v2 (#4451)
* add the ability to pass date param into Query.build

* stop returning interval from main_graph controller action

* globally rename 'date' interval to 'day'

* Allow parsing query date range from a 'period' param

The 'period' param will not be exposed in the public API, but makes it
possible to construct a "realtime" query.

* Revert "Allow parsing query date range from a 'period' param"

This reverts commit c5630eaef9.

* call beginning_of_time for first_datetime instead of last

* allow 'realtime' and '30m' date_range shortcuts

* evaluate date_range to 'realtime' or '30m' instead of Date.range(today, today)

* Revert "evaluate date_range to 'realtime' or '30m' instead of Date.range(today, today)"

This reverts commit a887569ec5.

* Revert "allow 'realtime' and '30m' date_range shortcuts"

This reverts commit 91ae0fa5e6.

* fix graph tooltips
2024-08-22 14:33:05 +03:00
Artur Pata
ef5bee43a1 Unify error handling and propose actions to user on error 2024-08-22 11:57:59 +03:00
Karl-Aksel Puulmann
11acadfde9
APIv2: docs-related changes (#4453)
* Order QueryResult in API response

This improves experience in docs when querying interactively

* More utm in seeds

* More improved seeds

* Proper QueryResult.query structure

* Allow docs to query /api/v2/query and sites

The new endpoints use cookie authentication. The docs site uses
these endpoints to provide an interactive docs editor.

* query_result ordering test

* Refresh router

* Test module name
2024-08-22 10:44:41 +03:00
Artur Pata
83b7a7ec53 Update Typescript config and add typecheck to CI 2024-08-21 12:40:22 +03:00
ruslandoga
2e37d99e18
update ecto and related deps (#4457) 2024-08-21 07:54:10 +02:00
ruslandoga
48dfce7a8b
update ecto_ch and use ecto hints for array joins (#4456) 2024-08-21 06:28:25 +02:00
ruslandoga
0328453e40
use ERL_FLAGS=+JMsingle true in ghcr.io images (#4450)
Co-authored-by: Cenk Kücük <cenk@plausible.io>
2024-08-19 13:30:55 +02:00
hq1
572f8abac5
First pass: unify onboarding UI (#4445)
* First pass: unify onboarding UI

* Dark mode fixes

* Format

* Update self-hosted index

* Remove unnecessary child box in Enter Your 2FA screen

* Fixup Enter Your 2FA screen
2024-08-19 09:10:54 +02:00
Cenk Kücük
3b485afc91
escape newlines in commit message (#4449)
* test description
2024-08-17 01:15:06 +02:00
Cenk Kücük
7f175a86e3
do not push private images to dockerhub anymore (#4447) 2024-08-17 01:08:54 +02:00
Cenk Kücük
1e31632a8a
Try-emojis (#4448)
* Try emojis for notification

* update msg
2024-08-17 01:00:19 +02:00
Cenk Kücük
4b6d8b6859
Send notification to chat when docker build was successful (#4446) 2024-08-17 00:46:30 +02:00
Adrian Gruntkowski
a20cb39652
Unify and refactor login regardless of trigger source (explicit/register) (#4434)
* Unify and refactor login regardless of trigger source (explicit or registration)

* Fix code formatting
2024-08-16 10:59:31 +02:00
Adrian Gruntkowski
77d841221b
Cut off 24h sites stats at respective native stats start dates (#4439) 2024-08-16 10:28:59 +02:00
hq1
0440d36577
Implement new onboarding/provisioning flow progress layout (#4441)
* Implement new onboarding/provisioning flow progress layout

* Delete dead template

* Fixup & test FlowProgress component
2024-08-16 10:07:48 +02:00
Artur Pata
8af3f7332a
Add testing framework (#4440)
* Add testing framework

* Test query period picking behaviour
2024-08-15 12:27:22 +03:00
hq1
4d4c9a8a21
Fix dark mode in clickhouse debug view (#4442) 2024-08-14 20:51:07 +02:00
Karl-Aksel Puulmann
4967960278
Populate log_comment with debug information, /debug/clickhouse route (#4435)
* Set log_comment with request information

* CRMAuthPlug -> SuperAdminOnlyPlug

* Super basic debug view

* Handle clustered setups

* Changelog entry

* Cleanup

* fragment trick to use ecto querying, filtering

* Move clustered_table? function to IngestRepo module

* Format

* More resilient user_id getting in helper
2024-08-14 12:33:36 +03:00
Cenk Kücük
9c1e198d05
validate that all checks passed (#4438) 2024-08-13 15:56:51 +02:00
RobertJoonas
d831a4e337
Enable search for Countries, Cities, and Regions Details views (#4436)
* enable search for locations details views

* update changelog
2024-08-13 12:40:32 +03:00
Karl-Aksel Puulmann
b88074bf1b
Fix migration typo (#4437) 2024-08-13 12:07:18 +03:00
Artur Pata
039f3baf8e
Add Typescript (#4427)
* Add typescript, rewrite Countries map

* Add back DB IP geolocation notice

* Silence all current eslint warnings: to be removed gradually

* Reconfigure eslint import plugin for typescript

* Insert formatting pragma by default, but ignore files without pragma in CI
2024-08-13 11:39:35 +03:00
Karl-Aksel Puulmann
ee3d1e770e
APIv2: visit:country_name, visit:region_name, visit:city_name dimensions (#4328)
* Add data migration for creating and syncing location_data table and dictionary

* Migration to populate location data

* Daily cron to refresh location dataset if changed

* Add support for visit:country_name, visit:region_name and visit:city_name dimensions

Under the hood this relies on a `location_data` table in clickhouse being regularly synced with
plausible/location repo and dictionary lookups used in ALIAS columns

* Update queue name

* Update documentation

* Explicit structs

* Improve docs further

* Migration comment

* Add queues

* Add error when already loaded

* Test for filtering by new dimensions

* Update deps

* dimension -> select_dimension

* Update a test
2024-08-13 09:44:58 +03:00
Karl-Aksel Puulmann
6a7fab6bb0
Clean up dead code in runtime.exs (#4432)
This caused quite a bit of confusion for cenk and I
2024-08-12 11:33:35 +03:00
Artur Pata
7d8b1cc19a Fix invalid rgba in stylesheet 2024-08-12 11:28:26 +03:00
ruslandoga
5e2a9563f7
Remove Timex.format (#4402) 2024-08-12 10:01:13 +02:00
Artur Pata
e2456ee215 Update assets dev dependencies
* Removes outdated precommit scripts
* Updates eslint, prettier, stylelint and their configurations: turns on plugins that were installed but off
* Fixes stylelint errors
* Applies prettier to css files
* Fixes new eslint errors
* Updates lint script to include both stylelint and eslint
2024-08-12 09:39:25 +03:00
Adrian Gruntkowski
4c5ce0f1fe
Fix flaky auth rate limit tests and refactor auth rate limiting (#4401)
* Add safeguard against flaky auth rate limit tests

* Fix typo in a log message

* Extract and abstract rate limiting from `AuthController`

* Fix flaky rate limit test tag

* Don't leak prefix from auth rate limit

* Use more compact map syntax

* Remove special tag in favor of `eventually` test util function
2024-08-09 14:58:34 +02:00
hq1
7fb2bfbd29
Migration: turn google auth tokens into text column type (#4428) 2024-08-09 12:17:26 +02:00
hq1
cc769dfb3d
Edit goals with display names (#4415)
* Update Goal schema

* Equip ComboBox with the ability of JS selection callbacks

* Update factory so display_name is always present

* Extend Goals context interface

* Update seeds

Also farming unsuspecting BEAM programmers for better
sample page paths :)

* Update ComboBox test

* Unify error message color class with helpers seen elsewhere

* Use goal.display_name where applicable

* Implement LiveView extensions for editing goals

* Sprinkle display name in external stats controller tests

* Format

* Fix goal list mobile view

* Update lib/plausible_web/live/goal_settings/list.ex

Co-authored-by: Artur Pata <artur.pata@gmail.com>

* Update lib/plausible_web/live/goal_settings/form.ex

Co-authored-by: Artur Pata <artur.pata@gmail.com>

* Update the APIs: plugins and external

* Update test so the intent is clearer

* Format

* Update CHANGELOG

* Simplify form tabs tests

* Revert "Format"

This reverts commit c1647b5307.

* Fixup format commit that went too far

* ComboBox: select the input contents on first focus

* Update lib/plausible/goal/schema.ex

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>

* Update lib/plausible/goals/goals.ex

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>

* Update lib/plausible_web/live/goal_settings/form.ex

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>

* Pass form goal instead of just ID

* Make tab component dumber

* Extract separate render functions for edit and create forms

* Update test to account for extracted forms

* Inline goal get query

* Extract revenue goal settings to a component and avoid computing assigns in flight

* Make LV modal preload optional

* Disable preload for goal settings form modal

* Get rid of phash component ID hack

* For another render after render_submit when testing goal updates

* Fix LV preload option

* Enable preload back for goals modal for now

* Make formatter happy

* Implement support for preopening of LV modal

* Preopen goals modal to avoid feedback gap on loading edited goal

* Remove `console.log` call from modal JS

* Clean up display name input IDs

* Make revenue settings functional on first edit again

* Display names: 2nd stage migration

* Update migration with data backfill

---------

Co-authored-by: Artur Pata <artur.pata@gmail.com>
Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-08-09 11:12:00 +02:00
hq1
2e6ba4ba42
Display names: 1st stage migration (#4425)
* Display names: 1st stage migration

* Trim migration scope for the 1st run
2024-08-09 10:51:31 +02:00
Artur Pata
f9ea5444b0
Fix legacy compatibility redirect (#4424) 2024-08-06 19:39:29 +03:00
RobertJoonas
1f8662438d
Add Details modals for all Devices reports (#4419)
* return concatenated browser names and versions directly from the API

* return concatenated os names and versions directly from the API

* add detailed views for all device reports

* extract put_combined_name_with_version function

* return only version under the name key when detailed=true

* update changelog

* add more metrics into detailed views of Devices reports

* split up different devices modals into separate files
2024-08-02 15:50:22 +03:00
Artur Pata
21372b2a7b
Fix the issue with JsonURL.parse failure (#4414) 2024-07-31 19:21:57 +03:00
Uku Taht
2f9ca72fd6
Expose goal contains filter in dashboard (#4412)
* Expose goal contains filter in dashboard

* CHANGELOG
2024-07-31 16:49:21 +03:00
Artur Pata
7bf2c5b189
Reapply conversions details button (#4413) 2024-07-31 16:48:22 +03:00
Artur Pata
6c4c078347
Update react-router to version 6 (#4408)
* Update react-router to version 6

* Update url search params polyfill and use forEach API instead
2024-07-31 16:29:03 +03:00
Uku Taht
b868042581
Refactor: remove transform_filters function from imported base (#4409) 2024-07-31 15:36:25 +03:00
Uku Taht
d73ed8fe7c
Goal detail tweaks (#4410)
* Always show details modal for goal conversions

* Make metrics smaller in breakdown table

So that revenue metrics fit

* So that revenue metrics fit

* Add more space for dimension value in breakdown modal
2024-07-31 15:19:11 +03:00
Marko Saric
cad7ae7f53
Change the example in the hostname block (#4403)
* Update hostname_rules.ex

* Update hostname_rules.ex
2024-07-31 15:18:38 +03:00
Uku Taht
e4ef3f2888
Add changelog for searching goals (#4407) 2024-07-31 10:26:11 +03:00
Uku Taht
0ac196d3d9
Improve how long URLs are displayed in dashboard (#4405)
* Do not truncate text in modals

* Add filter value to filter tooltip

* Show title for add filter links in ListReport and BreakdownModal
2024-07-31 10:21:41 +03:00
Uku Taht
a1ee58426e
Implement goal contains filter + search in Conversions > Details (#4404)
* Implement goal contains

* add search into ConversionsModal

---------

Co-authored-by: Robert Joonas <robertjoonas16@gmail.com>
2024-07-31 10:21:30 +03:00
Uku Taht
05b70e37a8
Generate goal filter SQL from postgres goals (#4391)
* Use goals from postgres to build goal filter

* Remove unnecessary goal preloading

* Add contains filter for goals

* Make sure the correct imported tables are used when goals are in filters

* Remove 'contains' filter type for now

* Remove TODO comment

* Fix QueryParser test

* move goals.ex into a goals subfolder

* extract goal filtering logic into a separate module

* remove duplication from Imported.Base

* Extract `get_filter_goals` function

* Credo suggestions

* Credo ignore nesting

* apply suggestion - remove Sql.Util

* apply suggestion - pass imported? via opts

* remove duplicate function

* Uncomment tests

* Fix 500 error with goal suggestions

---------

Co-authored-by: Robert Joonas <robertjoonas16@gmail.com>
2024-07-30 12:07:23 +03:00
Adrian Gruntkowski
783740468d
Update ua_inspector fork to sanitize multi-part prereleases properly (#4398)
* Update `ua_inspector` fork to sanitize multi-part prereleases properly

* Add regression tests

* Make another version bump to include a fix for a missed corner case
2024-07-29 11:10:27 +02:00
Artur Pata
785bacbaf7
Fix extraneous link fragment (#4400) 2024-07-29 09:45:26 +03:00
Adrian Gruntkowski
556c896936
Add ability to lookup by email and site domain in HelpScout integration (#4377)
* Add ability to lookup by email and site domain in HelpScout integration

* Handle callback with invalid parameters gracefully

* Add routine adjusting iframe height to the content of HS integration

* Add requestStorageAccess routine to support iframe cookies in Safari

* Fill first email pick when on failed user lookup

* Fix a typo in a comment
2024-07-26 16:26:51 +02:00
RobertJoonas
37014c86a8
Tracking improvements (#4392)
* track browser_language, theme, and logged_in for 'Filter Menu: Open'

* track props for 'Signup' and 'Signup via invitation'

* do not track theme as 'system' for non-logged-in users

* fix tests
2024-07-26 15:24:55 +02:00
Adrian Gruntkowski
df5e2cba12
Create migration adding help_scout_mappings table (#4395) 2024-07-26 15:22:59 +02:00