Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG_V10.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

### Breaking Changes

- Remove `sendDefaultPii`; use `dataCollection` to configure automatic data collection (#8253)
- Remove Objective-C `@objc` attributes from SentrySDK (#8308)
- Remove deprecated `locale` from device context; use `locale` in culture context instead (#8325)
- Change `SentryRequest.cookies` from a string to a dictionary of cookie names and values (#8460)
Expand Down
2 changes: 2 additions & 0 deletions Sources/SentryObjC/Public/SentryObjCOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,13 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic) NSUInteger maxAttachmentSize;

#if !SDK_V10
/**
* When enabled, the SDK sends personal identifiable information along with events.
* @note The default is @c NO.
*/
@property (nonatomic) BOOL sendDefaultPii;
#endif // !SDK_V10

/**
* When enabled, the SDK tracks performance for UIViewController subclasses and HTTP requests
Expand Down
2 changes: 2 additions & 0 deletions Sources/SentryObjCCompat/SentryObjCOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,12 @@ import Foundation
set { wrapped.maxAttachmentSize = newValue }
}

#if !SDK_V10
@objc public var sendDefaultPii: Bool {
get { wrapped.sendDefaultPii }
set { wrapped.sendDefaultPii = newValue }
}
#endif // !SDK_V10

@objc public var enableAutoPerformanceTracing: Bool {
get { wrapped.enableAutoPerformanceTracing }
Expand Down
2 changes: 2 additions & 0 deletions Sources/Swift/Options+Dictionary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ extension Options {
self.maxAttachmentSize = maxAttachmentSize.uintValue
}

#if !SDK_V10
if let sendDefaultPii = boolValue(dictionary["sendDefaultPii"]) {
self.sendDefaultPii = sendDefaultPii
}
#endif // !SDK_V10

if let enableAutoPerformanceTracing = boolValue(dictionary["enableAutoPerformanceTracing"]) {
self.enableAutoPerformanceTracing = enableAutoPerformanceTracing
Expand Down
2 changes: 2 additions & 0 deletions Sources/Swift/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
/// https://docs.sentry.io/product/relay/options/
@objc public var maxAttachmentSize: UInt = 200 * 1_024 * 1_024

#if !SDK_V10
/// When enabled, the SDK sends personal identifiable along with events.
/// @note The default is @c false.
/// @discussion When the user of an event doesn't contain an IP address, and this flag is @c true, the
Expand All @@ -248,6 +249,7 @@
/// auto out of the box for Cocoa. If you want to stop Sentry from using the connections IP address,
/// you have to enable Prevent Storing of IP Addresses in your project settings in Sentry.
@objc public var sendDefaultPii: Bool = false
#endif // !SDK_V10

/// When enabled, the SDK tracks performance for UIViewController subclasses and HTTP requests
/// automatically. It also measures the app start and slow and frozen frames.
Expand Down
15 changes: 15 additions & 0 deletions Tests/SentryObjCTests/SentryObjCOptionsTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ @interface SentryObjCOptionsTests : XCTestCase

@implementation SentryObjCOptionsTests

- (void)testSendDefaultPii_whenBuildingV10_shouldNotBeExposed
{
#if !SDK_V10
XCTSkip(@"Test skipped for SDK_V10");
#else
// -- Arrange --
SentryObjCOptions *options = [[SentryObjCOptions alloc] init];

// -- Assert --
XCTAssertFalse([options respondsToSelector:NSSelectorFromString(@"sendDefaultPii")]);
#endif
}

#pragma mark - Data Collection

- (void)testDataCollection_whenDefault_shouldReturnNotNil
Expand Down Expand Up @@ -334,6 +347,7 @@ - (void)testAttachAllThreads_whenSetToYes_shouldReturnYes
XCTAssertTrue(options.attachAllThreads);
}

#if !SDK_V10
- (void)testSendDefaultPii_whenSetToYes_shouldReturnYes
{
// -- Arrange --
Expand All @@ -345,6 +359,7 @@ - (void)testSendDefaultPii_whenSetToYes_shouldReturnYes
// -- Assert --
XCTAssertTrue(options.sendDefaultPii);
}
#endif // !SDK_V10

- (void)testEnableAutoPerformanceTracing_whenSetToYes_shouldReturnYes
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class SentryMetricsIntegrationTests: XCTestCase {
#else
// -- Arrange --
let client = try givenSdkWithHub { options in
options.sendDefaultPii = true
options.dataCollection.userInfo = false
}
let integration = try getSut()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ class SentryNetworkTrackerTests: XCTestCase {

func testSpan_whenURLQueryParamsAreOff_shouldNotStoreQueryInURLData() throws {
// -- Arrange --
fixture.options.sendDefaultPii = true
fixture.options.dataCollection.urlQueryParams = .off
let url = try XCTUnwrap(URL(string: "https://www.domain.com/api?token=secret&page=2"))
let task = URLSessionDataTaskMock(request: URLRequest(url: url))
Expand All @@ -390,24 +389,8 @@ class SentryNetworkTrackerTests: XCTestCase {
XCTAssertEqual(span.spanDescription, "GET https://www.domain.com/api")
}

func testSpan_whenSendDefaultPiiIsFalse_shouldUseConfiguredQueryParamBehavior() throws {
func testSpan_whenURLQueryParamsUseDefault_shouldCollectNonSensitiveValues() throws {
// -- Arrange --
fixture.options.sendDefaultPii = false
fixture.options.dataCollection.urlQueryParams = .off
let url = try XCTUnwrap(URL(string: "https://www.domain.com/api?forwarded=192.0.2.1&page=2"))
let task = URLSessionDataTaskMock(request: URLRequest(url: url))

// -- Act --
let span = try XCTUnwrap(spanForTask(task: task))

// -- Assert --
XCTAssertEqual(span.data["url"] as? String, "https://www.domain.com/api")
XCTAssertNil(span.data["http.query"])
}

func testSpan_whenSendDefaultPiiIsTrue_shouldUseConfiguredQueryParamBehavior() throws {
// -- Arrange --
fixture.options.sendDefaultPii = true
fixture.options.dataCollection = SentryDataCollection.Options()
let url = try XCTUnwrap(URL(string: "https://www.domain.com/api?forwarded=192.0.2.1&page=2"))
let task = URLSessionDataTaskMock(request: URLRequest(url: url))
Expand Down
11 changes: 7 additions & 4 deletions Tests/SentryTests/SentryClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2288,12 +2288,11 @@ final class SentryClientTests: XCTestCase {
#endif
}

func testDataCollectionUserInfoDisabled_GivenSendDefaultPiiEnabled_sdkIPIsNever() throws {
func testDataCollectionUserInfoDisabled_GivenNoIP_sdkIPIsNever() throws {
#if !SDK_V10
throw XCTSkip("Test skipped for SDK_V10")
#else
fixture.getSut(configureOptions: { options in
options.sendDefaultPii = true
options.dataCollection.userInfo = false
}).capture(message: "any")

Expand All @@ -2305,15 +2304,19 @@ final class SentryClientTests: XCTestCase {
}

func testSendDefaultPiiEnabled_GivenIP_IPAddressNotChanged() throws {
#if SDK_V10
throw XCTSkip("Test skipped for SDK_V10")
#else
let scope = Scope()
scope.setUser(fixture.user)

fixture.getSut(configureOptions: { options in
options.sendDefaultPii = true
}).capture(message: "any", scope: scope)

let actual = try lastSentEvent()
XCTAssertEqual(fixture.user.ipAddress, actual.user?.ipAddress)
#endif
}

func testSendDefaultPiiDisabled_GivenIP_IPAddressNotChanged() throws {
Expand Down
6 changes: 6 additions & 0 deletions Tests/SentryTests/SentryOptionsTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,9 @@ - (void)testNSNull_SetsDefaultValue
@"sessionTrackingIntervalMillis" : [NSNull null],
@"attachStacktrace" : [NSNull null],
@"maxAttachmentSize" : [NSNull null],
#if !SDK_V10
@"sendDefaultPii" : [NSNull null],
#endif // !SDK_V10
@"enableAutoPerformanceTracing" : [NSNull null],
#if SENTRY_HAS_UIKIT
@"enableUIViewControllerTracing" : [NSNull null],
Expand Down Expand Up @@ -761,7 +763,9 @@ - (void)assertDefaultValues:(SentryOptions *)options
XCTAssertEqual([@30000 unsignedIntValue], options.sessionTrackingIntervalMillis);
XCTAssertEqual(YES, options.attachStacktrace);
XCTAssertEqual(200 * 1024 * 1024, options.maxAttachmentSize);
#if !SDK_V10
XCTAssertEqual(NO, options.sendDefaultPii);
#endif // !SDK_V10
XCTAssertTrue(options.enableAutoPerformanceTracing);
#if SENTRY_HAS_UIKIT
XCTAssertTrue(options.enableUIViewControllerTracing);
Expand Down Expand Up @@ -882,10 +886,12 @@ - (void)testDefaultMaxAttachmentSize
XCTAssertEqual(200 * 1024 * 1024, options.maxAttachmentSize);
}

#if !SDK_V10
- (void)testSendDefaultPii
{
[self testBooleanField:@"sendDefaultPii" defaultValue:NO];
}
#endif // !SDK_V10

- (void)testEnableAutoPerformanceTracing
{
Expand Down
12 changes: 12 additions & 0 deletions Tests/SentryTests/SentryOptionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ import XCTest

final class SentryOptionsTests: XCTestCase {

func testSendDefaultPii_whenBuildingV10_shouldNotBeExposed() throws {
#if !SDK_V10
throw XCTSkip("Test skipped for SDK_V10")
#else
// -- Arrange --
let options = Options()

// -- Assert --
XCTAssertFalse(options.responds(to: NSSelectorFromString("sendDefaultPii")))
#endif
}

// MARK: - Data Collection

func testDataCollection_whenInitialized_shouldUseDefault() throws {
Expand Down
2 changes: 2 additions & 0 deletions Tests/SentryTests/Transaction/SentryTraceContextTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class SentryTraceContextTests: XCTestCase {
options.dsn = SentryTraceContextTests.dsnAsString
options.releaseName = releaseName
options.environment = environment
#if !SDK_V10
options.sendDefaultPii = true
#endif // !SDK_V10

tracer = SentryTracer(transactionContext: TransactionContext(name: transactionName, operation: transactionOperation, sampled: .yes, sampleRate: nil, sampleRand: nil), hub: nil)

Expand Down
20 changes: 0 additions & 20 deletions sdk_api_objc_v10.json
Original file line number Diff line number Diff line change
Expand Up @@ -5385,13 +5385,6 @@
"returnType": "BOOL",
"instance": true
},
{
"kind": "ObjCMethodDecl",
"name": "sendDefaultPii",
"parent": "SentryObjCOptions",
"returnType": "BOOL",
"instance": true
},
{
"kind": "ObjCMethodDecl",
"name": "sentAt",
Expand Down Expand Up @@ -7135,13 +7128,6 @@
"returnType": "void",
"instance": true
},
{
"kind": "ObjCMethodDecl",
"name": "setSendDefaultPii:",
"parent": "SentryObjCOptions",
"returnType": "void",
"instance": true
},
{
"kind": "ObjCMethodDecl",
"name": "setSentAt:",
Expand Down Expand Up @@ -10820,12 +10806,6 @@
"parent": "SentryObjCOptions",
"type": "BOOL"
},
{
"kind": "ObjCPropertyDecl",
"name": "sendDefaultPii",
"parent": "SentryObjCOptions",
"type": "BOOL"
},
{
"kind": "ObjCPropertyDecl",
"name": "sentAt",
Expand Down
76 changes: 0 additions & 76 deletions sdk_api_v10.json
Original file line number Diff line number Diff line change
Expand Up @@ -26503,82 +26503,6 @@
"printedName": "sendClientReports",
"usr": "c:@M@Sentry@objc(cs)SentryOptions(py)sendClientReports"
},
{
"accessors": [
{
"accessorKind": "get",
"children": [
{
"kind": "TypeNominal",
"name": "Bool",
"printedName": "Swift.Bool",
"usr": "s:Sb"
}
],
"declAttributes": [
"Final",
"ObjC"
],
"declKind": "Accessor",
"implicit": true,
"kind": "Accessor",
"mangledName": "$s6Sentry7OptionsC14sendDefaultPiiSbvg",
"moduleName": "Sentry",
"name": "Get",
"printedName": "Get()",
"usr": "c:@M@Sentry@objc(cs)SentryOptions(im)sendDefaultPii"
},
{
"accessorKind": "set",
"children": [
{
"kind": "TypeNominal",
"name": "Bool",
"printedName": "Swift.Bool",
"usr": "s:Sb"
},
{
"kind": "TypeNominal",
"name": "Void",
"printedName": "()"
}
],
"declAttributes": [
"Final",
"ObjC"
],
"declKind": "Accessor",
"implicit": true,
"kind": "Accessor",
"mangledName": "$s6Sentry7OptionsC14sendDefaultPiiSbvs",
"moduleName": "Sentry",
"name": "Set",
"printedName": "Set()",
"usr": "c:@M@Sentry@objc(cs)SentryOptions(im)setSendDefaultPii:"
}
],
"children": [
{
"kind": "TypeNominal",
"name": "Bool",
"printedName": "Swift.Bool",
"usr": "s:Sb"
}
],
"declAttributes": [
"Final",
"HasStorage",
"ObjC"
],
"declKind": "Var",
"hasStorage": true,
"kind": "Var",
"mangledName": "$s6Sentry7OptionsC14sendDefaultPiiSbvp",
"moduleName": "Sentry",
"name": "sendDefaultPii",
"printedName": "sendDefaultPii",
"usr": "c:@M@Sentry@objc(cs)SentryOptions(py)sendDefaultPii"
},
{
"accessors": [
{
Expand Down
Loading