|
1 | 1 | # Search Analytics (Matomo) |
2 | 2 |
|
3 | | -This repository supports MIT Libraries' implementation of [Matomo](https://matomo.org/), |
4 | | -which we use to collect discovery analytics. Our implementation uses the Docker |
5 | | -container provided by Matomo. We host the application in AWS Fargate. |
| 3 | +This repository supports MIT Libraries' implementation of [Matomo](https://matomo.org/), which we use to collect discovery analytics. Our implementation uses the Docker container provided by Matomo. We host the application in AWS Fargate. |
6 | 4 |
|
7 | | -## Building |
| 5 | +## Dependencies |
8 | 6 |
|
9 | | -Run `make build` to create a new container tagged as `analytics-stage:latest`. |
| 7 | +* Deploying this container to AWS requires that the AWS ECR Repository for the container has been created by the [mitlib-tf-workloads-ecr](https://github.com/MITLibraries/mitlib-tf-workloads-ecr) repository. |
| 8 | +* Building this container requires access to [Official Docker Matomo](https://hub.docker.com/_/matomo/). |
10 | 9 |
|
11 | | -## Deploying |
| 10 | +## Build |
12 | 11 |
|
13 | | -Run `make dist` to build, tag, and push a container to staging. To promote to |
14 | | -production, run `make publish`. |
| 12 | +Run `make dist-dev` to create a new container tagged as `matomo:latest`. |
15 | 13 |
|
16 | | -Please see the corresponding [Terraform module](https://github.com/MITLibraries/mitlib-terraform/tree/master/apps/analytics) for deployment config. |
| 14 | +## Deploy |
17 | 15 |
|
18 | | -## URLs |
19 | | - |
20 | | -- Staging: analytics-stage.mitlib.net (MIT VPN access only) |
21 | | -- Production: analytics-prod.mitlib.net |
| 16 | +Run `make publish-dev` to build, tag, and push a container to Dev1 for testing, or open a PR to `main`. Merge a PR to `main` to build, tag, and push the container to Stage-Workloads. After merging the PR to `main`, tag a release to promote to production. |
22 | 17 |
|
23 | 18 | ## Implementation notes |
24 | 19 |
|
25 | | -### PHP configuration file |
| 20 | +For detailed instructions on initial setup, migration, database upgrades, and application upgrades, see [docs/HOWTO.md](./docs/HOWTO.md). |
| 21 | + |
| 22 | +### Configuration Management |
| 23 | + |
| 24 | +"State" for Matomo is managed/stored in at most two locations: |
26 | 25 |
|
27 | | -`config.ini.php` file contains some basic Matomo configuration. There are a |
28 | | -couple of sections worth addressing: |
| 26 | +* the `config.ini.php` file |
| 27 | +* the MySQL database |
29 | 28 |
|
30 | | -1. The `Plugins` section tells Matomo which plugins to enable on installation. |
31 | | - To disable a plugin, simply remove it from this section. Our preference is to |
32 | | - modify this section and not the `PluginsInstalled` section, as removing a |
33 | | - plugin from `PluginsInstalled` would remove it from the application completely. |
34 | | -2. The `mail` section configures the SMTP server. Matomo uses mailers for |
35 | | - several core functions, including password resets and reporting. Some related |
36 | | - config values (e.g., `login_password_recovery_email_address`) are defined in |
37 | | - the `General` section. |
| 29 | +The `config.ini.php` file contains some core Matomo configuration. There are a couple of sections worth addressing: |
38 | 30 |
|
39 | | -When deploying from scratch, we noticed that the initial Matomo setup in the GUI |
40 | | -seems to overwrite our config. As a result, it may be necessary on rare occasion |
41 | | -to spin up an EC2 instance to touch the config file directly. So far, we've |
42 | | -only had to do this after the initial deploy, so it's unlikely to come up often. |
| 31 | +1. The `[Plugins]` section tells Matomo which plugins to enable on installation. To disable a plugin, simply remove it from this section. Our preference is to modify this section and not the `PluginsInstalled` section, as removing a plugin from `PluginsInstalled` would remove it from the application completely. *Sadly, with the container-based Matomo, it seems to only way to activate a plugin is to use the Matomo web UI*. |
| 32 | +1. The `[mail]` section configures the SMTP server. Matomo uses mailers for several core functions, including password resets and reporting. Some related config values (e.g., `login_password_recovery_email_address`) are defined in the `[General]` section. |
| 33 | +1. The `[General]` section handles other configurations. A few of these settings are covered by the EnvironmentVariables plugin, but the rest are managed in this code. |
| 34 | + |
| 35 | +By using the [EnvironmentVariables](https://plugins.matomo.org/EnvironmentVariables) plugin for Matomo, we generally don't need to store much in the `config.ini.php` file. Instead, the [mitlib-tf-workloads-matomo](https://github.com/MITLibraries/mitlib-tf-workloads-matomo) code defines the key environment variables for the ECS service, overriding anything in `config.ini.php` and `global.ini.php`. |
| 36 | + |
| 37 | +The database stores the rest of the state of Matomo: all the data itself along with the Superuser credentials and the other user accounts and credentials. |
43 | 38 |
|
44 | 39 | ### Data anonymization |
45 | 40 |
|
46 | | -We anonymize tracking data to protect our users' privacy. Specifically, we mask |
47 | | -two bytes of visitors' IPs (e.g., 192.186.x.x), and we have disabled [Matomo's |
48 | | -User ID plugin](https://matomo.org/docs/user-id/). |
| 41 | +We anonymize tracking data to protect our users' privacy. Specifically, we mask two bytes of visitors' IPs (e.g., 192.186.x.x), and we have disabled [Matomo's User ID plugin](https://matomo.org/docs/user-id/). |
49 | 42 |
|
50 | | -Before promoting a new build to production, ensure that IPs are anonymized by |
51 | | -visiting Administration -> Privacy -> Anonymize data in the GUI. (You shouldn't |
52 | | -ever need to modify these settings, but it's important to verify as part of the |
53 | | -deploy process.) |
| 43 | +Before promoting a new build to production, ensure that IPs are anonymized by visiting Administration -> Privacy -> Anonymize data in the GUI. (You shouldn't ever need to modify these settings, but it's important to verify as part of the deploy process.) |
54 | 44 |
|
55 | 45 | ### Archiving reports |
56 | 46 |
|
57 | | -Matomo calls the process by which it compiles raw log data into human-readable |
58 | | -report 'archiving'. By default, archiving occurs on demand, whenever a Matomo |
59 | | -user attempts to view a report in the GUI. Based on [Matomo's recommendation](https://matomo.org/docs/setup-auto-archiving/), we have configured a cron job to archive reports every |
60 | | -hour. |
61 | | - |
62 | | -The cron job runs as a scheduled ECS task and is defined in the |
63 | | -[Terraform config](https://github.com/MITLibraries/mitlib-terraform/tree/master/apps/analytics). |
| 47 | +Matomo calls the process by which it compiles raw log data into human-readable report 'archiving'. By default, archiving occurs on demand, whenever a Matomo user attempts to view a report in the GUI. Following [Matomo's recommendation](https://matomo.org/docs/setup-auto-archiving/) to schedule this, the mitlib-tf-workloads-matomo infrastructure repository creates an EventBridge rule/schedule for running the reporting archiving hourly. |
64 | 48 |
|
65 | 49 | ### Authentication |
66 | 50 |
|
67 | | -The superuser account can create and manage user |
68 | | -accounts in the GUI (Administration -> System -> Users). After creating a new |
69 | | -account, the superuser should notify the account holder. The account holder |
70 | | -can then reset their password by clicking the 'Lost your password?' link on the |
71 | | -Matomo sign-in page. |
| 51 | +The superuser account can create and manage user accounts in the GUI (Administration -> System -> Users). After creating a new account, the superuser should notify the account holder. The account holder can then reset their password by clicking the 'Lost your password?' link on the Matomo sign-in page. |
72 | 52 |
|
73 | | -We generally assign the 'View' role to new users, unless they require a higher |
74 | | -permissions level. |
| 53 | +We generally assign the 'View' role to new users, unless they require a higher permissions level. |
75 | 54 |
|
76 | | -Matomo has built-in two-factor authentication, which we enforce for all accounts. |
77 | | -When a user logs in to Matomo for the first time, they will be prompted to |
78 | | -configure 2FA. At this time, we are recommending Duo as an authenticator. |
| 55 | +Matomo has built-in two-factor authentication, which we enforce for all accounts. When a user logs in to Matomo for the first time, they will be prompted to configure 2FA. At this time, we are recommending Duo as an authenticator. |
79 | 56 |
|
80 | 57 | ## Additional documentation |
81 | 58 |
|
82 | | -* [MIT Libraries dev docs](https://mitlibraries.github.io/guides/misc/matomo.html) - includes |
83 | | -information about setting up a website for tracking in Matomo. |
84 | | -* [Matomo help center](https://matomo.org/help/) - offical Matomo docs. |
85 | | -Includes user guide, developer guide, FAQ, and community support forum. |
| 59 | +* [MIT Libraries dev docs](https://mitlibraries.github.io/guides/misc/matomo.html) - includes information about setting up a website for tracking in Matomo. |
| 60 | +* [Matomo help center](https://matomo.org/help/) - offical Matomo docs. Includes user guide, developer guide, FAQ, and community support forum. |
0 commit comments