don't have analytics rooms for bot user
This commit is contained in:
parent
e233848e64
commit
d9f272e389
3 changed files with 11 additions and 7 deletions
|
|
@ -233,11 +233,11 @@ class MyAnalyticsController {
|
|||
if (userL2 == null || _client.userID == null) return;
|
||||
|
||||
// analytics room for the user and current target language
|
||||
final Room analyticsRoom = await _client.getMyAnalyticsRoom(userL2!);
|
||||
final Room? analyticsRoom = await _client.getMyAnalyticsRoom(userL2!);
|
||||
|
||||
// get the last time analytics were updated for this room
|
||||
final DateTime? l2AnalyticsLastUpdated =
|
||||
await analyticsRoom.analyticsLastUpdated(
|
||||
await analyticsRoom?.analyticsLastUpdated(
|
||||
PangeaEventTypes.summaryAnalytics,
|
||||
_client.userID!,
|
||||
);
|
||||
|
|
@ -307,7 +307,7 @@ class MyAnalyticsController {
|
|||
// if there's new content to be sent, or if lastUpdated hasn't been
|
||||
// set yet for this room, send the analytics events
|
||||
if (summaryContent.isNotEmpty || l2AnalyticsLastUpdated == null) {
|
||||
await analyticsRoom.sendSummaryAnalyticsEvent(
|
||||
await analyticsRoom?.sendSummaryAnalyticsEvent(
|
||||
summaryContent,
|
||||
);
|
||||
}
|
||||
|
|
@ -347,7 +347,7 @@ class MyAnalyticsController {
|
|||
// );
|
||||
|
||||
if (recentConstructUses.isNotEmpty) {
|
||||
await analyticsRoom.sendConstructsEvent(
|
||||
await analyticsRoom?.sendConstructsEvent(
|
||||
recentConstructUses,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ part of "client_extension.dart";
|
|||
extension AnalyticsClientExtension on Client {
|
||||
/// Get the logged in user's analytics room matching
|
||||
/// a given langCode. If not present, create it.
|
||||
Future<Room> _getMyAnalyticsRoom(String langCode) async {
|
||||
Future<Room?> _getMyAnalyticsRoom(String langCode) async {
|
||||
final Room? analyticsRoom = _analyticsRoomLocal(langCode);
|
||||
if (analyticsRoom != null) return analyticsRoom;
|
||||
return _makeAnalyticsRoom(langCode);
|
||||
|
|
@ -35,7 +35,11 @@ extension AnalyticsClientExtension on Client {
|
|||
///
|
||||
/// If the room does not appear immediately after creation, this method waits for it to appear in sync.
|
||||
/// Returns the created [Room] object.
|
||||
Future<Room> _makeAnalyticsRoom(String langCode) async {
|
||||
Future<Room?> _makeAnalyticsRoom(String langCode) async {
|
||||
if (userID == null || userID == BotName.byEnvironment) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String roomID = await createRoom(
|
||||
creationContent: {
|
||||
'type': PangeaRoomTypes.analytics,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ extension PangeaClient on Client {
|
|||
|
||||
/// Get the logged in user's analytics room matching
|
||||
/// a given langCode. If not present, create it.
|
||||
Future<Room> getMyAnalyticsRoom(String langCode) async =>
|
||||
Future<Room?> getMyAnalyticsRoom(String langCode) async =>
|
||||
await _getMyAnalyticsRoom(langCode);
|
||||
|
||||
/// Get local analytics room for a given langCode and
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue