Skip to content

Commit

Permalink
Merge pull request #816 from betagouv/fix_repair_ab_testing
Browse files Browse the repository at this point in the history
fix: repair ab testing
  • Loading branch information
totakoko committed Jun 24, 2024
2 parents 819151c + f2841de commit a932663
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/services/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,20 @@ export const useAnalytics = () => {
},
});

// handle the case where matomo does not respond
const errorStateTimeout = setTimeout(() => {
if (matomoAnalyticsLoadingState === 'pending') {
setMatomoAnalyticsLoadedState('error');
}
}, 2000);

// track the async deferred loading of the script by matomo-next
// matomoAsyncInit is a specific callback used by Matomo
// matomoAbTestingAsyncInit is a specific callback used by Matomo AB Testing framework
window.matomoAbTestingAsyncInit = () => {
setMatomoAnalyticsLoadedState('loaded');
clearTimeout(errorStateTimeout);
};

// handle the case where matomo does not respond
setTimeout(() => {
if (matomoAnalyticsLoadingState === 'pending') {
setMatomoAnalyticsLoadedState('error');
}
}, 2000);
}
}, []);

Expand Down Expand Up @@ -630,7 +631,7 @@ const emptyActivateMethod = () => {

const matomoABTestingExperiments = [
{
name: 'TestMessagesFormulaireContact', // you can also use '1' (ID of the experiment) to hide the name
name: 'TestMessagesFormulaireContact',
percentage: 100,
includedTargets: [],
excludedTargets: [],
Expand Down

0 comments on commit a932663

Please sign in to comment.