Fix school browser initialization and redirect detection; improve diagnostics
This commit is contained in:
@@ -94,7 +94,45 @@ class DiagnosticLog {
|
||||
add('navigation_$phase', fields: {'school': school, 'page': page});
|
||||
}
|
||||
|
||||
void resourceFailure(
|
||||
String school,
|
||||
String? url, {
|
||||
required String code,
|
||||
int? status,
|
||||
bool? mainFrame,
|
||||
}) {
|
||||
final uri = Uri.tryParse(url ?? '');
|
||||
final path = uri?.path.toLowerCase() ?? '';
|
||||
final kind = path.endsWith('.js')
|
||||
? 'script'
|
||||
: path.endsWith('.css')
|
||||
? 'stylesheet'
|
||||
: RegExp(r'\.(png|jpg|jpeg|gif|webp|svg|ico)$').hasMatch(path)
|
||||
? 'image'
|
||||
: 'document_or_request';
|
||||
add(
|
||||
'school_resource_failed',
|
||||
fields: {
|
||||
'school': school,
|
||||
'phase': mainFrame == null
|
||||
? 'unknown'
|
||||
: mainFrame
|
||||
? 'main'
|
||||
: 'subresource',
|
||||
'page': kind,
|
||||
'code': code,
|
||||
'status': status,
|
||||
'type': uri?.scheme == 'http'
|
||||
? 'http'
|
||||
: uri?.scheme == 'https'
|
||||
? 'https'
|
||||
: 'other',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> attach(Directory directory) async {
|
||||
// Retention and export use the same bounded, sanitized entries.
|
||||
final file = File('${directory.path}/diagnostics-recent.json');
|
||||
try {
|
||||
if (await file.exists() && await file.length() <= maxBytes) {
|
||||
|
||||
Reference in New Issue
Block a user