Commit Graph

691 Commits

Author SHA1 Message Date
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
Artur Pata
785bacbaf7
Fix extraneous link fragment (#4400) 2024-07-29 09:45:26 +03: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
c862f15f0c
Revert "Install newest @tanstack/react-router (#4384)" (#4393)
This reverts commit 28cf3ff2b2.
2024-07-26 11:58:58 +02:00
Artur Pata
28cf3ff2b2
Install newest @tanstack/react-router (#4384)
* Install @tanstack/react-router

* Fix with imported switch

* Refactor redirect to new search parser

* Deregister timeout in ComparisonInput

* Comment uses of window.location

* Fix with imported switch appearing in realtime dashboard

* Handle not found routes more gracefully
2024-07-24 15:14:00 +03:00
RobertJoonas
2f87832532
Implement search and pagination in Google Keywords modal (#4378)
* Extend the GSC API with search functionality

* Fix typo in error tuple atom

* log GSC errors

* rename confusing variable name

* Fix the API response format and error handling

* Read results under the `results` key to be consistent with other
  endpoints

* Return errors with a non-200 status code, and with an error payload
  that will be well constructed into ApiError

* rebuild Google Keywords modal with useAPIClient

* Add pagination support in Search Terms API

* delete unused fixture file

* rename fixture files

* fix tests
2024-07-23 11:53:52 +03:00
RobertJoonas
afc2fbaeb2
fix location labels (#4382) 2024-07-23 11:53:29 +03:00
RobertJoonas
2edf3c94a3
fix sending endpoint prop from sources and countries modals (#4376) 2024-07-22 11:42:52 +03:00
Artur Pata
1acbbf292f
Install react-query (#4361)
* WIP

* Fix issue with more than one page cached

* Make sure we don't access properties of undefined objects

* slight cleanup

* reset limit to 100

* add back the bottom loading spinner when fetching next page

* disable refetchOnWindowFocus in the global queryClient

* render bottom loading spinner only when fetching next page

* create a wrapper for react-query

* fix exhaustive deps warnings in modals

* always pass the full api path to BreakdownModal

* improve function doc

---------

Co-authored-by: Robert Joonas <robertjoonas16@gmail.com>
Co-authored-by: RobertJoonas <56999674+RobertJoonas@users.noreply.github.com>
2024-07-22 11:09:45 +03:00
hq1
1c39f06ae8
Add curl browser icon (#4372) 2024-07-18 15:30:28 +02:00
hq1
1488683d26
Implement UI to edit existing funnels (#4369)
* Update tailwind config

Turns out `extra` wasn't scanned properly with
previous wildcards. I don't care any more, it's not slow.

* Add interface for updating funnels

* Extend ComboBox with the ability to preselect an initial value

* Implement editing funnels UI

* Update CHANGELOG

* s/add_funnel/setup_funnel

* modal width 2/5 => 2/3

* Let's not make the list disappear on modal pop-up

* Fix the damn modal width again

* Watch extra dir

* Format

* Remove commented code

The test is implemented elsewhere

* Track funnel modified to drop default selection

* Fix screen size adoption and format large numbers

* Preserve currency so that string casting includes it

* Format

* Fix ComboBox attribute for preselected option
2024-07-17 22:04:36 +02:00
RobertJoonas
5a58b5cb99
Fix debounce (#4349)
* Replace useDebouncedEffect with useDebounce

This commit refactors the debouncing mechanism in a more extendable way.
Using debounce as a hook that returns a callback (rather than an effect)
makes it reusable for Combobox. This way the useDebounce hook does not
need to worry about whether the function should be called on the first
render or not.

This commit also gets rid of redundant doubled search state.

* rename input to search in Combobox

* Fix debounce in Combobox

* remove debounce-promise

* Fix React CI warnings in PlausibleCombobox

* Silence NPM CI in custom-hooks.js

* cancel scheduled API calls in useDebounce hook when unmounted
2024-07-16 12:15:45 +03:00
Uku Taht
42d2a6f3b3
Nicer keybind hint styling (#4336)
* Nicer keybind hints

* Make hints the same size
2024-07-15 13:06:14 +02:00
Artur Pata
79188a90b7
Remove query and site props passing from everywhere except class components (#4340)
* Remove query and site props passing from everywhere except class components

* Fix invalid import
2024-07-12 10:59:26 +03:00
hq1
a2497f6f8c
Open verification modal when following drop notification link (#4344)
* Open verification modal when following drop notification link

* Add test

* Fixup

* Move `open-modal` event to Components.Modal API
2024-07-12 06:26:40 +02:00
Artur Pata
2dd2f058d1
Alleviate props passing: institute UserContext, QueryContext, SiteContext (#4334)
* Alleviate props passing: institute UserContext, QueryContext, SiteContext

* Remove unnecessary memo, fix SiteContext defaultValues
2024-07-10 17:02:05 +03:00
Karl-Aksel Puulmann
ef2e277f89
fix(suggestions): Properly provide suggestions (#4332)
* fix(suggestions): Properly provide suggestions

Previously, if a filter was applied then filter modal suggestions would
_always_ apply the previous suggestion. Now when say applying a `page`
filter suggestions we remove the previous `page` filter.

* Improve readability
2024-07-10 12:06:16 +03:00
Karl-Aksel Puulmann
7aff0760aa
APIv2: Allow sending numbers for visit:city along with strings (#4313)
* Allow sending numbers for visit:city along with strings

This simplifies querying as we pass the list of cities as numbers to clients

* use &is_integer/1

* Remove redundancy
2024-07-10 11:29:21 +03:00
RobertJoonas
8c6234604a
Modal Search Continued (#4326)
* update changelog

* remove redundant noop

* capitalize changelog entry
2024-07-09 16:31:32 +03:00
RobertJoonas
7d0321fd22
Implement search in Details views (#4318)
* Create a new BreakdownModal component and use it for Entry Pages

* Add search functionality into the new component

* Adjust FilterLink component and use it in BreakdownModal

* pass addSearchFilter fn through props

* pass fn props as useCallback

* add a function doc to BreakdownModal

* refactor: create a Metric class

* Fixup: use Metric class for defining BreakdownModal metrics

* keep revenueAvailable state in the Dashboard component

* move query context into a higher-order component

* fix react key error in BreakdownModal

* use BreakdownModal in PropsModal

* adjust EntryPagesModal to use query context

* fix variable name typo

* fixup: BreakdownModal function doc

* use BreakdownModal in SourcesModal

* use Breakdown modal in ReferrerDrilldownModal

* use BreakdownModal in PagesModal

* use BreakdownModal in ExitPagesModal

* replace ModalTable with LocationsModal and use BreakdownModal in it

* use BreakdownModal in Conversions

* make sure next pages are loaded with 'detailed: true'

* replace loading spinner logic in BreakdownModal

* fix two flaky tests

* unfocus search input element on Escape keyup event

* ignore Escape keyup handling when search disabled

* Review suggestion: remove redundant state

* do not fetch data on every search input change

* use longer variable names

* do not define renderIcon callbacks conditionally

* deconstruct props in function header of BreakdownModal

* refactor searchEnabled being true by default
2024-07-09 15:01:52 +03:00
Karl-Aksel Puulmann
a181f3eab3
APIv2: TimeSeries using QueryBuilder, release experimental_session_count (#4305)
* Move fragments module under Plausible.Stats.SQL

* Introduce select_merge_as macro

This simplifies some select_merge calls

* Simplify select_join_fields

* Remove a needless dynamic

* wrap_select_columns macro

* Move metrics from base.ex to expression.ex

* Move WhereBuilder under Plausible.Stats.SQL

* Moduledoc

* Improved macros

* Wrap more code

* select_merge_as more

* Move defp to the end

* include.time_labels parsing

* include.time_labels in result

Note that the previous implementation of the labels from TimeSeries.ex was broken

* Apply consistent function in imports and timeseries.ex

* Remove boilerplate

* WIP: Limited support for timeseries-with-querybuilder

* time:week dimension

* cleanup: property -> dimension

* Make querying with time series work

* Refactor: Move special metrics (percentage, conversion rate) to own module

* Explicitly format datetimes

* Consistent include_imported in special metrics

* Solve week-related crash

* conversion_rate hacking

* Keep include_imported consistent after splitting the query

* Simplify do_decide_tables

* Handle time dimensions in imports cleaner

* Allow time dimensions in custom property queries

* time:week handling continued

* cast_revenue_metrics_to_money

* fix `full_intervals` support

* Handle minute/realtime graphs

* experimental_session_count? with timeseries

This becomes required as we try to include visits from sessions by default

* Support hourly data in imports

* Update bounce_rate in more csv tests

* Update some time-series query tests

* Fix for meta.warning being included incorrectly

* Simplify imported.ex

* experimental_session_count flag removal

* moduledoc

* Split interval and time modules
2024-07-09 14:25:02 +03:00
Uku Taht
0da3517502 Hotfix for React map 2024-07-09 13:52:31 +03:00
Uku Taht
0bbe41eeae
Bump react major version to 18 (#4324)
* Bump react to 18

* Remove react-collapse
2024-07-09 13:23:04 +03:00
Uku Taht
b3669540bd
OS icons (#4254)
* Add popular OS icons

* Show OS name and icon in drilldown as well

* Fix OS version filter links
2024-07-09 13:22:37 +03:00
hq1
8733294d1b
Fix URLs breaking on date picker navigation (#4323)
This prevents the date picker from updating the URL
with data domain on each subsequent use. Only the query
string should be updated.
2024-07-09 10:52:00 +02:00
Marko Saric
379714c133
removing HI from the Top Pages details view (#4306) 2024-07-03 16:10:47 +02:00
hq1
839691d29f
Bugfix: custom props modal opens up with no filters (#4301) 2024-07-02 14:45:48 +02:00
hq1
c871759fc1
Bugfix: opening details UTM sources modal (#4295) 2024-07-01 12:39:55 +02:00
hq1
8188006c45
Fix new tab links + shared links losing URL context (#4278)
* Fix dashboard new tabs + preserve state for shared links

* Modal no longer needs site
2024-07-01 06:52:35 +02:00
Adam Rutkowski
5fae58e5e7 Revert "Make new tab dashboard links work (#4276)"
This reverts commit fa065c85a3.
2024-06-25 15:15:06 +02:00
hq1
fa065c85a3
Make new tab dashboard links work (#4276)
* Make new tab dashboard links work

* Urlencode domain

* Recognize shared links
2024-06-25 14:41:09 +02:00
Karl-Aksel Puulmann
70fca3e8d1
Fix browser version linking (#4259)
This was broken in https://github.com/plausible/analytics/pull/4246.

See also: https://3.basecamp.com/5308029/buckets/26383192/card_tables/cards/7514532175
2024-06-25 11:25:28 +03:00
hq1
59b1811368
Add max height/overflow to funnel picker (#4265) 2024-06-24 13:52:14 +02:00
Karl-Aksel Puulmann
284b4ebbf6
does_not_contain, new filters wildcard matching (#4228)
* Make goals accept wildcards in :is queries

* Add support for contains/does_not_contains in the backend

* Support all operations for event custom properties

* Support does_not_contain on the frontend

* Changelog entry

* Render filter operations nicely for does not contain

Found 3 extra pixels for operation dropdown

* Remove multiple_filters feature flag
2024-06-21 11:32:05 +03:00
Karl-Aksel Puulmann
ed8abf426b
Revert "Revert "Re-apply multiple filters in FE (#4219)" (#4223)" (#4227)
This reverts commit 2c05676d8e.
2024-06-21 11:31:02 +03:00
Adrian Gruntkowski
a7ddc1a141
Autoselect prop key (#4253)
* Autoselect propkey on opening properties breakdown

* reset propkey when query changes

* ignore custom prop filter when selecting a prop key

* throttle api requests

* Force loading state on combobox when loading propkey

* Remove artificial throttling of API requests

* Disable combobox when no prop keys are found

* drop prop_key and set loading true when query changes

* Update changelog

---------

Co-authored-by: Robert Joonas <robertjoonas16@gmail.com>
Co-authored-by: RobertJoonas <56999674+RobertJoonas@users.noreply.github.com>
2024-06-21 11:02:39 +03:00
Uku Taht
486ee68ca8
Browser icon improvements (#4246)
* Use png for Safari icon

* Fix spacing for screen sizes

* Add browser icon to version drilldown
2024-06-20 17:32:08 +03:00
hq1
e453d364d4
Add WP Search Queries special goal (#4250) 2024-06-20 09:33:04 +02:00
Uku Taht
0060954372
Add browser icons (#4239)
* Add popular browser icons

* Adjust fallback icon color for dark mode

* Add changelog

* Add MIUI browser logo

* Fix Edge and MacOS in seeds

* Add smaller browser logos
2024-06-18 12:45:08 +03:00
Karl-Aksel Puulmann
2c05676d8e
Revert "Re-apply multiple filters in FE (#4219)" (#4223)
This reverts commit 77520390f8.
2024-06-13 12:45:50 +03:00
Karl-Aksel Puulmann
77520390f8
Re-apply multiple filters in FE (#4219)
* Revert "Revert "Multiple filters on the frontend (#4174)" (#4218)"

This reverts commit 2f7dcae991.

* Make city links work again

By enforcing everything sent to the BE is stringified. We do this at serialization-time to ensure old dashboard links still work
2024-06-13 09:56:15 +03:00
hq1
2f7dcae991
Revert "Multiple filters on the frontend (#4174)" (#4218)
This reverts commit e1f0002d2e.
2024-06-11 17:42:07 +03:00
Karl-Aksel Puulmann
e1f0002d2e
Multiple filters on the frontend (#4174)
* Add new logic for query parsing

Note this is not yet final, but this scaffolding will soon be used

* Send filters to BE in new encoding, flag add more button

* query.property -> query.dimensions

* Reduce number of operations for filtering

This helps ensure we can be consistent/simple with apiv2

* Update search console filter mapping

* Update filters sent from frontend

* Update new filter parsing

* Remove redundant clause

* Make filtering by event:goal work

* Handle * as old backend did - prefix/suffix by **, if not using wildcards already

* Update imports logic

* Credo warning

* Spacing for add row button in filter modals

* query fix

* LegacyDashboardFilterParser

* only single hostname filter allowed

---------

Co-authored-by: Uku Taht <uku.taht@gmail.com>
2024-06-11 14:22:53 +03:00
RobertJoonas
56a9a1c72d
Make sure initial load re-evaluates viewport width (#4214) 2024-06-11 13:28:59 +03:00
RobertJoonas
f6360b8241
Reapply Filters component refactor + fix regression (#4213)
* Revert "revert filters.js from 14cf650 (#4208)"

This reverts commit 4edeed33ca.

* fix bug with wrong var name

* Do not cancel api requests on the first dashboard render
2024-06-11 13:15:24 +03:00
RobertJoonas
4edeed33ca
revert filters.js from 14cf650 (#4208) 2024-06-10 17:27:20 +03:00
RobertJoonas
14cf6501c3
Refactor: Move from class to function components in React (#4198)
* Remove dead code (ComparisonContext)

The state of ComparisonContext is never read. We are storing all the
necessary state either in localStorage or in the `query` object.

* turn Filters into a fn comp

* turn Dashboard and CurrentVisitors into fn components

* turn Realtime into a fn comp

* Turn QueryLink into a fn comp

Also fix the "staticContext" console error when opening the period picker.
We don't need to pass all props into the Link component.

* extract a WRAPSTATE object
2024-06-10 13:03:39 +03:00
RobertJoonas
b49bbbc8bb
fix with-imported-switch for safari (#4194) 2024-06-06 13:04:00 +03:00
RobertJoonas
2a529b4eaa
Fix with imported switch + warning bubble renders (#4187)
* prioritize other skip_imported_reasons over not requested

* return with_imported_switch info from top stats

* fix the with-imported-switch component

* Refactor ImportedQueryUnsupportedWarning

* do not render warning bubble when imported data not requested

* stop displaying warning bubble before the API response is received

* fix tab switch pills jumping due to bubble height

* drop loading condition of ImportedQueryUnsupportedWarning for Funnels

* add explicit check for realtime when rendering the bubble

* remove unused JS imports

* rename snake_case to camelCase
2024-06-06 11:50:54 +03:00
Karl-Aksel Puulmann
272fdb81d0
Fix parsing = in jsonurl (#4185)
* Fix parsing = in jsonurl

This works around a bug in the jsonurl library where the literal causes a syntaxerror.
The urlencoded = however is handled without errors

* Changelog
2024-06-04 13:06:19 +02:00
RobertJoonas
1d3b068233
Implement filtering for imported data (#4118)
* move imported.ex to imported subfolder

* move constructing base imported query into a separate module

* Implement imported table deciding and filtering

+ tests for pages, entry_pages, exit_pages and common filter types

* add top stats test with country filter

* add timeseries test

* Drop bounce_rate and time_on_page from imported & page-filtered Top Stats

* rename field returned by top stats

* turn pages into a fn comp

* Move dashboard API results under a results key

...and also return the skip_imported_reason to the frontend to be used
for displaying warnings.

* extend ListReport component with an optional afterFetchData prop

* turn Devices into a fn comp

* add not_requested as a skip_imported_reason

* display warning icons in the dashboard

* Implement filtering suggestions and translate filter fields for imported

* WIP

* Improve and cover filtering suggestions with tests

* Rename imported suggestions query helpers

* fix screen size breakdown with screen size filter

* support filtering by the same suggestion property

* support location filters when fetching location suggestions

* support filtering by multiple props from the same table

* Implement filtering by goals

* Make views per visit metric work for import entry and exit pages

* Get rid of circular dependencies between Stats.Imported and Stats.Imported.Base

* Clean up Query struct manipulation in Breakdown

* Rename helper function for clarity

* Automatically refresh query struct state after modifications

* Shutup credo

* display imported warning bubble in prop breakdown section

* Render warning bubble for funnels whenever imported data is in the view

* Transform any operator on respective goal filters

* Fix percentage and conversion_rate calculation in presence of custom props

* add tests for for combining page and pageview goal filters

* add skip_refresh option to query tweaking functions

* add imported CR support for timeseries

* still show url breakdown when special goal + url in filter

* rename Query.refresh

* use flat_map instead of map and concat

* fix darkmode color

* Handle invalid imported region codes in suggestions gracefully

* Add an entry to CHANGELOG.md

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-06-03 12:29:08 +02:00
RobertJoonas
57e28f0da6
Make React frontend capable of reading API results under a results key (#4159)
* Make React frontend capable of reading API results under a results key

* remove redundant double negation

* Update assets/js/dashboard/stats/modals/props.js

add length key back

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

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-05-31 09:01:15 +01:00
Karl-Aksel Puulmann
e5c3eabe31
Fix linking in dashboard sources/utm details modal (#4151)
This was broken by a recent refactor and the links did not filter properly
2024-05-28 13:28:56 +02:00
RobertJoonas
4d7a67d294
Fix setting with_imported to false explicitly in the URL (#4148) 2024-05-27 15:27:23 +02:00
hq1
c81cb16933
Snippet integration verification (#4106)
* Allow running browserless.io locally

* Compile tailwind classes based on extra/ too

* Add browserless runtime configuration

* Ignore verification events on ingestion

* Improve extracting HTML text in tests

* Update dependencies

- Floki will be used on production to parse site contents
- Req will be used to handle redundant stuff like retrying etc.

* Add shuttle SVG to generic components

Later on we'll use it to indicate verification errors

* Connect live socket & allow skipping awaiting the first pageview

* Connect live socket in general settings

* Implement verification checks & diagnostics

* Stub remote services with Req for testing

* Change snippet screen copy

* Update tracker script, so that:

1. headless browsers aren't ignored if `window.__plausible` is defined
2. callback optionally supplies the event response HTTP status

This will be later used to check whether the server acknowledged
the verification event.

* Implement LiveView verification UI

* Embed the verification UIs into settings and onboarding

* Implement browserless puppeteer verification script

It:
 - tries to visit the site
 - defines window.__plausible, so the tracker doesn't ignore test events
 - sends a verification event and instruments the callback
 - awaits the callback to fire and returns the result

* Improve diagnostics for CSP

Only report CSP error if the snippet is already found

* Put verification behind a feature flag/env setting

* Contact Us hint only for Enterprise Edition

* For headless code, use JS context instead of EEx interpolation

* Update diagnostics test with WordPress scenarios

* Shorten exception/throw interception

* Rename test

* Tidy up

* Bust URL always on headless check

* Update moduledoc

* Detect official Plausible WordPress Plugin

and act accordingly on diagnostics interoperation

* Stop using 'rating' in favour of 'interpretation'

* Only report CSP error if no proxy is likely

* Update CHANGELOG

* Allow event-* attributes on snippet elements

* Improve naive GTM detection, not to confuse it with GA4

* Update lib/plausible/verification.ex

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

* Update test/plausible/site/verification/checks_test.exs

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

* s/perform_wrapped/perform_safe

* Update lib/plausible/verification/checks/installation.ex

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

* Remove garbage

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-05-23 15:00:50 +02:00
Karl-Aksel Puulmann
850cc30e7a
Fix opening a filter modal (#4123)
Follow-up to #4117

Opening a utm modal crashed if there was an existing page filter. Bug
struck in during a refactoring.
2024-05-23 10:54:08 +03:00
Karl-Aksel Puulmann
ab1416ba10
Fix special goal conversions (#4122)
Follow-up to https://github.com/plausible/analytics/pull/4117

Special goals (e.g. 404, Outbound link click) always reported (none) as
results due to a function returning the wrong value.
2024-05-23 10:53:54 +03:00
Karl-Aksel Puulmann
23a6431adb
Frontend: Use jsonurl, update filtering (#4117)
* Start refactoring, supporting jsonurl

* WIP: Listing of applied filters works

* WIP: Remove some unneeded hackery

* WIP: Handle country labels better

* WIP: Handle multiple filters better

* WIP: Serializing filters for API queries

* Split modal code into 3

* Merge code paths for prop and other filter modals

* Get suggestions working again

* Display prop filters properly

* Handle re-opening a props modal properly

* Better label handling

* Better linking to filter modals

* Remove unneeded component

* Standardize how we update query more

* Use updatedQuery to remove more usecases of URLSearchParams

* Dont export toFilterQuery

* Custom toString for PlausibleSearchParams

* Fix props suggestions/filtering

* Refactor isFilteringOnFixedValue

* Improved encoding - goals now work again

* fix a typo

* Handle more cases where query.filters[ is used

* Fix locations tab changing behavior

* Fix for `setQuery` not to double up ?

* Handle goal filters properly now

* Delete dead code

* Update special goals handling

* Update <ListReport /> linking

* Show labeled values in list of filters

* Updae Props component handling of storage keys

* re-add special case handling in devices view

* Fix modal-related typo

* Get updatedQuery callsites working

* Update location modals linking

* Update props details model linking logic

* Switch back tab from props when removing goal filter

* Remove query.filters usage from within <Referrers /> component

* Private escapeFilterValue

* Fix sources/index.js

* Legacy redirect logic

* Update comment

* Disabled options in props modal

* Update escaping and is_not operator

* Restore `false` search property handling meaning unset

* changelog

* Fix filtering after clicking on a map

* FilterOperatorSelector

* replaceFilterByPrefix

* Improve naming for filter modals/groups
2024-05-22 11:01:41 +03:00
Uku Taht
b2860d1602
Fix unselecting filter from filter modal (#4109) 2024-05-21 09:23:57 +02:00
Uku Taht
06e8118dab
Filtering Search Console keywords (#4077)
* Apply filters in search console request

* Remove dead code from search console modal

* Remove unimportant information from keyword modal

* Show invalid filters from search console

* Fix tests

* Add/Fix tests

* Fix typo

* Remove unused variable

* Fix typo

* Changelog entry

* Fix Credo

* Display impressions, CTR and position in keyword modal

* Undo change that should not have been committed

* Fix test

* Fix test

* filters -> search_console_filters
2024-05-14 09:56:55 +03:00
Adrian Gruntkowski
d7ca8d9600
Revert "Debug queries for super-admins (#4010)" (#4073)
This reverts commit dd493fdad2.
2024-05-06 15:05:17 +02:00
Karl-Aksel Puulmann
bcde2b8cf2
Add Yesterday as an time range option in the dashboard (#4040) 2024-05-02 14:57:10 +03:00
hq1
dd493fdad2
Debug queries for super-admins (#4010)
* Debug queries for super-admins

* Fixup

* Update lib/plausible/clickhouse_repo.ex

Co-authored-by: ruslandoga <doga.ruslan@gmail.com>

* Try again with https://github.com/plausible/analytics/pull/3699

It's still clunky 😅

Co-authored-by: Karl-Aksel Puulmann <macobo@users.noreply.github.com>
Co-authored-by: ruslandoga <doga.ruslan@gmail.com>

* Move headers injection to a separate plug module

* Add tests

* Update repo test

* Format

* Add moduledoc

* Don't assume order in query_log

* Be patient about query_log maybe?

* huh?

* huh2

* Wait longer

* Guard against \x00 in response header - testing on stage

* Fixup

* fixup

* fixup

* s/debug_label/label

* Include `site_id` and `metadata` in `log_comment`

* Tolerate non-serializable log_comment contents

---------

Co-authored-by: ruslandoga <doga.ruslan@gmail.com>
Co-authored-by: Karl-Aksel Puulmann <macobo@users.noreply.github.com>
2024-04-30 09:57:28 +02:00
hq1
83643450c4
Remove obsolete feature flags (#4026) 2024-04-18 20:18:38 +02:00
RobertJoonas
f49bdef7dd
Fix main graph intervals (#4024)
* make sure valid intervals consider custom range

* make default intervals per period more logical

* remove unused function

* adjust defaults for custom range
2024-04-18 15:01:47 +01:00
Marko Saric
09612e21e7
Update search-terms.js (#4016) 2024-04-16 16:08:09 +02:00
hq1
f9f0407d68
Remove experimtnal_hostname_filter and keep it on by default (#3973)
* Remove `experimental_hostname_filter` and keep it on by default

* Catch up with changes done via e5b56dbe6
2024-04-04 17:20:16 +02:00
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
2024-04-04 13:39:55 +01:00
hq1
6af80dd246
Filter by hostnames (#3963)
* CH Migration: exit/entry hostnames in sessions_v2

* Leave only exit_page_hostname, we already record hostnames

* Use ClickHouse DDL in favour of ecto so that cluster is included

* Compress with ZSTD(3)

* Expose Hostname filter in the dashboard dropdown

* Add `exit_page_hostname` to ClickHouse `sessions_v2` schema

* Start tracking hostname changes in sessions

* Implement hostname filter suggestions

* Enable filtering by `event:hostname`

* Add tests for filtering by hostnames

* Ensure filter suggestions work for exit pages too

* Allow overriding hostnames with `send_pageview` mix task

* Remove `:window_time_on_page` flag

It seems that we can remove it after all?

* Initialize `experimental_hostname_filter` query parameter

* Rewrite cache store behaviour with regards to session hostnames

* Work around inconsistent session merging

So that `populate_stats` can get closer to actual ingestion

* Improve top stats test

* Make it possible to filter sessions by entry/exit hostnames

* Update pages tests

* Expose `experimental_hostname_filtering` temporarily in the UI

* Untested yet: also apply experimental filtering to sources

* Introduce `hostname_filter` feature flag

* Format

* Test top sources with hostname filter + experimental flag
2024-04-04 10:48:30 +02:00
Adrian Gruntkowski
23a3699dd7
Improve import stats toggle and with_imported flag computation (#3960)
* Check import presence across all imports and not just the first one

Also, simplify imported data toggle rendering to not explicitly
refer to the earliest import source.

* Change imported stats toggle icon in dashboard

* Test `Imported.get_imports_date_range/1`

* Simplify failed UA/GA import email copy
2024-04-02 12:53:19 +02:00
ruslandoga
c263df5805
CSV imports (UI) (#3845)
* add basic ui

* remove TODO

* credo

* allow folder upload

* redirect external

* mention folder, use folder icon for file picker

* back to multiple file upload

* mention zip

* escape dots in archive filename
2024-03-26 12:55:14 +01:00
Uku Taht
1d017e86a1
Fix escaping of source filters (#3930)
* Fix escaping of source filters

* CHANGELOG

* Fix typo

Co-authored-by: Karl-Aksel Puulmann <macobo@users.noreply.github.com>

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
Co-authored-by: Karl-Aksel Puulmann <macobo@users.noreply.github.com>
2024-03-22 11:16:44 +01:00
RobertJoonas
fb61f0b425
Capitalize Total Conversions in graph tooltip (#3934) 2024-03-22 09:51:17 +00:00
RobertJoonas
d6e1e8bebd
Put total conversions on the graph + goal-filtered CSV export improvements (#3929)
* Add validation for the events metric in main_graph

* Test the already existing events metric support in main-graph

* Put total conversions on the graph

* extract main_graph_csv function (refactor only)

* add total_conversions and conversion_rate to goal-filtered visitors.csv

* update changelog
2024-03-22 09:35:23 +00:00
Uku Taht
561dcd821e
Mask pathanme in filter menu event (#3932) 2024-03-22 10:25:10 +02:00
Uku Taht
8992c8ee07
Add tracking to filter button (#3928) 2024-03-21 17:44:51 +02:00
RobertJoonas
c32779a3e5
Timeseries for conversion rate (#3919)
* add conversion rate to Stats API timeseries

* make sure CR can be queried as the only metric

* add a test asserting zeros are returned

* add tests for filtering by other properties at the same time

* Remove unnecessary validation of params

1. It doesn't make to validate `interval` (and its granularity) in all
   endpoints. It's only relevant for the main graph.

2. The plug (renamed to `date_validation_plug`) already makes sure that
   the dates are validated. No need to call the same function again in
   Top Stats and Funnel endpoints.

* add metric validation to main graph

* Add tests for main graph API

* put conversion rate on the graph

* update changelog

* Add revenue metrics into metrics.ex

* make fn private

* avoid setting graph metric to visitors in goal-filtered view
2024-03-21 13:58:00 +00:00
Karl-Aksel Puulmann
d3586a81e3
UX improvement: don't autofocus on Custom properties on dashboard (#3872)
* UX improvement: don't autofocus on Custom properties on dashboard

Currently when you visit the dashboard with a certain configuration,
it will automatically scroll to the bottom, which is annoying.

To reproduce:
1. localStorage.clear() in console
2. Refresh, open properties at the very bottom
3. Refresh again

Expected behavior:
1. Dashboard shows

Actual behavior:
1. Dashboard scrolls to the bottom

* Changelog entry
2024-03-14 10:36:57 +02:00
hq1
518cdb3307
Shield: Country Rules (#3828)
* Migration: add country rules

* Add CountryRule schema

* Implement CountryRule cache

* Add country rules context interface

* Start country rules cache

* Lookup country rules on ingestion

* Remove :shields feature flag from test helpers

* Add nested sidebar menu for Shields

* Fix typo

* IP Rules: hide description on mobile view

* Prepare SiteController to handle multiple shield types

* Seed some country shield

* Implement LV for country rules

* Remove "YOU" indicator from country rules

* Fix small build

* Format

* Update typespecs

* Make docs link point at /countries

* Fix flash on top of modal for Safari

* Build the rule struct with site_id provided up-front

* Clarify why we're messaging the ComboBox component

* Re-open combobox suggestions after pressing Escape

* Update changelog

* Fix font size in country table cells

* Pass `added_by` via rule add options

* Display site's timezone timestamps in rule tooltips

* Display formatted timestamps in site's timezone

And simplify+test Timezone module; an input timestamp converted
to UTC can never be ambiguous.

* Remove no-op atom

* Display the maximum number of rules when reached

* Improve readability of remove button tests

* Credo

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-02-27 12:08:13 +01:00
RobertJoonas
dd428430f5
Query imported data for views_per_visit (#3830)
* query imported data for views_per_visit

* changelog update
2024-02-26 15:54:49 +00:00
Karl-Aksel Puulmann
c6e06359c6
Avoid changing Custom properties tab automatically every time filter changes (#3777)
Follow-up to https://github.com/plausible/analytics/pull/3719

The previous behavior was predicated on:
- Allowing a single custom property filter
- Allowing breaking down only by the chosen custom property filter

Now these restrictions are removed the previous auto-switching just becomes annoying
2024-02-26 11:12:50 +02:00
Cenk Kücük
0f0f604d2e
Branding stuff (#3816)
* Replace footer text

* add COPYING.txt file

* Add new logos

* Use new logos in all layouts

* New logos

* Check license key on startup

* Bypass license check when Mix.env == :dev

* Use new logos with smaller wordmarks

* Add generic logo_path/1 function

* Use new favicons everywhere

* Bypass license check in test env

* Use sha256 for license key hash

* Mix.env -> config_env()

* Use Mix.evn at compile time rather than runtime

* Mix format

---------

Co-authored-by: Uku Taht <uku.taht@gmail.com>
2024-02-23 13:35:22 +02:00
RobertJoonas
d74b1d5e60
Reapply conversion rate into Stats API + bugfixes (#3805)
* Revert "Revert api conversion rate (#3789)"

This reverts commit 8e8790dd30.

* fix browser_version CR breakdown bug

* changelog bugfix

* inspect data structures before sending to sentry
2024-02-21 15:53:05 +00:00
RobertJoonas
8e8790dd30
Revert api conversion rate (#3789)
* Revert "Unify percentage change for CR and bounce_rate (#3781)"

This reverts commit a6b1a6ebc7.

* Revert "Bring Stats API up to speed: Add `conversion_rate` to Aggregate and Breakdown (#3739)"

This reverts commit 672d682e95.
2024-02-15 17:43:35 +00:00
hq1
926de4dd10
Experimental session count (#3786)
* WIP

* Allow `experimetnal_session_count` request serialization

* Extend `Plausible.Stats.Query` with `experimental_session_count` flag

* Add `FunWithFlags` actor implementation for `Site`

* Change the way sessions are retrieved

* Remove redundant test

* Format

* Update the test

---------

Co-authored-by: Uku Taht <uku.taht@gmail.com>
2024-02-15 12:21:07 +01:00
RobertJoonas
672d682e95
Bring Stats API up to speed: Add conversion_rate to Aggregate and Breakdown (#3739)
* disable event metric with include_imported in every case

* add missing test for metric validation

* refactor metric validation functions

* implement conversion_rate metric validation

* move calculate_cr function into Stats.Util

* Refactor: Move aggregate CR logic into Stats.aggregate

* define atoms to exist

* Ensure that CR does not depend on visitors being queried

If 'visitors' are already queried, we'll use that value. Otherwise we'll
need to make another query to fetch it.

* confirm Stats API aggregate supports CR (tests only)

* small refactor

This is the only 'event_property' left after pattern matching on all
others in the function clauses defined above.

* Make it possible to optionally query conversion_rate

...in breakdown queries (excluding goal and custom prop breakdown)

* A little refactor asking for revenue metrics

1. The `@revenue_metrics` module attribute is an empty list on full build
   anyway
2. We don't need to query for revenue metrics if there are no revenue goals
   returned in the given query (even if revenue goals exist in site.goals)
3. Revenue metrics are already dropped in prop breakdown without a goal
   filter via (get_revenue_tracking_currency/3)

* Make it possible to optionally query conversion_rate (continuation)

... also from a custom prop and goal breakdown

* Frontend adjustments to the Locations report

* Display conversion rate in Regions and Cities (ListReport view)
* Display total conversions, conversions (visitors), and CR in the
  "Details" modals of Countries, Regions, and Cities
* Move the percentage into a separate column in the Countries details table

* confirm Stats API breakdown supports conversion_rate (tests only)

* small refactor: extract maybe_add_time_on_page function

* Make it possible to query cr alone

... (without the visitors metric). Already supported in aggregate, this
commit only implements it for the breakdown API.

* Reuse Stats.Util helper functions from b02db88 for aggregate API

We can follow the same logic as with breakdown for manually adding
`visitors` into the metrics list and taking it out of the response
later on.

That way we don't have to make another query, e.g. in a case where
only pageviews and conversion rate is queried. Also keeps things
consistent.

* changelog update

* fix test after resolving merge conflict

* Use explicit string->atom mapping instead of casting

* alias Util module instead of importing it

* use Enum.empty instead of Enum.any

* improve readability

* rename special_metrics to computed_metrics and explain with a comment

* rename visitors_without_event_filters to total_visitors

* keep a single function for removing unwanted metrics

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-02-15 09:18:57 +00:00
Karl-Aksel Puulmann
0065cd3052
Support using matches/contains for most filters (#3721)
* Support using matches/contains for most filters

* Change behavior where we auto-zoom to specific browser/os/source to only do so if filtering on a single value

* No contains filtering on `location`

* Update CHANGELOG.md

* Fix merge conflict
2024-02-14 13:49:17 +02:00
Karl-Aksel Puulmann
1cb7982cd9
Filtering by multiple custom properties (#3719)
* WIP: PropFilterRow

* Get multi-behavior working

* Render multiple prop filters in one

* Modal reads from query string correctly

* Backend support for multiple custom property filters

* Add backend tests for multiple custom property filters

* Disable already selected options in property keys

We can't allow choosing the same property multiple times without changing the request
params, which we decided against

* Allow choosing any property under Behaviors > Custom props even if custom prop filter applied

This was a limitation (I believe) introduced by using ARRAY JOINs to query custom properties

* CHANGELOG.md

* Solve credo warning about too deep nesting

* Update assets/js/dashboard/stats/modals/prop-filter-modal.js

Co-authored-by: RobertJoonas <56999674+RobertJoonas@users.noreply.github.com>

* Refactor internal function for clarity

* Add another step -> Add another

* Solve 500 error

* Separate boxes per property filter

* Retain other filters in props table

* removeFilter behavior for props

* matches_member support for custom props

* filter_suggestions for prop keys should account for prop filter

* find over filter

* refactor appliedFilters

* FILTER_TYPES => FILTER_OPERATIONS

* Make add another link not wrap the whole page

* Unique keys

---------

Co-authored-by: RobertJoonas <56999674+RobertJoonas@users.noreply.github.com>
2024-02-12 09:03:57 +02:00
hq1
9ad5ecebc2
Improve print dashboard css (#3754)
* Improve print dashboard CSS

* More improvements
2024-02-07 08:57:39 +01:00
Karl-Aksel Puulmann
1b95433d6e
Support contains/matches for custom properties (#3687)
* Allow `matches` operator to work in BE for custom props

Note: No FE support yet, needs further testing

* feat: allow choosing `contains` for property filters in the UI

* no autocomplete on prop values if `contains` for consistency

* CHANGELOG.md

* Fix: Handle (none) property in property breakdowns when using matching

When matching we should always exclude (none)
2024-01-22 12:23:59 +02:00
Adrian Gruntkowski
eaa7020230
Latency-friendly LV modal implementation and Goals form refactor (#3649)
* Make modal for goal settings trigger without BE roundtrip

* Turn goal form into a live component and extract modal into a wrapper

* Further extract modal component and handle reset action

* Make ComboBox selection callback more flexible

* Add rudimentary loading state to dialog

* Make form unaware of being put inside a modal

* Make modal a live component and completely reset contents on open server-side

* Try to avoid race condition

* Fix race condition

* Remove unnecessary conditional on socket assigns

* Add typespecs and fix formatting

* Make goals form high latency friendly

* Fix tests to account for goal settings form becoming live component

* Fix goal settings form live component declaration

* Add documentation for modal

* Fix small build test

* Fix typo

Co-authored-by: hq1 <hq@mtod.org>

* Revert no longer necessary test changes from 46f65d9

* Fix and clean up modal styling

* Keep focus on dialog when open and show only spinner on backdrop when loading

* Adjust corners and shadows and implement open/close transitions

* Lock body scroll when modal is open

* Make modal top-aligned again to avoid jumping around on variable content height

---------

Co-authored-by: hq1 <hq@mtod.org>
2024-01-15 11:39:30 +01:00
hq1
c1a1d697a4
Partially revert #3661 - just keep the real errors wrapped, but don't display anything to the user (#3677)
* Revert "Remove unused RocketIcon"

This reverts commit c5e8d0c172.

* Revert "Display either hash or actual error message"

This reverts commit 0c091ab35f.

* Revert "Use ApiErrorNotice in funnels"

This reverts commit 5929de248e.

* Revert "Don't render "No data yet" when there's a NetworkError for example"

This reverts commit 70bee07632.

* Revert "Show the sinking shuttle notice whenever an API error occurs"

This reverts commit 9a62c8af2b.

* Revert "Add Hahash dependency"

This reverts commit b94207ea0a.

* Remove support hash
2024-01-09 17:17:42 +01:00
Adrian Gruntkowski
aa139a73b8
Fix calendar picker for comparisons on small screens (#3669) 2024-01-08 11:47:30 +01:00
Adrian Gruntkowski
1021942863
Fix props availability check when listing stats filters in dropdown (#3671) 2024-01-08 11:47:09 +01:00
hq1
4569ac09c1
Don't leak internal server errors, use support hash (#3661)
* Add Hahash dependency

* Don't leak internal server error details to the user

* Show the sinking shuttle notice whenever an API error occurs

* Don't render "No data yet" when there's a NetworkError for example

* Use ApiErrorNotice in funnels

* Display either hash or actual error message

The reason "internal-server-error" doesn't work well as a fallback
hash is that e.g. `NetworkError when attempting to fetch resource`
might be completely at client's fault. In such cases it's better
to display the whole thing still.

* Remove unused RocketIcon
2024-01-04 10:13:37 +01:00
Vinicius Brasil
9e5d63ed96
Display premium features tabs on the dashboard (#3646)
* Display premium features tabs on the dashboard

This commit makes the funnels and props tab on the dashboard visible
even when the site owner's plan does not have access to that feature.
This is to raise awareness of those features, and if the site owner does
not want to see that tab, they can still click "Hide this report" to
hide it.

Previously, when the plan did not support a feature, the feature module
`enabled/1` function returned `false`, regardless of the
`sites.feature_enabled` toggle. This commit creates a new function
called `opted_out/1` to differentiate access from explicitly opting out
a feature.

* Remove unused data-conversions-enabled attribute

* DRY Plausible.Billing.Feature.check_availability/1 function

* Allow opting out features the user doesn't have access to

* add upgrade CTA to FeatureSetupNotice

* fix JS linting errors

* simplify notice.js

* fix behaviour when deleting funnels saved to localstorage

In case some other funnel exists, we will use that as the default
selected one. If not, a feature setup notice will be displayed again.

---------

Co-authored-by: RobertJoonas <56999674+RobertJoonas@users.noreply.github.com>
Co-authored-by: Robert Joonas <robertjoonas16@gmail.com>
2024-01-03 11:32:21 +00:00
Adrian Gruntkowski
af9b34a1c6
Revert "Prevent scrollbar click to close modal (#3651)" (#3664)
This reverts commit 75a7ef5241.
2024-01-02 16:25:50 +01:00
Vinicius Brasil
75a7ef5241
Prevent scrollbar click to close modal (#3651)
This commit replaces the `mousedown` event for `click` to close a modal,
such as the detail dialog. This allows the scrollbar to be clicked
without firing an event, and right clicks too.

Closes #2872
2024-01-02 10:31:04 +01:00