* Tidy up breakdown helper functions in CSV importer tests
* Fix a typo
* Extend city breakdown tests in CSV importer test suite
* Make visit duration computation consistent across native and imported data
* Fix broken hostname property and handle missing imported metrics gracefully
* Add test for CSV export of imported data
* Add extra coverage for property and metric combox which were failing
* Compute visit duration and bounce rate for exit pages in imported data
* Drop support for breaking down by `event:hostname` property for now
Currently, business tier users created after business tier launch can't
access Stats API due to faulty grandfathering logic. This change should
fix that.
* Export and import custom events via CSV
* Add prop support of url for cloaked links and path for 404s in imported queries
* Handle custom events with empty URL and path properties gracefully
* Make events with properties logic DRY and fix missed cloaked link
* Add test for path property breakdown
* Update raw CH data fixture and extend CSV importer tests
* Fix broken query condition after rebase
* Update CHANGELOG.md
* New struct format for query after parsing
* WIP refactoring
* WIP: Validations working
* WIP: tuple to list
* continued refactoring
* WIP: parsing defaults
* Breakdown tests pass
* Window functions fix
* Fix default
* Remove dead argument
* Update filters tests
* Update query_test.exs
* Fix table_decider
* sources tests pass
* Filter suggestions fix
* revenue/goal filter applied refactor
* Update top_stats matching
* Get stats_controller tests passing
* Update neighbor_aggregate_time_on_page
* Refactor Query.remove_event_filters into Query.remove_filters, add new callsites
* Move goal where clause building to new WhereBuilder module
* Move event:name filters
* Move more filters to WhereBuilder
* Update fragment to allow non-static meta columns
* Build where clause for events table using WhereBuilder
* Build sessions table where clause using WhereBuilder
* Move time range filtering and site checking to WhereBuilder
* WhereBuilder.build_condition method
* Remove TODO
* _rest pattern for TableDecider, Query pattern matching
Future-proofing in a tiny way
* Hacky fix to get tests passing for Google API tests
* Typespec fix
* Merge conflict
* refactor special goal filter logic in imported.ex
* Docs feedback
* put_filter
---------
Co-authored-by: Robert Joonas <robertjoonas16@gmail.com>
* 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
* add new goal suggestions API
* silence credo
* Order suggestions from subqueries explicitly
* allow autoconfiguring goals
Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
* Fix form modal tab switching behavior
* add test
* Remove redundant and invalid action link title
---------
Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
* Add Ecto schema for imported custom events
* Start importing custom events from GA4
* query imported goals
* make it possible to query events metric from imported
* make it possible to query pageviews in goal breakdown
* make it possible to query conversion rate
* fix rate limiting test
* add CR tests for dashboard API
* implement imported link_url breakdown
* override special custom event names coming from GA4
* allow specific goal filters in imported_q
* update GA4 import tests to use Stats API
* Improve tests slightly
* Update CHANGELOG.md
---------
Co-authored-by: Robert Joonas <robertjoonas16@gmail.com>
* Fix event props paygate
Previous code wasn't properly omitting event property filters from
queries.
Discovered while refactoring the code. Extracting fix from refactor for easier reviewability.
* a
* Drop function
* add inline csv fixture
* use new csvs
* cleanup csv reading and site_id replacing
* perform comparisons between native and imported queries
* help help help
* help help
* help
* eh
* fin
* exclude export/import e2e test when experimental_reduced_joins flag is enabled
* adapt to new pageviews
* adapt to experimental_reduced_joins
* credo is formatter
* cleanup
* assert bounce rates equal in city breakdown
* fix rebase against master
* clean-up dataset
* update comment
* fix typo
* apply csv changes to the files
* use sessions timestamp for exports' dates
---------
Co-authored-by: RobertJoonas <56999674+RobertJoonas@users.noreply.github.com>
* Fix typo in test name
* Update test_helper, enable experimental_session_count together with experimental_reduced_joins
* Return session in each time bucket its active in for hourly/minute timeseries
The behavior is behind experimental_session_count flag
This results in more accurate visitor showing compared to previous approach of showing each user only
active the _last_ time they did a pageview.
Were not doing this for monthly/weekly graphs due to query performance cost and it having a small effect there.
See also https://3.basecamp.com/5308029/buckets/35611491/messages/7085680123
* Add tests for new behavior
Note the new behavior mimics the old one precisely, these tests fail if only
experimental_reduced_joins is on, but not experimental_session_count
* Type erasure
* Dead comment remove
* Expected_plot change
* keep breakdown prop in the query struct
* Explicitly ignore property param in aggregate and timeseries
Since parameter validation depends on the breakdown property, we need to
make sure it doesn't have any unexpected effect in endpoints where it's
not expected.
* Add support for resuming import to GA4 importer
* Handle rate limiting gracefully for all remainig GA4 HTTP requests
* Show notice tooltip for long running imports
* Bump resume job schedule delay to 65 minutes
* Fix tooltip styling
* Rely on con_cache telemetry
Now that https://github.com/sasa1977/con_cache/pull/76
is released, we don't have to use low-level operations
to emit hit/miss events.
This PR also wraps cache processes with
a function returning appropriate child specs lists.
Ideally each cache will have its own supervisor/child specs
going forward. This is an intermediate step in that direction.
* Update lib/plausible/application.ex
Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
* Declare caches without warmers with plain child specs
---------
Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
* Implement `Auth.TOTP.force_disable/1`
* Add "Reset 2FA" action to users CRM
* Add `Purge.reset!/2` variant allowing to set arbitrary cutoff time
* Add ability to set native stats start time from CRM
* Revert "Add `Purge.reset!/2` variant allowing to set arbitrary cutoff time"
This reverts commit 6f294d5d58.
* Add test for CRM site update action
* Import `activeUsers` into `imported_pages.active_visitors` for GA4
* Add test for active visitors
* Simplify assertion in active visitors test
* Improve assertion for active visitors further
* Remove references to `site.imported_data`
* Count pre-existing ID 0 imports when showing pageview count summary for legacy imports
* Fix tests after rebase
* Dry `delete_imported_stats!`
* Clean up remaining imported data references and add notes
* Add runtime config option for enabled/disabling csv imports and exports
* Use the new option to toggle rendering exports UI
* Disable import buttons when at maximum imports or when option disabled for CSV
* Improve forms for GA import flow
* Add test for maximum imports reached
* Remove "Changed your mind?" prefixing back button
* Hide UA imports in Integrations when `imports_exports` flag is enabled
* Implement `csv_imports_exports` feature flag
* Revert "Add runtime config option for enabled/disabling csv imports and exports"
This reverts commit e30f202dd3.
* Send import notification email only to the user who ran the import
* Improve rendering of disabled button state
* Put import status heroicon in front of import label
* test fixture imported data with stats requests
* take visits metric from the events table in event:page breakdown
* Remove assert_referrers after all
pageReferrer is an event scoped property in GA4, which when queried
along with session-level dimensions will return unexpected data.
Adding the pageReferrer dimension to the GA4 Data API request, it will
cause the selected metric totals to increase significantly, even though
they shouldn't.
* Adjust sources and utm_mediums assertions
* adjust assert_pages
* Make formatter happy
---------
Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
* Add shield hostname rules migration
* Add hostname rule schema
* Initialize hostname rules cache
* Extend Shields context with hostname related functions
* Instrument ingestion pipeline with hostname rule lookups
* Limit hostname suggestions by shield patterns
* Add LiveView for hostname rules management
* Test hostname cache
* Rename feature flag - should be separate from hostname filter
* Remove :shield_pages feature flag
* Update CHANGELOG
* Format
* Update lib/plausible/shield/hostname_rule.ex
Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
* Move tests from `lib/` 🤦
* Use plain `assign` where no short-circuit is necessary
* Fine tune the copy a little bit
* Prevent misplaced tests
* Treat a test with common sense
* Fixup another test that hasn't been really run before
* Make the form hint dynamic depending on rules count
---------
Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
* Pass the actual date args that are returned in fixtures (just for clarity)
* Change select key from operating_system to os
* Select (not set) from imported data as done from native stats
* Support breakdown by imported os_version
* Remove dead code
The `query.include_imported` is set to `false` from the start when
filters are included.
* Refactor Plausible.Stats.Imported
Extract a function that does group_by and dimension select, instead of
doing both separately inside the merge_imported function body
* Further refactor of Plausible.Stats.Imported
Get rid of code repetition
* Support breakdown by imported browser_version
* Support breakdown by imported referrer
* Support breakdown by imported referrer
* remove redundant if in select
* use greatest instead of coalesce
Co-authored-by: ruslandoga <doga.ruslan@gmail.com>
* add back the :member filter handling in Stats.Imported
---------
Co-authored-by: Uku Taht <uku.taht@gmail.com>
Co-authored-by: ruslandoga <doga.ruslan@gmail.com>
* Reapply "Local CSV exports/imports and S3/UI updates (#3989)" (#3995)
This reverts commit aee69e44c8.
* remove unused functions
* eh, that one was actually used
* ugh, they were both used
---------
Co-authored-by: ruslandoga <67764432+ruslandoga@users.noreply.github.com>
* local CSV exports/imports and S3 updates
* credo
* dialyzer
* refactor input columns
* fix ci minio/clickhouse tests
* Update lib/plausible_web/live/csv_export.ex
Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
* fix date range filter in export_pages_q and process only pageviews
* remove toTimeZone(zero_timestamp) note
* use SiteImport.pending(), SiteImport.importing()
* escape [SiteImport.pending(), SiteImport.importing()]
* use random s3 keys for imports to avoid collisions (sometimes makes the upload get stuck)
* clamp import date ranges
* site is already in assigns
* recompute cutoff date each time
* use toDate(timestamp[, timezone]) shortcut
* show alreats on export cancel/delete and extract hint into a component
* switch to Imported.clamp_dates/4
* reprocess tables when imports are added
* recompute cutoff_date on each call
* actually use clamped_date_range on submit
* add warning message
* add expiry rules to buckets in make minio
* add site_id to imports notifications and use it in csv_importer
* try/catch safer
* return :ok
* date range is not available when no uploads
* improve ui and warning messages
* use Generic.notice
* fix flaky exports test
* begin tests
* Improve `Importer` notification payload shape
---------
Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>