Skip to content

Commit

Permalink
Add appHangTimeoutInterval to SentryFlutterOptions (#1568)
Browse files Browse the repository at this point in the history
Co-authored-by: Manoel Aranda Neto <[email protected]>
  • Loading branch information
denrase and marandaneto authored Jul 25, 2023
1 parent 0aaa46e commit 33d0587
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

[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.

- Add `appHangTimeoutInterval` to `SentryFlutterOptions` ([#1568](https://github.com/getsentry/sentry-dart/pull/1568))

### Dependencies

- Bump Cocoa SDK from v8.8.0 to v8.9.1 ([#1553](https://github.com/getsentry/sentry-dart/pull/1553))
Expand Down
1 change: 0 additions & 1 deletion flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import 'dart:async';
import 'dart:convert';
import 'dart:io' show Platform;

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
Expand Down
4 changes: 4 additions & 0 deletions flutter/ios/Classes/SentryFlutterPluginApple.swift
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,10 @@ public class SentryFlutterPluginApple: NSObject, FlutterPlugin {
if let enableAppHangTracking = arguments["enableAppHangTracking"] as? Bool {
options.enableAppHangTracking = enableAppHangTracking
}

if let appHangTimeoutIntervalMillis = arguments["appHangTimeoutIntervalMillis"] as? UInt {
options.appHangTimeoutInterval = TimeInterval(appHangTimeoutIntervalMillis) / 1000
}
}

private func logLevelFrom(diagnosticLevel: String) -> SentryLevel {
Expand Down
2 changes: 2 additions & 0 deletions flutter/lib/src/integrations/native_sdk_integration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class NativeSdkIntegration implements Integration<SentryFlutterOptions> {
'enableAppHangTracking': options.enableAppHangTracking,
'connectionTimeoutMillis': options.connectionTimeout.inMilliseconds,
'readTimeoutMillis': options.readTimeout.inMilliseconds,
'appHangTimeoutIntervalMillis':
options.appHangTimeoutInterval.inMilliseconds,
});

options.sdk.addIntegration('nativeSdkIntegration');
Expand Down
10 changes: 9 additions & 1 deletion flutter/lib/src/sentry_flutter_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,18 @@ class SentryFlutterOptions extends SentryOptions {
bool attachViewHierarchy = false;

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

/// The minimum amount of time an app should be unresponsive to be classified
/// as an App Hanging. The actual amount may be a little longer. Avoid using
/// values lower than 100ms, which may cause a lot of app hangs events being
/// transmitted.
/// Default to 2s.
/// Only available on iOS and macOS.
Duration appHangTimeoutInterval = Duration(seconds: 2);

/// Connection timeout. This will only be synced to the Android native SDK.
Duration connectionTimeout = Duration(seconds: 5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void main() {
'enableAppHangTracking': true,
'connectionTimeoutMillis': 5000,
'readTimeoutMillis': 5000,
'appHangTimeoutIntervalMillis': 2000,
});
});

Expand Down Expand Up @@ -100,7 +101,8 @@ void main() {
..captureFailedRequests = false
..enableAppHangTracking = false
..connectionTimeout = Duration(milliseconds: 9001)
..readTimeout = Duration(milliseconds: 9002);
..readTimeout = Duration(milliseconds: 9002)
..appHangTimeoutInterval = Duration(milliseconds: 9003);

options.sdk.addIntegration('foo');
options.sdk.addPackage('bar', '1');
Expand Down Expand Up @@ -143,6 +145,7 @@ void main() {
'enableAppHangTracking': false,
'connectionTimeoutMillis': 9001,
'readTimeoutMillis': 9002,
'appHangTimeoutIntervalMillis': 9003,
});
});

Expand Down

0 comments on commit 33d0587

Please sign in to comment.