Swiftpack.co -  nodes-vapor/bugsnag as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Report errors with Bugsnag πŸ›
.package(url: "https://github.com/nodes-vapor/bugsnag.git", from: "4.0.0-rc.2")

Bugsnag πŸ›

Swift Version Vapor Version Circle CI codebeat badge codecov Readme Score GitHub license

Reporting errors to Bugsnag.

πŸ“¦ Installation

Integrating Bugsnag in your project

Update your Package.swift file.

.package(url: "https://github.com/nodes-vapor/bugsnag.git", from: "4.0.0")

Update configure.swift

public func configure(_ app: Application) throws {
    // Configure Bugsnag.
    app.bugsnag.configuration = .init(
        apiKey: "<YOUR BUGSNAG API KEY>",
        releaseStage: app.environment.name,
        shouldReport: app.environment.name != "local"

    // Add Bugsnag middleware.


BugsnagMiddleware will automatically report errors thrown by your route handlers. You can report errors manually from Application or Request.

// Reporting from Application.

// Reporting from Request.
app.get("test") { req in
    return HTTPStatus.ok

By conforming to the BugsnagError protocol you can have full control over how your errors are reported. It has the following properties:

Name Type Function Default
shouldReport Bool Opt out of error reporting by returning false true
severity Severity Indicate error severity (.info|.warning|.error) .error
metadata [String: CustomDebugStringConvertible] Additional metadata to include in the report [:]


Conforming your Authenticatable model to BugsnagUser allows you to easily pair the data to a report.

extension TestUser: BugsnagUser {
    var bugsnagID: CustomStringConvertible? { 

Configure all user models you would like Bugsnag to report.

// Add to configure.swift.

Bugsnag will automatically check Vapor's authentication API for the configured user types and report the user's identifier if they are logged in.


Breadcrumbs enable you to attach custom events to your reports. Leave a breadcrumb using the convenience function on Request.

    name: "Something happened!",
    type: .manual,
    metadata: ["foo": "bar"]

The breadcrumb types are provided by Bugsnag:

enum BugsnagBreadcrumbType {
    case error
    case log
    case manual
    case navigation
    case process
    case request
    case state
    case user

Key Filters

Usually you will receive information such as headers, query params or post body fields in the reports from Bugsnag. To ensure that you do not track sensitive information, you can configure Bugsnag with a list of fields that should be filtered out:

app.bugsnag.configuration = .init(
    apiKey: "foo",
    releaseStage: "debug",
    keyFilters: ["email", "password"]

In this case Bugsnag Reports will hide header fields, query params or post body json fields with the keys/names email and password.

⚠️ Note: If key filters are defined and Bugsnag does not know how to parse the request body, the entire body will be hidden.

πŸ† Credits

This package is developed and maintained by the Vapor team at Nodes.

πŸ“„ License

This package is open-sourced software licensed under the MIT license.


Stars: 37
Last commit: 5 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.


Related Packages

Release Notes

Version 4.0.0 RC 2
42 weeks ago


  • Filter out sensitive data from the HTTP headers (#75 thanks to @raphaelcruzeiro πŸ’―)

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API