diff --git a/.codespellignore b/.codespellignore index cb20144e71..23d01f85ba 100644 --- a/.codespellignore +++ b/.codespellignore @@ -6,3 +6,4 @@ taht referer referers statics +firs diff --git a/tracker/src/plausible.js b/tracker/src/plausible.js index ad23e290b4..ca96894a2e 100644 --- a/tracker/src/plausible.js +++ b/tracker/src/plausible.js @@ -212,6 +212,15 @@ payload.h = 1 {{/if}} + {{#if pageleave}} + if (isPageview) { + currentPageLeaveIgnored = false + currentPageLeaveURL = payload.u + currentPageLeaveProps = payload.p + registerPageLeaveListener() + } + {{/if}} + var request = new XMLHttpRequest(); request.open('POST', endpoint, true); request.setRequestHeader('Content-Type', 'text/plain'); @@ -220,14 +229,6 @@ request.onreadystatechange = function() { if (request.readyState === 4) { - {{#if pageleave}} - if (isPageview) { - currentPageLeaveIgnored = false - currentPageLeaveURL = payload.u - currentPageLeaveProps = payload.p - registerPageLeaveListener() - } - {{/if}} options && options.callback && options.callback({status: request.status}) } } @@ -246,7 +247,7 @@ {{#unless hash}} if (lastPage === location.pathname) return; {{/unless}} - + {{#if pageleave}} if (isSPANavigation && listeningPageLeave) { triggerPageLeave(); diff --git a/tracker/test/file-downloads.spec.js b/tracker/test/file-downloads.spec.js index 5bac615d3b..a0dc3a131e 100644 --- a/tracker/test/file-downloads.spec.js +++ b/tracker/test/file-downloads.spec.js @@ -45,7 +45,7 @@ test.describe('file-downloads extension', () => { await page.goto('/file-download.html') const downloadURL = LOCAL_SERVER_ADDR + '/' + await page.locator('#local-download').getAttribute('href') - const downloadRequestMockList = mockManyRequests(page, downloadURL, 2) + const downloadRequestMockList = mockManyRequests({ page, path: downloadURL, numberOfRequests: 2 }) await page.click('#local-download') expect((await downloadRequestMockList).length).toBe(1) diff --git a/tracker/test/fixtures/manual.html b/tracker/test/fixtures/manual.html index de07061dc4..f1058c95ef 100644 --- a/tracker/test/fixtures/manual.html +++ b/tracker/test/fixtures/manual.html @@ -26,16 +26,16 @@ diff --git a/tracker/test/fixtures/pageleave-pageview-props.html b/tracker/test/fixtures/pageleave-pageview-props.html index 51aee537ed..c2c9cd11e3 100644 --- a/tracker/test/fixtures/pageleave-pageview-props.html +++ b/tracker/test/fixtures/pageleave-pageview-props.html @@ -11,6 +11,14 @@
Navigate away + +