All Projects → ChimeHQ → Wells

ChimeHQ / Wells

Licence: BSD-3-Clause License
A lightweight diagnostics report submission system

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Wells

Rome
Carthage cache for S3, Minio, Ceph, Google Storage, Artifactory and many others
Stars: ✭ 724 (+2684.62%)
Mutual labels:  apple, tvos, watchos
Swift Sdk
LeanCloud Swift SDK
Stars: ✭ 110 (+323.08%)
Mutual labels:  apple, tvos, watchos
Swiftui
A collaborative list of awesome SwiftUI resources. Feel free to contribute!
Stars: ✭ 774 (+2876.92%)
Mutual labels:  apple, tvos, watchos
TermiNetwork
🌏 A zero-dependency networking solution for building modern and secure iOS, watchOS, macOS and tvOS applications.
Stars: ✭ 80 (+207.69%)
Mutual labels:  apple, tvos, watchos
Objc Sdk
LeanCloud Objective-C SDK
Stars: ✭ 186 (+615.38%)
Mutual labels:  apple, tvos, watchos
Flint
The Flint framework for building apps on Apple platforms using Feature Driven Development
Stars: ✭ 636 (+2346.15%)
Mutual labels:  apple, tvos, watchos
Conbini
Publishers, operators, and subscribers to supplement Combine.
Stars: ✭ 109 (+319.23%)
Mutual labels:  apple, tvos, watchos
Countly Sdk Ios
Countly Product Analytics iOS SDK with macOS, watchOS and tvOS support.
Stars: ✭ 585 (+2150%)
Mutual labels:  crash-reporting, tvos, watchos
Wwdc Notes
WWDCNotes.com content ✨
Stars: ✭ 183 (+603.85%)
Mutual labels:  apple, tvos, watchos
Apple Runtime Headers
Objective-C runtime headers for Apple's iOS, macOS, tvOS and watchOS frameworks
Stars: ✭ 174 (+569.23%)
Mutual labels:  apple, tvos, watchos
Attributedstring
基于Swift插值方式优雅的构建富文本, 支持点击长按事件, 支持不同类型过滤, 支持自定义视图等.
Stars: ✭ 294 (+1030.77%)
Mutual labels:  apple, tvos, watchos
Wwdc
You don't have the time to watch all the WWDC session videos yourself? No problem me and many contributors extracted the gist for you 🥳
Stars: ✭ 2,561 (+9750%)
Mutual labels:  apple, tvos, watchos
Swiftui Charts
🚀 SwiftUI Charts with custom styles
Stars: ✭ 272 (+946.15%)
Mutual labels:  apple, tvos, watchos
Open Source Ios Apps
📱 Collaborative List of Open-Source iOS Apps
Stars: ✭ 28,826 (+110769.23%)
Mutual labels:  apple, tvos, watchos
SwiftGenStrings
genstrings replacement for Swift that actually works
Stars: ✭ 29 (+11.54%)
Mutual labels:  apple, tvos, watchos
Swiftui Grid
🚀 SwiftUI Grid layout with custom styles
Stars: ✭ 872 (+3253.85%)
Mutual labels:  apple, tvos, watchos
Sentry Cocoa
The official Sentry SDK for iOS, tvOS, macOS, watchOS
Stars: ✭ 370 (+1323.08%)
Mutual labels:  crash-reporting, tvos, watchos
Impact
Crash capturing library for Apple platforms
Stars: ✭ 395 (+1419.23%)
Mutual labels:  crash-reporting, tvos, watchos
Swiftui Shapes
🚀 Collection of SwiftUI shapes
Stars: ✭ 137 (+426.92%)
Mutual labels:  apple, tvos, watchos
Human Interface Guidelines Extras
Community additions to Apple's Human Interface Guidelines
Stars: ✭ 225 (+765.38%)
Mutual labels:  apple, tvos, watchos

License Platforms

Wells

A lightweight diagnostics report submission system.

Integration

dependencies: [
    .package(url: "https://github.com/ChimeHQ/Wells")
]

Getting Started

Wells is just a submission system, and tries not to make any assumptions about the source or contents of the reports it transmits. It contains two main components: WellsReporter and WellsUploader. By default, these work together. But, WellsUploader can be used separately if you need more control over the process.

