From 709d26735bdceb87036a09434cac878f3e4e8bc9 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 16 Dec 2021 16:48:50 +0100 Subject: [PATCH 01/16] Provide analytics on Front-end Signed-off-by: Thomas Citharel --- js/package.json | 6 +- js/src/App.vue | 10 + js/src/components/Error.vue | 158 +++++++- js/src/graphql/config.ts | 9 + js/src/i18n/en_US.json | 11 +- js/src/services/statistics/index.ts | 50 +++ js/src/services/statistics/matomo.ts | 14 + js/src/services/statistics/plausible.ts | 11 + js/src/services/statistics/sentry.ts | 54 +++ js/src/types/analytics/sentry.model.ts | 7 + js/src/types/config.model.ts | 13 + js/src/typings/matomo.d.ts | 1 + js/yarn.lock | 370 ++++++++++++------- lib/graphql/resolvers/config.ex | 4 +- lib/graphql/schema/config.ex | 26 ++ lib/service/front_end_analytics/analytics.ex | 53 +++ lib/service/front_end_analytics/matomo.ex | 30 ++ lib/service/front_end_analytics/plausible.ex | 31 ++ lib/service/front_end_analytics/sentry.ex | 31 ++ 19 files changed, 733 insertions(+), 156 deletions(-) create mode 100644 js/src/services/statistics/index.ts create mode 100644 js/src/services/statistics/matomo.ts create mode 100644 js/src/services/statistics/plausible.ts create mode 100644 js/src/services/statistics/sentry.ts create mode 100644 js/src/types/analytics/sentry.model.ts create mode 100644 js/src/typings/matomo.d.ts create mode 100644 lib/service/front_end_analytics/analytics.ex create mode 100644 lib/service/front_end_analytics/matomo.ex create mode 100644 lib/service/front_end_analytics/plausible.ex create mode 100644 lib/service/front_end_analytics/sentry.ex diff --git a/js/package.json b/js/package.json index 7eabe74f5..28348350e 100644 --- a/js/package.json +++ b/js/package.json @@ -8,7 +8,7 @@ "test:unit": "LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 TZ=UTC vue-cli-service test:unit", "test:e2e": "vue-cli-service test:e2e", "lint": "vue-cli-service lint", - "build:assets": "vue-cli-service build", + "build:assets": "vue-cli-service build --report", "build:pictures": "bash ./scripts/build/pictures.sh" }, "dependencies": { @@ -17,6 +17,8 @@ "@apollo/client": "^3.3.16", "@mdi/font": "^6.1.95", "@tailwindcss/line-clamp": "^0.3.0", + "@sentry/tracing": "^6.16.1", + "@sentry/vue": "^6.16.1", "@tiptap/core": "^2.0.0-beta.41", "@tiptap/extension-blockquote": "^2.0.0-beta.25", "@tiptap/extension-bold": "^2.0.0-beta.24", @@ -69,7 +71,9 @@ "vue": "^2.6.11", "vue-class-component": "^7.2.3", "vue-i18n": "^8.14.0", + "vue-matomo": "^4.1.0", "vue-meta": "^2.3.1", + "vue-plausible": "^1.3.1", "vue-property-decorator": "^9.0.0", "vue-router": "^3.1.6", "vue-scrollto": "^2.17.1", diff --git a/js/src/App.vue b/js/src/App.vue index c67807e88..309331248 100644 --- a/js/src/App.vue +++ b/js/src/App.vue @@ -203,6 +203,16 @@ export default class App extends Vue { this.interval = undefined; } + @Watch("config") + async initializeStatistics(config: IConfig) { + if (config) { + const { statistics } = (await import("./services/statistics")) as { + statistics: (config: IConfig, environment: Record) => void; + }; + statistics(config, { router: this.$router, version: config.version }); + } + } + @Watch("$route", { immediate: true }) updateAnnouncement(route: Route): void { const pageTitle = this.extractPageTitleFromRoute(route); diff --git a/js/src/components/Error.vue b/js/src/components/Error.vue index 752938f06..e10a22775 100644 --- a/js/src/components/Error.vue +++ b/js/src/components/Error.vue @@ -48,13 +48,75 @@ $t("Mobilizon") }} - {{ - $t( - "We improve this software thanks to your feedback. To let us know about this issue, two possibilities (both unfortunately require user account creation):" - ) - }} + + {{ + $t( + "We collect your feedback and the error information in order to improve this service." + ) + }} + + {{ + $t( + "We improve this software thanks to your feedback. To let us know about this issue, two possibilities (both unfortunately require user account creation):" + ) + }} +

-
+
+ + + + {{ + $t("Send feedback") + }} +

+ {{ + $t( + "Please add as many details as possible to help identify the problem." + ) + }} +

+
+ +

+ {{ + $t( + "Sorry, we wen't able to save your feedback. Don't worry, we'll try to fix this issue anyway." + ) + }} +

