Skip to content

Commit 8352df6

Browse files
feat(orga): added click count on export campaign results button
1 parent 458d2d8 commit 8352df6

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

orga/app/components/campaign/header/tabs.gjs

+7
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@ export default class CampaignTabs extends Component {
1010
@service notifications;
1111
@service fileSaver;
1212
@service session;
13+
@service metrics;
1314

1415
@action
1516
async exportData() {
1617
try {
1718
const token = this.session.data.authenticated.access_token;
1819
await this.fileSaver.save({ url: this.args.campaign.urlToResult, token });
20+
this.metrics.add({
21+
event: 'custom-event',
22+
'pix-event-category': 'Campagnes',
23+
'pix-event-action': "Cliquer sur le bouton d'export des résultats d'une campagne",
24+
'pix-event-name': "Clic sur le bouton d'export",
25+
});
1926
} catch (err) {
2027
this.notifications.sendError(this.intl.t('api-error-messages.global'));
2128
}

orga/tests/integration/components/campaign/header/tabs-test.js

+22
Original file line numberDiff line numberDiff line change
@@ -143,5 +143,27 @@ module('Integration | Component | Campaign::Header::Tabs', function (hooks) {
143143
}),
144144
);
145145
});
146+
147+
test('it should push matomo event when user clicks on export button', async function (assert) {
148+
const add = sinon.stub();
149+
150+
class MetricsStubService extends Service {
151+
add = add;
152+
}
153+
this.owner.register('service:metrics', MetricsStubService);
154+
155+
const screen = await render(hbs`<Campaign::Header::Tabs @campaign={{this.campaign}} />`);
156+
157+
// when
158+
await click(screen.getByRole('button', { name: t('pages.campaign.actions.export-results') }));
159+
160+
sinon.assert.calledWithExactly(add, {
161+
event: 'custom-event',
162+
'pix-event-category': 'Campagnes',
163+
'pix-event-action': "Cliquer sur le bouton d'export des résultats d'une campagne",
164+
'pix-event-name': "Clic sur le bouton d'export",
165+
});
166+
assert.ok(true);
167+
});
146168
});
147169
});

0 commit comments

Comments
 (0)