Skip to content

Commit

Permalink
Removing MeterPayloadProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Sep 15, 2024
1 parent 9481f6b commit 2d5c5c2
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 278 deletions.
38 changes: 29 additions & 9 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
// swift-tools-version:5.5
// swift-tools-version: 5.9

import PackageDescription

let package = Package(
name: "Meter",
platforms: [.macOS(.v10_13), .iOS(.v12), .tvOS(.v12), .watchOS(.v3)],
platforms: [
.macOS(.v10_13),
.iOS(.v12),
.tvOS(.v12),
.watchOS(.v4),
.visionOS(.v1),
],
products: [
.library(name: "Meter", targets: ["Meter"]),
],
dependencies: [],
targets: [
.target(name: "BinaryImage", publicHeadersPath: "."),
.target(name: "Meter", dependencies: ["BinaryImage"]),
.testTarget(name: "MeterTests",
dependencies: ["Meter"],
resources: [
.copy("Resources"),
]),
.testTarget(name: "BinaryImageTests",
dependencies: ["BinaryImage"]),
.testTarget(
name: "MeterTests",
dependencies: ["Meter"],
resources: [
.copy("Resources"),
]
),
.testTarget(
name: "BinaryImageTests",
dependencies: ["BinaryImage"]
),
]
)

let swiftSettings: [SwiftSetting] = [
.enableExperimentalFeature("StrictConcurrency")
]

for target in package.targets {
var settings = target.swiftSettings ?? []
settings.append(contentsOf: swiftSettings)
target.swiftSettings = settings
}
23 changes: 0 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,6 @@ As of iOS 17, macOS 14, visionOS 1.0, MetricKit does capture uncaught [NSExcepti

How you actually get access to the `NSException` is not defined by Meter. But, if you have one, the `CrashDiagnostic` type also includes an `exceptionInfo` property that can accept one of these for easy encoding.

## MXMetricManager and Diagnostics Polyfill

MetricKit's crash reporting facilities require iOS 14/macOS 12.0, and isn't supported at all for tvOS or watchOS. You may want to start moving towards using it as a standard interface between your app and whatever system consumes the data. Meter offers an API that's very similar to MetricKit's `MXMetricManager` to help do just that.

```swift
// adding a subscriber
MeterPayloadManager.shared.add(obj)

extension MyObject: MeterPayloadSubscriber {
func didReceive(_ payloads: [DiagnosticPayloadProtocol]) {
// this will be called for both simulated payloads *and* MeterKit payloads on OSes it supports
print("received payloads \(payloads)")
}
}

// posting diagnostics
MeterPayloadManager.shared.deliver(payloads)
```

This makes it easier to support the full capabilities of MetricKit when available, and gracefully degrade when they aren't. It can be nice to have a uniform interface to whatever backend system you are using to consume the reports. And, as you move towards a supported minimum, and as (hopefully) Apple starts supporting MetricKit on all platforms, it will be easier to pull out Meter altogether.

Backwards compatibility is still up to you, though. One solution is [ImpactMeterAdapter](https://github.com/ChimeHQ/ImpactMeterAdapter), which uses [Impact](https://github.com/ChimeHQ/Impact) to collect crash data for OSes that don't support `MXCrashDiagnostic`.

## On-Device Symbolication

The stack traces provided by MetricKit, like other types of crash logs, are not symbolicated. There are a bunch of different ways to tackle this problem, but one very convenient option is just to do it as a post-processing step on the device where the crash occurred. This does come, however, with one major drawback. It only works when you still have access to the same binaries. OS updates will almost certainly change all the OS binaries. The same is true for an app update, though in that case, an off-line symbolication step using a dSYM is still doable.
Expand Down
4 changes: 0 additions & 4 deletions Sources/Meter/CallStackTree.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,7 @@ public class CallStackTree: Codable {
}

#if canImport(MetricKit)
#if compiler(>=5.9)
@available(iOS 14.0, macOS 12.0, visionOS 1.0, *)
#else
@available(iOS 14.0, macOS 12.0, *)
#endif
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public static func from(callStackTree: MXCallStackTree) throws -> CallStackTree {
Expand Down
8 changes: 0 additions & 8 deletions Sources/Meter/DiagnosticPayload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ public class DiagnosticPayload: Codable {
}

#if canImport(MetricKit)
#if compiler(>=5.9)
@available(iOS 14.0, macOS 12.0, visionOS 1.0, *)
#else
@available(iOS 14.0, macOS 12.0, *)
#endif
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public static func from(payload: MXDiagnosticPayload) throws -> DiagnosticPayload {
Expand Down Expand Up @@ -119,11 +115,7 @@ public extension DiagnosticPayload {
}

#if canImport(MetricKit)
#if compiler(>=5.9)
@available(iOS 14.0, macOS 12.0, visionOS 1.0, *)
#else
@available(iOS 14.0, macOS 12.0, *)
#endif
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public extension MXDiagnosticPayload {
Expand Down
144 changes: 0 additions & 144 deletions Sources/Meter/MeterPayloadProvider.swift

This file was deleted.

90 changes: 0 additions & 90 deletions Tests/MeterTests/PayloadProviderTests.swift

This file was deleted.

0 comments on commit 2d5c5c2

Please sign in to comment.