In many cases you may want to set causer globally maybe inside jobs where there's no logged-in user, v4 made this possible by introducing CauserResolver
that will allow you to set the causer globally. See the example:
use Spatie\Activitylog\Facades\CauserResolver;
$product = Product::first(1);
$causer = $product->owner;
CauserResolver::setCauser($causer);
$product->update(['name' => 'New name']);
Activity::all()->last()->causer;
Activity::all()->last()->causer->id;
##Define Causer using callback
You can resolve causer using provided callback to resolve
method