Sentry (#3655)
* chore: render newlines in html message properly * chore: log timeouts as warnings * chore: update log level
This commit is contained in:
parent
d1b7b13ab6
commit
9b72bd8a09
9 changed files with 40 additions and 98 deletions
|
|
@ -239,6 +239,10 @@ class HtmlMessage extends StatelessWidget {
|
|||
position = substringIndex;
|
||||
}
|
||||
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
if (result[i] == '\n') result[i] = '<br>';
|
||||
}
|
||||
|
||||
if (pangeaMessageEvent?.textDirection == TextDirection.rtl) {
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
final tag = result[i];
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
|
|||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
|
||||
import 'package:fluffychat/config/themes.dart';
|
||||
|
|
@ -19,6 +20,7 @@ import 'package:fluffychat/pangea/activity_planner/media_enum.dart';
|
|||
import 'package:fluffychat/pangea/activity_suggestions/activity_plan_search_repo.dart';
|
||||
import 'package:fluffychat/pangea/activity_suggestions/activity_suggestion_card.dart';
|
||||
import 'package:fluffychat/pangea/activity_suggestions/activity_suggestion_dialog.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/common/widgets/error_indicator.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/constants/language_constants.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/enums/language_level_type_enum.dart';
|
||||
|
|
@ -131,6 +133,17 @@ class ActivitySuggestionsAreaState extends State<ActivitySuggestionsArea> {
|
|||
);
|
||||
_activityItems.addAll(resp.activityPlans);
|
||||
_timeout = false;
|
||||
} catch (e, s) {
|
||||
if (e is! TimeoutException) rethrow;
|
||||
ErrorHandler.logError(
|
||||
e: e,
|
||||
s: s,
|
||||
data: {
|
||||
'retries': retries,
|
||||
'request': _request.toJson(),
|
||||
},
|
||||
level: SentryLevel.warning,
|
||||
);
|
||||
} finally {
|
||||
if (mounted) setState(() => _loading = false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,6 +197,7 @@ class Choreographer {
|
|||
"l2LangCode": l2LangCode,
|
||||
"choreoRecord": choreoRecord?.toJson(),
|
||||
},
|
||||
level: e is TimeoutException ? SentryLevel.warning : SentryLevel.error,
|
||||
);
|
||||
} finally {
|
||||
chatController.send(
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/choreographer.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/error_service.dart';
|
||||
|
|
@ -168,6 +169,8 @@ class IgcController {
|
|||
"itEnabled": choreographer.itEnabled,
|
||||
"matches": igcTextData?.matches.map((e) => e.toJson()),
|
||||
},
|
||||
level:
|
||||
err is TimeoutException ? SentryLevel.warning : SentryLevel.error,
|
||||
);
|
||||
clear();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,6 +180,8 @@ class ITController {
|
|||
"sourceText": sourceText,
|
||||
"currentITStepPayloadID": currentITStep?.payloadId,
|
||||
},
|
||||
level:
|
||||
e is TimeoutException ? SentryLevel.warning : SentryLevel.error,
|
||||
);
|
||||
}
|
||||
choreographer.errorService.setErrorAndLock(
|
||||
|
|
|
|||
|
|
@ -76,15 +76,7 @@ class RepresentationEvent {
|
|||
|
||||
List<PangeaToken>? get tokens {
|
||||
if (_tokens != null) return _tokens!.tokens;
|
||||
|
||||
if (_event == null) {
|
||||
// debugger(when: kDebugMode);
|
||||
// ErrorHandler.logError(
|
||||
// m: '_event and _tokens both null',
|
||||
// s: StackTrace.current,
|
||||
// );
|
||||
return null;
|
||||
}
|
||||
if (_event == null) return null;
|
||||
|
||||
final Set<Event> tokenEvents = _event?.aggregatedEvents(
|
||||
timeline,
|
||||
|
|
@ -93,54 +85,7 @@ class RepresentationEvent {
|
|||
{};
|
||||
|
||||
if (tokenEvents.isEmpty) return null;
|
||||
|
||||
if (tokenEvents.length > 1) {
|
||||
// debugger(when: kDebugMode);
|
||||
Sentry.addBreadcrumb(
|
||||
Breadcrumb(
|
||||
message:
|
||||
'should not have more than one tokenEvent per representation ${_event?.eventId}',
|
||||
data: {
|
||||
"eventID": _event?.eventId,
|
||||
"content": tokenEvents.map((e) => e.content).toString(),
|
||||
"type": tokenEvents.map((e) => e.type).toString(),
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
PangeaMessageTokens? storedTokens;
|
||||
for (final tokenEvent in tokenEvents) {
|
||||
final tokenPangeaEvent =
|
||||
tokenEvent.getPangeaContent<PangeaMessageTokens>();
|
||||
if (PangeaToken.reconstructText(tokenPangeaEvent.tokens) != text) {
|
||||
Sentry.addBreadcrumb(
|
||||
Breadcrumb(
|
||||
message: 'Stored tokens do not match text for representation',
|
||||
data: {
|
||||
'text': text,
|
||||
'tokens': tokenPangeaEvent.tokens,
|
||||
},
|
||||
),
|
||||
);
|
||||
continue;
|
||||
}
|
||||
storedTokens = tokenPangeaEvent;
|
||||
break;
|
||||
}
|
||||
|
||||
if (storedTokens == null) {
|
||||
ErrorHandler.logError(
|
||||
e: "No tokens found for representation",
|
||||
data: {
|
||||
"event": _event?.toJson(),
|
||||
},
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
_tokens = storedTokens;
|
||||
|
||||
_tokens = tokenEvents.last.getPangeaContent<PangeaMessageTokens>();
|
||||
return _tokens?.tokens;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,47 +74,6 @@ class PangeaToken {
|
|||
return morphWithPos;
|
||||
}
|
||||
|
||||
/// reconstructs the text from the tokens
|
||||
/// [tokens] - the tokens to reconstruct
|
||||
/// [debugWalkThrough] - if true, will start the debugger
|
||||
static String reconstructText(
|
||||
List<PangeaToken> tokens, {
|
||||
bool debugWalkThrough = false,
|
||||
int startTokenIndex = 0,
|
||||
int endTokenIndex = -1,
|
||||
}) {
|
||||
debugger(when: kDebugMode && debugWalkThrough);
|
||||
|
||||
if (endTokenIndex == -1) {
|
||||
endTokenIndex = tokens.length;
|
||||
}
|
||||
|
||||
final List<PangeaToken> subset =
|
||||
tokens.sublist(startTokenIndex, endTokenIndex);
|
||||
|
||||
if (subset.isEmpty) {
|
||||
debugger(when: kDebugMode);
|
||||
return '';
|
||||
}
|
||||
|
||||
if (subset.length == 1) {
|
||||
return subset.first.text.content;
|
||||
}
|
||||
|
||||
String reconstruction = "";
|
||||
for (int i = 0; i < subset.length; i++) {
|
||||
int whitespace = subset[i].text.offset -
|
||||
(i > 0 ? (subset[i - 1].text.offset + subset[i - 1].text.length) : 0);
|
||||
|
||||
if (whitespace < 0) {
|
||||
whitespace = 0;
|
||||
}
|
||||
reconstruction += ' ' * whitespace + subset[i].text.content;
|
||||
}
|
||||
|
||||
return reconstruction;
|
||||
}
|
||||
|
||||
static Lemma _getLemmas(String text, dynamic json) {
|
||||
if (json != null) {
|
||||
// July 24, 2024 - we're changing from a list to a single lemma and this is for backwards compatibility
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
|
||||
|
|
@ -511,6 +513,7 @@ String? getGrammarCopy({
|
|||
'tag': key,
|
||||
'context': context,
|
||||
},
|
||||
level: SentryLevel.warning,
|
||||
);
|
||||
return lemma; // Fallback to the lemma itself if no match is found
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'dart:async';
|
|||
import 'package:collection/collection.dart';
|
||||
import 'package:jwt_decode/jwt_decode.dart';
|
||||
import 'package:matrix/matrix.dart' as matrix;
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/analytics_misc/client_analytics_extension.dart';
|
||||
import 'package:fluffychat/pangea/bot/utils/bot_name.dart';
|
||||
|
|
@ -200,6 +201,17 @@ class UserController {
|
|||
updatePublicProfile(
|
||||
level: _pangeaController.getAnalytics.constructListModel.level,
|
||||
);
|
||||
}).catchError((e, s) {
|
||||
ErrorHandler.logError(
|
||||
e: e,
|
||||
s: s,
|
||||
data: {
|
||||
"publicProfile": publicProfile?.toJson(),
|
||||
"userId": client.userID,
|
||||
},
|
||||
level:
|
||||
e is TimeoutException ? SentryLevel.warning : SentryLevel.error,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue