Skip to content

Commit be4ef1e

Browse files
authored
feat: Add dataCollection option and types (#8369)
1 parent 095fdf6 commit be4ef1e

49 files changed

Lines changed: 7427 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
### Features
1010

11+
- Add `dataCollection` option under `experimental` for configuring data scrubbing behavior (#8369)
1112
- Attach feature flag evaluations to active spans (#8158)
1213
- Add feature flag scope ObjC API (#8160)
1314

Sentry.xcodeproj/project.pbxproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,6 +1792,13 @@
17921792
Public/SentryObjCAttributeContent.h,
17931793
Public/SentryObjCBreadcrumb.h,
17941794
Public/SentryObjCClient.h,
1795+
Public/SentryObjCDataCollectionDatabaseCollectionOptions.h,
1796+
Public/SentryObjCDataCollectionGraphQLCollectionOptions.h,
1797+
Public/SentryObjCDataCollectionHttpBodyType.h,
1798+
Public/SentryObjCDataCollectionHttpHeaderCollectionOptions.h,
1799+
Public/SentryObjCDataCollectionKeyValueCollectionBehavior.h,
1800+
Public/SentryObjCDataCollectionKeyValueCollectionMode.h,
1801+
Public/SentryObjCDataCollectionOptions.h,
17951802
Public/SentryObjCDebugMeta.h,
17961803
Public/SentryObjCDefines.h,
17971804
Public/SentryObjCEnvelope.h,

Sources/SentryObjC/Public/SentryObjC.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,25 @@
130130
# import <SentryObjC/SentryObjCLogger.h>
131131
#endif
132132

133+
// --- Data collection types ---
134+
#if !__has_include(<SentryObjC/SentryObjCDefines.h>)
135+
# import "SentryObjCDataCollectionDatabaseCollectionOptions.h"
136+
# import "SentryObjCDataCollectionGraphQLCollectionOptions.h"
137+
# import "SentryObjCDataCollectionHttpBodyType.h"
138+
# import "SentryObjCDataCollectionHttpHeaderCollectionOptions.h"
139+
# import "SentryObjCDataCollectionKeyValueCollectionBehavior.h"
140+
# import "SentryObjCDataCollectionKeyValueCollectionMode.h"
141+
# import "SentryObjCDataCollectionOptions.h"
142+
#else
143+
# import <SentryObjC/SentryObjCDataCollectionDatabaseCollectionOptions.h>
144+
# import <SentryObjC/SentryObjCDataCollectionGraphQLCollectionOptions.h>
145+
# import <SentryObjC/SentryObjCDataCollectionHttpBodyType.h>
146+
# import <SentryObjC/SentryObjCDataCollectionHttpHeaderCollectionOptions.h>
147+
# import <SentryObjC/SentryObjCDataCollectionKeyValueCollectionBehavior.h>
148+
# import <SentryObjC/SentryObjCDataCollectionKeyValueCollectionMode.h>
149+
# import <SentryObjC/SentryObjCDataCollectionOptions.h>
150+
#endif
151+
133152
// --- Configuration ---
134153
#if !__has_include(<SentryObjC/SentryObjCDefines.h>)
135154
# import "SentryObjCExperimentalOptions.h"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#import <Foundation/Foundation.h>
2+
3+
NS_ASSUME_NONNULL_BEGIN
4+
5+
/// Controls database query parameter collection.
6+
@interface SentryObjCDataCollectionDatabaseCollectionOptions : NSObject
7+
8+
/// Whether to collect parameterized database query values. Defaults to @c YES.
9+
@property (nonatomic) BOOL queryParams;
10+
11+
- (instancetype)init;
12+
13+
@end
14+
15+
NS_ASSUME_NONNULL_END
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#import <Foundation/Foundation.h>
2+
3+
NS_ASSUME_NONNULL_BEGIN
4+
5+
/// Controls GraphQL document and variable collection.
6+
@interface SentryObjCDataCollectionGraphQLCollectionOptions : NSObject
7+
8+
/// Whether to collect GraphQL query/mutation documents. Defaults to @c YES.
9+
@property (nonatomic) BOOL document;
10+
11+
/// Whether to collect GraphQL variables. Defaults to @c YES.
12+
@property (nonatomic) BOOL variables;
13+
14+
- (instancetype)init;
15+
16+
@end
17+
18+
NS_ASSUME_NONNULL_END
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#import <Foundation/Foundation.h>
2+
3+
/// Identifies the direction and role of an HTTP body for collection purposes.
4+
typedef NS_OPTIONS(NSUInteger, SentryObjCDataCollectionHttpBodyType) {
5+
/// Body of an incoming HTTP request (server-side).
6+
SentryObjCDataCollectionHttpBodyTypeIncomingRequest = 1 << 0,
7+
/// Body of an outgoing HTTP request (client-side).
8+
SentryObjCDataCollectionHttpBodyTypeOutgoingRequest = 1 << 1,
9+
/// Body of an incoming HTTP response (client-side).
10+
SentryObjCDataCollectionHttpBodyTypeIncomingResponse = 1 << 2,
11+
/// Body of an outgoing HTTP response (server-side).
12+
SentryObjCDataCollectionHttpBodyTypeOutgoingResponse = 1 << 3,
13+
/// All body types.
14+
SentryObjCDataCollectionHttpBodyTypeAll = SentryObjCDataCollectionHttpBodyTypeIncomingRequest
15+
| SentryObjCDataCollectionHttpBodyTypeOutgoingRequest
16+
| SentryObjCDataCollectionHttpBodyTypeIncomingResponse
17+
| SentryObjCDataCollectionHttpBodyTypeOutgoingResponse
18+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#import <Foundation/Foundation.h>
2+
3+
@class SentryObjCDataCollectionKeyValueCollectionBehavior;
4+
5+
NS_ASSUME_NONNULL_BEGIN
6+
7+
/// Controls HTTP header collection independently for request and response directions.
8+
@interface SentryObjCDataCollectionHttpHeaderCollectionOptions : NSObject
9+
10+
/// Controls collection of request header values. Defaults to denyList.
11+
@property (nonatomic, strong) SentryObjCDataCollectionKeyValueCollectionBehavior *request;
12+
13+
/// Controls collection of response header values. Defaults to denyList.
14+
@property (nonatomic, strong) SentryObjCDataCollectionKeyValueCollectionBehavior *response;
15+
16+
- (instancetype)init;
17+
18+
@end
19+
20+
NS_ASSUME_NONNULL_END
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#import <Foundation/Foundation.h>
2+
#if !__has_include(<SentryObjC/SentryObjCDefines.h>)
3+
# import "SentryObjCDataCollectionKeyValueCollectionMode.h"
4+
# import "SentryObjCDefines.h"
5+
#else
6+
# import <SentryObjC/SentryObjCDataCollectionKeyValueCollectionMode.h>
7+
# import <SentryObjC/SentryObjCDefines.h>
8+
#endif
9+
10+
NS_ASSUME_NONNULL_BEGIN
11+
12+
/// Controls how key-value data (headers, cookies, query params) is collected and filtered.
13+
///
14+
/// Key names are always included regardless of mode. This type controls which
15+
/// values are sent in plaintext vs. replaced with @c [Filtered].
16+
///
17+
/// DenyList and AllowList are mutually exclusive.
18+
@interface SentryObjCDataCollectionKeyValueCollectionBehavior : NSObject
19+
SENTRY_NO_INIT
20+
21+
/// The active collection mode.
22+
@property (nonatomic, readonly) SentryObjCDataCollectionKeyValueCollectionMode mode;
23+
24+
/// Extra terms for the active mode. Empty for @c off.
25+
@property (nonatomic, readonly, copy) NSArray<NSString *> *terms;
26+
27+
/// Do not collect this category at all — no keys or values are attached.
28+
+ (instancetype)off;
29+
30+
/// Collect all values, scrubbing those matching the built-in sensitive denylist.
31+
/// @param terms Extra terms to add to the built-in denylist.
32+
+ (instancetype)denyListWithTerms:(NSArray<NSString *> *)terms;
33+
34+
/// Collect all values, scrubbing those matching the built-in sensitive denylist only.
35+
+ (instancetype)denyList;
36+
37+
/// Only send values for explicitly listed keys; scrub all others.
38+
/// @param terms The keys whose values should be sent in plaintext.
39+
+ (instancetype)allowListWithTerms:(NSArray<NSString *> *)terms;
40+
41+
@end
42+
43+
NS_ASSUME_NONNULL_END
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#import <Foundation/Foundation.h>
2+
3+
/// Modes for key-value data collection filtering.
4+
typedef NS_ENUM(NSInteger, SentryObjCDataCollectionKeyValueCollectionMode) {
5+
/// Do not collect this category at all.
6+
SentryObjCDataCollectionKeyValueCollectionModeOff = 0,
7+
/// Collect all values, scrubbing those matching the built-in sensitive denylist.
8+
SentryObjCDataCollectionKeyValueCollectionModeDenyList,
9+
/// Only send values for explicitly listed keys; scrub all others.
10+
SentryObjCDataCollectionKeyValueCollectionModeAllowList
11+
};
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#import <Foundation/Foundation.h>
2+
#if !__has_include(<SentryObjC/SentryObjCDefines.h>)
3+
# import "SentryObjCDataCollectionHttpBodyType.h"
4+
#else
5+
# import <SentryObjC/SentryObjCDataCollectionHttpBodyType.h>
6+
#endif
7+
8+
@class SentryObjCDataCollectionKeyValueCollectionBehavior;
9+
@class SentryObjCDataCollectionHttpHeaderCollectionOptions;
10+
@class SentryObjCDataCollectionGraphQLCollectionOptions;
11+
@class SentryObjCDataCollectionDatabaseCollectionOptions;
12+
13+
NS_ASSUME_NONNULL_BEGIN
14+
15+
/// Configuration for what data the SDK collects automatically.
16+
///
17+
/// All properties have spec-defined defaults. Users supply only the options they want to override;
18+
/// omitted fields use the documented defaults.
19+
///
20+
/// Data explicitly set by the user on the scope is not gated by these options.
21+
@interface SentryObjCDataCollectionOptions : NSObject
22+
23+
/// Automatically populate @c user.* fields from auto-instrumentation. Defaults to @c YES.
24+
@property (nonatomic) BOOL userInfo;
25+
26+
/// Controls cookie collection. Defaults to denyList.
27+
@property (nonatomic, strong) SentryObjCDataCollectionKeyValueCollectionBehavior *cookies;
28+
29+
/// Controls HTTP header collection for request and response directions.
30+
@property (nonatomic, strong) SentryObjCDataCollectionHttpHeaderCollectionOptions *httpHeaders;
31+
32+
/// Body types to collect. Defaults to @c SentryObjCDataCollectionHttpBodyTypeAll.
33+
@property (nonatomic) SentryObjCDataCollectionHttpBodyType httpBodies;
34+
35+
/// Controls URL query parameter filtering. Defaults to denyList.
36+
@property (nonatomic, strong) SentryObjCDataCollectionKeyValueCollectionBehavior *queryParams;
37+
38+
/// Controls GraphQL document and variable collection.
39+
@property (nonatomic, strong) SentryObjCDataCollectionGraphQLCollectionOptions *graphql;
40+
41+
/// Controls database query parameter collection.
42+
@property (nonatomic, strong) SentryObjCDataCollectionDatabaseCollectionOptions *database;
43+
44+
/// Include local variable values captured within stack frames. Defaults to @c YES.
45+
@property (nonatomic) BOOL stackFrameVariables;
46+
47+
/// Number of source code lines to include above and below each stack frame. Defaults to @c 5.
48+
@property (nonatomic) NSUInteger frameContextLines;
49+
50+
- (instancetype)init;
51+
52+
@end
53+
54+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)