Skip to content

Commit

Permalink
Merge pull request #1234 from DataDog/maxep/merge-develop-v2
Browse files Browse the repository at this point in the history
Update `feature/v2` with `develop`
  • Loading branch information
maxep authored Apr 4, 2023
2 parents a830ebb + 9969b08 commit 0b4ad3b
Show file tree
Hide file tree
Showing 111 changed files with 3,628 additions and 369 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Unreleased

# 1.17.0 / 23-03-2023
- [BUGFIX] Fix crash in `VitalInfoSampler`. See [#1216][] (Thanks [@cltnschlosser][])
- [IMPROVEMENT] Fix Xcode analysis warning. See [#1220][]
- [BUGFIX] Send crashes to both RUM and Logs. See [#1209][]

# 1.16.0 / 02-03-2023
- [IMPROVEMENT] Always create an ApplicationLaunch view on session initialization. See [#1160][]
- [BUGFIX] Remove the data race caused by sampling on the RUM thread. See [#1177][] (Thanks [@cltnschlosser][])
Expand Down Expand Up @@ -438,6 +443,9 @@
[#1160]: https://github.com/DataDog/dd-sdk-ios/pull/1160
[#1177]: https://github.com/DataDog/dd-sdk-ios/pull/1177
[#1188]: https://github.com/DataDog/dd-sdk-ios/pull/1188
[#1209]: https://github.com/DataDog/dd-sdk-ios/pull/1209
[#1216]: https://github.com/DataDog/dd-sdk-ios/pull/1216
[#1220]: https://github.com/DataDog/dd-sdk-ios/pull/1220
[@00fa9a]: https://github.com/00FA9A
[@britton-earnin]: https://github.com/Britton-Earnin
[@hengyu]: https://github.com/Hengyu
Expand Down
54 changes: 54 additions & 0 deletions Datadog/Datadog.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

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 = "1.16.0"
s.version = "1.17.0"
s.summary = "Datadog Internal Package. This module is not for public use."

s.homepage = "https://www.datadoghq.com"
Expand Down
7 changes: 7 additions & 0 deletions DatadogInternal/Sources/DatadogFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public protocol DatadogFeature {
/// The `FeatureMessageReceiver` defines an interface for Feature to receive any message
/// from a bus that is shared between Features registered in a core.
var messageReceiver: FeatureMessageReceiver { get }

/// (Optional) `PerformancePresetOverride` allows overriding certain performance presets if needed.
var performanceOverride: PerformancePresetOverride? { get }
}


Expand All @@ -52,3 +55,7 @@ public protocol DatadogRemoteFeature: DatadogFeature {
/// The request will be transported by `DatadogCore`.
var requestBuilder: FeatureRequestBuilder { get }
}

extension DatadogFeature {
public var performanceOverride: PerformancePresetOverride? { nil }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2019-Present Datadog, Inc.
*/

import Foundation

/// An extension for FixedWidthInteger that provides a convenient API for
/// converting numeric values into different units of data storage, such as
/// bytes, kilobytes, megabytes, and gigabytes.
public extension FixedWidthInteger {
/// A private property that represents the base unit (1024) used for
/// converting between data storage units.
private var base: Self { 1_024 }

/// A property that converts the given numeric value into kilobytes.
var KB: Self { return self.multipliedReportingOverflow(by: base).partialValue }

/// A property that converts the given numeric value into megabytes.
var MB: Self { return self.KB.multipliedReportingOverflow(by: base).partialValue }

/// A property that converts the given numeric value into gigabytes.
var GB: Self { return self.MB.multipliedReportingOverflow(by: base).partialValue }

/// A helper property that returns the current value as a direct representation in bytes.
var bytes: Self { return self }
}
71 changes: 71 additions & 0 deletions DatadogInternal/Sources/Extensions/TimeInterval+Convenience.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2019-Present Datadog, Inc.
*/

import Foundation

/// An extension for TimeInterval that provides a more semantic and expressive
/// API for converting time representations into TimeInterval's default unit: seconds.
public extension TimeInterval {
/// A helper property that returns the current value as a direct representation in seconds.
var seconds: TimeInterval { return TimeInterval(self) }

/// A property that converts the given number of minutes into seconds.
/// In case of overflow, TimeInterval.greatestFiniteMagnitude is returned.
var minutes: TimeInterval { return self.multiplyOrClamp(by: 60) }

/// A property that converts the given number of hours into seconds.
/// In case of overflow, TimeInterval.greatestFiniteMagnitude is returned.
var hours: TimeInterval { return self.multiplyOrClamp(by: 60.minutes) }

/// A property that converts the given number of days into seconds.
/// In case of overflow, TimeInterval.greatestFiniteMagnitude is returned.
var days: TimeInterval { return self.multiplyOrClamp(by: 24.hours) }

/// A private helper method for multiplying the TimeInterval value by a factor
/// and clamping the result to prevent overflow. If the multiplication results in
/// overflow, the greatest finite magnitude value of TimeInterval is returned.
///
/// - Parameter factor: The multiplier to apply to the time interval.
/// - Returns: The multiplied time interval, clamped to the greatest finite magnitude if necessary.
private func multiplyOrClamp(by factor: TimeInterval) -> TimeInterval {
guard factor != 0 else {
return 0
}
let multiplied = TimeInterval(self) * factor
if multiplied / factor != TimeInterval(self) {
return TimeInterval.greatestFiniteMagnitude
}
return multiplied
}
}

/// An extension for FixedWidthInteger that provides a more semantic and expressive
/// API for converting time representations into TimeInterval's default unit: seconds.
public extension FixedWidthInteger {
/// A helper property that returns the current value as a direct representation in seconds.
var seconds: TimeInterval { return TimeInterval(self) }

/// A property that converts the given numeric value of minutes into seconds.
/// In case of overflow, TimeInterval.greatestFiniteMagnitude is returned.
var minutes: TimeInterval {
let (result, overflow) = self.multipliedReportingOverflow(by: 60)
return overflow ? TimeInterval.greatestFiniteMagnitude : TimeInterval(result)
}

/// A property that converts the given numeric value of hours into seconds.
/// In case of overflow, TimeInterval.greatestFiniteMagnitude is returned.
var hours: TimeInterval {
let (result, overflow) = self.multipliedReportingOverflow(by: Self(60.minutes))
return overflow ? TimeInterval.greatestFiniteMagnitude : TimeInterval(result)
}

/// A property that converts the given numeric value of days into seconds.
/// In case of overflow, TimeInterval.greatestFiniteMagnitude is returned.
var days: TimeInterval {
let (result, overflow) = self.multipliedReportingOverflow(by: Self(24.hours))
return overflow ? TimeInterval.greatestFiniteMagnitude : TimeInterval(result)
}
}
31 changes: 31 additions & 0 deletions DatadogInternal/Sources/Storage/PerformancePresetOverride.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2019-Present Datadog, Inc.
*/

import Foundation

/// `PerformancePresetOverride` is a public structure that allows you to customize
/// performance presets by setting optional limits. If the limits are not provided, the default values from
/// the `PerformancePreset` object will be used.
public struct PerformancePresetOverride {
/// An optional value representing the maximum allowed file size in bytes.
/// If not provided, the default value from the `PerformancePreset` object is used.
public let maxFileSize: UInt64?

/// An optional value representing the maximum allowed object size in bytes.
/// If not provided, the default value from the `PerformancePreset` object is used.
public let maxObjectSize: UInt64?

/// Initializes a new `PerformancePresetOverride` instance with the provided
/// maximum file size and maximum object size limits.
///
/// - Parameters:
/// - maxFileSize: The maximum allowed file size in bytes, or `nil` to use the default value from `PerformancePreset`.
/// - maxObjectSize: The maximum allowed object size in bytes, or `nil` to use the default value from `PerformancePreset`.
public init(maxFileSize: UInt64?, maxObjectSize: UInt64?) {
self.maxFileSize = maxFileSize
self.maxObjectSize = maxObjectSize
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2019-Present Datadog, Inc.
*/

import XCTest
@testable import DatadogInternal

final class FixedWidthIntegerConvenienceTests: XCTestCase {
func test_Bytes() {
let value: Int = 1_000
XCTAssertEqual(value.bytes, 1_000)
}

func test_Kilobytes() {
let value: Int = 1
XCTAssertEqual(value.KB, 1_024)
}

func test_Megabytes() {
let value: Int = 1
XCTAssertEqual(value.MB, 1_048_576)
}

func test_Gigabytes() {
let value: Int = 1
XCTAssertEqual(value.GB, 1_073_741_824)
}

func test_OverflowKilobytes() {
let value = UInt64.max / 1_024
XCTAssertEqual(value.KB, UInt64.max &- 1_023)
}

func test_OverflowMegabytes() {
let value = UInt64.max / (1_024 * 1_024)
XCTAssertEqual(value.MB, UInt64.max &- 1_048_575)
}

func test_OverflowGigabytes() {
let value = UInt64.max / (1_024 * 1_024 * 1_024)
XCTAssertEqual(value.GB, UInt64.max &- 1_073_741_823)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2019-Present Datadog, Inc.
*/

import XCTest
@testable import Datadog

final class TimeIntervalConvenienceTests: XCTestCase {
func test_Seconds() {
XCTAssertEqual(TimeInterval(30).seconds, 30)
XCTAssertEqual(Int(30).seconds, 30)
}

func test_Minutes() {
XCTAssertEqual(TimeInterval(2).minutes, 120)
XCTAssertEqual(Int(2).minutes, 120)
}

func test_Hours() {
XCTAssertEqual(TimeInterval(3).hours, 10_800)
XCTAssertEqual(Int(2).minutes, 120)
}

func test_Days() {
XCTAssertEqual(TimeInterval(1).days, 86_400)
XCTAssertEqual(Int(2).minutes, 120)
}

func test_Overflow() {
let timeInterval = TimeInterval.greatestFiniteMagnitude
XCTAssertEqual(timeInterval.minutes, TimeInterval.greatestFiniteMagnitude)
XCTAssertEqual(timeInterval.hours, TimeInterval.greatestFiniteMagnitude)
XCTAssertEqual(timeInterval.days, TimeInterval.greatestFiniteMagnitude)

let integerTimeInterval = Int.max
XCTAssertEqual(integerTimeInterval.minutes, TimeInterval.greatestFiniteMagnitude)
XCTAssertEqual(integerTimeInterval.hours, TimeInterval.greatestFiniteMagnitude)
XCTAssertEqual(integerTimeInterval.days, TimeInterval.greatestFiniteMagnitude)
}
}
2 changes: 1 addition & 1 deletion DatadogLogs.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DatadogLogs"
s.version = "1.16.0"
s.version = "1.17.0"
s.summary = "Datadog Logs Module."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogLogs/Sources/Feature/MessageReceivers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal enum LoggingMessageKeys {
static let log = "log"

/// The key references a crash message.
static let crash = "crash-log"
static let crash = "crash"

/// The key references a browser log message.
static let browserLog = "browser-log"
Expand Down
2 changes: 1 addition & 1 deletion DatadogSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "DatadogSDK"
s.module_name = "Datadog"
s.version = "1.16.0"
s.version = "1.17.0"
s.summary = "Official Datadog Swift SDK for iOS."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogSDKAlamofireExtension.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "DatadogSDKAlamofireExtension"
s.module_name = "DatadogAlamofireExtension"
s.version = "1.16.0"
s.version = "1.17.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 DatadogSDKCrashReporting.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "DatadogSDKCrashReporting"
s.module_name = "DatadogCrashReporting"
s.version = "1.16.0"
s.version = "1.17.0"
s.summary = "Official Datadog Crash Reporting SDK for iOS."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogSDKObjc.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "DatadogSDKObjc"
s.module_name = "DatadogObjc"
s.version = "1.16.0"
s.version = "1.17.0"
s.summary = "Official Datadog Objective-C SDK for iOS."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogSDKSessionReplay.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "DatadogSDKSessionReplay"
s.module_name = "DatadogSessionReplay"
s.version = "1.16.0"
s.version = "1.17.0"
s.summary = "Official Datadog Session Replay SDK for iOS. This module is currently in beta - contact Datadog to request a try."

s.homepage = "https://www.datadoghq.com"
Expand Down
18 changes: 13 additions & 5 deletions DatadogSessionReplay/SRSnapshotTests/SRHost/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

var keyWindow: UIWindow? {
return UIApplication.shared
.connectedScenes
.compactMap { $0 as? UIWindowScene }
.first { scene in scene.windows.contains { window in window.isKeyWindow } }?
.keyWindow
if #available(iOS 15.0, *) {
return UIApplication.shared
.connectedScenes
.compactMap { $0 as? UIWindowScene }
.first { scene in scene.windows.contains { window in window.isKeyWindow } }?
.keyWindow
} else {
let application = UIApplication.value(forKeyPath: #keyPath(UIApplication.shared)) as? UIApplication // swiftlint:disable:this unsafe_uiapplication_shared
return application?
.connectedScenes
.flatMap { ($0 as? UIWindowScene)?.windows ?? [] }
.first { $0.isKeyWindow }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dd_logo.jpg",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0b4ad3b

Please sign in to comment.