SlackErrorExporter class
A convenience ErrorExporter that sends error reports to a Slack channel via an Incoming Webhook URL.
This is a thin wrapper around HttpErrorExporter pre-configured with SlackPayloadFormatter. For full control over the formatter or transport, compose HttpErrorExporter and SlackPayloadFormatter directly.
To obtain a webhook URL, create an Incoming Webhook in your Slack app settings: https://api.slack.com/messaging/webhooks
Use payloadBuilder to merge dynamic top-level fields into the Slack webhook payload, or headersBuilder to inject dynamic HTTP headers on every send. Both are useful when routing through a proxy that requires extra keys or authentication:
final exporter = SlackErrorExporter(
'https://proxy.example.com/slack',
payloadBuilder: () => {
'channel': '#alerts',
'username': 'ErrorBot',
},
headersBuilder: () => {
'Authorization': 'Bearer ${tokenProvider.current}',
'X-Routing-Key': 'my-service',
},
);
- Inheritance
-
- Object
- HttpErrorExporter
- SlackErrorExporter
Constructors
-
SlackErrorExporter(String webhookUrl, {Map<
String, dynamic> payloadBuilder()?, Map<String, String> headersBuilder()?}) -
Creates a SlackErrorExporter that posts to the given
webhookUrl.
Properties
- formatter → ErrorFormatter
-
The formatter that converts log records into the request body.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headersBuilder
→ Map<
String, String> Function()? -
Optional callback invoked on every send to supply additional HTTP headers.
finalinherited
-
payloadBuilder
→ Map<
String, dynamic> Function(Map<String, dynamic> )? -
Optional callback to transform the formatted payload before delivery.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- url → String
-
The URL to POST the formatted payload to.
finalinherited
Methods
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited