Skip to content

Commit

Permalink
[td] log error instead of throwing
Browse files Browse the repository at this point in the history
In clients whom intentionally decide to not initialise TelemetryDeck (for example on non-produciton environments, unit tests, etc), they would have to add a wrapper around all the interactions in order to avoid a situation which would throw 500s when used in requests.

This wasn't intentional, and the error didn't seem relevant enough to warrant a reaction by the client. If you've not registered - it's probably for a reason.

So we've replaced it with a log instead. May consider making it a one-off, will consider options.
  • Loading branch information
Sherlouk committed Feb 17, 2022
1 parent a205cb7 commit 8fd9cc5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 5 additions & 2 deletions Sources/TelemetryDeck/Application+Telemetry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ public extension Application {
additionalPayload: [String: String] = [:]
) -> EventLoopFuture<ClientResponse> {
guard let appID = storage.appID else {
return application.eventLoopGroup.next()
.future(error: TelemetryDeckError.notInitialised)
application.logger.error(
"failed to send TelemetryDeck signal - library not initialised",
metadata: ["signal": .string(signalType)]
)
return application.eventLoopGroup.next().future(ClientResponse())
}

var payload: [String: String] = [:]
Expand Down
4 changes: 0 additions & 4 deletions Sources/TelemetryDeck/Models.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ public struct TelemetryDeckConfiguration {
public let apiBaseURL: URL
}

public enum TelemetryDeckError: Error {
case notInitialised
}

internal struct SignalPostBody: Codable, Equatable {
/// When was this signal generated
let receivedAt: Date
Expand Down

0 comments on commit 8fd9cc5

Please sign in to comment.