Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add appHangTimeoutInterval to SentryFlutterOptions #1568

Merged
merged 4 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 8 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,17 @@ 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.
marandaneto marked this conversation as resolved.
Show resolved Hide resolved
/// 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.
/// 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