Skip to content

Commit

Permalink
Add SAM analytic (#899)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew2564 authored Oct 21, 2022
1 parent 7f36d3d commit 4469400
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/app/pages/back-to-office/back-to-office.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ export const BackToOfficeViewDidEnter = createAction(
export const DeferWriteUp = createAction(
'[BackToOfficePage] Defer write-up',
);

export const ASAMPopupPresented = createAction(
'[BackToOfficePage] ASAM popup presented',
);
20 changes: 20 additions & 0 deletions src/app/pages/back-to-office/back-to-office.analytics.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<typeof ASAMPopupPresented>, TestsModel]) => {
this.analytics.logEvent(
formatAnalyticsText(AnalyticsEventCategories.ERROR, tests),
formatAnalyticsText(AnalyticsEvents.ASAM, tests),
'Modal Triggered',
);
return of(AnalyticRecorded());
}),
));
}
7 changes: 6 additions & 1 deletion src/app/pages/back-to-office/back-to-office.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/app/providers/analytics/analytics.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4469400

Please sign in to comment.