-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: tracking manquant recherche cc * chore: clean * fix: test e2e ajout useeffect * fix: ajout tracking particulier employeur --------- Co-authored-by: victor <[email protected]>
- Loading branch information
Showing
14 changed files
with
329 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...ravail-frontend/src/modules/convention-collective/__tests__/AgreementSearchIntro.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { render, RenderResult } from "@testing-library/react"; | ||
import React from "react"; | ||
import { ui } from "./ui"; | ||
import { UserAction } from "src/common"; | ||
import { sendEvent } from "../../utils"; | ||
import { AgreementSearchIntro } from "../AgreementSearch"; | ||
|
||
jest.mock("../../utils", () => ({ | ||
sendEvent: jest.fn(), | ||
})); | ||
|
||
jest.mock("uuid", () => ({ | ||
v4: jest.fn(() => {}), | ||
})); | ||
|
||
describe("Trouver sa CC - intro", () => { | ||
let rendering: RenderResult; | ||
let userAction: UserAction; | ||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
it("Vérifier le tracking à l'arrivée", async () => { | ||
rendering = render(<AgreementSearchIntro />); | ||
expect(sendEvent).toHaveBeenLastCalledWith({ | ||
action: "view_step_Trouver sa convention collective", | ||
category: "outil", | ||
name: "start", | ||
}); | ||
}); | ||
it("Vérifier le tracking vers recherche CC", async () => { | ||
rendering = render(<AgreementSearchIntro />); | ||
userAction = new UserAction(); | ||
userAction.click(ui.searchAgreementIntro.buttonSearchAgreement.get()); | ||
expect(sendEvent).toHaveBeenLastCalledWith({ | ||
action: "click_p1", | ||
category: "cc_search_type_of_users", | ||
name: "Trouver sa convention collective", | ||
}); | ||
}); | ||
|
||
it("Vérifier le tracking vers recherche entreprise", async () => { | ||
rendering = render(<AgreementSearchIntro />); | ||
userAction = new UserAction(); | ||
userAction.click(ui.searchAgreementIntro.buttonSearchEnterprise.get()); | ||
expect(sendEvent).toHaveBeenLastCalledWith({ | ||
action: "click_p2", | ||
category: "cc_search_type_of_users", | ||
name: "Trouver sa convention collective", | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 67 additions & 4 deletions
71
packages/code-du-travail-frontend/src/modules/convention-collective/tracking.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,87 @@ | ||
import { v4 as generateUUID } from "uuid"; | ||
import { sendEvent } from "../utils"; | ||
|
||
export enum TrackingAgreementSearchEvent { | ||
export enum TrackingAgreementSearchCategory { | ||
CC_SEARCH = "cc_search", | ||
CC_SEARCH_TYPE_OF_USERS = "cc_search_type_of_users", | ||
ENTERPRISE_SEARCH = "enterprise_search", | ||
VIEW_STEP = "view_step_Trouver sa convention collective", | ||
CC_SELECT_P1 = "cc_select_p1", | ||
CC_SELECT_P2 = "cc_select_p2", | ||
CC_ENTERPRISE_SELECT = "enterprise_select", | ||
VIEW_STEP_CC_SEARCH_P1 = "view_step_cc_search_p1", | ||
VIEW_STEP_CC_SEARCH_P2 = "view_step_cc_search_p2", | ||
} | ||
|
||
export const AGREEMENT_SEARCH_ACTION = "Trouver sa convention collective"; | ||
export enum TrackingAgreementSearchAction { | ||
AGREEMENT_SEARCH = "Trouver sa convention collective", | ||
CLICK_P1 = "click_p1", | ||
CLICK_P2 = "click_p2", | ||
BACK_STEP_P1 = "back_step_cc_search_p1", | ||
BACK_STEP_P2 = "back_step_cc_search_p2", | ||
CLICK_NO_COMPANY = "click_je_n_ai_pas_d_entreprise", | ||
} | ||
|
||
export const useAgreementSearchTracking = () => { | ||
const emitAgreementSearchInputEvent = (query: string) => { | ||
sendEvent({ | ||
category: TrackingAgreementSearchEvent.CC_SEARCH, | ||
action: AGREEMENT_SEARCH_ACTION, | ||
category: TrackingAgreementSearchCategory.CC_SEARCH, | ||
action: TrackingAgreementSearchAction.AGREEMENT_SEARCH, | ||
name: JSON.stringify({ query }), | ||
value: generateUUID(), | ||
}); | ||
}; | ||
|
||
const emitViewStepEvent = () => { | ||
sendEvent({ | ||
category: "outil", | ||
action: `view_step_${TrackingAgreementSearchAction.AGREEMENT_SEARCH}`, | ||
name: "start", | ||
}); | ||
}; | ||
|
||
const emitNavigateAgreementSearchEvent = (): undefined => { | ||
sendEvent({ | ||
category: TrackingAgreementSearchCategory.CC_SEARCH_TYPE_OF_USERS, | ||
action: TrackingAgreementSearchAction.CLICK_P1, | ||
name: TrackingAgreementSearchAction.AGREEMENT_SEARCH, | ||
value: generateUUID(), | ||
}); | ||
}; | ||
|
||
const emitNavigateEnterpriseSearchEvent = (): undefined => { | ||
sendEvent({ | ||
category: TrackingAgreementSearchCategory.CC_SEARCH_TYPE_OF_USERS, | ||
action: TrackingAgreementSearchAction.CLICK_P2, | ||
name: TrackingAgreementSearchAction.AGREEMENT_SEARCH, | ||
value: generateUUID(), | ||
}); | ||
}; | ||
|
||
const emitSelectEvent = (idcc: string) => { | ||
sendEvent({ | ||
category: TrackingAgreementSearchCategory.CC_SELECT_P1, | ||
action: TrackingAgreementSearchAction.AGREEMENT_SEARCH, | ||
name: idcc, | ||
value: generateUUID(), | ||
}); | ||
}; | ||
|
||
const emitPreviousEvent = () => { | ||
sendEvent({ | ||
category: TrackingAgreementSearchCategory.VIEW_STEP_CC_SEARCH_P1, | ||
action: TrackingAgreementSearchAction.BACK_STEP_P1, | ||
name: TrackingAgreementSearchAction.AGREEMENT_SEARCH, | ||
value: generateUUID(), | ||
}); | ||
}; | ||
|
||
return { | ||
emitAgreementSearchInputEvent, | ||
emitViewStepEvent, | ||
emitNavigateAgreementSearchEvent, | ||
emitNavigateEnterpriseSearchEvent, | ||
emitSelectEvent, | ||
emitPreviousEvent, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.