Because of it's flexibility, Wells requires you to do a little more work to wire it up to your source of diagnostic data. Here's what an simple setup could look like. Keep in mind that Wells uploads data using NSURLSession background uploads. This means that the start and end of an upload may not occur during the same application launch.

If you use WellsReporter to submit data, it will manage the cross-launch details itself. But, if you need more control, or want to manage the on-disk files yourself, you'll need to provide it with a ReportLocationProvider that can map identifiers back to file URLs.

import Foundation
import Wells

class MyDiagnosticReporter {
    private let reporter: WellsReporter

    init() {
        self.reporter = WellsReporter()
        
        reporter.existingLogHandler = { url, date in
            // might want to examine date to see how old
            // the date is (and handle errors more gracefully)
            try? submit(url: url)
        }
    }

    func start() throws {
        // submit files, including an identifier unique to each file
        let logURLs = getExistingLogs()

        for url in logURLs {
            try submit(url: url)
        }

        // or, just submit bytes
        let dataList = getExistingData()

        for data in dataList {
            let request = makeURLRequest()
            reporter.submit(data, uploadRequest: request)
        }

    }

    func submit(url: URL) throws {
        let logIdentifier = computeUniqueIdentifier(for: url)
        let request = makeURLRequest()

        try reporter.submit(fileURL: url, identifier: logIdentifier, uploadRequest: request)
    }

    func computeUniqueIdentifier(for url: URL) -> String {
        // this works, but a more robust solution would be based on the content of the data. Note that
        // the url itself *may not* be consistent from launch to launch.
        return UUID().uuidString
    }

    // Finding logs/data is up to you
    func getExistingLogs() -> [URL] {
        return []
    }

    func getExistingData() -> [Data] {
        return []
    }

    func makeURLRequest() -> URLRequest {
        // You have control over the URLRequest that Wells uses. However,
        // some additional metadata will be added to enablee cross-launch tracking.
        let endpoint = URL(string: "https://mydiagnosticservice.com")!

        var request = URLRequest(url: endpoint)

        request.httpMethod = "PUT"
        request.addValue("hiya", forHTTPHeaderField: "custom-header")

        return request
    }
}

Retries

Because that Wells manages submissions across app launches, retry logic can be complex. Wells will do its best to retry unsuccesful submissions. It respects the Retry-After HTTP header and has backoff. But, it is possible that the hosting app is terminated while a backoff delay is pending. In this situation, WellsReporter relies on its existingLogHandler property to avoid needing persistent storage.

By default, if there are files found within the baseURL directory that are older than 2 days, Wells will give up and delete them.

Bottom line: Wells submissions are best effort. Robust retry support means you have to make use of existingLogHandler. There are pathological, if improbable situations that could prevent the submission and retry system from working in a predictable way.

Using With MetricKit

Wells works great for submitting data gathered from MetricKit. In fact, MeterReporter uses it for a full MetricKit-based reporting system.

But, you can also do it yourself. Here's a simple example.

import Foundation
import MetricKit
import Wells

class MetricKitOnlyReporter: NSObject {
    private let reporter: WellsReporter
    private let endpoint = URL(string: "https://mydiagnosticservice.com")!

    override init() {
        self.reporter = WellsReporter()

        super.init()

        MXMetricManager.shared.add(self)
    }

    private func submitData(_ data: Data) {
        var request = URLRequest(url: endpoint)

        request.httpMethod = "PUT"

        // ok, yes, I have glossed over error handling
        try? reporter.submit(data, uploadRequest: request)
    }
}

extension MetricKitOnlyReporter: MXMetricManagerSubscriber {
    func didReceive(_ payloads: [MXMetricPayload]) {
    }

    func didReceive(_ payloads: [MXDiagnosticPayload]) {
        payloads.map({ $0.jsonRepresentation() }).forEach({ submitData($0) })
    }
}

Namesake

Wells is all about reporting, so it seemed logical to name it after a notable journalist.

Suggestions or Feedback

We'd love to hear from you! Get in touch via twitter, an issue, or a pull request.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

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].