@@ -20,9 +20,17 @@ export const ReferrerKind = {
20
20
21
21
export const MatomoActions = {
22
22
firstAnswer : 'Simulation First answer' ,
23
- finishedSimulations : ' Simulation Completed',
23
+ finishedSimulations : [ 'A terminé la simulation' , ' Simulation Completed'] ,
24
24
} as const
25
25
26
+ export const MatomoActionsSet : Record <
27
+ keyof typeof MatomoActions ,
28
+ Set < string >
29
+ > = {
30
+ firstAnswer : new Set ( MatomoActions . firstAnswer ) ,
31
+ finishedSimulations : new Set ( MatomoActions . finishedSimulations ) ,
32
+ }
33
+
26
34
const ReferrerBaseSchema = z
27
35
. object ( {
28
36
label : z . string ( ) ,
@@ -177,7 +185,9 @@ export const matomoClientFactory = (client: AxiosInstance) => {
177
185
method : 'Events.getAction' ,
178
186
'label[]' : [
179
187
encodeURIComponent ( MatomoActions . firstAnswer ) ,
180
- encodeURIComponent ( MatomoActions . finishedSimulations ) ,
188
+ ...MatomoActions . finishedSimulations . map ( ( action ) =>
189
+ encodeURIComponent ( action )
190
+ ) ,
181
191
] ,
182
192
period : 'day' ,
183
193
date,
@@ -188,12 +198,13 @@ export const matomoClientFactory = (client: AxiosInstance) => {
188
198
const actions = z . array ( DayActionSchema ) . parse ( data )
189
199
190
200
const firstAnswer = + (
191
- actions . find ( ( { label } ) => label === MatomoActions . firstAnswer )
201
+ actions . find ( ( { label } ) => MatomoActionsSet . firstAnswer . has ( label ) )
192
202
?. nb_visits || '0'
193
203
)
194
204
const finishedSimulations = + (
195
- actions . find ( ( { label } ) => label === MatomoActions . finishedSimulations )
196
- ?. nb_visits || '0'
205
+ actions . find ( ( { label } ) =>
206
+ MatomoActionsSet . finishedSimulations . has ( label )
207
+ ) ?. nb_visits || '0'
197
208
)
198
209
199
210
return { firstAnswer, finishedSimulations }
0 commit comments