Skip to content

Commit 33d0587

Browse files
denrasemarandaneto
andauthored
Add appHangTimeoutInterval to SentryFlutterOptions (#1568)
Co-authored-by: Manoel Aranda Neto <[email protected]>
1 parent 0aaa46e commit 33d0587

File tree

6 files changed

+21
-3
lines changed

6 files changed

+21
-3
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
[Trace origin](https://develop.sentry.dev/sdk/performance/trace-origin/) indicates what created a trace or a span. Not all transactions and spans contain enough information to tell whether the user or what precisely in the SDK created it. Origin solves this problem. The SDK now sends origin for transactions and spans.
1010

11+
- Add `appHangTimeoutInterval` to `SentryFlutterOptions` ([#1568](https://github.com/getsentry/sentry-dart/pull/1568))
12+
1113
### Dependencies
1214

1315
- Bump Cocoa SDK from v8.8.0 to v8.9.1 ([#1553](https://github.com/getsentry/sentry-dart/pull/1553))

flutter/example/lib/main.dart

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import 'dart:async';
44
import 'dart:convert';
5-
import 'dart:io' show Platform;
65

76
import 'package:flutter/foundation.dart';
87
import 'package:flutter/material.dart';

flutter/ios/Classes/SentryFlutterPluginApple.swift

+4
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,10 @@ public class SentryFlutterPluginApple: NSObject, FlutterPlugin {
384384
if let enableAppHangTracking = arguments["enableAppHangTracking"] as? Bool {
385385
options.enableAppHangTracking = enableAppHangTracking
386386
}
387+
388+
if let appHangTimeoutIntervalMillis = arguments["appHangTimeoutIntervalMillis"] as? UInt {
389+
options.appHangTimeoutInterval = TimeInterval(appHangTimeoutIntervalMillis) / 1000
390+
}
387391
}
388392

389393
private func logLevelFrom(diagnosticLevel: String) -> SentryLevel {

flutter/lib/src/integrations/native_sdk_integration.dart

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class NativeSdkIntegration implements Integration<SentryFlutterOptions> {
5151
'enableAppHangTracking': options.enableAppHangTracking,
5252
'connectionTimeoutMillis': options.connectionTimeout.inMilliseconds,
5353
'readTimeoutMillis': options.readTimeout.inMilliseconds,
54+
'appHangTimeoutIntervalMillis':
55+
options.appHangTimeoutInterval.inMilliseconds,
5456
});
5557

5658
options.sdk.addIntegration('nativeSdkIntegration');

flutter/lib/src/sentry_flutter_options.dart

+9-1
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,18 @@ class SentryFlutterOptions extends SentryOptions {
195195
bool attachViewHierarchy = false;
196196

197197
/// When enabled, the SDK tracks when the application stops responding for a
198-
/// specific amount of time (default 2s).
198+
/// specific amount of time, See [appHangTimeoutInterval].
199199
/// Only available on iOS and macOS.
200200
bool enableAppHangTracking = true;
201201

202+
/// The minimum amount of time an app should be unresponsive to be classified
203+
/// as an App Hanging. The actual amount may be a little longer. Avoid using
204+
/// values lower than 100ms, which may cause a lot of app hangs events being
205+
/// transmitted.
206+
/// Default to 2s.
207+
/// Only available on iOS and macOS.
208+
Duration appHangTimeoutInterval = Duration(seconds: 2);
209+
202210
/// Connection timeout. This will only be synced to the Android native SDK.
203211
Duration connectionTimeout = Duration(seconds: 5);
204212

flutter/test/integrations/init_native_sdk_integration_test.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ void main() {
6262
'enableAppHangTracking': true,
6363
'connectionTimeoutMillis': 5000,
6464
'readTimeoutMillis': 5000,
65+
'appHangTimeoutIntervalMillis': 2000,
6566
});
6667
});
6768

@@ -100,7 +101,8 @@ void main() {
100101
..captureFailedRequests = false
101102
..enableAppHangTracking = false
102103
..connectionTimeout = Duration(milliseconds: 9001)
103-
..readTimeout = Duration(milliseconds: 9002);
104+
..readTimeout = Duration(milliseconds: 9002)
105+
..appHangTimeoutInterval = Duration(milliseconds: 9003);
104106

105107
options.sdk.addIntegration('foo');
106108
options.sdk.addPackage('bar', '1');
@@ -143,6 +145,7 @@ void main() {
143145
'enableAppHangTracking': false,
144146
'connectionTimeoutMillis': 9001,
145147
'readTimeoutMillis': 9002,
148+
'appHangTimeoutIntervalMillis': 9003,
146149
});
147150
});
148151

0 commit comments

Comments
 (0)