Skip to content

Commit 3e3cc2e

Browse files
authored
audit activity proc (#445)
* audit activity proc * update dead links
1 parent 98db069 commit 3e3cc2e

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

docs/3.0/audit-logging/index.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,21 @@ end # [!code focus]
174174
```
175175
:::
176176

177+
The `activity` key also supports a lambda to dynamically determine if the activity should be logged.
178+
179+
Within this block, you gain access to all attributes of [`Avo::ExecutionContext`](./../execution-context) along with the `payload`, `action`, `records` and `activity_class`.
180+
181+
A common use case is to configure audit logging for specific users, for example if you have a `User` model and a method `audit_avo_activity?` on it that returns a boolean that indicates if activities should be logged for the user:
182+
183+
```ruby
184+
# app/avo/resources/product.rb
185+
class Avo::Resources::Product < Avo::BaseResource # [!code focus]
186+
self.audit_logging = { # [!code ++] [!code focus]
187+
activity: -> { current_user.audit_avo_activity? } # [!code ++] [!code focus]
188+
} # [!code ++] [!code focus]
189+
end # [!code focus]
190+
```
191+
177192
All resources and actions with audit logging activity enabled are being tracked now.
178193

179194
But these activities aren't visible yet, right? Let's look at how to display them in the next step.

docs/4.0/audit-logging/index.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,21 @@ end # [!code focus]
174174
```
175175
:::
176176

177+
The `activity` key also supports a lambda to dynamically determine if the activity should be logged.
178+
179+
Within this block, you gain access to all attributes of [`Avo::ExecutionContext`](./../execution-context) along with the `payload`, `action`, `records` and `activity_class`.
180+
181+
A common use case is to configure audit logging for specific users, for example if you have a `User` model and a method `audit_avo_activity?` on it that returns a boolean that indicates if activities should be logged for the user:
182+
183+
```ruby
184+
# app/avo/resources/product.rb
185+
class Avo::Resources::Product < Avo::BaseResource # [!code focus]
186+
self.audit_logging = { # [!code ++] [!code focus]
187+
activity: -> { current_user.audit_avo_activity? } # [!code ++] [!code focus]
188+
} # [!code ++] [!code focus]
189+
end # [!code focus]
190+
```
191+
177192
All resources and actions with audit logging activity enabled are being tracked now.
178193

179194
But these activities aren't visible yet, right? Let's look at how to display them in the next step.

0 commit comments

Comments
 (0)