Skip to content

Commit

Permalink
add post test event as they were in the spreadsheet for this ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsetterfield committed Mar 15, 2024
1 parent ee788c4 commit ed549b3
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import {
AnalyticsErrorTypes,
AnalyticsEventCategories,
AnalyticsEvents,
AnalyticsScreenNames,
AnalyticsScreenNames, GoogleAnalyticsEvents, GoogleAnalyticsEventsTitles, GoogleAnalyticsEventsValues,
} from '@providers/analytics/analytics.model';
import { AnalyticNotRecorded, AnalyticRecorded } from '@providers/analytics/analytics.actions';
import { formatAnalyticsText } from '@shared/helpers/format-analytics-text';
import { analyticsEventTypePrefix, formatAnalyticsText } from '@shared/helpers/format-analytics-text';
import { getTests } from '@store/tests/tests.reducer';
import { getActivityCode } from '@store/tests/activity-code/activity-code.reducer';
import { TestsModel } from '@store/tests/tests.model';
Expand Down Expand Up @@ -73,8 +73,13 @@ export class NonPassFinalisationAnalyticsEffects {
switchMap((
[, tests]: [ReturnType<typeof NonPassFinalisationViewDidEnter>, TestsModel, boolean],
) => {

// TODO - MES-9495 - remove old analytics
const screenName = formatAnalyticsText(AnalyticsScreenNames.NON_PASS_FINALISATION, tests);
this.analytics.setCurrentPage(screenName);

//GA4 Analytics
this.analytics.setGACurrentPage(analyticsEventTypePrefix(AnalyticsScreenNames.NON_PASS_FINALISATION, tests));
return of(AnalyticRecorded());
}),
));
Expand Down Expand Up @@ -135,11 +140,19 @@ export class NonPassFinalisationAnalyticsEffects {
) => {
// D255Yes used in pass & non-pass flows, this guard stops the appearance of duplicated events.
if (activityCode !== ActivityCodes.PASS) {

// TODO - MES-9495 - remove old analytics
this.analytics.logEvent(
formatAnalyticsText(AnalyticsEventCategories.POST_TEST, tests),
formatAnalyticsText(AnalyticsEvents.D255, tests),
'Yes',
);

this.analytics.logGAEvent(
analyticsEventTypePrefix(GoogleAnalyticsEvents.SET_D255, tests),
GoogleAnalyticsEventsTitles.FINALISATION_D255,
GoogleAnalyticsEventsValues.YES,
);
return of(AnalyticRecorded());
}
return of(AnalyticNotRecorded());
Expand Down Expand Up @@ -173,11 +186,19 @@ export class NonPassFinalisationAnalyticsEffects {
) => {
// D255No used in pass & non-pass flows, this guard stops the appearance of duplicated events.
if (activityCode !== ActivityCodes.PASS) {

// TODO - MES-9495 - remove old analytics
this.analytics.logEvent(
formatAnalyticsText(AnalyticsEventCategories.POST_TEST, tests),
formatAnalyticsText(AnalyticsEvents.D255, tests),
'No',
);

this.analytics.logGAEvent(
analyticsEventTypePrefix(GoogleAnalyticsEvents.SET_D255, tests),
GoogleAnalyticsEventsTitles.FINALISATION_D255,
GoogleAnalyticsEventsValues.NO,
);
return of(AnalyticRecorded());
}
return of(AnalyticNotRecorded());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import {
AnalyticsErrorTypes,
AnalyticsEventCategories,
AnalyticsEvents,
AnalyticsScreenNames,
AnalyticsScreenNames, GoogleAnalyticsEvents, GoogleAnalyticsEventsTitles, GoogleAnalyticsEventsValues,
} from '@providers/analytics/analytics.model';
import { StoreModel } from '@shared/models/store.model';
import { AnalyticsProvider } from '@providers/analytics/analytics';
import { getTests } from '@store/tests/tests.reducer';
import { formatAnalyticsText } from '@shared/helpers/format-analytics-text';
import { analyticsEventTypePrefix, formatAnalyticsText } from '@shared/helpers/format-analytics-text';
import { AnalyticNotRecorded, AnalyticRecorded } from '@providers/analytics/analytics.actions';
import * as passCompletionActions from '@store/tests/pass-completion/pass-completion.actions';
import * as testSummaryActions from '@store/tests/test-summary/test-summary.actions';
Expand Down Expand Up @@ -77,8 +77,13 @@ export class PassFinalisationAnalyticsEffects {
[, tests]:
[ReturnType<typeof PassFinalisationViewDidEnter>, TestsModel, boolean],
) => {

// TODO - MES-9495 - remove old analytics
const screenName = formatAnalyticsText(AnalyticsScreenNames.PASS_FINALISATION, tests);
this.analytics.setCurrentPage(screenName);

//GA4 Analytics
this.analytics.setGACurrentPage(analyticsEventTypePrefix(AnalyticsScreenNames.PASS_FINALISATION, tests));
return of(AnalyticRecorded());
}),
));
Expand Down Expand Up @@ -300,11 +305,19 @@ export class PassFinalisationAnalyticsEffects {
) => {
// D255Yes used in pass & non-pass flows, this guard stops the appearance of duplicated events.
if (activityCode === ActivityCodes.PASS) {

// TODO - MES-9495 - remove old analytics
this.analytics.logEvent(
formatAnalyticsText(AnalyticsEventCategories.POST_TEST, tests),
formatAnalyticsText(AnalyticsEvents.D255, tests),
'Yes',
);

this.analytics.logGAEvent(
analyticsEventTypePrefix(GoogleAnalyticsEvents.SET_D255, tests),
GoogleAnalyticsEventsTitles.FINALISATION_D255,
GoogleAnalyticsEventsValues.YES,
);
return of(AnalyticRecorded());
}
return of(AnalyticNotRecorded());
Expand Down Expand Up @@ -339,11 +352,19 @@ export class PassFinalisationAnalyticsEffects {
) => {
// D255No used in pass & non-pass flows, this guard stops the appearance of duplicated events.
if (activityCode === ActivityCodes.PASS) {

// TODO - MES-9495 - remove old analytics
this.analytics.logEvent(
formatAnalyticsText(AnalyticsEventCategories.POST_TEST, tests),
formatAnalyticsText(AnalyticsEvents.D255, tests),
'No',
);

this.analytics.logGAEvent(
analyticsEventTypePrefix(GoogleAnalyticsEvents.SET_D255, tests),
GoogleAnalyticsEventsTitles.FINALISATION_D255,
GoogleAnalyticsEventsValues.NO,
);
return of(AnalyticRecorded());
}
return of(AnalyticNotRecorded());
Expand Down
4 changes: 4 additions & 0 deletions src/app/providers/analytics/analytics.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,14 @@ export enum GoogleAnalyticsEventPrefix {
export enum GoogleAnalyticsEvents {
VALIDATION_ERROR = 'validation_error',
CANDIDATE_RECEIVE_TEST_RESULTS = 'send _candidate_test_results',
SET_D255 = 'set_d255',
}

export enum GoogleAnalyticsEventsTitles {
BLANK_FIELD = 'blank_field',
OUTCOME = 'outcome',
COMMS_CHANNEL = 'comms_channel',
FINALISATION_D255 = 'd255'
}

export enum GoogleAnalyticsEventsValues {
Expand All @@ -284,4 +286,6 @@ export enum GoogleAnalyticsEventsValues {
COMMS_METHOD_BOOKING_EMAIL = 'booking email',
COMMS_METHOD_NEW_EMAIL = 'new email',
COMMS_METHOD_POST = 'by email',
YES = 'yes',
NO = 'no',
}

0 comments on commit ed549b3

Please sign in to comment.