@@ -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,86 @@ 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 = 10_000 ,
100+ crashTimelineDurationSeconds: Number = 300 ,
101+ anrTimelineDurationSeconds: Number = 300 ,
102+ bugReportTimelineDurationSeconds: Number = 300 ,
103+ traceSamplingRate: Float = 0.01 ,
104+ journeySamplingRate: Float = 0.01 ,
105+ screenshotMaskLevel: ScreenshotMaskLevel = . allTextAndMedia,
106+ cpuUsageInterval: Number = 5 ,
107+ memoryUsageInterval: Number = 5 ,
108+ crashTakeScreenshot: Bool = true ,
109+ anrTakeScreenshot: Bool = true ,
110+ launchSamplingRate: Float = 0.01 ,
111+ gestureClickTakeSnapshot: Bool = true ,
112+ httpSamplingRate: Float = 0.01 ,
113+ httpDisableEventForUrls: [ String ] = [ ] ,
114+ httpTrackRequestForUrls: [ String ] = [ ] ,
115+ httpTrackResponseForUrls: [ String ] = [ ] ,
116+ httpBlockedHeaders: [ String ] = [
117+ " Authorization " ,
118+ " Cookie " ,
119+ " Set-Cookie " ,
120+ " Proxy-Authorization " ,
121+ " WWW-Authenticate " ,
122+ " X-Api-Key " ,
123+ ]
124+ ) {
125+ self . maxEventsInBatch = maxEventsInBatch
126+ self . crashTimelineDurationSeconds = crashTimelineDurationSeconds
127+ self . anrTimelineDurationSeconds = anrTimelineDurationSeconds
128+ self . bugReportTimelineDurationSeconds = bugReportTimelineDurationSeconds
129+ self . traceSamplingRate = traceSamplingRate
130+ self . journeySamplingRate = journeySamplingRate
131+ self . screenshotMaskLevel = screenshotMaskLevel
132+ self . cpuUsageInterval = cpuUsageInterval
133+ self . memoryUsageInterval = memoryUsageInterval
134+ self . crashTakeScreenshot = crashTakeScreenshot
135+ self . anrTakeScreenshot = anrTakeScreenshot
136+ self . launchSamplingRate = launchSamplingRate
137+ self . gestureClickTakeSnapshot = gestureClickTakeSnapshot
138+ self . httpSamplingRate = httpSamplingRate
139+ self . httpDisableEventForUrls = httpDisableEventForUrls
140+ self . httpTrackRequestForUrls = httpTrackRequestForUrls
141+ self . httpTrackResponseForUrls = httpTrackResponseForUrls
142+ self . httpBlockedHeaders = httpBlockedHeaders
143+ }
144+
145+ init ( from decoder: Decoder ) throws {
146+ let c = try decoder. container ( keyedBy: CodingKeys . self)
147+
148+ maxEventsInBatch = try c. decodeIfPresent ( Number . self, forKey: . maxEventsInBatch) ?? 10_000
149+ crashTimelineDurationSeconds = try c. decodeIfPresent ( Number . self, forKey: . crashTimelineDurationSeconds) ?? 300
150+ anrTimelineDurationSeconds = try c. decodeIfPresent ( Number . self, forKey: . anrTimelineDurationSeconds) ?? 300
151+ bugReportTimelineDurationSeconds = try c. decodeIfPresent ( Number . self, forKey: . bugReportTimelineDurationSeconds) ?? 300
152+ traceSamplingRate = try c. decodeIfPresent ( Float . self, forKey: . traceSamplingRate) ?? 0.01
153+ journeySamplingRate = try c. decodeIfPresent ( Float . self, forKey: . journeySamplingRate) ?? 0.01
154+ screenshotMaskLevel = try c. decodeIfPresent ( ScreenshotMaskLevel . self, forKey: . screenshotMaskLevel) ?? . allTextAndMedia
155+ cpuUsageInterval = try c. decodeIfPresent ( Number . self, forKey: . cpuUsageInterval) ?? 5
156+ memoryUsageInterval = try c. decodeIfPresent ( Number . self, forKey: . memoryUsageInterval) ?? 5
157+ crashTakeScreenshot = try c. decodeIfPresent ( Bool . self, forKey: . crashTakeScreenshot) ?? true
158+ anrTakeScreenshot = try c. decodeIfPresent ( Bool . self, forKey: . anrTakeScreenshot) ?? true
159+ launchSamplingRate = try c. decodeIfPresent ( Float . self, forKey: . launchSamplingRate) ?? 0.01
160+ gestureClickTakeSnapshot = try c. decodeIfPresent ( Bool . self, forKey: . gestureClickTakeSnapshot) ?? true
161+ httpSamplingRate = try c. decodeIfPresent ( Float . self, forKey: . httpSamplingRate) ?? 0.01
162+ httpDisableEventForUrls = try c. decodeIfPresent ( [ String ] . self, forKey: . httpDisableEventForUrls) ?? [ ]
163+ httpTrackRequestForUrls = try c. decodeIfPresent ( [ String ] . self, forKey: . httpTrackRequestForUrls) ?? [ ]
164+ httpTrackResponseForUrls = try c. decodeIfPresent ( [ String ] . self, forKey: . httpTrackResponseForUrls) ?? [ ]
165+ httpBlockedHeaders = try c. decodeIfPresent ( [ String ] . self, forKey: . httpBlockedHeaders) ?? [
166+ " Authorization " ,
167+ " Cookie " ,
168+ " Set-Cookie " ,
169+ " Proxy-Authorization " ,
170+ " WWW-Authenticate " ,
171+ " X-Api-Key " ,
172+ ]
119173 }
120174
121175 private enum CodingKeys : String , CodingKey {
@@ -132,6 +186,7 @@ struct BaseDynamicConfig: DynamicConfig, Codable {
132186 case anrTakeScreenshot = " anr_take_screenshot "
133187 case launchSamplingRate = " launch_sampling_rate "
134188 case gestureClickTakeSnapshot = " gesture_click_take_snapshot "
189+ case httpSamplingRate = " http_sampling_rate "
135190 case httpDisableEventForUrls = " http_disable_event_for_urls "
136191 case httpTrackRequestForUrls = " http_track_request_for_urls "
137192 case httpTrackResponseForUrls = " http_track_response_for_urls "
0 commit comments