diff --git a/src/frontend/analytics/piwik.relevant.period.confirm.goals.ts b/src/frontend/analytics/piwik.relevant.period.confirm.goals.ts deleted file mode 100644 index fdc5c0749..000000000 --- a/src/frontend/analytics/piwik.relevant.period.confirm.goals.ts +++ /dev/null @@ -1,19 +0,0 @@ -export function isCiDevEnvironment(hostname: string): boolean { - return hostname.includes("cidev"); -} - -export type MatomoPaq = { - push: (args: [string, number]) => void; -}; - -export function trackRelevantPeriodGoal( - value: string, - paq: MatomoPaq | undefined = (window as any).paq -): void { - - if (value === "1") { - paq.push(["trackGoal", 55]); // User selected YES - } else if (value === "0") { - paq.push(["trackGoal", 118]); // User selected NO - } -} diff --git a/test/frontend/analytics/piwik.relevant.period.confirm.goals.spec.ts b/test/frontend/analytics/piwik.relevant.period.confirm.goals.spec.ts deleted file mode 100644 index 6af125b59..000000000 --- a/test/frontend/analytics/piwik.relevant.period.confirm.goals.spec.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { - isCiDevEnvironment, - trackRelevantPeriodGoal, - MatomoPaq, -} from "../../../src/frontend/analytics/piwik.relevant.period.confirm.goals"; - -describe("isCiDevEnvironment", () => { - it("returns true when hostname includes 'cidev'", () => { - expect(isCiDevEnvironment("dev.cidev.internal")).toBe(true); - }); - - it("returns false when hostname does not include 'cidev'", () => { - expect(isCiDevEnvironment("example.gov.uk")).toBe(false); - }); -}); - -describe("trackRelevantPeriodGoal", () => { - let mockPaq: MatomoPaq; - - beforeEach(() => { - mockPaq = { push: jest.fn() }; - }); - - it("tracks goal 55 for value '1'", () => { - trackRelevantPeriodGoal("1", mockPaq); - expect(mockPaq.push).toHaveBeenCalledWith(["trackGoal", 55]); - }); - - it("tracks goal 118 for value '0'", () => { - trackRelevantPeriodGoal("0", mockPaq); - expect(mockPaq.push).toHaveBeenCalledWith(["trackGoal", 118]); - }); -}); - diff --git a/views/includes/piwik-pre-reg-goals-button.html b/views/includes/piwik-pre-reg-goals-button.html new file mode 100644 index 000000000..f355c8363 --- /dev/null +++ b/views/includes/piwik-pre-reg-goals-button.html @@ -0,0 +1,11 @@ +{% if PIWIK_RELEVANT_PERIOD_START_GOAL_ID > 0 %} + {{ govukButton({ + text: "Continue", + attributes: { + "id": "submit" + } + }) }} + {% include "includes/piwik-relevant-period-confirm-goals.html" %} +{% else %} + {% include "includes/continue-button.html" %} +{% endif %} diff --git a/views/includes/piwik-relevant-period-confirm-goals.html b/views/includes/piwik-relevant-period-confirm-goals.html index a28d53047..a4916f582 100644 --- a/views/includes/piwik-relevant-period-confirm-goals.html +++ b/views/includes/piwik-relevant-period-confirm-goals.html @@ -1,29 +1,33 @@ - diff --git a/views/update/relevant-period-required-information-confirm.html b/views/update/relevant-period-required-information-confirm.html index a0a351ba7..3395c0f90 100644 --- a/views/update/relevant-period-required-information-confirm.html +++ b/views/update/relevant-period-required-information-confirm.html @@ -81,14 +81,9 @@