Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ part 'src/screens/crashes_page.dart';

part 'src/screens/bug_reporting.dart';

part 'src/screens/session_replay_page.dart';

part 'src/screens/complex_page.dart';

part 'src/screens/apm_page.dart';
Expand Down
5 changes: 5 additions & 0 deletions example/lib/src/app_routes.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/widgets.dart' show BuildContext;
import 'package:instabug_flutter/instabug_flutter.dart';
import 'package:instabug_flutter_example/main.dart';

final appRoutes = {
Expand All @@ -12,6 +13,10 @@ final appRoutes = {
BugReportingPage.screenName: (BuildContext context) =>
const BugReportingPage(),
ComplexPage.screenName: (BuildContext context) => const ComplexPage(),
SessionReplayPage.screenName: (BuildContext context) =>
const SessionReplayPage(),
TopTabBarScreen.route: (BuildContext context) => const TopTabBarScreen(),

ApmPage.screenName: (BuildContext context) => const ApmPage(),
ScreenLoadingPage.screenName: (BuildContext context) =>
const ScreenLoadingPage(),
Expand Down
36 changes: 36 additions & 0 deletions example/lib/src/components/network_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,42 @@ class _NetworkContentState extends State<NetworkContent> {
text: 'Send Request Without Custom traceparent header',
onPressed: () => _sendRequestToUrl(endpointUrlController.text),
),
InstabugButton(
text: 'obfuscateLog',
onPressed: () {
NetworkLogger.obfuscateLog((networkData) async {
return networkData.copyWith(url: 'fake url');
});
},
),
InstabugButton(
text: 'omitLog',
onPressed: () {
NetworkLogger.omitLog((networkData) async {
return networkData.url.contains('google.com');
});
},
),
InstabugButton(
text: 'obfuscateLogWithException',
onPressed: () {
NetworkLogger.obfuscateLog((networkData) async {
throw Exception("obfuscateLogWithException");

return networkData.copyWith(url: 'fake url');
});
},
),
InstabugButton(
text: 'omitLogWithException',
onPressed: () {
NetworkLogger.omitLog((networkData) async {
throw Exception("OmitLog with exception");

return networkData.url.contains('google.com');
});
},
),
],
);
}
Expand Down
22 changes: 7 additions & 15 deletions example/lib/src/components/non_fatal_crashes_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,24 @@ class _NonFatalCrashesContentState extends State<NonFatalCrashesContent> {
InstabugButton(
text: 'Throw ArgumentError',
key: const Key('non_fatal_argument_exception'),

onPressed: () =>
throwHandledException(ArgumentError('This is an ArgumentError.')),
),
InstabugButton(
text: 'Throw RangeError',
key: const Key('non_fatal_range_exception'),

onPressed: () => throwHandledException(
RangeError.range(5, 0, 3, 'Index out of range')),
),
InstabugButton(
text: 'Throw FormatException',
key: const Key('non_fatal_format_exception'),

onPressed: () =>
throwHandledException(UnsupportedError('Invalid format.')),
),
InstabugButton(
text: 'Throw NoSuchMethodError',
key: const Key('non_fatal_no_such_method_exception'),

onPressed: () {
dynamic obj;
throwHandledException(obj.methodThatDoesNotExist());
Expand All @@ -85,7 +81,6 @@ class _NonFatalCrashesContentState extends State<NonFatalCrashesContent> {
const InstabugButton(
text: 'Throw Handled Native Exception',
key: Key('non_fatal_native_exception'),

onPressed:
InstabugFlutterExampleMethodChannel.sendNativeNonFatalCrash,
),
Expand Down Expand Up @@ -113,9 +108,8 @@ class _NonFatalCrashesContentState extends State<NonFatalCrashesContent> {
Expanded(
child: InstabugTextField(
label: "User Attribute key",
key: const Key("non_fatal_user_attribute_key_textfield"),

controller: crashUserAttributeKeyController,
key: const Key("non_fatal_user_attribute_key_textfield"),
controller: crashUserAttributeKeyController,
validator: (value) {
if (crashUserAttributeValueController.text.isNotEmpty) {
if (value?.trim().isNotEmpty == true) return null;
Expand All @@ -128,9 +122,8 @@ class _NonFatalCrashesContentState extends State<NonFatalCrashesContent> {
Expanded(
child: InstabugTextField(
label: "User Attribute Value",
key: const Key("non_fatal_user_attribute_value_textfield"),

controller: crashUserAttributeValueController,
key: const Key("non_fatal_user_attribute_value_textfield"),
controller: crashUserAttributeValueController,
validator: (value) {
if (crashUserAttributeKeyController.text.isNotEmpty) {
if (value?.trim().isNotEmpty == true) return null;
Expand All @@ -147,9 +140,9 @@ class _NonFatalCrashesContentState extends State<NonFatalCrashesContent> {
Expanded(
child: InstabugTextField(
label: "Fingerprint",
key: const Key("non_fatal_user_attribute_fingerprint_textfield"),

controller: crashfingerPrintController,
key: const Key(
"non_fatal_user_attribute_fingerprint_textfield"),
controller: crashfingerPrintController,
)),
],
),
Expand All @@ -161,7 +154,6 @@ class _NonFatalCrashesContentState extends State<NonFatalCrashesContent> {
flex: 5,
child: DropdownButtonHideUnderline(
key: const Key("non_fatal_crash_level_dropdown"),

child:
DropdownButtonFormField<NonFatalExceptionLevel>(
value: crashType,
Expand Down
81 changes: 72 additions & 9 deletions example/lib/src/screens/bug_reporting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ class _BugReportingPageState extends State<BugReportingPage> {
} else {
reportTypes.add(reportType);
}
setState(() {

});
setState(() {});
BugReporting.setReportTypes(reportTypes);
}

Expand Down Expand Up @@ -129,6 +127,34 @@ class _BugReportingPageState extends State<BugReportingPage> {
});
}

void setOnDismissCallbackWithException() {
BugReporting.setOnDismissCallback((dismissType, reportType) {
throw Exception("Test crash from dismiss callback");
});
}

void setOnInvokeCallbackWithException() {
BugReporting.setOnInvokeCallback(() {
throw Exception("Test crash from invoke callback");
});
}

void setOnInvoiceCallback() {
BugReporting.setOnInvokeCallback(() {
showDialog(
context: context,
builder: (context) {
return const AlertDialog(
title: Text('On Invoke'),
content: Text(
'onInvoke callback called',
),
);
},
);
});
}

void setDisclaimerText() {
BugReporting.setDisclaimerText(disclaimerTextController.text);
}
Expand Down Expand Up @@ -323,7 +349,6 @@ class _BugReportingPageState extends State<BugReportingPage> {
title: const Text("Screenshot"),
subtitle: const Text('Enable attachment for screenShot'),
key: const Key('attachment_option_screenshot'),

),
CheckboxListTile(
value: attachmentsOptionsExtraScreenshot,
Expand All @@ -336,7 +361,6 @@ class _BugReportingPageState extends State<BugReportingPage> {
title: const Text("Extra Screenshot"),
subtitle: const Text('Enable attachment for extra screenShot'),
key: const Key('attachment_option_extra_screenshot'),

),
CheckboxListTile(
value: attachmentsOptionsGalleryImage,
Expand All @@ -349,7 +373,6 @@ class _BugReportingPageState extends State<BugReportingPage> {
title: const Text("Gallery"),
subtitle: const Text('Enable attachment for gallery'),
key: const Key('attachment_option_gallery'),

),
CheckboxListTile(
value: attachmentsOptionsScreenRecording,
Expand All @@ -362,11 +385,42 @@ class _BugReportingPageState extends State<BugReportingPage> {
title: const Text("Screen Recording"),
subtitle: const Text('Enable attachment for screen Recording'),
key: const Key('attachment_option_screen_recording'),

),
],
),
const SectionTitle('Bug reporting type'),
ButtonBar(
mainAxisSize: MainAxisSize.min,
alignment: MainAxisAlignment.start,
children: <Widget>[
ElevatedButton(
key: const Key('bug_report_type_bug'),
style: ElevatedButton.styleFrom(
backgroundColor: reportTypes.contains(ReportType.bug)
? Colors.grey.shade400
: null),
onPressed: () => toggleReportType(ReportType.bug),
child: const Text('Bug'),
),
ElevatedButton(
key: const Key('bug_report_type_feedback'),
onPressed: () => toggleReportType(ReportType.feedback),
style: ElevatedButton.styleFrom(
backgroundColor: reportTypes.contains(ReportType.feedback)
? Colors.grey.shade400
: null),
child: const Text('Feedback'),
),
ElevatedButton(
key: const Key('bug_report_type_question'),
onPressed: () => toggleReportType(ReportType.question),
style: ElevatedButton.styleFrom(
backgroundColor: reportTypes.contains(ReportType.question)
? Colors.grey.shade400
: null),
child: const Text('Question'),
),
],

CheckboxListTile(
value: reportTypes.contains(ReportType.bug),
Expand Down Expand Up @@ -403,7 +457,6 @@ class _BugReportingPageState extends State<BugReportingPage> {
title: const Text("Question"),
subtitle: const Text('Enable Question reporting type'),
key: const Key('bug_report_type_question'),

),
InstabugButton(
onPressed: () =>
Expand All @@ -424,7 +477,6 @@ class _BugReportingPageState extends State<BugReportingPage> {
onPressed: () => setDisclaimerText,
child: const Text('set disclaimer text'),
),

const SectionTitle('Extended Bug Reporting'),
ButtonBar(
mainAxisSize: MainAxisSize.min,
Expand Down Expand Up @@ -466,6 +518,17 @@ class _BugReportingPageState extends State<BugReportingPage> {
onPressed: setOnDismissCallback,
text: 'Set On Dismiss Callback',
),
InstabugButton(
onPressed: setOnInvoiceCallback,
text: 'Set On Invoice Callback',
),
InstabugButton(
onPressed: setOnDismissCallbackWithException,
text: 'Set On Dismiss Callback with Exception',
),
InstabugButton(
onPressed: setOnInvokeCallbackWithException,
text: 'Set On Invoice Callback with Exception',
const SectionTitle('Attachments'),
if(fileAttachment!=null)
Text(fileAttachment!.path
Expand Down
Loading