+ + + +
+ +

{{ $t("Thanks a lot, your feedback was submitted!") }}

+ + + +
+ -

+

{{ $t( "Please add as many details as possible to help identify the problem." @@ -89,14 +151,14 @@

{{ $t("Error stacktrace") }}

{{ error.stack }}
-

+

{{ $t( "The technical details of the error can help developers solve the problem more easily. Please add them to your feedback." ) }}

-
+
diff --git a/js/src/components/Event/EventCard.vue b/js/src/components/Event/EventCard.vue index bfb778394..8ef70a2f3 100644 --- a/js/src/components/Event/EventCard.vue +++ b/js/src/components/Event/EventCard.vue @@ -67,7 +67,6 @@
Date: Wed, 6 Apr 2022 18:40:22 +0200 Subject: [PATCH 14/16] Update Postgis image used in tests Signed-off-by: Thomas Citharel --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6bd4358a7..8be02da7e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -110,7 +110,7 @@ deps: exunit: stage: test services: - - name: postgis/postgis:13-3.1 + - name: postgis/postgis:14-3.2 alias: postgres variables: MIX_ENV: test From 68c24e2425ffdb875d155087eac716802584cbb9 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 6 Apr 2022 18:40:46 +0200 Subject: [PATCH 15/16] Update tests Dockerfile Signed-off-by: Thomas Citharel --- docker/tests/Dockerfile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/docker/tests/Dockerfile b/docker/tests/Dockerfile index 801029422..4c87c709b 100644 --- a/docker/tests/Dockerfile +++ b/docker/tests/Dockerfile @@ -1,15 +1,11 @@ FROM elixir:latest LABEL maintainer="Thomas Citharel " -ENV REFRESHED_AT=2021-12-15 +ENV REFRESHED_AT=2022-04-06 RUN apt-get update -yq && apt-get install -yq build-essential inotify-tools postgresql-client git curl gnupg xvfb libgtk-3-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 cmake exiftool python3-pip python3-setuptools RUN curl -sL https://deb.nodesource.com/setup_16.x | bash && apt-get install nodejs -yq RUN npm install -g yarn wait-on RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* RUN mix local.hex --force && mix local.rebar --force -# Weasyprint 53 requires pango >= 1.44.0, which is not available in Stretch. -# TODO: Remove the version requirement when elixir:latest is based on Bullseye -# https://github.com/erlang/docker-erlang-otp/issues/362 -# https://github.com/Kozea/WeasyPrint/issues/1384 -RUN pip3 install -Iv weasyprint==52 pyexcel_ods3 +RUN pip3 install -Iv weasyprint pyexcel_ods3 RUN curl https://dbip.mirror.framasoft.org/files/dbip-city-lite-latest.mmdb --output GeoLite2-City.mmdb -s && mkdir -p /usr/share/GeoIP && mv GeoLite2-City.mmdb /usr/share/GeoIP/ From 257050eabc8ad8f9fc2a50afe7b2cf93fe6bca16 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 6 Apr 2022 18:56:49 +0200 Subject: [PATCH 16/16] Pin ex_cldr version until ex_cldr_dates_times is updated Signed-off-by: Thomas Citharel --- mix.exs | 2 +- mix.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mix.exs b/mix.exs index 835749c3f..7fd786b06 100644 --- a/mix.exs +++ b/mix.exs @@ -168,7 +168,7 @@ defmodule Mobilizon.Mixfile do {:mogrify, "~> 0.9"}, {:linkify, "~> 0.3"}, {:http_signatures, "~> 0.1.0"}, - {:ex_cldr, "~> 2.0"}, + {:ex_cldr, "2.27.1"}, {:ex_cldr_dates_times, "~> 2.2"}, {:ex_optimizer, "~> 0.1"}, {:progress_bar, "~> 2.0"}, diff --git a/mix.lock b/mix.lock index 4ee2fd68f..373a48f50 100644 --- a/mix.lock +++ b/mix.lock @@ -34,12 +34,12 @@ "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, "erlport": {:hex, :erlport, "0.10.1", "c96ffa51bbcab0298232fcdfe8c3e110f1598011de71ae6b9082b80c9e2e476a", [:rebar3], [], "hexpm", "34931e8cb62a131d1bc8a2bd04d4007c73c03e4f10e22ee4a218e7172227a918"}, "eternal": {:hex, :eternal, "1.2.2", "d1641c86368de99375b98d183042dd6c2b234262b8d08dfd72b9eeaafc2a1abd", [:mix], [], "hexpm", "2c9fe32b9c3726703ba5e1d43a1d255a4f3f2d8f8f9bc19f094c7cb1a7a9e782"}, - "ex_cldr": {:hex, :ex_cldr, "2.28.0", "8f7a8c70a49dc31f656eb02d4c6280550ab52abd340406e8341dd4ba2390798d", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:cldr_utils, "~> 2.17", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:gettext, "~> 0.19", [hex: :gettext, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "564608c4a344c9cca54874e95fb77cd7149f593ccf522db5cbe8943c0b183630"}, + "ex_cldr": {:hex, :ex_cldr, "2.27.1", "b4fdedc29d6566b5201aea9bb7b554db16ac7b30366188aa0c50790b4393c268", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:cldr_utils, "~> 2.17", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:gettext, "~> 0.19", [hex: :gettext, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "b5c5c31fb7cf43d47e1267a7ede8e46c2cf12de3308ea1ba614241bd29bdcebf"}, "ex_cldr_calendars": {:hex, :ex_cldr_calendars, "1.18.0", "aa86e673f02b3c65d9cc29c483a4dfec1878b2e2460619c2b06c121ef801334e", [:mix], [{:calendar_interval, "~> 0.2", [hex: :calendar_interval, repo: "hexpm", optional: true]}, {:ex_cldr_lists, "~> 2.10", [hex: :ex_cldr_lists, repo: "hexpm", optional: true]}, {:ex_cldr_numbers, "~> 2.25", [hex: :ex_cldr_numbers, repo: "hexpm", optional: false]}, {:ex_cldr_units, "~> 3.12", [hex: :ex_cldr_units, repo: "hexpm", optional: true]}, {:ex_doc, "~> 0.21", [hex: :ex_doc, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "5b47bf4e90bdd6746ac9ca9cb3f9d36c3e656c18768ace8366061e3e02899cdc"}, "ex_cldr_currencies": {:hex, :ex_cldr_currencies, "2.13.0", "13188b99e527d724ed3dc2af37e54f0dac42dec42b620a34c4ed4d4902fad6dd", [:mix], [{:ex_cldr, "~> 2.24", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "64731e49ac3530aa88872b52c319eb5231bfb1a3ebb0956044c34abc0ed4f520"}, "ex_cldr_dates_times": {:hex, :ex_cldr_dates_times, "2.11.0", "eb00d2def8c16feb250ea2436c2e07b31b6e0ad22f9ff569c7714e807c8327df", [:mix], [{:calendar_interval, "~> 0.2", [hex: :calendar_interval, repo: "hexpm", optional: true]}, {:ex_cldr_calendars, "~> 1.18", [hex: :ex_cldr_calendars, repo: "hexpm", optional: false]}, {:ex_cldr_numbers, "~> 2.25", [hex: :ex_cldr_numbers, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "36b2dd6bea88f295b9761d6ca26cccce573708cffe6e196f9930a24ca57baecf"}, "ex_cldr_languages": {:hex, :ex_cldr_languages, "0.3.3", "9787002803552b15a7ade19496c9e46fc921baca992ea80d0394e11fe3acea45", [:mix], [{:ex_cldr, "~> 2.25", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "22fb1fef72b7b4b4872d243b34e7b83734247a78ad87377986bf719089cc447a"}, - "ex_cldr_numbers": {:hex, :ex_cldr_numbers, "2.26.0", "f1104498a96666fc0b0c0995f17266c8700593e984418aa05e7b731bfd8c5670", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ex_cldr, "~> 2.28", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:ex_cldr_currencies, "~> 2.13", [hex: :ex_cldr_currencies, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "35b1c7bd6c87149e7f31ef24705d254419b35f9f26fe439af88d02950710e11b"}, + "ex_cldr_numbers": {:hex, :ex_cldr_numbers, "2.25.2", "9bd1f21bb7a300e1e0fd080b99f0c912d2adf90292e7d7c0335a6da84758c8a8", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ex_cldr, "~> 2.26", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:ex_cldr_currencies, "~> 2.13", [hex: :ex_cldr_currencies, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "5de180d21018797bc412aae727402b3004df4c5666ed2602863448993b035c9b"}, "ex_doc": {:hex, :ex_doc, "0.28.3", "6eea2f69995f5fba94cd6dd398df369fe4e777a47cd887714a0976930615c9e6", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "05387a6a2655b5f9820f3f627450ed20b4325c25977b2ee69bed90af6688e718"}, "ex_ical": {:hex, :ex_ical, "0.2.0", "4b928b554614704016cc0c9ee226eb854da9327a1cc460457621ceacb1ac29a6", [:mix], [{:timex, "~> 3.1", [hex: :timex, repo: "hexpm", optional: false]}], "hexpm", "db76473b2ae0259e6633c6c479a5a4d8603f09497f55c88f9ef4d53d2b75befb"}, "ex_machina": {:hex, :ex_machina, "2.7.0", "b792cc3127fd0680fecdb6299235b4727a4944a09ff0fa904cc639272cd92dc7", [:mix], [{:ecto, "~> 2.2 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_sql, "~> 3.0", [hex: :ecto_sql, repo: "hexpm", optional: true]}], "hexpm", "419aa7a39bde11894c87a615c4ecaa52d8f107bbdd81d810465186f783245bf8"},