@@ -3,6 +3,7 @@ import 'dart:io';
33
44import 'package:dualmate/canteen/business/canteen_provider.dart' ;
55import 'package:dualmate/common/appstart/background_initialize.dart' ;
6+ import 'package:dualmate/common/logging/app_diagnostics.dart' ;
67import 'package:dualmate/common/appstart/localization_initialize.dart' ;
78import 'package:dualmate/common/appstart/notification_schedule_changed_initialize.dart' ;
89import 'package:dualmate/common/appstart/notifications_initialize.dart' ;
@@ -85,10 +86,28 @@ Future<void> initializeAppBackground(bool isBackground) async {
8586 print ("Background init: workmanager failed (${exception .runtimeType })" );
8687 print (exception);
8788 print (trace);
89+ await AppDiagnostics .instance.reportCaughtException (
90+ exception,
91+ trace,
92+ message: 'Background init: workmanager failed' ,
93+ tags: {'feature' : 'background' },
94+ contexts: {
95+ 'background' : {'phase' : 'workmanager.setup' },
96+ },
97+ );
8898 } catch (error, trace) {
8999 print ("Background init: workmanager failed" );
90100 print (error);
91101 print (trace);
102+ await AppDiagnostics .instance.reportCaughtException (
103+ error,
104+ trace,
105+ message: 'Background init: workmanager failed' ,
106+ tags: {'feature' : 'background' },
107+ contexts: {
108+ 'background' : {'phase' : 'workmanager.setup' },
109+ },
110+ );
92111 }
93112
94113 try {
@@ -99,10 +118,28 @@ Future<void> initializeAppBackground(bool isBackground) async {
99118 print ("Background init: schedule notify failed (${exception .runtimeType })" );
100119 print (exception);
101120 print (trace);
121+ await AppDiagnostics .instance.reportCaughtException (
122+ exception,
123+ trace,
124+ message: 'Background init: schedule notify failed' ,
125+ tags: {'feature' : 'notifications' },
126+ contexts: {
127+ 'notifications' : {'phase' : 'schedule_changed.setup' },
128+ },
129+ );
102130 } catch (error, trace) {
103131 print ("Background init: schedule notify failed" );
104132 print (error);
105133 print (trace);
134+ await AppDiagnostics .instance.reportCaughtException (
135+ error,
136+ trace,
137+ message: 'Background init: schedule notify failed' ,
138+ tags: {'feature' : 'notifications' },
139+ contexts: {
140+ 'notifications' : {'phase' : 'schedule_changed.setup' },
141+ },
142+ );
106143 }
107144
108145 tz.initializeTimeZones ();
@@ -176,11 +213,29 @@ Future<void> _prewarmCanteenIfStaleInBackground(
176213 print ("Foreground canteen prewarm failed (${exception .runtimeType })" );
177214 print (exception);
178215 print (trace);
216+ await AppDiagnostics .instance.reportCaughtException (
217+ exception,
218+ trace,
219+ message: 'Foreground canteen prewarm failed' ,
220+ tags: {'feature' : 'canteen' },
221+ contexts: {
222+ 'canteen' : {'phase' : 'foreground_prewarm' },
223+ },
224+ );
179225 // Swallowing here is intentional; we don't want to block startup.
180226 } catch (error, trace) {
181227 print ("Foreground canteen prewarm failed" );
182228 print (error);
183229 print (trace);
230+ await AppDiagnostics .instance.reportCaughtException (
231+ error,
232+ trace,
233+ message: 'Foreground canteen prewarm failed' ,
234+ tags: {'feature' : 'canteen' },
235+ contexts: {
236+ 'canteen' : {'phase' : 'foreground_prewarm' },
237+ },
238+ );
184239 // Swallowing here is intentional; we don't want to block startup.
185240 }
186241}
@@ -202,11 +257,29 @@ Future<void> _setupCalendarSyncInBackground(Stopwatch stopwatch) async {
202257 "Foreground heavy init: calendar sync failed (${exception .runtimeType })" );
203258 print (exception);
204259 print (trace);
260+ await AppDiagnostics .instance.reportCaughtException (
261+ exception,
262+ trace,
263+ message: 'Foreground heavy init: calendar sync failed' ,
264+ tags: {'feature' : 'calendar' },
265+ contexts: {
266+ 'calendar' : {'phase' : 'foreground_sync_setup' },
267+ },
268+ );
205269 // Swallowing here is intentional; we don't want to block startup.
206270 } catch (error, trace) {
207271 print ("Foreground heavy init: calendar sync failed" );
208272 print (error);
209273 print (trace);
274+ await AppDiagnostics .instance.reportCaughtException (
275+ error,
276+ trace,
277+ message: 'Foreground heavy init: calendar sync failed' ,
278+ tags: {'feature' : 'calendar' },
279+ contexts: {
280+ 'calendar' : {'phase' : 'foreground_sync_setup' },
281+ },
282+ );
210283 // Swallowing here is intentional; we don't want to block startup.
211284 }
212285}
0 commit comments