Skip to content

Commit

Permalink
Merge branch 'develop' into feature/webview-replay
Browse files Browse the repository at this point in the history
  • Loading branch information
maxep authored Apr 25, 2024
2 parents 7ec152f + 79943d3 commit 0930c24
Show file tree
Hide file tree
Showing 54 changed files with 1,622 additions and 303 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Unreleased

- [FEATURE] Support WebView recording in Session Replay. See [#1776][]

# 2.10.0 / 23-04-2024

- [IMPROVEMENT] Add image duplicate detection between sessions. See [#1747][]
- [FEATURE] Add support for 128 bit trace IDs. See [#1721][]
- [FEATURE] Fatal App Hangs are tracked in RUM. See [#1763][]
- [FIX] Avoid name collision with Required Reason APIs. See [#1774][]
- [FEATURE] Support WebView recording in Session Replay. See [#1776][]
- [IMPROVEMENT] Make the SDK compile on macOS 12+. See [#1711][]

# 2.9.0 / 11-04-2024

Expand Down Expand Up @@ -628,6 +632,7 @@ Release `2.0` introduces breaking changes. Follow the [Migration Guide](MIGRATIO
[#1696]: https://github.com/DataDog/dd-sdk-ios/pull/1696
[#1697]: https://github.com/DataDog/dd-sdk-ios/pull/1697
[#1707]: https://github.com/DataDog/dd-sdk-ios/pull/1707
[#1711]: https://github.com/DataDog/dd-sdk-ios/pull/1711
[#1721]: https://github.com/DataDog/dd-sdk-ios/pull/1721
[#1722]: https://github.com/DataDog/dd-sdk-ios/pull/1722
[#1724]: https://github.com/DataDog/dd-sdk-ios/pull/1724
Expand Down
2 changes: 1 addition & 1 deletion DatadogAlamofireExtension.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DatadogAlamofireExtension"
s.version = "2.9.0"
s.version = "2.10.0"
s.summary = "An Official Extensions of Datadog Swift SDK for Alamofire."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogCore.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DatadogCore"
s.version = "2.9.0"
s.version = "2.10.0"
s.summary = "Official Datadog Swift SDK for iOS."

s.homepage = "https://www.datadoghq.com"
Expand Down
8 changes: 6 additions & 2 deletions DatadogCore/Private/ObjcAppLaunchHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
* Copyright 2019-Present Datadog, Inc.
*/

#import <UIKit/UIKit.h>
#import <pthread.h>
#import <sys/sysctl.h>

#import "ObjcAppLaunchHandler.h"

#if TARGET_OS_IOS || TARGET_OS_TV
#import <UIKit/UIKit.h>
#endif

// A very long application launch time is most-likely the result of a pre-warmed process.
// We consider 30s as a threshold for pre-warm detection.
#define COLD_START_TIME_THRESHOLD 30
Expand Down Expand Up @@ -39,7 +42,7 @@ + (void)load {
// This is called at the `DatadogPrivate` load time, keep the work minimal
_shared = [[self alloc] initWithProcessInfo:NSProcessInfo.processInfo
loadTime:CFAbsoluteTimeGetCurrent()];

#if TARGET_OS_IOS || TARGET_OS_TV
NSNotificationCenter * __weak center = NSNotificationCenter.defaultCenter;
id __block __unused token = [center addObserverForName:UIApplicationDidBecomeActiveNotification
object:nil
Expand All @@ -55,6 +58,7 @@ + (void)load {
[center removeObserver:token];
token = nil;
}];
#endif
}

+ (__dd_private_AppLaunchHandler *)shared {
Expand Down
2 changes: 2 additions & 0 deletions DatadogCore/Sources/Core/Context/LaunchTimePublisher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright 2019-Present Datadog, Inc.
*/

#if !os(macOS)
import Foundation
import DatadogInternal

Expand Down Expand Up @@ -42,3 +43,4 @@ internal struct LaunchTimePublisher: ContextValuePublisher {
AppLaunchHandler.shared.setApplicationDidBecomeActiveCallback { _ in }
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,13 @@ extension NetworkConnectionInfo.Reachability {
extension NetworkConnectionInfo.Interface {
@available(iOS 2.0, macCatalyst 13.0, *)
init?(_ flags: SCNetworkReachabilityFlags?) {
#if os(iOS) || os(tvOS)
guard let flags = flags, flags.contains(.isWWAN) else {
return nil
}
self = .cellular
#else
self = .other
#endif
}
}
3 changes: 3 additions & 0 deletions DatadogCore/Sources/Core/DatadogCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,10 @@ extension DatadogContextProvider {
self.init(context: context)

subscribe(\.serverTimeOffset, to: ServerOffsetPublisher(provider: serverDateProvider))

#if !os(macOS)
subscribe(\.launchTime, to: LaunchTimePublisher())
#endif

if #available(iOS 12, tvOS 12, *) {
subscribe(\.networkConnectionInfo, to: NWPathMonitorPublisher())
Expand Down
2 changes: 1 addition & 1 deletion DatadogCore/Sources/Core/Upload/FeatureUpload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal struct FeatureUpload {
? UIKitBackgroundTaskCoordinator()
: nil
#else
let backgroundTaskCoordinator = nil
let backgroundTaskCoordinator: BackgroundTaskCoordinator? = nil
#endif

self.init(
Expand Down
15 changes: 13 additions & 2 deletions DatadogCore/Sources/Datadog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,14 @@ public enum Datadog {
/// Verbosity level of Datadog SDK. Can be used for debugging purposes.
/// If set, internal events occuring inside SDK will be printed to debugger console if their level is equal or greater than `verbosityLevel`.
/// Default is `nil`.
public static var verbosityLevel: CoreLoggerLevel? = nil
public static var verbosityLevel: CoreLoggerLevel? {
get { _verbosityLevel.wrappedValue }
set { _verbosityLevel.wrappedValue = newValue }
}

/// The backing storage for `verbosityLevel`, ensuring efficient synchronized
/// read/write access to the shared value.
private static let _verbosityLevel = ReadWriteLock<CoreLoggerLevel?>(wrappedValue: nil)

/// Returns `true` if the Datadog SDK is already initialized, `false` otherwise.
///
Expand Down Expand Up @@ -365,8 +372,12 @@ public enum Datadog {
consolePrint("⚠️ Catalyst is not officially supported by Datadog SDK: some features may NOT be functional!", .warn)
#endif

#if os(macOS)
consolePrint("⚠️ macOS is not officially supported by Datadog SDK: some features may NOT be functional!", .warn)
#endif

#if swift(>=5.9) && os(visionOS)
consolePrint("⚠️ VisionOS is not officially supported by Datadog SDK: some features may NOT be functional!", .warn)
consolePrint("⚠️ visionOS is not officially supported by Datadog SDK: some features may NOT be functional!", .warn)
#endif

do {
Expand Down
2 changes: 1 addition & 1 deletion DatadogCore/Sources/Versioning.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// GENERATED FILE: Do not edit directly

internal let __sdkVersion = "2.9.0"
internal let __sdkVersion = "2.10.0"
2 changes: 1 addition & 1 deletion DatadogCrashReporting.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DatadogCrashReporting"
s.version = "2.9.0"
s.version = "2.10.0"
s.summary = "Official Datadog Crash Reporting SDK for iOS."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogInternal.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DatadogInternal"
s.version = "2.9.0"
s.version = "2.10.0"
s.summary = "Datadog Internal Package. This module is not for public use."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogInternal/Sources/Concurrency/ReadWriteLock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Foundation
/// An additional method `mutate` allow to safely mutate the value in-place (to read it
/// and write it while obtaining the lock only once).
@propertyWrapper
public final class ReadWriteLock<Value> {
public final class ReadWriteLock<Value>: @unchecked Sendable {
/// The wrapped value.
private var value: Value

Expand Down
33 changes: 31 additions & 2 deletions DatadogInternal/Sources/Context/DeviceInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public struct DeviceInfo: Codable, Equatable, PassthroughAnyCodable {
}
}

#if canImport(UIKit)
import MachO

#if canImport(UIKit)
import UIKit
import MachO

extension DeviceInfo {
/// Creates device info based on UIKit description.
Expand Down Expand Up @@ -96,4 +96,33 @@ extension DeviceInfo {
#endif
}
}
#elseif os(macOS)
/// Creates device info based on Host description.
///
/// - Parameters:
/// - processInfo: The current process information.
extension DeviceInfo {
public init(
processInfo: ProcessInfo = .processInfo
) {
var architecture = "unknown"
if let archInfo = NXGetLocalArchInfo()?.pointee {
architecture = String(utf8String: archInfo.name) ?? "unknown"
}
Host.current().name

let build = (try? Sysctl.osVersion()) ?? ""
let model = (try? Sysctl.model()) ?? ""
let systemVersion = processInfo.operatingSystemVersion

self.init(
name: model.components(separatedBy: CharacterSet.letters.inverted).joined(),
model: model,
osName: "macOS",
osVersion: "\(systemVersion.majorVersion).\(systemVersion.minorVersion).\(systemVersion.patchVersion)",
osBuildNumber: build,
architecture: architecture
)
}
}
#endif
20 changes: 0 additions & 20 deletions DatadogInternal/Sources/Telemetry/Telemetry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ public struct ConfigurationTelemetry: Equatable {
public let forwardErrorsToLogs: Bool?
public let initializationType: String?
public let mobileVitalsUpdatePeriod: Int64?
public let premiumSampleRate: Int64?
public let reactNativeVersion: String?
public let reactVersion: String?
public let replaySampleRate: Int64?
public let sessionReplaySampleRate: Int64?
public let sessionSampleRate: Int64?
public let silentMultipleInit: Bool?
Expand All @@ -36,7 +34,6 @@ public struct ConfigurationTelemetry: Equatable {
public let trackErrors: Bool?
public let trackFlutterPerformance: Bool?
public let trackFrustrations: Bool?
public let trackInteractions: Bool?
public let trackLongTask: Bool?
public let trackNativeErrors: Bool?
public let trackNativeLongTasks: Bool?
Expand All @@ -47,10 +44,8 @@ public struct ConfigurationTelemetry: Equatable {
public let trackUserInteractions: Bool?
public let trackViewsManually: Bool?
public let unityVersion: String?
public let useAllowedTracingOrigins: Bool?
public let useAllowedTracingUrls: Bool?
public let useBeforeSend: Bool?
public let useCrossSiteSessionCookie: Bool?
public let useExcludedActivityUrls: Bool?
public let useFirstPartyHosts: Bool?
public let useLocalEncryption: Bool?
Expand Down Expand Up @@ -253,10 +248,8 @@ extension Telemetry {
forwardErrorsToLogs: Bool? = nil,
initializationType: String? = nil,
mobileVitalsUpdatePeriod: Int64? = nil,
premiumSampleRate: Int64? = nil,
reactNativeVersion: String? = nil,
reactVersion: String? = nil,
replaySampleRate: Int64? = nil,
sessionReplaySampleRate: Int64? = nil,
sessionSampleRate: Int64? = nil,
silentMultipleInit: Bool? = nil,
Expand All @@ -269,7 +262,6 @@ extension Telemetry {
trackErrors: Bool? = nil,
trackFlutterPerformance: Bool? = nil,
trackFrustrations: Bool? = nil,
trackInteractions: Bool? = nil,
trackLongTask: Bool? = nil,
trackNativeErrors: Bool? = nil,
trackNativeLongTasks: Bool? = nil,
Expand All @@ -280,10 +272,8 @@ extension Telemetry {
trackUserInteractions: Bool? = nil,
trackViewsManually: Bool? = nil,
unityVersion: String? = nil,
useAllowedTracingOrigins: Bool? = nil,
useAllowedTracingUrls: Bool? = nil,
useBeforeSend: Bool? = nil,
useCrossSiteSessionCookie: Bool? = nil,
useExcludedActivityUrls: Bool? = nil,
useFirstPartyHosts: Bool? = nil,
useLocalEncryption: Bool? = nil,
Expand All @@ -306,10 +296,8 @@ extension Telemetry {
forwardErrorsToLogs: forwardErrorsToLogs,
initializationType: initializationType,
mobileVitalsUpdatePeriod: mobileVitalsUpdatePeriod,
premiumSampleRate: premiumSampleRate,
reactNativeVersion: reactNativeVersion,
reactVersion: reactVersion,
replaySampleRate: replaySampleRate,
sessionReplaySampleRate: sessionReplaySampleRate,
sessionSampleRate: sessionSampleRate,
silentMultipleInit: silentMultipleInit,
Expand All @@ -322,7 +310,6 @@ extension Telemetry {
trackErrors: trackErrors,
trackFlutterPerformance: trackFlutterPerformance,
trackFrustrations: trackFrustrations,
trackInteractions: trackInteractions,
trackLongTask: trackLongTask,
trackNativeErrors: trackNativeErrors,
trackNativeLongTasks: trackNativeLongTasks,
Expand All @@ -333,10 +320,8 @@ extension Telemetry {
trackUserInteractions: trackUserInteractions,
trackViewsManually: trackViewsManually,
unityVersion: unityVersion,
useAllowedTracingOrigins: useAllowedTracingOrigins,
useAllowedTracingUrls: useAllowedTracingUrls,
useBeforeSend: useBeforeSend,
useCrossSiteSessionCookie: useCrossSiteSessionCookie,
useExcludedActivityUrls: useExcludedActivityUrls,
useFirstPartyHosts: useFirstPartyHosts,
useLocalEncryption: useLocalEncryption,
Expand Down Expand Up @@ -416,10 +401,8 @@ extension ConfigurationTelemetry {
forwardErrorsToLogs: other.forwardErrorsToLogs ?? forwardErrorsToLogs,
initializationType: other.initializationType ?? initializationType,
mobileVitalsUpdatePeriod: other.mobileVitalsUpdatePeriod ?? mobileVitalsUpdatePeriod,
premiumSampleRate: other.premiumSampleRate ?? premiumSampleRate,
reactNativeVersion: other.reactNativeVersion ?? reactNativeVersion,
reactVersion: other.reactVersion ?? reactVersion,
replaySampleRate: other.replaySampleRate ?? replaySampleRate,
sessionReplaySampleRate: other.sessionReplaySampleRate ?? sessionReplaySampleRate,
sessionSampleRate: other.sessionSampleRate ?? sessionSampleRate,
silentMultipleInit: other.silentMultipleInit ?? silentMultipleInit,
Expand All @@ -432,7 +415,6 @@ extension ConfigurationTelemetry {
trackErrors: other.trackErrors ?? trackErrors,
trackFlutterPerformance: other.trackFlutterPerformance ?? trackFlutterPerformance,
trackFrustrations: other.trackFrustrations ?? trackFrustrations,
trackInteractions: other.trackInteractions ?? trackInteractions,
trackLongTask: other.trackLongTask ?? trackLongTask,
trackNativeErrors: other.trackNativeErrors ?? trackNativeErrors,
trackNativeLongTasks: other.trackNativeLongTasks ?? trackNativeLongTasks,
Expand All @@ -443,10 +425,8 @@ extension ConfigurationTelemetry {
trackUserInteractions: other.trackUserInteractions ?? trackUserInteractions,
trackViewsManually: other.trackViewsManually ?? trackViewsManually,
unityVersion: other.unityVersion ?? unityVersion,
useAllowedTracingOrigins: other.useAllowedTracingOrigins ?? useAllowedTracingOrigins,
useAllowedTracingUrls: other.useAllowedTracingUrls ?? useAllowedTracingUrls,
useBeforeSend: other.useBeforeSend ?? useBeforeSend,
useCrossSiteSessionCookie: other.useCrossSiteSessionCookie ?? useCrossSiteSessionCookie,
useExcludedActivityUrls: other.useExcludedActivityUrls ?? useExcludedActivityUrls,
useFirstPartyHosts: other.useFirstPartyHosts ?? useFirstPartyHosts,
useLocalEncryption: other.useLocalEncryption ?? useLocalEncryption,
Expand Down
2 changes: 1 addition & 1 deletion DatadogInternal/Sources/Upload/DefaultJSONEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension DatadogExtension where ExtendedType == JSONEncoder {
let formatted = iso8601DateFormatter.string(from: date)
try container.encode(formatted)
}
if #available(iOS 13, tvOS 13, macOS 10.15, *) {
if #available(iOS 13, tvOS 13, *) {
encoder.outputFormatting = [.withoutEscapingSlashes]
}
return encoder
Expand Down
5 changes: 0 additions & 5 deletions DatadogInternal/Tests/Telemetry/TelemetryMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ extension ConfigurationTelemetry {
forwardErrorsToLogs: .mockRandom(),
initializationType: .mockRandom(),
mobileVitalsUpdatePeriod: .mockRandom(),
premiumSampleRate: .mockRandom(),
reactNativeVersion: .mockRandom(),
reactVersion: .mockRandom(),
replaySampleRate: .mockRandom(),
sessionReplaySampleRate: .mockRandom(),
sessionSampleRate: .mockRandom(),
silentMultipleInit: .mockRandom(),
Expand All @@ -40,7 +38,6 @@ extension ConfigurationTelemetry {
trackErrors: .mockRandom(),
trackFlutterPerformance: .mockRandom(),
trackFrustrations: .mockRandom(),
trackInteractions: .mockRandom(),
trackLongTask: .mockRandom(),
trackNativeErrors: .mockRandom(),
trackNativeLongTasks: .mockRandom(),
Expand All @@ -51,10 +48,8 @@ extension ConfigurationTelemetry {
trackUserInteractions: .mockRandom(),
trackViewsManually: .mockRandom(),
unityVersion: .mockRandom(),
useAllowedTracingOrigins: .mockRandom(),
useAllowedTracingUrls: .mockRandom(),
useBeforeSend: .mockRandom(),
useCrossSiteSessionCookie: .mockRandom(),
useExcludedActivityUrls: .mockRandom(),
useFirstPartyHosts: .mockRandom(),
useLocalEncryption: .mockRandom(),
Expand Down
Loading

0 comments on commit 0930c24

Please sign in to comment.