decoupled_json_log
Provides a "JSON log" entity type for decoupled websites to upload frontend errors to Drupal.
This module provides a JSON Log entity type (machine name: log_json) to help
developers log frontend errors to Drupal.
This is especially useful for decoupled apps, like mobile apps that use a
frontend framework like Ionic with Drupal for the backend.
Sure, you could use a third-party service, but then you have to put your users'
privacy at risk, plus you usually have to pay for it.
If you're already using Drupal, why not use that to collect logs, too?
Features
- Uses JSON fields to store log data. Since you are likely already using JSON on the frontend, you can just send the JSON directly up to Drupal.
Post-Installation
Todo
Additional Requirements
- JSON Field module: Because this module stores JSON objects, it uses JSON field.
Post Installation
Go to `/admin/people/permissions` and give the `Create json logs` permission to
all roles that should be able to create logs.
Determine what you want to log. By default, this module provides an `error`
bundle for logging errors. You can add other log types at
`/admin/structure/log_json_types`.
Go to `/admin/config/decoupled_json_log` and confirm the rate limit settings.
By default, the anonymous users can log 500 events a day, while authenticated
users can log up to 50 events each. This is done to prevent too many logs from
being created and causing your Drupal site to experience a DDoS attack from your
own app if the frontend code is buggy.
Assumptions
This module assumes you want to let users log events but limit access to
managing those logged events to admins.
For this reason, you can only POST log entities via REST and JSON:API;
you cannot GET, PATCH, or DELETE them. If you object to this open a feature
request and I will make it configurable.
More Information
For sample frontend code, see the README.
Supporting this Module
All contributions are welcome. Please submit MRs, not patches, so that the CI tests are run. Please add tests if possible.
If you post an issue and do not receive a response, feel free to contact me by private message in the Drupal Slack (ptmkenny) or via my Drupal.org contact form.