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); + }); }); });