Browse Source

fix(analytics): report event publishing

Karol Sójko 2 years ago
parent
commit
a6056600eb
1 changed files with 21 additions and 20 deletions
  1. 21 20
      packages/analytics/bin/report.ts

+ 21 - 20
packages/analytics/bin/report.ts

@@ -219,26 +219,27 @@ const requestReport = async (
   }
 
   for (const adminEmail of adminEmails) {
-    const event = domainEventFactory.createEmailRequestedEvent({
-      messageIdentifier: 'VERSION_ADOPTION_REPORT',
-      subject: getSubject(),
-      body: getBody(
-        {
-          activityStatistics: yesterdayActivityStatistics,
-          activityStatisticsOverTime: analyticsOverTime,
-          statisticsOverTime,
-          statisticMeasures,
-          churn: {
-            periodKeys: monthlyPeriodKeys,
-            values: churnRates,
+    await domainEventPublisher.publish(
+      domainEventFactory.createEmailRequestedEvent({
+        messageIdentifier: 'VERSION_ADOPTION_REPORT',
+        subject: getSubject(),
+        body: getBody(
+          {
+            activityStatistics: yesterdayActivityStatistics,
+            activityStatisticsOverTime: analyticsOverTime,
+            statisticsOverTime,
+            statisticMeasures,
+            churn: {
+              periodKeys: monthlyPeriodKeys,
+              values: churnRates,
+            },
           },
-        },
-        timer,
-      ),
-      level: EmailLevel.LEVELS.System,
-      userEmail: adminEmail,
-    })
-    await domainEventPublisher.publish(event)
+          timer,
+        ),
+        level: EmailLevel.LEVELS.System,
+        userEmail: adminEmail,
+      }),
+    )
   }
 }
 
@@ -262,7 +263,7 @@ void container.load().then((container) => {
   )
   const adminEmails = container.get(TYPES.ADMIN_EMAILS) as string[]
 
-  logger.info(`Sending report to following admins: ${adminEmails}`)
+  logger.info('Sending report to following admins: %O', adminEmails)
 
   Promise.resolve(
     requestReport(