@@ -59,6 +59,10 @@ protocol DynamicConfig {
5959 /// Defaults to true.
6060 var gestureClickTakeSnapshot : Bool { get }
6161
62+ /// Sampling rate for htto events.
63+ /// Defaults to 0.01%.
64+ var httpSamplingRate : Float { get }
65+
6266 /// URLs for which HTTP events should be disabled.
6367 var httpDisableEventForUrls : [ String ] { get }
6468
@@ -86,36 +90,72 @@ struct BaseDynamicConfig: DynamicConfig, Codable {
8690 let anrTakeScreenshot : Bool
8791 let launchSamplingRate : Float
8892 let gestureClickTakeSnapshot : Bool
93+ let httpSamplingRate : Float
8994 let httpDisableEventForUrls : [ String ]
9095 let httpTrackRequestForUrls : [ String ]
9196 let httpTrackResponseForUrls : [ String ]
9297 let httpBlockedHeaders : [ String ]
93-
94- static func `default`( ) -> BaseDynamicConfig {
95- BaseDynamicConfig ( maxEventsInBatch: 10_000 ,
96- crashTimelineDurationSeconds: 300 ,
97- anrTimelineDurationSeconds: 300 ,
98- bugReportTimelineDurationSeconds: 300 ,
99- traceSamplingRate: 0.01 ,
100- journeySamplingRate: 0.01 ,
101- screenshotMaskLevel: . allTextAndMedia,
102- cpuUsageInterval: 5 ,
103- memoryUsageInterval: 5 ,
104- crashTakeScreenshot: true ,
105- anrTakeScreenshot: true ,
106- launchSamplingRate: 0.01 ,
107- gestureClickTakeSnapshot: true ,
108- httpDisableEventForUrls: [ ] ,
109- httpTrackRequestForUrls: [ ] ,
110- httpTrackResponseForUrls: [ ] ,
111- httpBlockedHeaders: [
112- " Authorization " ,
113- " Cookie " ,
114- " Set-Cookie " ,
115- " Proxy-Authorization " ,
116- " WWW-Authenticate " ,
117- " X-Api-Key " ,
118- ] )
98+
99+ init ( maxEventsInBatch: Number = DefaultConfig . maxEventsInBatch,
100+ crashTimelineDurationSeconds: Number = DefaultConfig . crashTimelineDurationSeconds,
101+ anrTimelineDurationSeconds: Number = DefaultConfig . anrTimelineDurationSeconds,
102+ bugReportTimelineDurationSeconds: Number = DefaultConfig . bugReportTimelineDurationSeconds,
103+ traceSamplingRate: Float = DefaultConfig . traceSamplingRate,
104+ journeySamplingRate: Float = DefaultConfig . journeySamplingRate,
105+ screenshotMaskLevel: ScreenshotMaskLevel = DefaultConfig . screenshotMaskLevel,
106+ cpuUsageInterval: Number = DefaultConfig . cpuUsageInterval,
107+ memoryUsageInterval: Number = DefaultConfig . memoryUsageInterval,
108+ crashTakeScreenshot: Bool = DefaultConfig . crashTakeScreenshot,
109+ anrTakeScreenshot: Bool = DefaultConfig . anrTakeScreenshot,
110+ launchSamplingRate: Float = DefaultConfig . launchSamplingRate,
111+ gestureClickTakeSnapshot: Bool = DefaultConfig . gestureClickTakeSnapshot,
112+ httpSamplingRate: Float = DefaultConfig . httpSamplingRate,
113+ httpDisableEventForUrls: [ String ] = DefaultConfig . httpDisableEventForUrls,
114+ httpTrackRequestForUrls: [ String ] = DefaultConfig . httpTrackRequestForUrls,
115+ httpTrackResponseForUrls: [ String ] = DefaultConfig . httpTrackResponseForUrls,
116+ httpBlockedHeaders: [ String ] = DefaultConfig . httpBlockedHeaders
117+ ) {
118+ self . maxEventsInBatch = maxEventsInBatch
119+ self . crashTimelineDurationSeconds = crashTimelineDurationSeconds
120+ self . anrTimelineDurationSeconds = anrTimelineDurationSeconds
121+ self . bugReportTimelineDurationSeconds = bugReportTimelineDurationSeconds
122+ self . traceSamplingRate = traceSamplingRate
123+ self . journeySamplingRate = journeySamplingRate
124+ self . screenshotMaskLevel = screenshotMaskLevel
125+ self . cpuUsageInterval = cpuUsageInterval
126+ self . memoryUsageInterval = memoryUsageInterval
127+ self . crashTakeScreenshot = crashTakeScreenshot
128+ self . anrTakeScreenshot = anrTakeScreenshot
129+ self . launchSamplingRate = launchSamplingRate
130+ self . gestureClickTakeSnapshot = gestureClickTakeSnapshot
131+ self . httpSamplingRate = httpSamplingRate
132+ self . httpDisableEventForUrls = httpDisableEventForUrls
133+ self . httpTrackRequestForUrls = httpTrackRequestForUrls
134+ self . httpTrackResponseForUrls = httpTrackResponseForUrls
135+ self . httpBlockedHeaders = httpBlockedHeaders
136+ }
137+
138+ init ( from decoder: Decoder ) throws {
139+ let c = try decoder. container ( keyedBy: CodingKeys . self)
140+
141+ maxEventsInBatch = try c. decodeIfPresent ( Number . self, forKey: . maxEventsInBatch) ?? DefaultConfig . maxEventsInBatch
142+ crashTimelineDurationSeconds = try c. decodeIfPresent ( Number . self, forKey: . crashTimelineDurationSeconds) ?? DefaultConfig . crashTimelineDurationSeconds
143+ anrTimelineDurationSeconds = try c. decodeIfPresent ( Number . self, forKey: . anrTimelineDurationSeconds) ?? DefaultConfig . anrTimelineDurationSeconds
144+ bugReportTimelineDurationSeconds = try c. decodeIfPresent ( Number . self, forKey: . bugReportTimelineDurationSeconds) ?? DefaultConfig . bugReportTimelineDurationSeconds
145+ traceSamplingRate = try c. decodeIfPresent ( Float . self, forKey: . traceSamplingRate) ?? DefaultConfig . traceSamplingRate
146+ journeySamplingRate = try c. decodeIfPresent ( Float . self, forKey: . journeySamplingRate) ?? DefaultConfig . journeySamplingRate
147+ screenshotMaskLevel = try c. decodeIfPresent ( ScreenshotMaskLevel . self, forKey: . screenshotMaskLevel) ?? DefaultConfig . screenshotMaskLevel
148+ cpuUsageInterval = try c. decodeIfPresent ( Number . self, forKey: . cpuUsageInterval) ?? DefaultConfig . cpuUsageInterval
149+ memoryUsageInterval = try c. decodeIfPresent ( Number . self, forKey: . memoryUsageInterval) ?? DefaultConfig . memoryUsageInterval
150+ crashTakeScreenshot = try c. decodeIfPresent ( Bool . self, forKey: . crashTakeScreenshot) ?? DefaultConfig . crashTakeScreenshot
151+ anrTakeScreenshot = try c. decodeIfPresent ( Bool . self, forKey: . anrTakeScreenshot) ?? DefaultConfig . anrTakeScreenshot
152+ launchSamplingRate = try c. decodeIfPresent ( Float . self, forKey: . launchSamplingRate) ?? DefaultConfig . launchSamplingRate
153+ gestureClickTakeSnapshot = try c. decodeIfPresent ( Bool . self, forKey: . gestureClickTakeSnapshot) ?? DefaultConfig . gestureClickTakeSnapshot
154+ httpSamplingRate = try c. decodeIfPresent ( Float . self, forKey: . httpSamplingRate) ?? DefaultConfig . httpSamplingRate
155+ httpDisableEventForUrls = try c. decodeIfPresent ( [ String ] . self, forKey: . httpDisableEventForUrls) ?? DefaultConfig . httpDisableEventForUrls
156+ httpTrackRequestForUrls = try c. decodeIfPresent ( [ String ] . self, forKey: . httpTrackRequestForUrls) ?? DefaultConfig . httpTrackRequestForUrls
157+ httpTrackResponseForUrls = try c. decodeIfPresent ( [ String ] . self, forKey: . httpTrackResponseForUrls) ?? DefaultConfig . httpTrackResponseForUrls
158+ httpBlockedHeaders = try c. decodeIfPresent ( [ String ] . self, forKey: . httpBlockedHeaders) ?? DefaultConfig . httpBlockedHeaders
119159 }
120160
121161 private enum CodingKeys : String , CodingKey {
@@ -132,6 +172,7 @@ struct BaseDynamicConfig: DynamicConfig, Codable {
132172 case anrTakeScreenshot = " anr_take_screenshot "
133173 case launchSamplingRate = " launch_sampling_rate "
134174 case gestureClickTakeSnapshot = " gesture_click_take_snapshot "
175+ case httpSamplingRate = " http_sampling_rate "
135176 case httpDisableEventForUrls = " http_disable_event_for_urls "
136177 case httpTrackRequestForUrls = " http_track_request_for_urls "
137178 case httpTrackResponseForUrls = " http_track_response_for_urls "
0 commit comments