Skip to content

Commit

Permalink
feat(orga): added click count on export campaign results button
Browse files Browse the repository at this point in the history
  • Loading branch information
alicegoarnisson committed Dec 4, 2024
1 parent 10dffd1 commit 11ca0ee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions orga/app/components/campaign/header/tabs.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
Expand Down
22 changes: 22 additions & 0 deletions orga/tests/integration/components/campaign/header/tabs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`<Campaign::Header::Tabs @campaign={{this.campaign}} />`);

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

0 comments on commit 11ca0ee

Please sign in to comment.