Execute PrivacyManager.anonymizeSomeRawData via cron/API


I want to execute PrivacyManager.anonymizeSomeRawData via an API so that I can regularly anonymize IPs in the database.

How can that be done? I found ./console privacymanager:anonymize-some-raw-data, but not sure how to use it with parameters. Is there any documentation for that (https://developer.matomo.org/api-reference/reporting-api doesn’t mention the console command).

Bonus question: Which cron/script executes the scheduled anonymizations found in matomo_privacy_logdata_anonymizations?

I figured out you can run ./console privacymanager:anonymize-some-raw-data --anonymize-ip --date "2023-09-01,2023-09-30" this command.

The problem is, you still have to confirm it with “OK”. How to do this in a bash script so I can use it in a cron? Is there any --force parameter to skip the confirmation?

Hi @chr1d
I would say there is a --force parameter, as there is also a command for running all tasks:

/console core:run-scheduled-tasks --force

There is also a plugin that displays scheduled tasks:

./console privacymanager:anonymize-some-raw-data --force --anonymize-ip --date "2023-09-01,2023-09-30"

The “–force” option does not exist.

Your code seems to work, but how can I add privacymanager:anonymize-some-raw-data as a scheduled task?

Hi @chr1d
I created a GitHub ticket to get console tools exhaustive documentation:

Can you try:

./console privacymanager:anonymize-some-raw-data

Then you’ll be able to know which options can be applied?