Skip to content

Commit 9b4191b

Browse files
chore: update example app (#600)
* chore: update example app * chore: update example app
1 parent 86f9ca3 commit 9b4191b

File tree

8 files changed

+337
-32
lines changed

8 files changed

+337
-32
lines changed

example/lib/main.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ part 'src/screens/crashes_page.dart';
2222

2323
part 'src/screens/bug_reporting.dart';
2424

25+
part 'src/screens/session_replay_page.dart';
26+
2527
part 'src/screens/complex_page.dart';
2628

2729
part 'src/screens/apm_page.dart';

example/lib/src/app_routes.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/widgets.dart' show BuildContext;
2+
import 'package:instabug_flutter/instabug_flutter.dart';
23
import 'package:instabug_flutter_example/main.dart';
34

45
final appRoutes = {
@@ -12,6 +13,10 @@ final appRoutes = {
1213
BugReportingPage.screenName: (BuildContext context) =>
1314
const BugReportingPage(),
1415
ComplexPage.screenName: (BuildContext context) => const ComplexPage(),
16+
SessionReplayPage.screenName: (BuildContext context) =>
17+
const SessionReplayPage(),
18+
TopTabBarScreen.route: (BuildContext context) => const TopTabBarScreen(),
19+
1520
ApmPage.screenName: (BuildContext context) => const ApmPage(),
1621
ScreenLoadingPage.screenName: (BuildContext context) =>
1722
const ScreenLoadingPage(),

example/lib/src/components/network_content.dart

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,42 @@ class _NetworkContentState extends State<NetworkContent> {
3636
text: 'Send Request Without Custom traceparent header',
3737
onPressed: () => _sendRequestToUrl(endpointUrlController.text),
3838
),
39+
InstabugButton(
40+
text: 'obfuscateLog',
41+
onPressed: () {
42+
NetworkLogger.obfuscateLog((networkData) async {
43+
return networkData.copyWith(url: 'fake url');
44+
});
45+
},
46+
),
47+
InstabugButton(
48+
text: 'omitLog',
49+
onPressed: () {
50+
NetworkLogger.omitLog((networkData) async {
51+
return networkData.url.contains('google.com');
52+
});
53+
},
54+
),
55+
InstabugButton(
56+
text: 'obfuscateLogWithException',
57+
onPressed: () {
58+
NetworkLogger.obfuscateLog((networkData) async {
59+
throw Exception("obfuscateLogWithException");
60+
61+
return networkData.copyWith(url: 'fake url');
62+
});
63+
},
64+
),
65+
InstabugButton(
66+
text: 'omitLogWithException',
67+
onPressed: () {
68+
NetworkLogger.omitLog((networkData) async {
69+
throw Exception("OmitLog with exception");
70+
71+
return networkData.url.contains('google.com');
72+
});
73+
},
74+
),
3975
],
4076
);
4177
}

