Commit Graph

1031 Commits

Author SHA1 Message Date
Uku Taht
aadf892a71
Increase DB query timeout for site transfers (#2309) 2022-10-06 14:17:35 +03:00
Vinicius Brasil
4a2e0af337
Override stats_start_date in CRM (#2310)
* Refactor Plausible.Sites.stats_start_date/1 function

This commit adds documentation, typespecs and better pattern matching to
the Plausible.Sites.stats_start_date/1 function.

* Use memoized stats_start_date instead of querying CH

* Prevent domain from being updated from CRM

* Add stats_start_date to CRM site form

This commit adds stats_start_date to CRM site form, and creates a
separate Ecto changeset for CRM changes.

* Alias Plausible.Site calls

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

* List all timezones in CRM form

* Require sites.public in CRM changeset

Co-authored-by: Adam Rutkowski <hq@mtod.org>
2022-10-06 08:08:22 -03:00
Adam Rutkowski
523b114682
Allow super-admin Stats API access for locked sites (#2308) 2022-10-05 12:04:37 +02:00
Adam Rutkowski
ceff6e17b2
CRM: order sites by latest. Tolerate missing owner (#2305) 2022-10-05 11:41:04 +03:00
Vinicius Brasil
beabef7269
Redirect user after upgrading only when subscription is created (#2285)
* Create API to check for an active subscription

* Redirect after upgrading only when subscription is created

* Change upgrade page copy

* Add timeout notice to upgrade success page
2022-10-04 15:54:54 +03:00
Adam Rutkowski
bf2b6880c5
Block Stats API for locked sites (#2302)
* Extract Sites.locked? predicate

* Lock Stats API when dashboard is locked

* Tidy tests

* Don't pollute application env from tests

* Add changelog entry

* Revert "Add changelog entry"

This reverts commit 76346074f9.
2022-10-04 15:34:45 +03:00
Adam Rutkowski
992ce0e802
Remove redundant logger from Plug (#2303) 2022-10-04 09:09:08 -03:00
Uku Taht
0bc762bfdc
Fix svg favicons (#2295)
* Overrides content-type for SVG favicons

* Organize favicon rendering

Make sure the placeholder icon is always requested from
/favicon/sources/placeholder

* Run prettier on site-switcher.js

* Yak Shave: upgrade Heroicons to 2.0

* Use HeroIcons instead of custom svg

* Update lib/plausible_web/plugs/favicon.ex

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

Co-authored-by: Adam Rutkowski <hq@mtod.org>
2022-10-04 13:20:51 +03:00
Adam Rutkowski
c8ffcc413f
Prevent sensitive information from being logged (#2300) 2022-10-04 10:46:01 +03:00
Uku Taht
4096d88171
[Sentry APP-189] Fallback to current date in all time parsing (#2277)
* Fallback to current date in all time parsing

* Add changelog
2022-09-28 09:45:37 -03:00
Uku Taht
65f0ce3061
[Sentry APP-5B] Ensure form errors can be rendered on /settings (#2278)
* Ensure form errors can be rendered on /settings

* Changelog
2022-09-28 08:56:07 -03:00
Uku Taht
d104abb53d
Add fallback for favicon (#2279)
* Add fallback for favicon

* Add Favicon tests

* Changelog

* Move placeholder icon to priv folder
2022-09-28 08:55:46 -03:00
Vinicius Brasil
7489290d11
International Domain Names (IDN) Support (#2034)
* Accept letters from non-Latin alphabets in domain names

* Replace static URLs with Router functions in settings_visibility

* Beautify dashboard URL in visibility tab

* Add IDN support to CHANGELOG
2022-09-28 10:42:15 +03:00
Vinicius Brasil
c07361fbce
Increase GA import request receive_timeout to 30s (#2274)
This commit increases the receive_timeout from 15s to 30s for Google
Analytics import requests. Timeouts have been reported, and I could
replay some requests that took 15-20 seconds to complete when fetching
10,000 records in a single request.
2022-09-28 10:37:44 +03:00
Uku Taht
519a1fa669
Add script to send pageview (#2272)
* Add script to send fake pageviews

* Fix option typo

* Remove dummy_event from .PHONY in Makefile
2022-09-27 17:58:22 +03:00
Vinicius Brasil
52b4ee6287
fixup! Refresh Google Analytics token before import (#2254) (#2273) 2022-09-26 16:21:19 -03:00
RobertJoonas
155e274150
Stats API: allow escaping | literal character with \| when filtering (#2266)
* add separate module for filter parsing

* add tests for filter parser

* allow escaping pipe character in filter value

* add documentation and doctests

* do not remove escape chars from wildcard values

* changelog update

* change the parse_filters/1 function argument
2022-09-26 16:20:08 +03:00
Vinicius Brasil
db03cc0ac6
Fix timezone list when time changes (#2268)
This commit fixes an exception when calling `Timex.Timezone.get/2` after
there has been a timezone change. Similar issues have already been reported
in Timex (bitwaker/timex#691, bitwalker/timex#555, bitwalker/timex#625).

This skips timezones from the list when they fail to fetch, and use
`Timex.Timezone.get/2` to get the current offset using `DateTime.utc_now/0`
instead of the `NaiveDateTime` default.
2022-09-26 12:30:20 +03:00
Vinicius Brasil
1adda42a75
Refresh Google Analytics token before import (#2254)
* Capture refresh and expires from GA callback

* Pass GA refresh token to import worker

* Refresh GA token before import
2022-09-26 12:29:56 +03:00
Uku Taht
e849e03058
Fix favicons (#2257) 2022-09-23 07:22:43 -03:00
RobertJoonas
80e01fedd5
do not show invoices for free subscription (#2249)
* do not show invoices for free subscription

* use refute instead of negative assert

* changed to refute in the other test too
2022-09-22 17:25:24 -03:00
Adam Rutkowski
3f7c1ce549
Aggregate DBConnection.ConnectionError in Sentry (#2260) 2022-09-22 12:24:54 -03:00
Uku Taht
3d54b88f0a
Make Finch pools lighter for self-hosting (#2250)
* Make Finch pools lighter

* Use standard http1 Finch pools
2022-09-21 12:51:07 +03:00
Vinicius Brasil
2b753cdcfd
Improve GA Imports error reporting (#2244)
* Return error tuple instead of exception when GA request fails

* Report Google Analytics failed request body to Sentry

* Improve Google Analytics function @doc

* fixup! Report Google Analytics failed request body to Sentry

* fixup! Improve Google Analytics function @doc
2022-09-20 15:41:23 +02:00
Uku Taht
e16e357dd2
Fix shared link with bad auth (#2225)
* Render 404 when shared link cannot be found

* Add documentation for StatsController and shared link rendering

* Refactor shared_link/2 for more clarity

* Add changelog entry

* Use mermaid graph for sequence diagram

* Use more accurate return value in sequence diagram

* Refactor Ecto query to be more idiomatic

* Remove order dependence in test

* Restore backwards compatibility for older shared links

* Add changelog entry
2022-09-20 15:37:18 +03:00
Adam Rutkowski
30b79e5239
Inspect extra sentry payload for get_invoices/1 failure (#2248)
* Inspect extra sentry payload for get_invoices/1 failure

* Include params and invoices url in paddle trace
2022-09-20 09:06:53 -03:00
Uku Taht
669091f2ef
Ignore unknown country in imported data (#2247) 2022-09-20 15:02:14 +03:00
Adam Rutkowski
df76cd2c8c
Ensure Sentry extras are maps that can be JSON-encoded (#2246)
* Ensure Sentry extras are maps that can be JSON-encoded

* Fix terminator
2022-09-20 11:13:29 +02:00
Vinicius Brasil
40182f6d6e
Manually lock outgrown enterprise accounts (#2197)
* Rename enterprise_over_limit e-mail template

* Change suggested_plan/2 function to suggest enterprise plans

* Start grace period for enterprise accounts

* Create separate module for GracePeriod schema

* Enable manual locking of enterprise accounts

* Update outgrown account alert for enterprise accounts

* Document account locking feature

* fixup! Enable manual locking of enterprise accounts
2022-09-20 11:46:28 +03:00
Adam Rutkowski
75264f8f1c
Treat non-200 HTTP responses as errors (#2243)
* Tag non-200 HTTP responses as errors

Co-authored-by: RobertJoonas <robertjoonas16@gmail.com>

* Send get_invoices/1 errors to Sentry

Co-authored-by: RobertJoonas <robertjoonas16@gmail.com>

* Keep Google API module matching non-200 responses

Co-authored-by: RobertJoonas <robertjoonas16@gmail.com>

* Make sure HTTPClient.Error.t() doesn't appear in the UI

* Unify get_invoices/1 signature

Co-authored-by: RobertJoonas <robertjoonas16@gmail.com>

Co-authored-by: RobertJoonas <robertjoonas16@gmail.com>
2022-09-20 09:31:12 +02:00
ruslandoga
bc5aa84d05
enable google import for everyone (#2242) 2022-09-19 16:49:44 +03:00
Uku Taht
5d4918b66b
Allow admins to grant admin rights (#2216)
* Make sure admin can grant the admin role

* Use `site` and `current_user_role` from conn.assigns to avoid extra lookups

* Add some missing documentation

* Restrict owners in the `update_role` action

* Move @moduledoc to appropriate location

* Use Ecto.Enum to get role atoms

* Remove unused functionality

* Ensure that owners cannot lock themselves out

* Add question mark to `can_grant_role`

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

* Use strict short-circuit operator for booleans

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

Co-authored-by: Adam Rutkowski <hq@mtod.org>
2022-09-16 11:03:09 +03:00
Uku Taht
b239f73a6d
Ignore unknown country code (#2223)
* Ignore unknown country code

* Add changelog entry
2022-09-16 11:02:39 +03:00
RobertJoonas
0194d57b38
add upper bound to limit parameter (#2226)
* add upper bound to limit parameter

* add more strict validation for limit parameter + 2 tests

* update changelog
2022-09-16 10:21:44 +03:00
Vinicius Brasil
dcd1640b1b
Sort timezone list by current offset (#2229)
This commit fixes a bug where the timezone list was sorted by the
standard offset, not considering timezone changes. The list was working
properly, but sorting was wrong.
2022-09-16 10:20:32 +03:00
Vinicius Brasil
178e34b9e7
Fix timezone input (#2222)
* Update Timex version from 3.7.7 to 3.7.8

* Generate timezone list from Tzdata

This commit fixes a bug where timezone changes weren't updating the
timezone list displayed when editing or creating a site.

Timezones were being pulled from a static list. This commit changes it
to generate the list from Tzdata, that uses a timezone database with
updated information on time changes. Additionally it adds more timezones
with aliases and links to the list.

Closes #1340

* Use timezone name from browser to recommend timezone

This commit matches the timezone name instead of offset to recommend a
timezone when creating a new site. The JavaScript Intl.DateTimeFormat
API is widely supported according to the link. In any case, if the
timezone fails to match by name, it fallbacks to the offset strategy.

https://caniuse.com/mdn-javascript_builtins_intl_datetimeformat_resolvedoptions_computed_timezone

Closes #904
2022-09-14 09:58:42 -03:00
Vinicius Brasil
119640486e
Remove parallel requests to Google Analytics (#2219) 2022-09-13 17:20:38 +03:00
Adam Rutkowski
cc4d4bb8e0
Fixup error reporting (ref #2181) (#2204)
* Fixup error reporting (ref #2181)

Fixes two problems:

 - `extra` sent to Sentry is always expected to be a map
 - no `String.Chars` protocol is implemented for `Finch.Error` struct

* Use explicit paths in http client tests

* Make HTTP Client tests sync
2022-09-12 13:46:23 +03:00
Vinicius Brasil
d31db86b49
List all Google Analytics views during import (#2184)
* List all Google Analytics views during import

This commit fixes a bug where different Google Analytics views with the
same name and URI were not shown. This was caused because GA views were
stored as a map, that naturally doesn't support duplicate keys.

This change updates the GA views list to display view IDs, making it
clearer to know what is being imported. The dropdown is now grouped by
website URL.

* Put Google Analytics API URLs in app env

* Add controller test to GA view list
2022-09-08 21:02:17 +03:00
Adam Rutkowski
e2aa519c31
Test HTTPClient (#2185)
* Sort dependencies

* Add :bypass dependency

* Test HTTPClient

* Rename test module
2022-09-07 14:17:57 +02:00
Vinicius Brasil
263a359366
Add missing application/ to Content-Type match (#2183) 2022-09-07 07:47:19 +02:00
Adam Rutkowski
1a294854e3
Fix improper pattern matching on Finch responses (#2181) 2022-09-06 21:27:25 +02:00
Adam Rutkowski
2275cd8e22 Respond with 400 when no auth supplied to shared link request 2022-09-05 11:15:09 +02:00
Marko Saric
b9ae568bad
Fixing Innenstadt II/III to Frankfurt (#2162) 2022-09-01 17:34:56 +03:00
Vinicius Brasil
e417c82a26
Perform calculations in SQL instead of app when creating sites (#2156)
This commit removes some Enum calls to rely on the database for
aggregating data. This improves performance when creating new sites,
especially if the user has multiple sites.
2022-09-01 17:09:28 +03:00
Uku Taht
7683638b84
Embed improvements (#2148)
* Replace current tooltip with Popper.js

* Merge tooltip and title for top stats

* Format bounce rate and visit duration numbers in tooltip

* Add 'width=manual' mode for embed

* Add changelog entry

* Use helper function canMetricBeGraphed
2022-09-01 11:22:04 +03:00
Vinicius Brasil
f4a242ac71
Handle unexpected Google Analytics responses (#2158)
This commit handles unexpected Google Analytics responses while
importing, and logs to Sentry and Logger. This will improve
observability when things go wrong with GA imports.
2022-09-01 11:21:10 +03:00
Vinicius Brasil
bc68235d04
Add fallback for GA reports without rows (#2121) 2022-08-19 13:14:49 +03:00
Uku Taht
00d82fd5b1 Increase user_agents cache size to 10k 2022-08-18 12:35:14 +03:00
Uku Taht
f4db53109c Add guard to CRM subscription_plan function 2022-08-17 14:35:25 +03:00