Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect Statistics from Matomo #1113

Merged
merged 12 commits into from
Oct 5, 2023
Merged

Collect Statistics from Matomo #1113

merged 12 commits into from
Oct 5, 2023

Conversation

sarahsporck
Copy link
Contributor

Credentials for matomo can be found in passbolt. For now I tracked:

  • search
  • card activation
  • card verification
  • card creation

in each request I tried to include:

  • the user ip address
  • user agent (for device information)
  • language (especially interesting after we implement i18next)
  • region (if possible)

Furthermore I decided to implement tracking completely in the backend, as this is where all information is present. This also means we don't have to implement tracking in frontend AND administration.

What's still missing?

  • option to disable tracking in the frontend and probably also in administration
  • a matomo health endpoint as errors are currently only logged, so it could go unnoticed if matomo is down or behaves strangely (@svenseeberg or does this already exist?)
  • production credentials

Comment on lines 18 to 20
enum class EventCategory {
Cards
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also change the category. I guess adding Cards as category is kind of meaningless


object Matomo {
val logger = LoggerFactory.getLogger(Matomo::class.java)
private const val ACTION_NAME = "Request"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without an action name the request is not displayed properly in matomo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind. I tested this again. Should work fine without the action name

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you plan to remove this then?

@sarahsporck sarahsporck linked an issue Sep 4, 2023 that may be closed by this pull request
Copy link
Member

@michael-markl michael-markl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some drive-by comments;

I didn't pay attention to what's collected and if we can deduce all desired statistics from that.

Copy link
Contributor

@f1sh1918 f1sh1918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm i can not find matomo credential in passbolt.
Maybe i don't have sufficient rights?
Please provide me access to test :)

@michael-markl
Copy link
Member

michael-markl commented Sep 5, 2023

On a side note: It might be beneficial to also add a matomo docker container to the dev setup, so we can more easily test the tracking locally. I am not sure how complicated that would be, though.

@sarahsporck
Copy link
Contributor Author

On a side note: It might be beneficial to also add a matomo docker container to the dev setup, so we can more easily test the tracking locally. I am not sure how complicated that would be, though.

Added fancy docker setup for this :) Besides there is a dev site in our live matomo where we can test against the live system.

Hm i can not find matomo credential in passbolt. Maybe i don't have sufficient rights? Please provide me access to test :)

Don't have the rights to do this @svenseeberg

14. Set up the matomo instance [http://localhost:5003](http://localhost:5003) (The public version is available at https://matomo-entitlementcard.tuerantuer.org)
15. (optional) Add your matomo config to the backend config
```yaml
matomo:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be added to config-local.yaml?
Even i do that i can not start the backend since

Exception in thread "main" com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "matomo" (class app.ehrenamtskarte.backend.config.BackendConfiguration), not marked as ignorable (7 known properties: "server", "production", "projects", "geocoding", "map", "postgres", "csvWriter"])

Where exactly do i have to add this @sarahsporck

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to add this to the project config. that's in the config.local.yml e.g.

projects:
  - id: nuernberg.sozialpass.app
  ...
  matomo:
    ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so not in the first level? probably this was my problem. i got an error when i started the backend with this additional parameters

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please update the docs that its easier to know where to add matomo

matomo:
siteId: 1
url: http://localhost:5003
accessToken: <matomo-access-token>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can i find the token?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

visit localhost:5003 and go to the settigns. Either search for "token" or go to "Persönlich->Sicherheit"

Copy link
Contributor

@f1sh1918 f1sh1918 Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i had to adjust the config.ini.php on the docker container to change the trusted hosts and add the port
Not sure if that is just my problem. If not maybe this can be adjusted somehow

[General]
salt = "36941bec3f510a9c9411000c89ee712b"
trusted_hosts[] = "localhost:5003"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sarahsporck please add how to findthe matomo-access-token and update the url to http://localhost:5003/matomo.php

Copy link
Contributor

@f1sh1918 f1sh1918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me everything looks fine i just could need some help how to configure matomo locally to proper test this pr. The docker instance and everything works so far :)
And don't we have to put the matomo config for the backend in the config.yml for the different stages?

Copy link
Contributor

@f1sh1918 f1sh1918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works fine. just some updates to docs are missing :)
Amazing work!

matomo:
siteId: 1
url: http://localhost:5003
accessToken: <matomo-access-token>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sarahsporck please add how to findthe matomo-access-token and update the url to http://localhost:5003/matomo.php

frontend/lib/graphql/configured_graphql_provider.dart Outdated Show resolved Hide resolved
State<StatefulWidget> createState() => ConfiguredGraphQlProviderState();
}

class ConfiguredGraphQlProviderState extends State<ConfiguredGraphQlProvider> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are we using this whole thing for? What events/things are we tracking from the frontend? How is the tracking with matomo connected to graphql?


object Matomo {
val logger = LoggerFactory.getLogger(Matomo::class.java)
private const val ACTION_NAME = "Request"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you plan to remove this then?

import java.io.IOException
import java.util.concurrent.ExecutionException

object Matomo {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: I think in this file there is some duplicated stuff which might be reduced.

@f1sh1918
Copy link
Contributor

f1sh1918 commented Oct 4, 2023

@sarahsporck when do you expect to finish/merge this pr?
I would like to create a release this week but could also do it without that

@sarahsporck
Copy link
Contributor Author

@sarahsporck when do you expect to finish/merge this pr? I would like to create a release this week but could also do it without that

In the best szenario I'll finish today.

Copy link
Contributor

@f1sh1918 f1sh1918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for me its fine to merge @sarahsporck

@sarahsporck sarahsporck merged commit 0b5523c into main Oct 5, 2023
@sarahsporck sarahsporck deleted the collect-statistics branch October 5, 2023 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Statistics] Collect Statistics
4 participants