Skip to content

Commit

Permalink
Merge pull request #2087 from DataDog/privacy-overrides-objc-interface
Browse files Browse the repository at this point in the history
Privacy Overrides ObjC Interface
  • Loading branch information
mariedm authored Oct 23, 2024
2 parents 8e23728 + f798be8 commit 2cc9bf5
Show file tree
Hide file tree
Showing 13 changed files with 442 additions and 339 deletions.
22 changes: 14 additions & 8 deletions Datadog/Datadog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -680,20 +680,21 @@
61FDBA15269722B4001D9D43 /* CrashReportMinifierTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61FDBA14269722B4001D9D43 /* CrashReportMinifierTests.swift */; };
61FDBA1726974CA9001D9D43 /* DDCrashReportBuilderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61FDBA1626974CA9001D9D43 /* DDCrashReportBuilderTests.swift */; };
61FF282824B8A31E000B3D9B /* RUMEventMatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61FF282724B8A31E000B3D9B /* RUMEventMatcher.swift */; };
962C41A92CB00FD60050B747 /* DDSessionReplayTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A434AD2A8E426C0028E329 /* DDSessionReplayTests.swift */; };
962C41A72CA431370050B747 /* PrivacyLevel+SessionReplay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966253B52C98807400B90B63 /* PrivacyLevel+SessionReplay.swift */; };
962C41A72CA431370050B747 /* SessionReplayPrivacyOverrides.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966253B52C98807400B90B63 /* SessionReplayPrivacyOverrides.swift */; };
962C41A82CA431AA0050B747 /* DDSessionReplayOverridesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E863752C9C7E800023BF78 /* DDSessionReplayOverridesTests.swift */; };
962C41A92CB00FD60050B747 /* DDSessionReplayTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A434AD2A8E426C0028E329 /* DDSessionReplayTests.swift */; };
969B3B212C33F80500D62400 /* UIActivityIndicatorRecorder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 969B3B202C33F80500D62400 /* UIActivityIndicatorRecorder.swift */; };
969B3B232C33F81E00D62400 /* UIActivityIndicatorRecorderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 969B3B222C33F81E00D62400 /* UIActivityIndicatorRecorderTests.swift */; };
96E414142C2AF56F005A6119 /* UIProgressViewRecorder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E414132C2AF56F005A6119 /* UIProgressViewRecorder.swift */; };
96E414162C2AF5C1005A6119 /* UIProgressViewRecorderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E414152C2AF5C1005A6119 /* UIProgressViewRecorderTests.swift */; };
96E863722C9C547B0023BF78 /* SessionReplayOverrideTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E863712C9C547B0023BF78 /* SessionReplayOverrideTests.swift */; };
96F25A822CC7EA4400459567 /* SessionReplayPrivacyOverrides+objc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F25A802CC7EA4300459567 /* SessionReplayPrivacyOverrides+objc.swift */; };
96F25A832CC7EA4400459567 /* UIView+SessionReplayPrivacyOverrides+objc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F25A812CC7EA4300459567 /* UIView+SessionReplayPrivacyOverrides+objc.swift */; };
96F25A852CC7EB3700459567 /* PrivacyOverridesMock+objc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F25A842CC7EB3700459567 /* PrivacyOverridesMock+objc.swift */; };
96F69D6C2CBE94A800A6178B /* DatadogCoreTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 614B78EA296D7B63009C6B92 /* DatadogCoreTests.swift */; };
96F69D6D2CBE94A900A6178B /* DatadogCoreTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 614B78EA296D7B63009C6B92 /* DatadogCoreTests.swift */; };
96F69D6E2CBE94F500A6178B /* MockFeature.swift in Sources */ = {isa = PBXBuildFile; fileRef = A71265852B17980C007D63CE /* MockFeature.swift */; };
96F69D6F2CBE94F600A6178B /* MockFeature.swift in Sources */ = {isa = PBXBuildFile; fileRef = A71265852B17980C007D63CE /* MockFeature.swift */; };
96E863722C9C547B0023BF78 /* SessionReplayOverrideTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E863712C9C547B0023BF78 /* SessionReplayOverrideTests.swift */; };
96E863742C9C64180023BF78 /* SessionReplayOverrides+objc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E863732C9C64180023BF78 /* SessionReplayOverrides+objc.swift */; };
9E55407C25812D1C00F6E3AD /* RUM+objc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E55407B25812D1C00F6E3AD /* RUM+objc.swift */; };
9E58E8E324615EDA008E5063 /* JSONEncoderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E58E8E224615EDA008E5063 /* JSONEncoderTests.swift */; };
9E5B6D2E270C84B4002499B8 /* RUMMonitorE2ETests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E5B6D2D270C84B4002499B8 /* RUMMonitorE2ETests.swift */; };
Expand Down Expand Up @@ -2744,8 +2745,10 @@
96E414132C2AF56F005A6119 /* UIProgressViewRecorder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIProgressViewRecorder.swift; sourceTree = "<group>"; };
96E414152C2AF5C1005A6119 /* UIProgressViewRecorderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIProgressViewRecorderTests.swift; sourceTree = "<group>"; };
96E863712C9C547B0023BF78 /* SessionReplayOverrideTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SessionReplayOverrideTests.swift; sourceTree = "<group>"; };
96E863732C9C64180023BF78 /* SessionReplayOverrides+objc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SessionReplayOverrides+objc.swift"; sourceTree = "<group>"; };
96E863752C9C7E800023BF78 /* DDSessionReplayOverridesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DDSessionReplayOverridesTests.swift; sourceTree = "<group>"; };
96F25A802CC7EA4300459567 /* SessionReplayPrivacyOverrides+objc.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SessionReplayPrivacyOverrides+objc.swift"; sourceTree = "<group>"; };
96F25A812CC7EA4300459567 /* UIView+SessionReplayPrivacyOverrides+objc.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+SessionReplayPrivacyOverrides+objc.swift"; sourceTree = "<group>"; };
96F25A842CC7EB3700459567 /* PrivacyOverridesMock+objc.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PrivacyOverridesMock+objc.swift"; sourceTree = "<group>"; };
9E0542CA25F8EBBE007A3D0B /* Kronos.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Kronos.xcframework; path = ../Carthage/Build/Kronos.xcframework; sourceTree = "<group>"; };
9E26E6B824C87693000B3270 /* RUMDataModels.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RUMDataModels.swift; sourceTree = "<group>"; };
9E2EF44E2694FA14008A7DAE /* VitalInfoSamplerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VitalInfoSamplerTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3572,7 +3575,8 @@
61054E0B2A6EE10A00AAA894 /* SessionReplayConfiguration.swift */,
966253B52C98807400B90B63 /* SessionReplayPrivacyOverrides.swift */,
A795069B2B974C8100AC4814 /* SessionReplay+objc.swift */,
96E863732C9C64180023BF78 /* SessionReplayOverrides+objc.swift */,
96F25A802CC7EA4300459567 /* SessionReplayPrivacyOverrides+objc.swift */,
96F25A812CC7EA4300459567 /* UIView+SessionReplayPrivacyOverrides+objc.swift */,
61054E3B2A6EE10A00AAA894 /* Feature */,
61054E482A6EE10A00AAA894 /* Processor */,
61054E0D2A6EE10A00AAA894 /* Recorder */,
Expand Down Expand Up @@ -3999,6 +4003,7 @@
61054F7D2A6EE1BA00AAA894 /* Mocks */ = {
isa = PBXGroup;
children = (
96F25A842CC7EB3700459567 /* PrivacyOverridesMock+objc.swift */,
3C33E4062BEE35A7003B2988 /* RUMContextMocks.swift */,
61054F7E2A6EE1BA00AAA894 /* UIKitMocks.swift */,
61054F7F2A6EE1BA00AAA894 /* CoreGraphicsMocks.swift */,
Expand Down Expand Up @@ -4344,7 +4349,6 @@
A7DA18062AB0CA4700F76337 /* DDUIKitRUMActionsPredicateTests.swift */,
9EE5AD8126205B82001E699E /* DDNSURLSessionDelegateTests.swift */,
3CCCA5C62ABAF5230029D7BD /* DDURLSessionInstrumentationConfigurationTests.swift */,
D2A434AD2A8E426C0028E329 /* DDSessionReplayTests.swift */,
61D03BDE273404BB00367DE0 /* RUM */,
F603F1282CAEA4E90088E6B7 /* DDInternalLoggerTests.swift */,
);
Expand Down Expand Up @@ -8376,7 +8380,6 @@
61054E612A6EE10A00AAA894 /* SRCompression.swift in Sources */,
61054E8F2A6EE10A00AAA894 /* SegmentRequestBuilder.swift in Sources */,
61054E8B2A6EE10A00AAA894 /* SessionReplayFeature.swift in Sources */,
96E863742C9C64180023BF78 /* SessionReplayOverrides+objc.swift in Sources */,
61054E992A6EE10A00AAA894 /* WireframesBuilder.swift in Sources */,
61054E892A6EE10A00AAA894 /* NodeIDGenerator.swift in Sources */,
61054E962A6EE10A00AAA894 /* Diff+SRWireframes.swift in Sources */,
Expand All @@ -8394,6 +8397,7 @@
61054E9E2A6EE10B00AAA894 /* Queue.swift in Sources */,
61054E872A6EE10A00AAA894 /* ViewAttributes+Copy.swift in Sources */,
61054E6A2A6EE10A00AAA894 /* UIView+SessionReplay.swift in Sources */,
96F25A832CC7EA4400459567 /* UIView+SessionReplayPrivacyOverrides+objc.swift in Sources */,
61054E7D2A6EE10A00AAA894 /* UITextFieldRecorder.swift in Sources */,
61054E832A6EE10A00AAA894 /* UISwitchRecorder.swift in Sources */,
61054E9A2A6EE10A00AAA894 /* NodesFlattener.swift in Sources */,
Expand Down Expand Up @@ -8428,6 +8432,7 @@
D22442C52CA301DA002E71E4 /* UIColor+SessionReplay.swift in Sources */,
61054E8E2A6EE10A00AAA894 /* SRContextPublisher.swift in Sources */,
61054E732A6EE10A00AAA894 /* WindowTouchSnapshotProducer.swift in Sources */,
96F25A822CC7EA4400459567 /* SessionReplayPrivacyOverrides+objc.swift in Sources */,
A70ADCD22B583B1300321BC9 /* UIImageResource.swift in Sources */,
61054E792A6EE10A00AAA894 /* UITextViewRecorder.swift in Sources */,
61054E9B2A6EE10B00AAA894 /* CGRectExtensions.swift in Sources */,
Expand Down Expand Up @@ -8468,6 +8473,7 @@
61054FC22A6EE1BA00AAA894 /* ViewTreeSnapshotTests.swift in Sources */,
D2BCB2A32B7B9683005C2AAB /* WKWebViewRecorderTests.swift in Sources */,
61054FC62A6EE1BA00AAA894 /* CoreGraphicsMocks.swift in Sources */,
96F25A852CC7EB3700459567 /* PrivacyOverridesMock+objc.swift in Sources */,
61054FCA2A6EE1BA00AAA894 /* TestScheduler.swift in Sources */,
962C41A92CB00FD60050B747 /* DDSessionReplayTests.swift in Sources */,
61054FBD2A6EE1BA00AAA894 /* UIViewRecorderTests.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,44 +41,40 @@ - (void)testStartAndStopRecording {
- (void)testSettingAndGettingOverrides {
// Given
UIView *view = [[UIView alloc] init];
DDSessionReplayPrivacyOverrides *override = [[DDSessionReplayPrivacyOverrides alloc] init];

// When
view.ddSessionReplayOverrides = override;
view.ddSessionReplayOverrides.textAndInputPrivacy = DDTextAndInputPrivacyLevelOverrideMaskAll;
view.ddSessionReplayOverrides.imagePrivacy = DDImagePrivacyLevelOverrideMaskAll;
view.ddSessionReplayOverrides.touchPrivacy = DDTouchPrivacyLevelOverrideHide;
view.ddSessionReplayOverrides.hide = @YES;
view.ddSessionReplayPrivacyOverrides.textAndInputPrivacy = DDTextAndInputPrivacyLevelOverrideMaskAll;
view.ddSessionReplayPrivacyOverrides.imagePrivacy = DDImagePrivacyLevelOverrideMaskAll;
view.ddSessionReplayPrivacyOverrides.touchPrivacy = DDTouchPrivacyLevelOverrideHide;
view.ddSessionReplayPrivacyOverrides.hide = @YES;

// Then
XCTAssertEqual(view.ddSessionReplayOverrides.textAndInputPrivacy, DDTextAndInputPrivacyLevelOverrideMaskAll);
XCTAssertEqual(view.ddSessionReplayOverrides.imagePrivacy, DDImagePrivacyLevelOverrideMaskAll);
XCTAssertEqual(view.ddSessionReplayOverrides.touchPrivacy, DDTouchPrivacyLevelOverrideHide);
XCTAssertTrue(view.ddSessionReplayOverrides.hide.boolValue);
XCTAssertEqual(view.ddSessionReplayPrivacyOverrides.textAndInputPrivacy, DDTextAndInputPrivacyLevelOverrideMaskAll);
XCTAssertEqual(view.ddSessionReplayPrivacyOverrides.imagePrivacy, DDImagePrivacyLevelOverrideMaskAll);
XCTAssertEqual(view.ddSessionReplayPrivacyOverrides.touchPrivacy, DDTouchPrivacyLevelOverrideHide);
XCTAssertTrue(view.ddSessionReplayPrivacyOverrides.hide.boolValue);
}

- (void)testClearingOverride {
// Given
UIView *view = [[UIView alloc] init];
DDSessionReplayPrivacyOverrides *overrides = [[DDSessionReplayPrivacyOverrides alloc] init];

// Set initial values
view.ddSessionReplayOverrides = overrides;
view.ddSessionReplayOverrides.textAndInputPrivacy = DDTextAndInputPrivacyLevelOverrideMaskAll;
view.ddSessionReplayOverrides.imagePrivacy = DDImagePrivacyLevelOverrideMaskAll;
view.ddSessionReplayOverrides.touchPrivacy = DDTouchPrivacyLevelOverrideHide;
view.ddSessionReplayOverrides.hide = @YES;
view.ddSessionReplayPrivacyOverrides.textAndInputPrivacy = DDTextAndInputPrivacyLevelOverrideMaskAll;
view.ddSessionReplayPrivacyOverrides.imagePrivacy = DDImagePrivacyLevelOverrideMaskAll;
view.ddSessionReplayPrivacyOverrides.touchPrivacy = DDTouchPrivacyLevelOverrideHide;
view.ddSessionReplayPrivacyOverrides.hide = @YES;

// When
view.ddSessionReplayOverrides.textAndInputPrivacy = DDTextAndInputPrivacyLevelOverrideNone;
view.ddSessionReplayOverrides.imagePrivacy = DDImagePrivacyLevelOverrideNone;
view.ddSessionReplayOverrides.touchPrivacy = DDTouchPrivacyLevelOverrideNone;
view.ddSessionReplayOverrides.hide = nil;
view.ddSessionReplayPrivacyOverrides.textAndInputPrivacy = DDTextAndInputPrivacyLevelOverrideNone;
view.ddSessionReplayPrivacyOverrides.imagePrivacy = DDImagePrivacyLevelOverrideNone;
view.ddSessionReplayPrivacyOverrides.touchPrivacy = DDTouchPrivacyLevelOverrideNone;
view.ddSessionReplayPrivacyOverrides.hide = nil;

// Then
XCTAssertEqual(view.ddSessionReplayOverrides.textAndInputPrivacy, DDTextAndInputPrivacyLevelOverrideNone);
XCTAssertEqual(view.ddSessionReplayOverrides.imagePrivacy, DDImagePrivacyLevelOverrideNone);
XCTAssertEqual(view.ddSessionReplayOverrides.touchPrivacy, DDTouchPrivacyLevelOverrideNone);
XCTAssertNil(view.ddSessionReplayOverrides.hide);
XCTAssertEqual(view.ddSessionReplayPrivacyOverrides.textAndInputPrivacy, DDTextAndInputPrivacyLevelOverrideNone);
XCTAssertEqual(view.ddSessionReplayPrivacyOverrides.imagePrivacy, DDImagePrivacyLevelOverrideNone);
XCTAssertEqual(view.ddSessionReplayPrivacyOverrides.touchPrivacy, DDTouchPrivacyLevelOverrideNone);
XCTAssertNil(view.ddSessionReplayPrivacyOverrides.hide);
}
@end
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal struct ViewTreeRecorder {
/// Creates `Nodes` for given view and its subtree hierarchy.
func record(_ anyView: UIView, in context: ViewTreeRecordingContext) -> [Node] {
var nodes: [Node] = []
recordRecursively(nodes: &nodes, view: anyView, context: context, overrides: anyView.dd.sessionReplayOverrides)
recordRecursively(nodes: &nodes, view: anyView, context: context, overrides: anyView.dd.sessionReplayPrivacyOverrides)
return nodes
}

Expand Down Expand Up @@ -46,7 +46,7 @@ internal struct ViewTreeRecorder {
switch semantics.subtreeStrategy {
case .record:
for subview in view.subviews {
let subviewOverrides = SessionReplayPrivacyOverrides.merge(subview.dd.sessionReplayOverrides, with: overrides)
let subviewOverrides = SessionReplayPrivacyOverrides.merge(subview.dd.sessionReplayPrivacyOverrides, with: overrides)
recordRecursively(nodes: &nodes, view: subview, context: context, overrides: subviewOverrides)
}
case .ignore:
Expand Down
Loading

0 comments on commit 2cc9bf5

Please sign in to comment.