# אנונימיזציה של משתמשים ו-staff\_action\_logs

**URL:** https://meta.discourse.org/t/user-anonymization-and-staff-action-logs/199582
**Category:** Support
**Created:** [7 באוגוסט,‏ 2021,‏ 12:54pm UTC](https://meta.discourse.org/t/user-anonymization-and-staff-action-logs/199582 "2021-08-07T12:54:39Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![blackbird](https://avatars.discourse-cdn.com/v4/letter/b/b782af/32.png) [@blackbird](https://meta.discourse.org/u/blackbird)
#### Post date: [7 באוגוסט,‏ 2021,‏ 12:54pm UTC](https://meta.discourse.org/t/user-anonymization-and-staff-action-logs/199582/1 "2021-08-07T12:54:39Z")

</div>

Hi all,

I found it odd, that after I anonymize a user I am still able to see an old user name and email linked to new “anonymized”, random username under admin/logs/staff\_action\_logs. It does not seem to me like it  
is real anonymization and probably keeping this data in logs forever is an offense against EU GDPR laws.

I also see a little benefit from keeping logs of such actions. Could you please tell me how to remove this logs permanently and maybe it is also possibly to clean Discourse logs periodically and limit logging policy somehow?

Thank you in advance

---

<div class="post-metadata">

### Author: ![ondrej](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ondrej/32/198804_2.png) [@ondrej](https://meta.discourse.org/u/ondrej)
#### Post date: [7 באוגוסט,‏ 2021,‏ 12:58pm UTC](https://meta.discourse.org/t/user-anonymization-and-staff-action-logs/199582/2 "2021-08-07T12:58:03Z")

</div>

Hello,

You need to uncheck this setting `log anonymizer details` to stop this happening again. When complying with GDPR you must turn this off.

I’m not sure about removing this from logs though.

---

<div class="post-metadata">

### Author: ![blackbird](https://avatars.discourse-cdn.com/v4/letter/b/b782af/32.png) [@blackbird](https://meta.discourse.org/u/blackbird)
#### Post date: [7 באוגוסט,‏ 2021,‏ 1:01pm UTC](https://meta.discourse.org/t/user-anonymization-and-staff-action-logs/199582/3 "2021-08-07T13:01:31Z")

</div>

Hi Ondrej, thank you for fast answer.

Ok, I disabled this option however the actions that are logged already are still visible. How can I remove logs?

---

<div class="post-metadata">

### Author: ![Hooksmith](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hooksmith/32/142826_2.png) [@Hooksmith](https://meta.discourse.org/u/Hooksmith)
#### Post date: [7 באוגוסט,‏ 2021,‏ 2:28pm UTC](https://meta.discourse.org/t/user-anonymization-and-staff-action-logs/199582/4 "2021-08-07T14:28:25Z")

</div>

For getting rid of old rows after enabling the aforementioned setting, first inspect relevant user history rows via rails console:  
`UserHistory.where(action: 24)`

Once you’re sure that the above covers all the rows you want to ensure no longer have any user data attached in the logs, run this in the rails console:  
`UserHistory.where(action: 24).update_all(details: nil, email: nil)`

(The “details” and “email” is what contains the personal data and will be wiped by above. Deleting the rows is not necessary for GDPR compliance, but if you want that, use `delete_all`.)

Run at your own risk and make backups before running database commands at scale.

You might also want to trigger a vacuum on postgresql so that any dead tuples that still have the values are actually deleted, after running the commands above.

---

<div class="post-metadata">

### Author: ![blackbird](https://avatars.discourse-cdn.com/v4/letter/b/b782af/32.png) [@blackbird](https://meta.discourse.org/u/blackbird)
#### Post date: [7 באוגוסט,‏ 2021,‏ 6:32pm UTC](https://meta.discourse.org/t/user-anonymization-and-staff-action-logs/199582/5 "2021-08-07T18:32:04Z")

</div>

Thanks Hooksmith, your solution works. However I can see no reason for not running from time to time:  
`
UserHistory.delete_all
`  
Maybe I will write a script to run it weekly.  
Take care

---

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [8 באוגוסט,‏ 2021,‏ 11:46am UTC](https://meta.discourse.org/t/user-anonymization-and-staff-action-logs/199582/6 "2021-08-08T11:46:00Z")

</div>

That night be the better way as sometimes I have had to undo an anonymous action due to poor judgement of a staff member. It is not perfect but as an admin did figure a way to restore and anonymized user.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [9 באוגוסט,‏ 2021,‏ 11:39pm UTC](https://meta.discourse.org/t/user-anonymization-and-staff-action-logs/199582/7 "2021-08-09T23:39:11Z")

</div>

> [@blackbird](#):
>
> However I can see no reason for not running from time to time:  
> `UserHistory.delete_all`

This table provides the data that is used to populate your site’s staff action logs. It’s useful to keep the history of your site’s staff members intact. At the very least, it’s helpful for debugging issues on the site that are related to settings being changed by staff members.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [8 בספטמבר,‏ 2021,‏ 11:39pm UTC](https://meta.discourse.org/t/user-anonymization-and-staff-action-logs/199582/8 "2021-09-08T23:39:39Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
