I am trying to build a Platform Event
-based application logger where arbitrary application code calls Tracker.log(...);
and this is sent as an Event into an external database via an API. As it's important that
- Events are sent even if the transaction fails
- The tracking itself should merely never interfere with the app code
- Tracking should not share Governor limits with triggering transaction
I moved the actual EventBus.publish(...)
to a separate Queueable and configured the event to Publish immediately
.
But when there is a DML or Callout after the Tracker is called like this:
Tracker.log(...);
...
app.makeCallout();
it fails with:
Failed calling callout:XYZ :You have uncommitted work pending. Please
commit or rollback before calling out