Sync
Activity Log
The activity log shows every webhook Shopify sends to your site and every import you run, and what each one changed in Statamic. Find it under Shopify > Activity in the control panel. The Shopify dashboard also shows the latest entries.
You need the Manage Shopify Imports (access shopify) permission to see it.
What's recorded
Each entry shows:
When it happened.
Source: a webhook, the control panel (import buttons, the re-import action, retries) or the command line (
php artisan shopify:import:*).Topic and store: the webhook topic, such as
products/update, and in multi-store mode, the store it came from.Resource: the product, collection, order or customer in Shopify, with a link to the Statamic entry or term it updated.
Status:
Status |
Meaning |
|---|---|
Received |
A webhook was accepted and is being handled |
Queued |
An import job is waiting on the queue |
Updated |
Statamic content was created or updated |
Deleted |
Statamic content was deleted |
Skipped |
Nothing needed doing, e.g. the product no longer exists in Shopify |
Duplicate |
Shopify re-sent a webhook that had already been handled |
Rejected |
A webhook failed verification (bad signature or unknown store) |
Failed |
The import failed; the error is shown |
Details: the error message for failures, and for products, how many variants were added, updated or removed.
An order webhook records the order itself and, beneath it, an entry for each product it updated (purchase history and stock).
Customer webhooks only record the customer's Shopify ID; names and email addresses are never stored in the log. For rejected webhooks, nothing from the request body is stored.
Each imported product also gets a shopify_synced_at timestamp, so you can see when it was last updated from Shopify.
Retrying failed imports
Failed product and collection imports have a Retry button, which queues the import again. The retry gets its own entry, linked to the one that failed.
Storage
By default the log is stored as files under storage/statamic/shopify/activity. This works on a single server.
If your site runs on more than one server, or has queue workers on other machines, they'd each write to their own files. Use the database driver instead so they share one log:
SHOPIFY_ACTIVITY_DRIVER=database
Then run the migration that creates the shopify_activity table:
php artisan migrate
The migration loads automatically when the database driver is selected. To customise it, publish it with php artisan vendor:publish --tag=shopify-migrations. You can also set the connection and table name:
SHOPIFY_ACTIVITY_DB_CONNECTION=mysql
SHOPIFY_ACTIVITY_TABLE=shopify_activity
Retention
Entries older than 30 days are removed by the shopify:activity:prune command, which the addon schedules to run daily. Make sure Laravel's scheduler is running. To keep entries for longer or shorter:
SHOPIFY_ACTIVITY_RETENTION_DAYS=90
You can also prune manually, e.g. php artisan shopify:activity:prune --days=7.
Turning it off
SHOPIFY_ACTIVITY_ENABLED=false
Recording activity never affects webhooks or imports. If the log can't be written (a full disk, or the database is unavailable), the webhook or import carries on and a warning is written to your application log.
Using the log in your own code
The log is behind the Thoughtco\Shopify\Contracts\ActivityRepository interface, so you can read it yourself or bind your own implementation:
use Thoughtco\Shopify\Contracts\ActivityRepository;
$failed = app(ActivityRepository::class)->paginate(['status' => 'failed'], perPage: 50);