-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Average Scroll Depth Metric: Track custom props on pageleaves (#4964)
* improve tracker test util to handle custom props * track pageleave props * make test util more powerful * also test with pageview-props extension * add test for sending props on hash navigation * simplify tracker logic around currentPageLeaveURL * clarify the intent of a timeout by extracting a fn * bugfix: stop sending pageleaves from ignored pages + fix the test to actually fail if this doesn't work. * refactor: drop expectCustomEvent in favour of the new test util * add test for pageleave props ingestion * add query tests * improve test util readability
- Loading branch information
1 parent
90a2c5d
commit f262bea
Showing
17 changed files
with
577 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,36 @@ | ||
const { mockRequest, mockManyRequests, expectCustomEvent } = require('./support/test-utils') | ||
const { expect, test } = require('@playwright/test') | ||
const { expectPlausibleInAction } = require('./support/test-utils') | ||
const { test } = require('@playwright/test') | ||
const { LOCAL_SERVER_ADDR } = require('./support/server') | ||
|
||
test.describe('script.file-downloads.outbound-links.tagged-events.js', () => { | ||
test('sends only outbound link event when clicked link is both download and outbound', async ({ page }) => { | ||
await page.goto('/custom-event-edge-case.html') | ||
const downloadURL = await page.locator('#outbound-download-link').getAttribute('href') | ||
|
||
const plausibleRequestMockList = mockManyRequests(page, '/api/event', 2) | ||
await page.click('#outbound-download-link') | ||
|
||
const requests = await plausibleRequestMockList | ||
expect(requests.length).toBe(1) | ||
expectCustomEvent(requests[0], 'Outbound Link: Click', {url: downloadURL}) | ||
await expectPlausibleInAction(page, { | ||
action: () => page.click('#outbound-download-link'), | ||
expectedRequests: [{n: 'Outbound Link: Click', p: {url: downloadURL}}] | ||
}) | ||
}) | ||
|
||
test('sends file download event when local download link clicked', async ({ page }) => { | ||
await page.goto('/custom-event-edge-case.html') | ||
const downloadURL = LOCAL_SERVER_ADDR + '/' + await page.locator('#local-download').getAttribute('href') | ||
|
||
const plausibleRequestMock = mockRequest(page, '/api/event') | ||
await page.click('#local-download') | ||
|
||
expectCustomEvent(await plausibleRequestMock, 'File Download', {url: downloadURL}) | ||
await expectPlausibleInAction(page, { | ||
action: () => page.click('#local-download'), | ||
expectedRequests: [{n: 'File Download', p: {url: downloadURL}}] | ||
}) | ||
}) | ||
|
||
test('sends only tagged event when clicked link is tagged + outbound + download', async ({ page }) => { | ||
await page.goto('/custom-event-edge-case.html') | ||
|
||
const plausibleRequestMockList = mockManyRequests(page, '/api/event', 3) | ||
await page.click('#tagged-outbound-download-link') | ||
|
||
const requests = await plausibleRequestMockList | ||
expect(requests.length).toBe(1) | ||
expectCustomEvent(requests[0], 'Foo', {}) | ||
await expectPlausibleInAction(page, { | ||
action: () => page.click('#tagged-outbound-download-link'), | ||
expectedRequests: [{n: 'Foo', p: {url: 'https://awesome.website.com/file.pdf'}}], | ||
awaitedRequestCount: 3, | ||
expectedRequestCount: 1 | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.