From 44694005989caa346c44f8f728c1cb8b172eb36e Mon Sep 17 00:00:00 2001 From: Matthew Bell <33056264+matthew2564@users.noreply.github.com> Date: Fri, 21 Oct 2022 13:58:41 +0100 Subject: [PATCH] Add SAM analytic (#899) --- .../back-to-office/back-to-office.actions.ts | 4 ++++ .../back-to-office.analytics.effects.ts | 20 +++++++++++++++++++ .../back-to-office/back-to-office.page.ts | 7 ++++++- .../providers/analytics/analytics.model.ts | 1 + 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/app/pages/back-to-office/back-to-office.actions.ts b/src/app/pages/back-to-office/back-to-office.actions.ts index 2cdc0b29a..d40f26fa5 100644 --- a/src/app/pages/back-to-office/back-to-office.actions.ts +++ b/src/app/pages/back-to-office/back-to-office.actions.ts @@ -7,3 +7,7 @@ export const BackToOfficeViewDidEnter = createAction( export const DeferWriteUp = createAction( '[BackToOfficePage] Defer write-up', ); + +export const ASAMPopupPresented = createAction( + '[BackToOfficePage] ASAM popup presented', +); diff --git a/src/app/pages/back-to-office/back-to-office.analytics.effects.ts b/src/app/pages/back-to-office/back-to-office.analytics.effects.ts index 099056d35..dd9b5aa94 100644 --- a/src/app/pages/back-to-office/back-to-office.analytics.effects.ts +++ b/src/app/pages/back-to-office/back-to-office.analytics.effects.ts @@ -22,6 +22,7 @@ import { getApplicationNumber, } from '@store/tests/journal-data/common/application-reference/application-reference.selector'; import { + ASAMPopupPresented, BackToOfficeViewDidEnter, DeferWriteUp, } from './back-to-office.actions'; @@ -92,4 +93,23 @@ export class BackToOfficeAnalyticsEffects { return of(AnalyticRecorded()); }), )); + + asamPopupShown$ = createEffect(() => this.actions$.pipe( + ofType(ASAMPopupPresented), + concatMap((action) => of(action).pipe( + withLatestFrom( + this.store$.pipe( + select(getTests), + ), + ), + )), + switchMap(([, tests]: [ReturnType, TestsModel]) => { + this.analytics.logEvent( + formatAnalyticsText(AnalyticsEventCategories.ERROR, tests), + formatAnalyticsText(AnalyticsEvents.ASAM, tests), + 'Modal Triggered', + ); + return of(AnalyticRecorded()); + }), + )); } diff --git a/src/app/pages/back-to-office/back-to-office.page.ts b/src/app/pages/back-to-office/back-to-office.page.ts index 588588d36..90be9c71f 100644 --- a/src/app/pages/back-to-office/back-to-office.page.ts +++ b/src/app/pages/back-to-office/back-to-office.page.ts @@ -4,7 +4,11 @@ import { PracticeableBasePageComponent } from '@shared/classes/practiceable-base import { AuthenticationProvider } from '@providers/authentication/authentication'; import { Store, select } from '@ngrx/store'; import { StoreModel } from '@shared/models/store.model'; -import { BackToOfficeViewDidEnter, DeferWriteUp } from '@pages/back-to-office/back-to-office.actions'; +import { + ASAMPopupPresented, + BackToOfficeViewDidEnter, + DeferWriteUp, +} from '@pages/back-to-office/back-to-office.actions'; import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx'; import { Insomnia } from '@ionic-native/insomnia/ngx'; import { merge, Observable, Subscription } from 'rxjs'; @@ -127,6 +131,7 @@ export class BackToOfficePage extends PracticeableBasePageComponent { showBackdrop: true, }); + this.store$.dispatch(ASAMPopupPresented()); await asamModal.present(); await asamModal.onDidDismiss(); await this.onContinue(navigationTarget); diff --git a/src/app/providers/analytics/analytics.model.ts b/src/app/providers/analytics/analytics.model.ts index 2d9c7cd2d..1e48dc270 100644 --- a/src/app/providers/analytics/analytics.model.ts +++ b/src/app/providers/analytics/analytics.model.ts @@ -206,6 +206,7 @@ export enum AnalyticsEvents { PRACTICE_TEST_SELECTED = 'practice test report selected', PRACTICE_FULL_TEST_SELECTED = 'practice full test selected', BACK = 'back', + ASAM = 'Single App Mode (SAM)', } export enum AnalyticsLabels {