Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow SDK consumers to specify release name #285

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/Remote Logging/Crash Logging/CrashLogging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public class CrashLogging {
options.diagnosticLevel = .error

options.environment = self.dataProvider.buildType
switch self.dataProvider.releaseName {
case .setByApplication(let name): options.releaseName = name
case .setByTracksLibrary: options.releaseName = nil
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving a breadcrumb: this is bug (addressed in Android in: Automattic/Automattic-Tracks-Android#209)

}
options.enableAutoSessionTracking = self.dataProvider.shouldEnableAutomaticSessionTracking
options.enableAppHangTracking = self.dataProvider.enableAppHangTracking
options.enableCaptureFailedRequests = self.dataProvider.enableCaptureFailedRequests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public protocol CrashLoggingDataProvider {
var sentryDSN: String { get }
var userHasOptedOut: Bool { get }
var buildType: String { get }
var releaseName: ReleaseName { get }
var currentUser: TracksUser? { get }
var additionalUserData: [String: Any] { get }
var errorEventsSamplingRate: Double { get }
Expand All @@ -19,9 +20,28 @@ public protocol CrashLoggingDataProvider {
var enableCaptureFailedRequests: Bool { get }
}

public enum ReleaseName {
/**
Sets the release name attached for every event sent to Sentry. It's intended to use in debug.
- Parameter name: The name of the release.
*/
case setByApplication(name: String)

/**
Delegates setting the release name to the Tracks library. It's intended to use in release
builds. The crash logging framework will single-handedly set the release name based on the
build configuration.
*/
case setByTracksLibrary
}

/// Default implementations of common protocol properties
public extension CrashLoggingDataProvider {

var releaseName: ReleaseName {
return ReleaseName.setByTracksLibrary
}

var additionalUserData: [String: Any] {
return [ : ]
}
Expand Down