Skip to content

chore: update example app #600

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

Open
wants to merge 4 commits into
base: update-example-app
Choose a base branch
from
Open
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
74 changes: 55 additions & 19 deletions example/lib/src/screens/bug_reporting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ class BugReportingPage extends StatefulWidget {
}

class _BugReportingPageState extends State<BugReportingPage> {
List<ReportType> reportTypes = [ReportType.bug,ReportType.feedback,ReportType.question];
List<ReportType> reportTypes = [
ReportType.bug,
ReportType.feedback,
ReportType.question
];
List<InvocationOption> invocationOptions = [];

final disclaimerTextController = TextEditingController();
Expand Down Expand Up @@ -63,9 +67,7 @@ class _BugReportingPageState extends State<BugReportingPage> {
} else {
reportTypes.add(reportType);
}
setState(() {

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

Expand Down Expand Up @@ -107,6 +109,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 @@ -296,7 +326,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 @@ -305,12 +334,10 @@ class _BugReportingPageState extends State<BugReportingPage> {
attachmentsOptionsExtraScreenshot = value ?? false;
});
addAttachmentOptions();

},
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 @@ -319,12 +346,10 @@ class _BugReportingPageState extends State<BugReportingPage> {
attachmentsOptionsGalleryImage = value ?? false;
});
addAttachmentOptions();

},
title: const Text("Gallery"),
subtitle: const Text('Enable attachment for gallery'),
key: const Key('attachment_option_gallery'),

),
CheckboxListTile(
value: attachmentsOptionsScreenRecording,
Expand All @@ -333,43 +358,43 @@ class _BugReportingPageState extends State<BugReportingPage> {
attachmentsOptionsScreenRecording = value ?? false;
});
addAttachmentOptions();

},
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
),
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
),
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
),
backgroundColor: reportTypes.contains(ReportType.question)
? Colors.grey.shade400
: null),
child: const Text('Question'),
),
],
Expand All @@ -392,7 +417,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 @@ -431,6 +455,18 @@ 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',
),
], // This trailing comma makes auto-formatting nicer for build methods.
);
}
Expand Down
Loading