-
-
Notifications
You must be signed in to change notification settings - Fork 718
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
Allow to log system activity without a causer or a null causer #567
Comments
Hey, the causer columns are already laravel-activitylog/src/ActivityLogger.php Line 196 in d5fd05e
If you want to log a system activity with a logged in user this could be done by creating the |
as explained by @Gummibeer.
2. Create a new ActivitylogServiceProvider which will extend "Spatie\Activitylog\ActivitylogServiceProvider" and register it in "config/app.php". Add following code in register method of newly created service provider:
This is tested so you should get no issue. |
@junaid-A-khan instead of the laravel-activitylog/src/ActivityLogger.php Lines 189 to 200 in d5fd05e
This does set the init causer - so if you remove this line or adjust the condition when the causer is set yo have a |
@Gummibeer yes, parent construct call can be removed and I'm sorry, my bad, as I tested it on an old Laravel 5.7 witch has v2.8. |
Because atm it's impossible to set the causer to activity()
->anonymous()
->log('my log message'); Doing this for a whole runtime could belong to: |
Perhaps we can use,
or
or
|
I had a look today at a possible solution introducing an AnonymousCauser model which should function as a "null object". Therefore, I would propose the following PR: #604 , though I have some doubt if this approach is suitable. |
It's not clear from the documentation if this can be done or not.
Sometimes there can be activity triggered on events without a causer. Examples are when an action is taken by an unregistered user, a SYSTEM Cron, or a Bot.
Example log items can be:
'Project 123 was archived by the SYSTEM due to non-activity'
'GithubBot locked this thread on 23/05/2019'
'Anonymous user viewed the phone number'
etc
I think the workaround would be to create users with the names 'SYSTEM', 'Bot' etc, and hardcode that userID. Which can cause problems in production and testing environments.
Is there a better way to log such activities?
The text was updated successfully, but these errors were encountered: