mirror of
https://github.com/plausible/analytics.git
synced 2024-12-25 02:24:55 +03:00
67be43b6e6
* Add tagged events support for revenue goals This commit adds two special classes for tracking revenue with tagged events. The following example sends an event with revenue data when the tracker script has revenue and tagged-events script extensions: ```html <button class="plausible-event-revenue-amount=10.29 plausible-event-revenue-currency=EUR"></button> ``` * Rename special revenue tracking class name
23 lines
959 B
JavaScript
23 lines
959 B
JavaScript
const { mockRequest, expectCustomEvent } = require('./support/test-utils');
|
|
const { expect, test } = require('@playwright/test');
|
|
|
|
test.describe('with revenue script extension', () => {
|
|
test('sends revenue currency and amount in manual mode', async ({ page }) => {
|
|
const plausibleRequestMock = mockRequest(page, '/api/event')
|
|
await page.goto('/revenue.html');
|
|
await page.click('#manual-purchase')
|
|
|
|
const plausibleRequest = await plausibleRequestMock
|
|
expect(plausibleRequest.postDataJSON()["$"]).toEqual({amount: 15.99, currency: "USD"})
|
|
});
|
|
|
|
test('sends revenue currency and amount with tagged class name', async ({ page }) => {
|
|
const plausibleRequestMock = mockRequest(page, '/api/event')
|
|
await page.goto('/revenue.html');
|
|
await page.click('#tagged-purchase')
|
|
|
|
const plausibleRequest = await plausibleRequestMock
|
|
expect(plausibleRequest.postDataJSON()["$"]).toEqual({amount: "13.32", currency: "EUR"})
|
|
});
|
|
});
|