example/lib/src/components/non_fatal_crashes_content.dart

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,24 @@ class _NonFatalCrashesContentState extends State<NonFatalCrashesContent> {
5555
InstabugButton(
5656
text: 'Throw ArgumentError',
5757
key: const Key('non_fatal_argument_exception'),
58-
5958
onPressed: () =>
6059
throwHandledException(ArgumentError('This is an ArgumentError.')),
6160
),
6261
InstabugButton(
6362
text: 'Throw RangeError',
6463
key: const Key('non_fatal_range_exception'),
65-
6664
onPressed: () => throwHandledException(
6765
RangeError.range(5, 0, 3, 'Index out of range')),
6866
),
6967
InstabugButton(
7068
text: 'Throw FormatException',
7169
key: const Key('non_fatal_format_exception'),
72-
7370
onPressed: () =>
7471
throwHandledException(UnsupportedError('Invalid format.')),
7572
),
7673
InstabugButton(
7774
text: 'Throw NoSuchMethodError',
7875
key: const Key('non_fatal_no_such_method_exception'),
79-
8076
onPressed: () {
8177
dynamic obj;
8278
throwHandledException(obj.methodThatDoesNotExist());
@@ -85,7 +81,6 @@ class _NonFatalCrashesContentState extends State<NonFatalCrashesContent> {
8581
const InstabugButton(
8682
text: 'Throw Handled Native Exception',
8783
key: Key('non_fatal_native_exception'),
88-
8984
onPressed:
9085
InstabugFlutterExampleMethodChannel.sendNativeNonFatalCrash,
9186
),
@@ -113,9 +108,8 @@ class _NonFatalCrashesContentState extends State<NonFatalCrashesContent> {
113108
Expanded(
114109
child: InstabugTextField(
115110
label: "User Attribute key",
116-
key: const Key("non_fatal_user_attribute_key_textfield"),
117-
118-
controller: crashUserAttributeKeyController,
111+
key: const Key("non_fatal_user_attribute_key_textfield"),
112+
controller: crashUserAttributeKeyController,
119113
validator: (value) {
120114
if (crashUserAttributeValueController.text.isNotEmpty) {
121115
if (value?.trim().isNotEmpty == true) return null;
@@ -128,9 +122,8 @@ class _NonFatalCrashesContentState extends State<NonFatalCrashesContent> {
128122
Expanded(
129123
child: InstabugTextField(
130124
label: "User Attribute Value",
131-
key: const Key("non_fatal_user_attribute_value_textfield"),
132-
133-
controller: crashUserAttributeValueController,
125+
key: const Key("non_fatal_user_attribute_value_textfield"),
126+
controller: crashUserAttributeValueController,
134127
validator: (value) {
135128
if (crashUserAttributeKeyController.text.isNotEmpty) {
136129
if (value?.trim().isNotEmpty == true) return null;
@@ -147,9 +140,9 @@ class _NonFatalCrashesContentState extends State<NonFatalCrashesContent> {
147140
Expanded(
148141
child: InstabugTextField(
149142
label: "Fingerprint",
150-
key: const Key("non_fatal_user_attribute_fingerprint_textfield"),
151-
152-
controller: crashfingerPrintController,
143+
key: const Key(
144+
"non_fatal_user_attribute_fingerprint_textfield"),
145+
controller: crashfingerPrintController,
153146
)),
154147
],
155148
),
@@ -161,7 +154,6 @@ class _NonFatalCrashesContentState extends State<NonFatalCrashesContent> {
161154
flex: 5,
162155
child: DropdownButtonHideUnderline(
163156
key: const Key("non_fatal_crash_level_dropdown"),
164-
165157
child:
166158
DropdownButtonFormField<NonFatalExceptionLevel>(
167159
value: crashType,

example/lib/src/screens/bug_reporting.dart

Lines changed: 72 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ class _BugReportingPageState extends State<BugReportingPage> {
8484
} else {
8585
reportTypes.add(reportType);
8686
}
87-
setState(() {
88-
89-
});
87+
setState(() {});
9088
BugReporting.setReportTypes(reportTypes);
9189
}
9290

@@ -129,6 +127,34 @@ class _BugReportingPageState extends State<BugReportingPage> {
129127
});
130128
}
131129

130+
void setOnDismissCallbackWithException() {
131+
BugReporting.setOnDismissCallback((dismissType, reportType) {
132+
throw Exception("Test crash from dismiss callback");
133+
});
134+
}
135+
136+
void setOnInvokeCallbackWithException() {
137+
BugReporting.setOnInvokeCallback(() {
138+
throw Exception("Test crash from invoke callback");
139+
});
140+
}
141+
142+
void setOnInvoiceCallback() {
143+
BugReporting.setOnInvokeCallback(() {
144+
showDialog(
145+
context: context,
146+
builder: (context) {
147+
return const AlertDialog(
148+
title: Text('On Invoke'),
149+
content: Text(
150+
'onInvoke callback called',
151+
),
152+
);
153+
},
154+
);
155+
});
156+
}
157+
132158
void setDisclaimerText() {
133159
BugReporting.setDisclaimerText(disclaimerTextController.text);
134160
}
@@ -323,7 +349,6 @@ class _BugReportingPageState extends State<BugReportingPage> {
323349
title: const Text("Screenshot"),
324350
subtitle: const Text('Enable attachment for screenShot'),
325351
key: const Key('attachment_option_screenshot'),
326-
327352
),
328353
CheckboxListTile(
329354
value: attachmentsOptionsExtraScreenshot,
@@ -336,7 +361,6 @@ class _BugReportingPageState extends State<BugReportingPage> {
336361
title: const Text("Extra Screenshot"),
337362
subtitle: const Text('Enable attachment for extra screenShot'),
338363
key: const Key('attachment_option_extra_screenshot'),
339-
340364
),
341365
CheckboxListTile(
342366
value: attachmentsOptionsGalleryImage,
@@ -349,7 +373,6 @@ class _BugReportingPageState extends State<BugReportingPage> {
349373
title: const Text("Gallery"),
350374
subtitle: const Text('Enable attachment for gallery'),
351375
key: const Key('attachment_option_gallery'),
352-
353376
),
354377
CheckboxListTile(
355378
value: attachmentsOptionsScreenRecording,
@@ -362,11 +385,42 @@ class _BugReportingPageState extends State<BugReportingPage> {
362385
title: const Text("Screen Recording"),
363386
subtitle: const Text('Enable attachment for screen Recording'),
364387
key: const Key('attachment_option_screen_recording'),
365-
366388
),
367389
],
368390
),
369391
const SectionTitle('Bug reporting type'),
392+
ButtonBar(
393+
mainAxisSize: MainAxisSize.min,
394+
alignment: MainAxisAlignment.start,
395+
children: <Widget>[
396+
ElevatedButton(
397+
key: const Key('bug_report_type_bug'),
398+
style: ElevatedButton.styleFrom(
399+
backgroundColor: reportTypes.contains(ReportType.bug)
400+
? Colors.grey.shade400
401+
: null),
402+
onPressed: () => toggleReportType(ReportType.bug),
403+
child: const Text('Bug'),
404+
),
405+
ElevatedButton(
406+
key: const Key('bug_report_type_feedback'),
407+
onPressed: () => toggleReportType(ReportType.feedback),
408+
style: ElevatedButton.styleFrom(
409+
backgroundColor: reportTypes.contains(ReportType.feedback)
410+
? Colors.grey.shade400
411+
: null),
412+
child: const Text('Feedback'),
413+
),
414+
ElevatedButton(
415+
key: const Key('bug_report_type_question'),
416+
onPressed: () => toggleReportType(ReportType.question),
417+
style: ElevatedButton.styleFrom(
418+
backgroundColor: reportTypes.contains(ReportType.question)
419+
? Colors.grey.shade400
420+
: null),
421+
child: const Text('Question'),
422+
),
423+
],
370424

371425
CheckboxListTile(
372426
value: reportTypes.contains(ReportType.bug),
@@ -403,7 +457,6 @@ class _BugReportingPageState extends State<BugReportingPage> {
403457
title: const Text("Question"),
404458
subtitle: const Text('Enable Question reporting type'),
405459
key: const Key('bug_report_type_question'),
406-
407460
),
408461
InstabugButton(
409462
onPressed: () =>
@@ -424,7 +477,6 @@ class _BugReportingPageState extends State<BugReportingPage> {
424477
onPressed: () => setDisclaimerText,
425478
child: const Text('set disclaimer text'),
426479
),
427-
428480
const SectionTitle('Extended Bug Reporting'),
429481
ButtonBar(
430482
mainAxisSize: MainAxisSize.min,
@@ -466,6 +518,17 @@ class _BugReportingPageState extends State<BugReportingPage> {
466518
onPressed: setOnDismissCallback,
467519
text: 'Set On Dismiss Callback',
468520
),
521+
InstabugButton(
522+
onPressed: setOnInvoiceCallback,
523+
text: 'Set On Invoice Callback',
524+
),
525+
InstabugButton(
526+
onPressed: setOnDismissCallbackWithException,
527+
text: 'Set On Dismiss Callback with Exception',
528+
),
529+
InstabugButton(
530+
onPressed: setOnInvokeCallbackWithException,
531+
text: 'Set On Invoice Callback with Exception',
469532
const SectionTitle('Attachments'),
470533
if(fileAttachment!=null)
471534
Text(fileAttachment!.path

0 commit comments

Comments
 (0)