All Projects → nodes-vapor → bugsnag

nodes-vapor / bugsnag

Licence: other
Report errors with Bugsnag 🐛

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to bugsnag

template
A Vapor template for convenient and fast scaffolding 🏎
Stars: ✭ 33 (-10.81%)
Mutual labels:  vapor, server-side-swift, vapor-2, stso
sourcery-templates
Building Vapor projects using meta programming with Sourcery ✨
Stars: ✭ 24 (-35.14%)
Mutual labels:  vapor, server-side-swift, vapor-2, stso
readme
Welcome to Vapor development at Nodes 📖
Stars: ✭ 47 (+27.03%)
Mutual labels:  vapor, server-side-swift, stso
paginator
Offset pagination for Vapor 🗂
Stars: ✭ 67 (+81.08%)
Mutual labels:  vapor, server-side-swift, vapor-2
flash
Flash messages between views ⚡️
Stars: ✭ 34 (-8.11%)
Mutual labels:  vapor, server-side-swift, vapor-2
Telegrammer
Telegram Bot - written with Swift 5.2 / NIO, supports Linux, macOS
Stars: ✭ 248 (+570.27%)
Mutual labels:  vapor, server-side-swift
Console Kit
💻 APIs for creating interactive CLI tools.
Stars: ✭ 252 (+581.08%)
Mutual labels:  vapor, server-side-swift
gatekeeper
Rate limiting middleware for Vapor 👮
Stars: ✭ 54 (+45.95%)
Mutual labels:  vapor, server-side-swift
auth
👤 Authentication and Authorization framework for Fluent.
Stars: ✭ 51 (+37.84%)
Mutual labels:  vapor, server-side-swift
Websocket Kit
WebSocket client library built on SwiftNIO
Stars: ✭ 155 (+318.92%)
Mutual labels:  vapor, server-side-swift
sqlite-kit
Non-blocking SQLite client library with SQL builder built on SwiftNIO
Stars: ✭ 51 (+37.84%)
Mutual labels:  vapor, server-side-swift
fluent-mysql-driver
🖋🐬 Swift ORM (queries, models, relations, etc) built on MySQL.
Stars: ✭ 69 (+86.49%)
Mutual labels:  vapor, server-side-swift
Htmlkit
A type-safe DSL that renders dynamic HTML templates in Swift
Stars: ✭ 229 (+518.92%)
Mutual labels:  vapor, server-side-swift
Http
🚀 Non-blocking, event-driven HTTP built on Swift NIO.
Stars: ✭ 220 (+494.59%)
Mutual labels:  vapor, server-side-swift
VaporTwilioService
Twilio API provider for all your Vapor needs
Stars: ✭ 19 (-48.65%)
Mutual labels:  vapor, server-side-swift
Mysql Kit
🐬 Pure Swift MySQL client built on non-blocking, event-driven sockets.
Stars: ✭ 159 (+329.73%)
Mutual labels:  vapor, server-side-swift
routing-kit
🚍 High-performance trie-node router.
Stars: ✭ 95 (+156.76%)
Mutual labels:  vapor, server-side-swift
async
⏱ Promises and reactive-streams in Swift built for high-performance and scalability.
Stars: ✭ 35 (-5.41%)
Mutual labels:  vapor, server-side-swift
GraphQLRouteCollection
A GraphQL based RouteCollection for Vapor
Stars: ✭ 18 (-51.35%)
Mutual labels:  vapor, server-side-swift
Mistkit
Swift Package for Server-Side and Command-Line Access to CloudKit Web Services
Stars: ✭ 129 (+248.65%)
Mutual labels:  vapor, server-side-swift

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.
    app.middleware.use(BugsnagMiddleware())
}

Reporting

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

// Reporting from Application.
app.bugsnag.report(Abort(.internalServerError))

// Reporting from Request.
app.get("test") { req in
    req.bugsnag.report(Abort(.upgradeRequired))
    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 [:]

Users

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

extension TestUser: BugsnagUser {
    var bugsnagID: CustomStringConvertible? { 
        self.id
    }
}

Configure all user models you would like Bugsnag to report.

// Add to configure.swift.
app.bugsnag.users.add(TestUser.self)

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

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

req.bugsnag.breadcrumb(
    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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].