Commit Graph

1013 Commits

Author SHA1 Message Date
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
Uku Taht
7bfd7cc219 Fix captcha HTTP request 2022-08-17 14:01:33 +03:00
Uku Taht
eb99133791 Fix favicon requests 2022-08-17 14:01:19 +03:00
RobertJoonas
4f4b05335e
link to contact page instead of mailto (#2108) 2022-08-16 16:57:02 +03:00
Vinicius Brasil
a10d44a0d7
Refactor event struct creation function (#2098)
* Replace Ingestion.Request headers with user_agent

* Replace generic Ingestion.Request params with specific fields

* Refactor event building function into small functions

* Move Plausible.Ingestion to Plausible.Ingestion.Event

* Add option to override event fields while building

* Rename Ingestion.Request meta to props

* Replace UTM-specific fields with generic query_params

* Remove Map.from_struct/1 call from ingestion pipeline

* Remove stash options from ingestion
2022-08-16 14:43:10 +03:00
Uku Taht
ad739f603b Fix compile error 2022-08-16 14:35:45 +03:00
Uku Taht
57c758cff9 Fix favicon HTTP response handling 2022-08-16 14:31:09 +03:00
Vinicius Brasil
4d20c7ce70
Catch Google Search Console grant error (#2101)
* Remove invalid Jason.decode argument

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

* Add custom message to Google invalid grant error

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

* Test invalid_grant while refreshing Google token

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

Co-authored-by: Robert Joonas <robertjoonas16@gmail.com>
2022-08-16 10:55:46 +03:00
RobertJoonas
8595332717
Merge pull request #2105 from renbaoshuo/update-links-to-docs
Update links to documents
2022-08-16 07:57:57 +03:00
Manu S Ajith
777c69b1d6
Migrate HTTPoison to Finch (#2054)
Signed-off-by: Manu S Ajith <neo@codingarena.in>

Signed-off-by: Manu S Ajith <neo@codingarena.in>
2022-08-15 10:41:48 +03:00
Baoshuo
eac4660354
Update links to documents 2022-08-15 09:20:40 +08:00
Uku Taht
5c83ea77de Remove cache reporting to logs 2022-08-12 11:05:47 +03:00
Manu S Ajith
c7a9da75b4
Enable Cachex stats (#2100)
Signed-off-by: Manu S Ajith <neo@codingarena.in>

Signed-off-by: Manu S Ajith <neo@codingarena.in>
2022-08-12 11:04:56 +03:00
Manu S Ajith
c0c36646e2
Add Custom telemetry for Plausible.Event.WriteBuffer, Plausible.Event.WriteBuffer and Cachex (#2095)
* Add Custom telemetry for Plausible.Event.WriteBuffer, Plausible.Event.WriteBuffer and Cachex

Signed-off-by: Manu S Ajith <neo@codingarena.in>

* Rename telemetry.ex to avoid confusion with Phoenix Telemetry supervisor

Signed-off-by: Manu S Ajith <neo@codingarena.in>

* Remove duplicate event

Signed-off-by: Manu S Ajith <neo@codingarena.in>

Signed-off-by: Manu S Ajith <neo@codingarena.in>
2022-08-12 09:50:18 +03:00
Uku Taht
a5757bc61e Allow ownership transfers 2022-08-11 13:16:46 +03:00
Vinicius Brasil
6b8ed12567
Fix Google Search Console API call (#2090)
This commit fixes a bug where fetching Google Search Console keywords
raised a FunctionClauseError. This was introduced in #2046. This commit
also adds test coverage.
2022-08-11 11:03:06 +03:00
ruslandoga
ce461b5192 Auth updates 2022-08-10 10:37:37 +03:00
Vinicius Brasil
d41fd68e99
Create struct for event requests (#2084)
* Create struct for saving ingestion request

* Create separate function to buffer events
2022-08-10 10:36:40 +03:00
RobertJoonas
a058cf6240
added a test and changed hashmode condition (#2082) 2022-08-09 14:31:37 +03:00