Skip to content

Commit 9cffdeb

Browse files
authored
feat: add public interface to the sdk version (#428)
Adds Capture.Logger.sdkVersion() for both Apple and Android platforms (using `+[CAPLogger sdkVersion]` for Objective-C) Picked `sdkVersion` over `version` to avoid shadowing NSObject.version() https://developer.apple.com/documentation/objectivec/nsobject-swift.class/version()
1 parent 5891298 commit 9cffdeb

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/Capture.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ object Capture {
105105
// This is a lazy property to avoid the need to initialize the main thread handler unless needed here
106106
private val mainThreadHandler by lazy { MainThreadHandler() }
107107

108+
/**
109+
* Get the current version of the Capture library
110+
*
111+
* @return the version as a String
112+
*/
113+
@JvmStatic
114+
val sdkVersion: String get() {
115+
return BuildConstants.SDK_VERSION
116+
}
117+
108118
/**
109119
* WARNING: For now this API is not exposed to customers. If there is a request for this
110120
* will open visibility again

platform/swift/source/Capture.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ extension Logger {
3131
self.getShared()
3232
}
3333

34+
/// Get the current version of the Capture library
35+
///
36+
/// - returns: the version as a String
37+
public static var sdkVersion: String {
38+
capture_get_sdk_version()
39+
}
40+
3441
/// Initializes the Capture SDK with the specified API key, providers, and configuration.
3542
/// Calling other SDK methods has no effect unless the logger has been initialized.
3643
/// Subsequent calls to this function will have no effect.

platform/swift/source/LoggerObjc.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// LICENSE file or at:
66
// https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt
77

8+
internal import CaptureLoggerBridge
89
import Foundation
910

1011
@objc(CAPIssueReporterType)
@@ -124,6 +125,14 @@ public final class LoggerObjc: NSObject {
124125
Capture.Logger.setSleepMode(mode)
125126
}
126127

128+
/// Get the current version of the Capture library
129+
///
130+
/// - returns: the version as a String
131+
@objc
132+
public static func sdkVersion() -> String {
133+
return capture_get_sdk_version()
134+
}
135+
127136
/// Defines the initialization of a new session within the current configured logger.
128137
/// If no logger is configured, this is a no-op.
129138
@objc

0 commit comments

Comments
 (0)