Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TECH] Ajouter un tracking Matomo sur les recherches FAQ support (PIX-15433). #730

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions pix-pro/error.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<template>
<div class="error">
<a :href="t('home-page-url')">
<img class="logo" src="/images/pix-logo.svg" alt="Lien pour revenir à l'accueil" />
</a>
<!-- eslint-disable-next-line vue/no-v-html -->
<div v-html="t('error-content')" />
</div>
<template v-if="isDevelopmentMode">
<h1>Nuxt error</h1>
<pre>{{ error }}</pre>
</template>
<template v-else>
<div class="error">
<a :href="t('home-page-url')">
<img class="logo" src="/images/pix-logo.svg" alt="Lien pour revenir à l'accueil" />
</a>
<!-- eslint-disable-next-line vue/no-v-html -->
<div v-html="t('error-content')" />
</div>
</template>
</template>

<script setup>
Expand All @@ -17,6 +23,13 @@ useHead({
lang: i18nLocale,
},
});

const error = useError();
const isDevelopmentMode = process.env.NODE_ENV !== 'production';

if (isDevelopmentMode) {
console.table(error.value);
}
</script>

<style lang="scss">
Expand Down
27 changes: 20 additions & 7 deletions pix-site/error.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<template>
<div class="error">
<a :href="t('home-page-url')">
<img class="logo" src="/images/pix-logo.svg" alt="Lien pour revenir à l'accueil" />
</a>
<!-- eslint-disable-next-line vue/no-v-html -->
<div v-html="t('error-content')" />
</div>
<template v-if="isDevelopmentMode">
<h1>Nuxt error</h1>
<pre>{{ error }}</pre>
</template>
<template v-else>
<div class="error">
<a :href="t('home-page-url')">
<img class="logo" src="/images/pix-logo.svg" alt="Lien pour revenir à l'accueil" />
</a>
<!-- eslint-disable-next-line vue/no-v-html -->
<div v-html="t('error-content')" />
</div>
</template>
</template>

<script setup>
Expand All @@ -17,6 +23,13 @@ useHead({
lang: i18nLocale,
},
});

const error = useError();
const isDevelopmentMode = process.env.NODE_ENV !== 'production';

if (isDevelopmentMode) {
console.table(error.value);
}
</script>

<style lang="scss">
Expand Down
14 changes: 14 additions & 0 deletions shared/pages/support/faq/[faq-persona].vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
</template>

<script setup>
import { useDebounceFn } from '@vueuse/core';

const { $pushMatomoEvent } = useNuxtApp();
const { client } = usePrismic();
const { locale: i18nLocale, t } = useI18n();
const route = useRoute();
Expand Down Expand Up @@ -143,6 +146,15 @@ const displayPost = ({ post }) => {
return simplifyString(getPostTitle(post.uid)).includes(simplifyString(searchInput.value));
};

const debouncedMatomoEvent = useDebounceFn((inputValue) => {
$pushMatomoEvent(
'Support',
'FAQ',
"Recherche dans la barre d'une FAQ support",
`${data.value.currentPersona.faq_page_title[0].text}: '${inputValue}'`,
);
}, 1500);

const handleSearch = async (inputValue) => {
searchInput.value = inputValue;

Expand All @@ -160,6 +172,8 @@ const handleSearch = async (inputValue) => {
});

filteredPostsCount.value = postsCount;

debouncedMatomoEvent(inputValue);
};
</script>

Expand Down
11 changes: 11 additions & 0 deletions shared/plugins/matomo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default defineNuxtPlugin(() => {
return {
provide: {
pushMatomoEvent: (eventCategory: string, eventAction: string, eventName: string, value: string | number): void => {
if (import.meta.client && _mtm) {
_mtm.push(['trackEvent', eventCategory, eventAction, eventName, value]);
}
},
},
};
});