From 652dc2da6e37016a30b551b164749fc3363812c5 Mon Sep 17 00:00:00 2001 From: alicegoarnisson Date: Wed, 4 Dec 2024 16:27:38 +0100 Subject: [PATCH] feat(orga): added click count on export campaign results button --- orga/app/components/campaign/header/tabs.gjs | 7 ++++++ .../components/campaign/header/tabs-test.js | 22 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/orga/app/components/campaign/header/tabs.gjs b/orga/app/components/campaign/header/tabs.gjs index d32b9343680..fc275f62910 100644 --- a/orga/app/components/campaign/header/tabs.gjs +++ b/orga/app/components/campaign/header/tabs.gjs @@ -10,12 +10,19 @@ export default class CampaignTabs extends Component { @service notifications; @service fileSaver; @service session; + @service metrics; @action async exportData() { try { const token = this.session.data.authenticated.access_token; await this.fileSaver.save({ url: this.args.campaign.urlToResult, token }); + this.metrics.add({ + event: 'custom-event', + 'pix-event-category': 'Campagnes', + 'pix-event-action': "Cliquer sur le bouton d'export des résultats d'une campagne", + 'pix-event-name': "Clic sur le bouton d'export", + }); } catch (err) { this.notifications.sendError(this.intl.t('api-error-messages.global')); } diff --git a/orga/tests/integration/components/campaign/header/tabs-test.js b/orga/tests/integration/components/campaign/header/tabs-test.js index daacb59df91..a4b41d35e5f 100644 --- a/orga/tests/integration/components/campaign/header/tabs-test.js +++ b/orga/tests/integration/components/campaign/header/tabs-test.js @@ -143,5 +143,27 @@ module('Integration | Component | Campaign::Header::Tabs', function (hooks) { }), ); }); + + test('it should push matomo event when user clicks on export button', async function (assert) { + const add = sinon.stub(); + + class MetricsStubService extends Service { + add = add; + } + this.owner.register('service:metrics', MetricsStubService); + + const screen = await render(hbs``); + + // when + await click(screen.getByRole('button', { name: t('pages.campaign.actions.export-results') })); + + sinon.assert.calledWithExactly(add, { + event: 'custom-event', + 'pix-event-category': 'Campagnes', + 'pix-event-action': "Cliquer sur le bouton d'export des résultats d'une campagne", + 'pix-event-name': "Clic sur le bouton d'export", + }); + assert.ok(true); + }); }); });