From 9f072b7eae25e8c36bb5e8835cfbc0c3d7b6dfa8 Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Wed, 23 Feb 2022 15:15:38 +0000 Subject: [PATCH 01/20] fix(messageHandlerService): store triggered assessment when handling the message --- .../services/config/questionnaire.service.ts | 1 + .../notifications/message-handler.service.ts | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/app/core/services/config/questionnaire.service.ts b/src/app/core/services/config/questionnaire.service.ts index e7c2af4c2..ca69fc856 100644 --- a/src/app/core/services/config/questionnaire.service.ts +++ b/src/app/core/services/config/questionnaire.service.ts @@ -159,6 +159,7 @@ export class QuestionnaireService { } addToAssessments(type, assessment) { + // NOTE: If an assessment does not exist, it is added, otherwise it is updated return this.getAssessments(type).then(assessments => { if (!assessments) assessments = [] const index = assessments.findIndex(a => a.name == assessment.name) diff --git a/src/app/core/services/notifications/message-handler.service.ts b/src/app/core/services/notifications/message-handler.service.ts index fc5c509a9..6131a9047 100644 --- a/src/app/core/services/notifications/message-handler.service.ts +++ b/src/app/core/services/notifications/message-handler.service.ts @@ -27,6 +27,7 @@ export class MessageHandlerService { onMessageReceived(data: Map) { const action = data.get('action') + console.log(data) switch (action) { case MessagingAction.QUESTIONNAIRE_TRIGGER: this.logger.log('A questionnaire was triggered!') @@ -51,12 +52,16 @@ export class MessageHandlerService { return Promise.all([ this.appConfig.getReferenceDate(), this.questionnaire.pullDefinitionForSingleQuestionnaire(questionnaire) - ]).then(([refTimestamp, questionnaire]) => - this.schedule.generateSingleAssessmentTask( - questionnaire, - AssessmentType.SCHEDULED, - refTimestamp - ) - ) + ]).then(([refTimestamp, questionnaire]) => { + return this.questionnaire + .addToAssessments(AssessmentType.SCHEDULED, questionnaire) + .then(() => + this.schedule.generateSingleAssessmentTask( + questionnaire, + AssessmentType.SCHEDULED, + refTimestamp + ) + ) + }) } } From 1fafb59b23e86b921693c3fa7385dea84e2643bc Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Wed, 23 Feb 2022 15:18:18 +0000 Subject: [PATCH 02/20] fix: cleanup --- src/app/core/services/notifications/message-handler.service.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/core/services/notifications/message-handler.service.ts b/src/app/core/services/notifications/message-handler.service.ts index 6131a9047..c227d88b2 100644 --- a/src/app/core/services/notifications/message-handler.service.ts +++ b/src/app/core/services/notifications/message-handler.service.ts @@ -27,7 +27,6 @@ export class MessageHandlerService { onMessageReceived(data: Map) { const action = data.get('action') - console.log(data) switch (action) { case MessagingAction.QUESTIONNAIRE_TRIGGER: this.logger.log('A questionnaire was triggered!') From 42978ed86c37de3c9828c7e8787614087a741021 Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Thu, 24 Feb 2022 22:53:47 +0000 Subject: [PATCH 03/20] fix(questionnaireService): single questionnaire assessment type bug --- src/app/core/services/config/questionnaire.service.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/core/services/config/questionnaire.service.ts b/src/app/core/services/config/questionnaire.service.ts index e7c2af4c2..43bf8e817 100644 --- a/src/app/core/services/config/questionnaire.service.ts +++ b/src/app/core/services/config/questionnaire.service.ts @@ -40,14 +40,13 @@ export class QuestionnaireService { // NOTE: Update assessment list from protocol return Promise.all( this.util.deepCopy(assessments).map(a => { - const type = this.getAssessmentTypeFromAssessment(a) return this.pullDefinitionForSingleQuestionnaire(a) - .then(res => - this.addToAssessments(type, Object.assign(res, { type })) + .then(assessment => + this.addToAssessments(assessment.type, assessment) ) .catch(e => { throw this.logger.error( - 'Failed to update ' + type + ' assessments', + 'Failed to update ' + a.name + ' assessment', e ) }) @@ -64,6 +63,9 @@ export class QuestionnaireService { }) const language = this.localization.getLanguage().value let uri = this.formatQuestionnaireUri(assessment.questionnaire, language) + assessment.type = assessment.type + ? assessment.type + : this.getAssessmentTypeFromAssessment(assessment) return this.githubClient .getContent(uri) .catch(e => { From dc265c63c245dca591840b103c300b19ed1ed115 Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Thu, 24 Feb 2022 22:54:35 +0000 Subject: [PATCH 04/20] fix(questionComponent): scroll down bug --- .../components/question/question.component.ts | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/app/pages/questions/components/question/question.component.ts b/src/app/pages/questions/components/question/question.component.ts index d74269833..582ee9cdd 100755 --- a/src/app/pages/questions/components/question/question.component.ts +++ b/src/app/pages/questions/components/question/question.component.ts @@ -67,8 +67,11 @@ export class QuestionComponent implements OnInit, OnChanges { // Input set where height is set to auto AUTO_HEIGHT_INPUT_SET: Set = new Set([ QuestionType.radio, + QuestionType.checkbox, QuestionType.yesno, - QuestionType.slider + QuestionType.slider, + QuestionType.range, + QuestionType.text ]) SCROLLBAR_VISIBLE_SET: Set = new Set([ @@ -187,13 +190,16 @@ export class QuestionComponent implements OnInit, OnChanges { } onScroll(event) { - if ( - event && - event.target.scrollTop >= - (event.target.scrollHeight - event.target.clientHeight) * 0.1 - ) { - this.showScrollButton = false - } else this.showScrollButton = true + // This will hide/show the scroll arrow depending on the user's scroll event + if (this.showScrollButton) { + if ( + event && + event.target.scrollTop >= + (event.target.scrollHeight - event.target.clientHeight) * 0.1 + ) { + this.showScrollButton = false + } else this.showScrollButton = true + } } scrollDown() { From d3ab85c556e9e0eb76acc1415fa9489afdac9f3a Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Thu, 24 Feb 2022 23:25:51 +0000 Subject: [PATCH 05/20] fix(messageHandlerService): unsubscribe from message listener on destroy --- .../services/notifications/message-handler.service.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/app/core/services/notifications/message-handler.service.ts b/src/app/core/services/notifications/message-handler.service.ts index fc5c509a9..8fce862b4 100644 --- a/src/app/core/services/notifications/message-handler.service.ts +++ b/src/app/core/services/notifications/message-handler.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core' import { FirebaseX } from '@ionic-native/firebase-x/ngx' +import { Subscription } from 'rxjs' import { UsageEventType } from '../../../shared/enums/events' import { Assessment, AssessmentType } from '../../../shared/models/assessment' @@ -12,6 +13,8 @@ import { UsageService } from '../usage/usage.service' @Injectable() export class MessageHandlerService { + messageListener: Subscription = new Subscription() + constructor( public firebase: FirebaseX, public logger: LogService, @@ -20,11 +23,15 @@ export class MessageHandlerService { public usage: UsageService, public appConfig: AppConfigService ) { - this.firebase + this.messageListener = this.firebase .onMessageReceived() .subscribe(data => this.onMessageReceived(new Map(Object.entries(data)))) } + ngOnDestroy() { + this.messageListener.unsubscribe() + } + onMessageReceived(data: Map) { const action = data.get('action') switch (action) { From 9ad2ab0342162ded4f902f3933f71c09d335996c Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Wed, 2 Mar 2022 11:22:36 +0100 Subject: [PATCH 06/20] Ensure that tasks are unique This prevents tasks that arrive via multiple channels, or protocols with overlapping time sets, to generate multiple of the same tasks at the same time. --- src/app/core/services/schedule/schedule.service.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app/core/services/schedule/schedule.service.ts b/src/app/core/services/schedule/schedule.service.ts index e82ebeb0f..ac90934b2 100755 --- a/src/app/core/services/schedule/schedule.service.ts +++ b/src/app/core/services/schedule/schedule.service.ts @@ -100,14 +100,19 @@ export class ScheduleService { }) } - setTasks(type: AssessmentType, tasks): Promise { + setTasks(type: AssessmentType, tasks: Task[]): Promise { + const uniqueTasks = [ + ...new Map( + tasks.map<[string, Task]>(task => [task.timestamp + '-' + task.name, task]) + ).values() + ]; switch (type) { case AssessmentType.SCHEDULED: - return this.setScheduledTasks(tasks) + return this.setScheduledTasks(uniqueTasks) case AssessmentType.ON_DEMAND: - return this.setOnDemandTasks(tasks) + return this.setOnDemandTasks(uniqueTasks) case AssessmentType.CLINICAL: - return this.setClinicalTasks(tasks) + return this.setClinicalTasks(uniqueTasks) } } From 06ccdabcbda58eb9cab54d6ae21e790f41b70968 Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Thu, 3 Mar 2022 15:48:48 +0000 Subject: [PATCH 07/20] fix: publishing script and targetsdk --- config.xml | 1 + publishing_script.sh | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config.xml b/config.xml index 295059609..029e12833 100755 --- a/config.xml +++ b/config.xml @@ -21,6 +21,7 @@ + diff --git a/publishing_script.sh b/publishing_script.sh index fe2458989..aa099d67c 100755 --- a/publishing_script.sh +++ b/publishing_script.sh @@ -1,5 +1,6 @@ ionic cordova build --release android -jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ~/Downloads/radar-armt-release-key.keystore platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk alias_name +~/Library/Android/sdk/build-tools/28.0.3/zipalign -v 4 platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk ~/Downloads/radar-armt-app-zipaligned.apk + +~/Library/Android/sdk/build-tools/28.0.3/apksigner sign -v --out ~/Downloads/radar-armt-app-$1.apk --ks ~/Downloads/radar-armt-release-key.keystore --ks-key-alias alias_name ~/Downloads/radar-armt-app-zipaligned.apk - ~/Library/Android/sdk/build-tools/28.0.3/zipalign -v 4 platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk ~/Downloads/radar-armt-app-$1.apk From fc6b4d7986a45ee86ffe43eb3840e6da6b78fb28 Mon Sep 17 00:00:00 2001 From: Pauline Conde Date: Thu, 3 Mar 2022 21:41:04 +0000 Subject: [PATCH 08/20] chore: bump version --- config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.xml b/config.xml index 029e12833..3cbc6ec8e 100755 --- a/config.xml +++ b/config.xml @@ -1,5 +1,5 @@ - + RADAR Questionnaire An application that collects active data for research. RADAR-Base From a230e891b970655cf061ddc4cedf15ac48c22509 Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Mon, 21 Mar 2022 16:15:17 +0000 Subject: [PATCH 09/20] fix(questionnaireService): support different directory structures in questionnaire repo --- .../services/config/questionnaire.service.ts | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/app/core/services/config/questionnaire.service.ts b/src/app/core/services/config/questionnaire.service.ts index e7c2af4c2..179b3f591 100644 --- a/src/app/core/services/config/questionnaire.service.ts +++ b/src/app/core/services/config/questionnaire.service.ts @@ -87,17 +87,22 @@ export class QuestionnaireService { const organization = urlParts[1], repo = urlParts[2], branch = urlParts[3], - directory = urlParts[4] + '/' + questionnaireName + directory = urlParts.slice(4).join('/') const suffix = lang.length ? `_${lang}` : '' const fileName = questionnaireName + metadata.type + suffix + metadata.format - return urljoin( - GIT_API_URI, - organization, - repo, - 'contents', - directory, - fileName + return ( + urljoin( + GIT_API_URI, + organization, + repo, + 'contents', + directory, + questionnaireName, + fileName + ) + + '?ref=' + + branch ) } From 2e1ba6517c6f9ce442c6f3e8ff42bc5668320e4d Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Wed, 23 Mar 2022 02:09:29 +0000 Subject: [PATCH 10/20] fix(schedule): make schedule generation more readable --- .../services/config/app-config.service.ts | 4 +- .../schedule/schedule-generator.service.ts | 84 ++++++++++--------- .../services/schedule/schedule.service.ts | 12 +-- src/app/pages/home/services/tasks.service.ts | 7 +- src/app/shared/utilities/time.ts | 8 +- 5 files changed, 66 insertions(+), 49 deletions(-) diff --git a/src/app/core/services/config/app-config.service.ts b/src/app/core/services/config/app-config.service.ts index 877e60518..8b8257a42 100644 --- a/src/app/core/services/config/app-config.service.ts +++ b/src/app/core/services/config/app-config.service.ts @@ -8,7 +8,7 @@ import { DefaultSettingsWeeklyReport } from '../../../../assets/data/defaultConfig' import { StorageKeys } from '../../../shared/enums/storage' -import { setDateTimeToMidnight } from '../../../shared/utilities/time' +import { setDateTimeToMidnightEpoch } from '../../../shared/utilities/time' import { StorageService } from '../storage/storage.service' @Injectable() @@ -103,7 +103,7 @@ export class AppConfigService { setReferenceDate(enrolmentDate) { return this.storage.set( this.CONFIG_STORE.REFERENCEDATE, - setDateTimeToMidnight(new Date(enrolmentDate)).getTime() + setDateTimeToMidnightEpoch(new Date(enrolmentDate)) ) } diff --git a/src/app/core/services/schedule/schedule-generator.service.ts b/src/app/core/services/schedule/schedule-generator.service.ts index 6dbfeadda..8e26ff574 100644 --- a/src/app/core/services/schedule/schedule-generator.service.ts +++ b/src/app/core/services/schedule/schedule-generator.service.ts @@ -15,8 +15,8 @@ import { Task } from '../../../shared/models/task' import { compareTasks } from '../../../shared/utilities/compare-tasks' import { advanceRepeat, - getMilliseconds, setDateTimeToMidnight, + setDateTimeToMidnightEpoch, timeIntervalToMillis } from '../../../shared/utilities/time' import { Utility } from '../../../shared/utilities/util' @@ -75,8 +75,14 @@ export class ScheduleGeneratorService { }) } - getRepeatProtocol(protocol, type) { - let repeatP, repeatQ + getProtocolValues(protocol, type, refTimestamp) { + // repeatProtocol/repeatP - This repeats the protocol until the end of the year coverage (default: 3 years). + // - This specifices the reference timestamp from which to generate the individual tasks. + // repeatQuestionnaire/repeatQ - The child protocol which specifies the individual task time based on the reference timestamp generated by the repeatProtocol. + // refTime - The reference timestamp from which to generate the schedule (default: midnight of enrolment date). + // endTime - The timestamp until which to generate the schedule. + let repeatP, repeatQ, completionWindow, refTime, endTime + switch (type) { case AssessmentType.CLINICAL: repeatQ = protocol.clinicalProtocol.repeatAfterClinicVisit @@ -85,7 +91,16 @@ export class ScheduleGeneratorService { repeatP = protocol.repeatProtocol repeatQ = protocol.repeatQuestionnaire } - return { repeatP, repeatQ } + completionWindow = protocol.completionWindow + ? timeIntervalToMillis(protocol.completionWindow) + : DefaultTaskCompletionWindow + refTime = this.getReferenceTimestamp(protocol, refTimestamp) + endTime = advanceRepeat(refTime, { + unit: 'year', + amount: this.getScheduleYearCoverage() + }) + + return { repeatP, repeatQ, completionWindow, refTime, endTime } } getReferenceTimestamp(protocol, refTimestamp) { @@ -109,39 +124,35 @@ export class ScheduleGeneratorService { refTimestamp, type: AssessmentType ): Task[] { - const protocol = assessment.protocol - const scheduleYearCoverage = this.getScheduleYearCoverage() - const { repeatP, repeatQ } = this.getRepeatProtocol(protocol, type) + // This generates an array of tasks from a single assessment and protocol. + const tasks: Task[] = [] + const today = setDateTimeToMidnightEpoch(new Date()) + let { + repeatP, + repeatQ, + completionWindow, + refTime, + endTime + } = this.getProtocolValues(assessment.protocol, type, refTimestamp) - let iterTime = this.getReferenceTimestamp(protocol, refTimestamp) - const endTime = iterTime + getMilliseconds({ years: scheduleYearCoverage }) - const completionWindow = ScheduleGeneratorService.computeCompletionWindow( - assessment - ) - const today = setDateTimeToMidnight(new Date()) - const tmpScheduleAll: Task[] = [] - while (iterTime <= endTime) { + while (refTime <= endTime) { repeatQ.unitsFromZero.map(amount => { - const taskTime = advanceRepeat(iterTime, { + const taskTime = advanceRepeat(refTime, { unit: repeatQ.unit, amount: amount }) - if (taskTime + completionWindow > today.getTime()) { - const idx = indexOffset + tmpScheduleAll.length - const task = this.taskBuilder( - idx, - assessment, - taskTime, - completionWindow - ) - tmpScheduleAll.push(task) - } + const task = this.taskBuilder( + indexOffset + tasks.length, + assessment, + taskTime, + completionWindow + ) + tasks.push(task) }) - iterTime = setDateTimeToMidnight(new Date(iterTime)).getTime() if (!repeatP) break - iterTime = advanceRepeat(iterTime, repeatP) + refTime = advanceRepeat(refTime, repeatP) } - return tmpScheduleAll + return tasks.filter(t => t.timestamp + t.completionWindow > today) } taskBuilder( @@ -186,10 +197,11 @@ export class ScheduleGeneratorService { const completed = [] if (completedTasks && completedTasks.length > 0) { // NOTE: If utcOffsetPrev exists, timezone has changed - const currentMidnight = new Date().setHours(0, 0, 0, 0) - const prevMidnight = - new Date().setUTCHours(0, 0, 0, 0) + - getMilliseconds({ minutes: utcOffsetPrev }) + const currentMidnight = setDateTimeToMidnightEpoch(new Date()) + const prevMidnight = advanceRepeat(currentMidnight, { + unit: 'min', + amount: utcOffsetPrev + }) completedTasks.map(d => { const task = schedule.find( s => @@ -228,10 +240,4 @@ export class ScheduleGeneratorService { throw this.logger.error('Failed to fetch Firebase config', e) }) } - - static computeCompletionWindow(assessment: Assessment): number { - if (assessment.protocol.completionWindow) - return timeIntervalToMillis(assessment.protocol.completionWindow) - else return DefaultTaskCompletionWindow - } } diff --git a/src/app/core/services/schedule/schedule.service.ts b/src/app/core/services/schedule/schedule.service.ts index ac90934b2..6bb2ff6a6 100755 --- a/src/app/core/services/schedule/schedule.service.ts +++ b/src/app/core/services/schedule/schedule.service.ts @@ -8,7 +8,7 @@ import { Task } from '../../../shared/models/task' import { compareTasks } from '../../../shared/utilities/compare-tasks' import { getMilliseconds, - setDateTimeToMidnight + setDateTimeToMidnightEpoch } from '../../../shared/utilities/time' import { LogService } from '../misc/log.service' import { StorageService } from '../storage/storage.service' @@ -59,7 +59,7 @@ export class ScheduleService { getTasksForDate(date: Date, type: AssessmentType) { return this.getTasks(type).then(schedule => { - const startTime = setDateTimeToMidnight(date).getTime() + const startTime = setDateTimeToMidnightEpoch(date) const endTime = startTime + getMilliseconds({ days: 1 }) return schedule ? schedule.filter(d => { @@ -103,9 +103,12 @@ export class ScheduleService { setTasks(type: AssessmentType, tasks: Task[]): Promise { const uniqueTasks = [ ...new Map( - tasks.map<[string, Task]>(task => [task.timestamp + '-' + task.name, task]) + tasks.map<[string, Task]>(task => [ + task.timestamp + '-' + task.name, + task + ]) ).values() - ]; + ] switch (type) { case AssessmentType.SCHEDULED: return this.setScheduledTasks(uniqueTasks) @@ -160,7 +163,6 @@ export class ScheduleService { assessmentType, referenceDate: number ) { - console.log(assessment) return this.getTasks(assessmentType).then((tasks: Task[]) => { const schedule = this.schedule.buildTasksForSingleAssessment( assessment, diff --git a/src/app/pages/home/services/tasks.service.ts b/src/app/pages/home/services/tasks.service.ts index 9fb0928a9..5e99d6b24 100644 --- a/src/app/pages/home/services/tasks.service.ts +++ b/src/app/pages/home/services/tasks.service.ts @@ -12,7 +12,10 @@ import { ScheduleService } from '../../../core/services/schedule/schedule.servic import { ConfigKeys } from '../../../shared/enums/config' import { AssessmentType } from '../../../shared/models/assessment' import { Task, TasksProgress } from '../../../shared/models/task' -import { setDateTimeToMidnight } from '../../../shared/utilities/time' +import { + setDateTimeToMidnight, + setDateTimeToMidnightEpoch +} from '../../../shared/utilities/time' @Injectable() export class TasksService { @@ -62,7 +65,7 @@ export class TasksService { return this.getTasksOfToday().then(tasks => { const sortedTasks = new Map() tasks.forEach(t => { - const midnight = setDateTimeToMidnight(new Date(t.timestamp)).getTime() + const midnight = setDateTimeToMidnightEpoch(new Date(t.timestamp)) if (sortedTasks.has(midnight)) sortedTasks.get(midnight).push(t) else sortedTasks.set(midnight, [t]) }) diff --git a/src/app/shared/utilities/time.ts b/src/app/shared/utilities/time.ts index 7e687e64f..a15b6a74f 100644 --- a/src/app/shared/utilities/time.ts +++ b/src/app/shared/utilities/time.ts @@ -100,10 +100,16 @@ export function timeIntervalToMillis(interval: TimeInterval): number { } export function setDateTimeToMidnight(date: Date): Date { - return new Date(new Date(date).setHours(0, 0, 0, 0)) + return new Date(setDateTimeToMidnightEpoch(date)) +} + +export function setDateTimeToMidnightEpoch(date: Date): number { + return new Date(date).setHours(0, 0, 0, 0) } export function advanceRepeat(timestamp: number, interval: TimeInterval) { + // This generates a new timestamp from a timestamp plus a specified offset/interval. + // This also checks at the end that if hour was midnight then it should stay midnight (accounting for timezone) const date = new Date(timestamp) const returnDate = new Date(timestamp) switch (interval.unit) { From ebbb71b1ba11cbaf482665e9fd1cc08b67368912 Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Wed, 23 Mar 2022 19:35:05 +0000 Subject: [PATCH 11/20] fix(scheduleGeneration): Add support for different referenceTimestamp formats --- .../schedule/schedule-generator.service.ts | 42 ++++++++++++------- src/app/shared/models/protocol.ts | 14 ++++++- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/app/core/services/schedule/schedule-generator.service.ts b/src/app/core/services/schedule/schedule-generator.service.ts index 8e26ff574..9914699b5 100644 --- a/src/app/core/services/schedule/schedule-generator.service.ts +++ b/src/app/core/services/schedule/schedule-generator.service.ts @@ -11,6 +11,10 @@ import { AssessmentType, SchedulerResult } from '../../../shared/models/assessment' +import { + ProtocolReferenceTimestamp, + ReferenceTimestampFormat +} from '../../../shared/models/protocol' import { Task } from '../../../shared/models/task' import { compareTasks } from '../../../shared/utilities/compare-tasks' import { @@ -94,7 +98,10 @@ export class ScheduleGeneratorService { completionWindow = protocol.completionWindow ? timeIntervalToMillis(protocol.completionWindow) : DefaultTaskCompletionWindow - refTime = this.getReferenceTimestamp(protocol, refTimestamp) + refTime = this.getReferenceTimestamp( + protocol.referenceTimestamp, + refTimestamp + ) endTime = advanceRepeat(refTime, { unit: 'year', amount: this.getScheduleYearCoverage() @@ -103,21 +110,6 @@ export class ScheduleGeneratorService { return { repeatP, repeatQ, completionWindow, refTime, endTime } } - getReferenceTimestamp(protocol, refTimestamp) { - // NOTE: Get initial timestamp to start schedule generation from - // If ref timestamp is specified in the protocol, gets refTimestamp (in the timezone of device) - return protocol.referenceTimestamp - ? setDateTimeToMidnight( - this.localization - .moment( - protocol.referenceTimestamp, - this.REFERENCE_TIMESTAMP_FORMAT - ) - .toDate() - ).getTime() - : refTimestamp - } - buildTasksForSingleAssessment( assessment: Assessment, indexOffset: number, @@ -221,6 +213,24 @@ export class ScheduleGeneratorService { return { schedule, completed } } + getReferenceTimestamp(refTimestamp, defaultRefTimestamp) { + // NOTE: Get initial timestamp to start schedule generation from + switch (true) { + case refTimestamp.timestamp && refTimestamp.format: + switch (refTimestamp.format) { + case ReferenceTimestampFormat.DATE: + case ReferenceTimestampFormat.DATETIME: + return this.localization.moment(refTimestamp) + case ReferenceTimestampFormat.NOW: + return Date.now() + case ReferenceTimestampFormat.TODAY: + return setDateTimeToMidnightEpoch(new Date()) + } + default: + return defaultRefTimestamp + } + } + getScheduleYearCoverage() { if (this.SCHEDULE_YEAR_COVERAGE > 0) return this.SCHEDULE_YEAR_COVERAGE else return DefaultScheduleYearCoverage diff --git a/src/app/shared/models/protocol.ts b/src/app/shared/models/protocol.ts index 9d45b9e57..29ba7d1a1 100755 --- a/src/app/shared/models/protocol.ts +++ b/src/app/shared/models/protocol.ts @@ -13,7 +13,19 @@ export interface Protocol { clinicalProtocol?: ClinicalProtocol onDemandProtocol? completionWindow?: TimeInterval - referenceTimestamp?: string + referenceTimestamp?: string | ProtocolReferenceTimestamp +} + +export interface ProtocolReferenceTimestamp { + timestamp: string + format: ReferenceTimestampFormat +} + +export enum ReferenceTimestampFormat { + DATE = 'date', + DATETIME = 'datetime', + TODAY = 'today', + NOW = 'now' } export interface ProtocolMetaData { From b27d9f31925430d4fcdc53ce92e6f12032a7f2c1 Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Wed, 23 Mar 2022 23:54:20 +0000 Subject: [PATCH 12/20] fix(scheduleGenerator): use moment to format reference timestamp --- .../schedule/schedule-generator.service.ts | 39 +++++++++---------- .../services/schedule/schedule.service.ts | 7 ++-- src/app/shared/models/protocol.ts | 5 ++- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/src/app/core/services/schedule/schedule-generator.service.ts b/src/app/core/services/schedule/schedule-generator.service.ts index 9914699b5..d93fafcdf 100644 --- a/src/app/core/services/schedule/schedule-generator.service.ts +++ b/src/app/core/services/schedule/schedule-generator.service.ts @@ -11,10 +11,7 @@ import { AssessmentType, SchedulerResult } from '../../../shared/models/assessment' -import { - ProtocolReferenceTimestamp, - ReferenceTimestampFormat -} from '../../../shared/models/protocol' +import { ReferenceTimestampKey } from '../../../shared/models/protocol' import { Task } from '../../../shared/models/task' import { compareTasks } from '../../../shared/utilities/compare-tasks' import { @@ -79,7 +76,7 @@ export class ScheduleGeneratorService { }) } - getProtocolValues(protocol, type, refTimestamp) { + getProtocolValues(protocol, type, defaultRefTime) { // repeatProtocol/repeatP - This repeats the protocol until the end of the year coverage (default: 3 years). // - This specifices the reference timestamp from which to generate the individual tasks. // repeatQuestionnaire/repeatQ - The child protocol which specifies the individual task time based on the reference timestamp generated by the repeatProtocol. @@ -100,13 +97,12 @@ export class ScheduleGeneratorService { : DefaultTaskCompletionWindow refTime = this.getReferenceTimestamp( protocol.referenceTimestamp, - refTimestamp + defaultRefTime ) endTime = advanceRepeat(refTime, { unit: 'year', amount: this.getScheduleYearCoverage() }) - return { repeatP, repeatQ, completionWindow, refTime, endTime } } @@ -215,20 +211,21 @@ export class ScheduleGeneratorService { getReferenceTimestamp(refTimestamp, defaultRefTimestamp) { // NOTE: Get initial timestamp to start schedule generation from - switch (true) { - case refTimestamp.timestamp && refTimestamp.format: - switch (refTimestamp.format) { - case ReferenceTimestampFormat.DATE: - case ReferenceTimestampFormat.DATETIME: - return this.localization.moment(refTimestamp) - case ReferenceTimestampFormat.NOW: - return Date.now() - case ReferenceTimestampFormat.TODAY: - return setDateTimeToMidnightEpoch(new Date()) - } - default: - return defaultRefTimestamp - } + if (refTimestamp && refTimestamp.format) { + switch (refTimestamp.format) { + case ReferenceTimestampKey.DATE: + case ReferenceTimestampKey.DATETIME: + case ReferenceTimestampKey.DATETIMEUTC: + return this.localization + .moment(refTimestamp.timestamp) + .toDate() + .getTime() + case ReferenceTimestampKey.NOW: + return Date.now() + case ReferenceTimestampKey.TODAY: + return setDateTimeToMidnightEpoch(new Date()) + } + } else return defaultRefTimestamp } getScheduleYearCoverage() { diff --git a/src/app/core/services/schedule/schedule.service.ts b/src/app/core/services/schedule/schedule.service.ts index 6bb2ff6a6..efb18e83e 100755 --- a/src/app/core/services/schedule/schedule.service.ts +++ b/src/app/core/services/schedule/schedule.service.ts @@ -139,17 +139,16 @@ export class ScheduleService { return this.storage.push(this.SCHEDULE_STORE.SCHEDULE_TASKS_COMPLETED, task) } - generateSchedule(referenceDate, utcOffsetPrev) { - this.logger.log('Updating schedule..', referenceDate) + generateSchedule(referenceTimestamp, utcOffsetPrev) { + this.logger.log('Updating schedule..', referenceTimestamp) return this.getCompletedTasks() .then(completedTasks => { return this.schedule.runScheduler( - referenceDate, + referenceTimestamp, completedTasks, utcOffsetPrev ) }) - .catch(e => e) .then(res => Promise.all([ this.setTasks(AssessmentType.SCHEDULED, res.schedule), diff --git a/src/app/shared/models/protocol.ts b/src/app/shared/models/protocol.ts index 29ba7d1a1..dd55858c1 100755 --- a/src/app/shared/models/protocol.ts +++ b/src/app/shared/models/protocol.ts @@ -18,12 +18,13 @@ export interface Protocol { export interface ProtocolReferenceTimestamp { timestamp: string - format: ReferenceTimestampFormat + format: ReferenceTimestampKey } -export enum ReferenceTimestampFormat { +export enum ReferenceTimestampKey { DATE = 'date', DATETIME = 'datetime', + DATETIMEUTC = 'datetimeutc', TODAY = 'today', NOW = 'now' } From c4e7d4ff1c2f47e1f50aa11d0f029b5a0507d81c Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Thu, 24 Mar 2022 13:11:35 +0000 Subject: [PATCH 13/20] fix: lint errors --- .../notifications/message-handler.service.ts | 18 ++++++++++-------- .../schedule/schedule-generator.service.ts | 6 ++++-- .../containers/questions-page.component.ts | 2 +- src/assets/data/defaultConfig.ts | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/app/core/services/notifications/message-handler.service.ts b/src/app/core/services/notifications/message-handler.service.ts index bfcbca55f..fa9c538e0 100644 --- a/src/app/core/services/notifications/message-handler.service.ts +++ b/src/app/core/services/notifications/message-handler.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core' +import { Injectable, OnDestroy } from '@angular/core' import { FirebaseX } from '@ionic-native/firebase-x/ngx' import { Subscription } from 'rxjs' @@ -12,14 +12,14 @@ import { ScheduleService } from '../schedule/schedule.service' import { UsageService } from '../usage/usage.service' @Injectable() -export class MessageHandlerService { +export class MessageHandlerService implements OnDestroy { messageListener: Subscription = new Subscription() constructor( public firebase: FirebaseX, public logger: LogService, public schedule: ScheduleService, - public questionnaire: QuestionnaireService, + public questionnaireService: QuestionnaireService, public usage: UsageService, public appConfig: AppConfigService ) { @@ -57,13 +57,15 @@ export class MessageHandlerService { triggerQuestionnaire(questionnaire: Assessment) { return Promise.all([ this.appConfig.getReferenceDate(), - this.questionnaire.pullDefinitionForSingleQuestionnaire(questionnaire) - ]).then(([refTimestamp, questionnaire]) => { - return this.questionnaire - .addToAssessments(AssessmentType.SCHEDULED, questionnaire) + this.questionnaireService.pullDefinitionForSingleQuestionnaire( + questionnaire + ) + ]).then(([refTimestamp, questionnaireWithDef]) => { + return this.questionnaireService + .addToAssessments(AssessmentType.SCHEDULED, questionnaireWithDef) .then(() => this.schedule.generateSingleAssessmentTask( - questionnaire, + questionnaireWithDef, AssessmentType.SCHEDULED, refTimestamp ) diff --git a/src/app/core/services/schedule/schedule-generator.service.ts b/src/app/core/services/schedule/schedule-generator.service.ts index d93fafcdf..8f74ec455 100644 --- a/src/app/core/services/schedule/schedule-generator.service.ts +++ b/src/app/core/services/schedule/schedule-generator.service.ts @@ -1,3 +1,4 @@ +// tslint:disable: prefer-const import { Injectable } from '@angular/core' import { @@ -78,8 +79,9 @@ export class ScheduleGeneratorService { getProtocolValues(protocol, type, defaultRefTime) { // repeatProtocol/repeatP - This repeats the protocol until the end of the year coverage (default: 3 years). - // - This specifices the reference timestamp from which to generate the individual tasks. - // repeatQuestionnaire/repeatQ - The child protocol which specifies the individual task time based on the reference timestamp generated by the repeatProtocol. + // - This specifices the reference timestamp from which to generate the individual tasks. + // repeatQuestionnaire/repeatQ - The child protocol which specifies the individual task time based on the + // reference timestamp generated by the repeatProtocol. // refTime - The reference timestamp from which to generate the schedule (default: midnight of enrolment date). // endTime - The timestamp until which to generate the schedule. let repeatP, repeatQ, completionWindow, refTime, endTime diff --git a/src/app/pages/questions/containers/questions-page.component.ts b/src/app/pages/questions/containers/questions-page.component.ts index c40ce1a78..26de37296 100644 --- a/src/app/pages/questions/containers/questions-page.component.ts +++ b/src/app/pages/questions/containers/questions-page.component.ts @@ -186,7 +186,7 @@ export class QuestionsPageComponent implements OnInit { } getCurrentQuestions() { - // NOTE: For non-matrix type this will only return one question (array) but for matrix types this can be more than one + // For non-matrix type this will only return one question (array) but for matrix types, this can be more than one const key = Array.from(this.groupedQuestions.keys())[ this.currentQuestionGroupId ] diff --git a/src/assets/data/defaultConfig.ts b/src/assets/data/defaultConfig.ts index a2abe5e59..bcf67b33b 100755 --- a/src/assets/data/defaultConfig.ts +++ b/src/assets/data/defaultConfig.ts @@ -1,3 +1,4 @@ +// tslint:disable:max-line-length import { LocKeys } from '../../app/shared/enums/localisations' import { AssessmentType } from '../../app/shared/models/assessment' import { QuestionType } from '../../app/shared/models/question' @@ -163,7 +164,6 @@ export const DefaultSchemaGithubRepo = 'RADAR-Base/RADAR-Schemas' export const DefaultSchemaBranch = 'master' // *The path to the schema specifications file -// tslint:disable-next-line: max-line-length export const DefaultSchemaSpecPath = `specifications/active/${DefaultSourcePrefix}-${DefaultSourceTypeRegistrationBody.sourceTypeCatalogVersion}.yml?ref=${DefaultSchemaBranch}` // *The URL of the Kafka topic specification (REMOTE CONFIG KEY: `kafka_specification_url`) From 50010510689ea27fe609b547234456b793bced82 Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Mon, 4 Apr 2022 18:11:31 +0800 Subject: [PATCH 14/20] fix: reference timestamp --- src/app/core/services/schedule/schedule-generator.service.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/core/services/schedule/schedule-generator.service.ts b/src/app/core/services/schedule/schedule-generator.service.ts index 8f74ec455..61dcfa7fb 100644 --- a/src/app/core/services/schedule/schedule-generator.service.ts +++ b/src/app/core/services/schedule/schedule-generator.service.ts @@ -227,6 +227,11 @@ export class ScheduleGeneratorService { case ReferenceTimestampKey.TODAY: return setDateTimeToMidnightEpoch(new Date()) } + } else if (refTimestamp) { + return this.localization + .moment(refTimestamp, this.REFERENCE_TIMESTAMP_FORMAT) + .toDate() + .getTime() } else return defaultRefTimestamp } From 95b206eb63f7ecc6bb7273648712aaeca939149d Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Mon, 4 Apr 2022 18:32:36 +0800 Subject: [PATCH 15/20] fix: add comments --- src/app/core/services/schedule/schedule-generator.service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/core/services/schedule/schedule-generator.service.ts b/src/app/core/services/schedule/schedule-generator.service.ts index 61dcfa7fb..9ef124884 100644 --- a/src/app/core/services/schedule/schedule-generator.service.ts +++ b/src/app/core/services/schedule/schedule-generator.service.ts @@ -228,6 +228,7 @@ export class ScheduleGeneratorService { return setDateTimeToMidnightEpoch(new Date()) } } else if (refTimestamp) { + // Keeps support for previous configuration return this.localization .moment(refTimestamp, this.REFERENCE_TIMESTAMP_FORMAT) .toDate() From 2cc6f75b7e2c2774074dc9fbd459ec984f8691fd Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Tue, 5 Apr 2022 18:51:00 +0800 Subject: [PATCH 16/20] fix: rename ReferenceTimestampFormat enum --- .../services/schedule/schedule-generator.service.ts | 12 ++++++------ src/app/shared/models/protocol.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/core/services/schedule/schedule-generator.service.ts b/src/app/core/services/schedule/schedule-generator.service.ts index 9ef124884..3d0295fda 100644 --- a/src/app/core/services/schedule/schedule-generator.service.ts +++ b/src/app/core/services/schedule/schedule-generator.service.ts @@ -12,7 +12,7 @@ import { AssessmentType, SchedulerResult } from '../../../shared/models/assessment' -import { ReferenceTimestampKey } from '../../../shared/models/protocol' +import { ReferenceTimestampFormat } from '../../../shared/models/protocol' import { Task } from '../../../shared/models/task' import { compareTasks } from '../../../shared/utilities/compare-tasks' import { @@ -215,16 +215,16 @@ export class ScheduleGeneratorService { // NOTE: Get initial timestamp to start schedule generation from if (refTimestamp && refTimestamp.format) { switch (refTimestamp.format) { - case ReferenceTimestampKey.DATE: - case ReferenceTimestampKey.DATETIME: - case ReferenceTimestampKey.DATETIMEUTC: + case ReferenceTimestampFormat.DATE: + case ReferenceTimestampFormat.DATETIME: + case ReferenceTimestampFormat.DATETIMEUTC: return this.localization .moment(refTimestamp.timestamp) .toDate() .getTime() - case ReferenceTimestampKey.NOW: + case ReferenceTimestampFormat.NOW: return Date.now() - case ReferenceTimestampKey.TODAY: + case ReferenceTimestampFormat.TODAY: return setDateTimeToMidnightEpoch(new Date()) } } else if (refTimestamp) { diff --git a/src/app/shared/models/protocol.ts b/src/app/shared/models/protocol.ts index dd55858c1..98479d7cd 100755 --- a/src/app/shared/models/protocol.ts +++ b/src/app/shared/models/protocol.ts @@ -18,10 +18,10 @@ export interface Protocol { export interface ProtocolReferenceTimestamp { timestamp: string - format: ReferenceTimestampKey + format: ReferenceTimestampFormat } -export enum ReferenceTimestampKey { +export enum ReferenceTimestampFormat { DATE = 'date', DATETIME = 'datetime', DATETIMEUTC = 'datetimeutc', From 75d1d30a8c26cf08d2d73a95ef2575f66031f7a4 Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Wed, 13 Apr 2022 23:11:22 +0800 Subject: [PATCH 17/20] fix(scheduleGenerator): keep previous refTimestamp configuration behaviour the same for backwards compatibility --- .../core/services/schedule/schedule-generator.service.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app/core/services/schedule/schedule-generator.service.ts b/src/app/core/services/schedule/schedule-generator.service.ts index 3d0295fda..d68647b64 100644 --- a/src/app/core/services/schedule/schedule-generator.service.ts +++ b/src/app/core/services/schedule/schedule-generator.service.ts @@ -229,10 +229,11 @@ export class ScheduleGeneratorService { } } else if (refTimestamp) { // Keeps support for previous configuration - return this.localization - .moment(refTimestamp, this.REFERENCE_TIMESTAMP_FORMAT) - .toDate() - .getTime() + return setDateTimeToMidnightEpoch( + this.localization + .moment(refTimestamp, this.REFERENCE_TIMESTAMP_FORMAT) + .toDate() + ) } else return defaultRefTimestamp } From a886d2d1894fff144062d80c2453377e68d34871 Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Thu, 21 Apr 2022 19:16:00 +0800 Subject: [PATCH 18/20] fix: add more questionnaire trigger events for debugging purposes --- .../notifications/message-handler.service.ts | 35 +++++++++++++------ src/app/shared/enums/events.ts | 4 +++ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/app/core/services/notifications/message-handler.service.ts b/src/app/core/services/notifications/message-handler.service.ts index fa9c538e0..6e5194521 100644 --- a/src/app/core/services/notifications/message-handler.service.ts +++ b/src/app/core/services/notifications/message-handler.service.ts @@ -23,9 +23,10 @@ export class MessageHandlerService implements OnDestroy { public usage: UsageService, public appConfig: AppConfigService ) { - this.messageListener = this.firebase - .onMessageReceived() - .subscribe(data => this.onMessageReceived(new Map(Object.entries(data)))) + this.messageListener = this.firebase.onMessageReceived().subscribe(data => { + this.usage.sendGeneralEvent(UsageEventType.MESSAGE_RECEIVED) + return this.onMessageReceived(new Map(Object.entries(data))) + }) } ngOnDestroy() { @@ -36,19 +37,30 @@ export class MessageHandlerService implements OnDestroy { const action = data.get('action') switch (action) { case MessagingAction.QUESTIONNAIRE_TRIGGER: + this.usage.sendGeneralEvent( + UsageEventType.QUESTIONNAIRE_TRIGGER_MESSAGE_RECEIVED + ) this.logger.log('A questionnaire was triggered!') const questionnaire = JSON.parse(data.get('questionnaire')) const metadata = new Map( Object.entries(JSON.parse(data.get('metadata'))) ) - return this.triggerQuestionnaire(questionnaire).then(() => - this.usage.sendQuestionnaireEvent( - UsageEventType.QUESTIONNAIRE_TRIGGERED, - questionnaire.name, - Date.now(), - metadata + return this.triggerQuestionnaire(questionnaire) + .then(() => + this.usage.sendQuestionnaireEvent( + UsageEventType.QUESTIONNAIRE_TRIGGERED, + questionnaire.name, + Date.now(), + metadata + ) + ) + .catch(e => + this.usage.sendGeneralEvent( + UsageEventType.QUESTIONNAIRE_TRIGGER_ERROR, + false, + e.message + ) ) - ) default: this.logger.log('Cannot process message.') } @@ -61,6 +73,9 @@ export class MessageHandlerService implements OnDestroy { questionnaire ) ]).then(([refTimestamp, questionnaireWithDef]) => { + this.usage.sendGeneralEvent( + UsageEventType.QUESTIONNAIRE_TRIGGER_DEFINITION_PULL_SUCCESS + ) return this.questionnaireService .addToAssessments(AssessmentType.SCHEDULED, questionnaireWithDef) .then(() => diff --git a/src/app/shared/enums/events.ts b/src/app/shared/enums/events.ts index 2df59b68e..ccbd30d02 100644 --- a/src/app/shared/enums/events.ts +++ b/src/app/shared/enums/events.ts @@ -5,6 +5,10 @@ export enum UsageEventType { QUESTIONNAIRE_FINISHED = 'questionnaire_finished', QUESTIONNAIRE_CANCELLED = 'questionnaire_cancelled', QUESTIONNAIRE_TRIGGERED = 'questionnaire_triggered', + MESSAGE_RECEIVED = 'message_received', + QUESTIONNAIRE_TRIGGER_MESSAGE_RECEIVED = 'questionnaire_trigger_message_received', + QUESTIONNAIRE_TRIGGER_DEFINITION_PULL_SUCCESS = 'questionnaire_trigger_definition_pull_success', + QUESTIONNAIRE_TRIGGER_ERROR = 'questionnaire_trigger_error', QR_SCANNED = 'qr_code_scanned', CLICK = 'click', RESUMED = 'resumed', From 6a7c20b00539b935542bd0c18b5a0be055831778 Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Thu, 21 Apr 2022 20:25:31 +0800 Subject: [PATCH 19/20] fix: message_received event --- src/app/shared/enums/events.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/enums/events.ts b/src/app/shared/enums/events.ts index ccbd30d02..1bafe00f0 100644 --- a/src/app/shared/enums/events.ts +++ b/src/app/shared/enums/events.ts @@ -5,7 +5,7 @@ export enum UsageEventType { QUESTIONNAIRE_FINISHED = 'questionnaire_finished', QUESTIONNAIRE_CANCELLED = 'questionnaire_cancelled', QUESTIONNAIRE_TRIGGERED = 'questionnaire_triggered', - MESSAGE_RECEIVED = 'message_received', + FCM_MESSAGE_RECEIVED = 'fcm_message_received', QUESTIONNAIRE_TRIGGER_MESSAGE_RECEIVED = 'questionnaire_trigger_message_received', QUESTIONNAIRE_TRIGGER_DEFINITION_PULL_SUCCESS = 'questionnaire_trigger_definition_pull_success', QUESTIONNAIRE_TRIGGER_ERROR = 'questionnaire_trigger_error', From 75d45132025b2e4cabc3c31600efe45e678a1795 Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Thu, 21 Apr 2022 20:35:11 +0800 Subject: [PATCH 20/20] fix: message_received event --- src/app/core/services/notifications/message-handler.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/core/services/notifications/message-handler.service.ts b/src/app/core/services/notifications/message-handler.service.ts index 6e5194521..7b4f54a0c 100644 --- a/src/app/core/services/notifications/message-handler.service.ts +++ b/src/app/core/services/notifications/message-handler.service.ts @@ -24,7 +24,7 @@ export class MessageHandlerService implements OnDestroy { public appConfig: AppConfigService ) { this.messageListener = this.firebase.onMessageReceived().subscribe(data => { - this.usage.sendGeneralEvent(UsageEventType.MESSAGE_RECEIVED) + this.usage.sendGeneralEvent(UsageEventType.FCM_MESSAGE_RECEIVED) return this.onMessageReceived(new Map(Object.entries(data))) }) }