Skip to content

Commit

Permalink
Merge branch 'develop' into ganeshnj/feat/reduce-view-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshnj authored Jun 29, 2023
2 parents aabebe5 + 1b8cd0b commit 60fc50e
Show file tree
Hide file tree
Showing 61 changed files with 1,093 additions and 433 deletions.
5 changes: 5 additions & 0 deletions .spi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: 1
builder:
configs:
- platform: ios
documentation_targets: ["Datadog", "DatadogObjc", "DatadogCrashReporting"]
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

- [IMPROVEMENT] Reduce number of view updates by filtering events from payload. See [#1328][]

# 1.21.0 / 27-07-2023
- [BUGFIX] Fix TracingUUID string format. See [#1311][] (Thanks [@changm4n][])
- [BUGFIX] Rename _Datadog_Private to DatadogPrivate. See [#1331] (Thanks [@alexfanatics][])
- [IMPROVEMENT] Add context to crash when there's an active view. See [#1315][]


# 1.20.0 / 01-06-2023
- [BUGFIX] Use targetTimestamp as reference to calculate FPS for variable refresh rate displays. See [#1272][]

Expand Down Expand Up @@ -466,6 +472,9 @@
[#1259]: https://github.com/DataDog/dd-sdk-ios/pull/1259
[#1264]: https://github.com/DataDog/dd-sdk-ios/pull/1264
[#1272]: https://github.com/DataDog/dd-sdk-ios/pull/1272
[#1311]: https://github.com/DataDog/dd-sdk-ios/pull/1311
[#1315]: https://github.com/DataDog/dd-sdk-ios/pull/1315
[#1331]: https://github.com/DataDog/dd-sdk-ios/pull/1331
[#1328]: https://github.com/DataDog/dd-sdk-ios/pull/1328
[@00fa9a]: https://github.com/00FA9A
[@britton-earnin]: https://github.com/Britton-Earnin
Expand Down Expand Up @@ -494,3 +503,5 @@
[@avdlee]: https://github.com/AvdLee
[@dfed]: https://github.com/dfed
[@cltnschlosser]: https://github.com/cltnschlosser
[@alexfanatics]: https://github.com/alexfanatics
[@changm4n]: https://github.com/changm4n
8 changes: 4 additions & 4 deletions Datadog/Datadog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2290,7 +2290,7 @@
61133B9C2423979B00786299 /* Datadog */,
61133C082423983800786299 /* DatadogObjc */,
6170DC1325C1864B003AED5C /* DatadogCrashReporting */,
9E68FB52244707FD0013A8AA /* _Datadog_Private */,
9E68FB52244707FD0013A8AA /* DatadogPrivate */,
61133C122423990D00786299 /* DatadogTests */,
6170DC1425C18663003AED5C /* DatadogCrashReportingTests */,
61441C772461A204003D8BB8 /* DatadogBenchmarkTests */,
Expand Down Expand Up @@ -4147,15 +4147,15 @@
path = RUM;
sourceTree = "<group>";
};
9E68FB52244707FD0013A8AA /* _Datadog_Private */ = {
9E68FB52244707FD0013A8AA /* DatadogPrivate */ = {
isa = PBXGroup;
children = (
9E47010324471027000073A4 /* include */,
6179FFD2254ADB1100556A0B /* ObjcAppLaunchHandler.m */,
9E68FB53244707FD0013A8AA /* ObjcExceptionHandler.m */,
);
name = _Datadog_Private;
path = ../Sources/_Datadog_Private;
name = DatadogPrivate;
path = ../Sources/DatadogPrivate;
sourceTree = "<group>";
};
9EA95C182791C9BE00F6C1F3 /* WebView */ = {
Expand Down
6 changes: 3 additions & 3 deletions 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.20.0"
s.version = "1.21.0"
s.summary = "Official Datadog Swift SDK for iOS."

s.homepage = "https://www.datadoghq.com"
Expand All @@ -21,9 +21,9 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/DataDog/dd-sdk-ios.git", :tag => s.version.to_s }

s.source_files = ["Sources/Datadog/**/*.swift",
"Sources/_Datadog_Private/**/*.{h,m}",
"Sources/DatadogPrivate/**/*.{h,m}",
"Datadog/TargetSupport/Datadog/Datadog.h"]
s.public_header_files = ["Datadog/TargetSupport/Datadog/Datadog.h",
"Sources/_Datadog_Private/include/*.h"]
"Sources/DatadogPrivate/include/*.h"]

end
4 changes: 2 additions & 2 deletions DatadogSDK.podspec.src
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/DataDog/dd-sdk-ios.git", :tag => s.version.to_s }

s.source_files = ["Sources/Datadog/**/*.swift",
"Sources/_Datadog_Private/**/*.{h,m}",
"Sources/DatadogPrivate/**/*.{h,m}",
"Datadog/TargetSupport/Datadog/Datadog.h"]
s.public_header_files = ["Datadog/TargetSupport/Datadog/Datadog.h",
"Sources/_Datadog_Private/include/*.h"]
"Sources/DatadogPrivate/include/*.h"]

end
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.20.0"
s.version = "1.21.0"
s.summary = "An Official Extensions of Datadog Swift SDK for Alamofire."

s.homepage = "https://www.datadoghq.com"
Expand Down
4 changes: 2 additions & 2 deletions 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.20.0"
s.version = "1.21.0"
s.summary = "Official Datadog Crash Reporting SDK for iOS."

s.homepage = "https://www.datadoghq.com"
Expand All @@ -22,6 +22,6 @@ Pod::Spec.new do |s|
s.static_framework = true

s.source_files = "Sources/DatadogCrashReporting/**/*.swift"
s.dependency 'DatadogSDK', '1.20.0'
s.dependency 'DatadogSDK', '1.21.0'
s.dependency 'PLCrashReporter', '~> 1.11.0'
end
4 changes: 2 additions & 2 deletions 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.20.0"
s.version = "1.21.0"
s.summary = "Official Datadog Objective-C SDK for iOS."

s.homepage = "https://www.datadoghq.com"
Expand All @@ -21,5 +21,5 @@ Pod::Spec.new do |s|
s.source = { :git => 'https://github.com/DataDog/dd-sdk-ios.git', :tag => s.version.to_s }

s.source_files = "Sources/DatadogObjc/**/*.swift"
s.dependency 'DatadogSDK', '1.20.0'
s.dependency 'DatadogSDK', '1.21.0'
end
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.20.0"
s.version = "1.21.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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/

import XCTest
import Datadog
import TestUtilities
@testable import DatadogSessionReplay
@testable import SRHost

Expand Down Expand Up @@ -33,26 +35,20 @@ internal class SnapshotTestCase: XCTestCase {
let expectation = self.expectation(description: "Wait for wireframes")

// Set up SR recorder:
let scheduler = TestScheduler()
let processor = Processor(queue: NoQueue(), writer: Writer())
let recorder = try Recorder(
configuration: configuration,
rumContextObserver: RUMContextObserverMock(),
processor: processor,
scheduler: scheduler
)
let recorder = try Recorder(processor: processor)

// Set up wireframes interception and trigger recorder once:
// Set up wireframes interception :
var wireframes: [SRWireframe]?

processor.interceptWireframes = {
wireframes = $0
expectation.fulfill()
}

recorder.start()
scheduler.triggerOnce()
recorder.stop()
// Capture next record with mock RUM Context
recorder.captureNextRecord(
.init(privacy: configuration.privacy, applicationID: "", sessionID: "", viewID: "", viewServerTimeOffset: 0)
)

waitForExpectations(timeout: 10) // very pessimistic timeout to mitigate CI lags

Expand Down Expand Up @@ -127,28 +123,3 @@ internal class SnapshotTestCase: XCTestCase {
private struct NoQueue: Queue {
func run(_ block: @escaping () -> Void) { block() }
}

private struct RUMContextObserverMock: RUMContextObserver {
func observe(on queue: Queue, notify: @escaping (RUMContext?) -> Void) {
queue.run {
notify(RUMContext(ids: .init(applicationID: "", sessionID: "", viewID: ""), viewServerTimeOffset: 0))
}
}
}

private class TestScheduler: Scheduler {
private var operations: [() -> Void] = []

let queue: Queue = NoQueue()

func schedule(operation: @escaping () -> Void) {
operations.append(operation)
}

func start() {}
func stop() {}

func triggerOnce() {
operations.forEach { $0() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ internal struct RUMContext: Decodable, Equatable {
let applicationID: String
/// Current RUM session ID - standard UUID string, lowecased.
let sessionID: String
/// Current RUM view ID - standard UUID string, lowecased.
let viewID: String
/// Current RUM view ID - standard UUID string, lowecased. It can be empty when view is being loaded.
let viewID: String?
}

enum CodingKeys: String, CodingKey {
Expand Down
17 changes: 2 additions & 15 deletions DatadogSessionReplay/Sources/Drafts/SessionReplay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,6 @@ public struct SessionReplay {

/// A draft interface of SR controller.
/// TODO: RUMM-2268 Design convenient public API
public protocol SessionReplayController {
/// Start recording.
func start()
public protocol SessionReplayController { }

/// Stop recording.
func stop()

/// Changes the content recording policy.
func change(privacy: SessionReplayPrivacy)
}

internal struct NOPSessionReplayController: SessionReplayController {
func start() {}
func stop() {}
func change(privacy: SessionReplayPrivacy) {}
}
internal struct NOPSessionReplayController: SessionReplayController { }
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@ public struct SessionReplayConfiguration {
/// the target instance of Datadog SDK.
public var customUploadURL: URL?

/// Defines the percentage of sessions that should be tracked by Session Replay.
///
/// It should be a number between 0.0 and 100.0, where 0.0 indicates that no sessions should be tracked and 100.0 indicates that all sessions should be tracked.
/// By default, it is set to 0.0. Adjust the `samplingRate` based on the needs of your application and any resource constraints.
public var samplingRate: Float = 0.0

public init(
privacy: SessionReplayPrivacy = .maskAll,
customUploadURL: URL? = nil
customUploadURL: URL? = nil,
samplingRate: Float = 0.0
) {
self.privacy = privacy
self.customUploadURL = customUploadURL
self.samplingRate = samplingRate
}
}
38 changes: 12 additions & 26 deletions DatadogSessionReplay/Sources/Drafts/SessionReplayFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@ internal class SessionReplayFeature: DatadogFeature, SessionReplayController {
let messageReceiver: FeatureMessageReceiver
let performanceOverride: PerformancePresetOverride?

// MARK: - Integrations with other features

/// Updates other Features with SR context.
private let contextPublisher: SRContextPublisher

// MARK: - Main Components

private let recorder: Recording
private let recordingCoordinator: RecordingCoordinator
private let processor: Processing
private let writer: Writing

Expand All @@ -45,42 +40,33 @@ internal class SessionReplayFeature: DatadogFeature, SessionReplayController {
writer: writer
)

let scheduler = MainThreadScheduler(interval: 0.1)
let messageReceiver = RUMContextReceiver()

let recorder = try Recorder(
configuration: configuration,
rumContextObserver: messageReceiver,
processor: processor
)
let recordingCoordinator = RecordingCoordinator(
scheduler: scheduler,
privacy: configuration.privacy,
rumContextObserver: messageReceiver,
srContextPublisher: SRContextPublisher(core: core),
recorder: recorder,
sampler: Sampler(samplingRate: configuration.samplingRate)
)

self.messageReceiver = messageReceiver
self.recorder = recorder
self.recordingCoordinator = recordingCoordinator
self.processor = processor
self.writer = writer
self.requestBuilder = RequestBuilder(customUploadURL: configuration.customUploadURL)
self.contextPublisher = SRContextPublisher(core: core)
self.performanceOverride = PerformancePresetOverride(
maxFileSize: UInt64(10).MB,
maxObjectSize: UInt64(10).MB
)
// Set initial SR context (it is configured, but not yet started):
contextPublisher.setRecordingIsPending(false)
}

func register(sessionReplayScope: FeatureScope) {
writer.startWriting(to: sessionReplayScope)
}

// MARK: - SessionReplayController

func start() {
contextPublisher.setRecordingIsPending(true)
recorder.start()
}

func stop() {
contextPublisher.setRecordingIsPending(false)
recorder.stop()
}

func change(privacy: SessionReplayPrivacy) { recorder.change(privacy: privacy) }
}
8 changes: 5 additions & 3 deletions DatadogSessionReplay/Sources/Processor/Processor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ internal class Processor: Processing {

var records: [SRRecord] = []
// Create records for describing UI:
if viewTreeSnapshot.rumContext != lastSnapshot?.rumContext {
// If RUM context has changed, new segment should be started.
if viewTreeSnapshot.context.applicationID != lastSnapshot?.context.applicationID ||
viewTreeSnapshot.context.sessionID != lastSnapshot?.context.sessionID ||
viewTreeSnapshot.context.viewID != lastSnapshot?.context.viewID {
// If RUM context ids have changed, new segment should be started.
// Segment must always start with "meta" → "focus" → "full snapshot" records.
records.append(recordsBuilder.createMetaRecord(from: viewTreeSnapshot))
records.append(recordsBuilder.createFocusRecord(from: viewTreeSnapshot))
Expand Down Expand Up @@ -111,7 +113,7 @@ internal class Processor: Processing {
if !records.isEmpty {
// Transform `[SRRecord]` to `EnrichedRecord` so we can write it to `DatadogCore` and
// later read it back (as `EnrichedRecordJSON`) for preparing upload request(s):
let enrichedRecord = EnrichedRecord(rumContext: viewTreeSnapshot.rumContext, records: records)
let enrichedRecord = EnrichedRecord(context: viewTreeSnapshot.context, records: records)
writer.write(nextRecord: enrichedRecord)
}

Expand Down
Loading

0 comments on commit 60fc50e

Please sign in to comment.