Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Start passing official installs that are using legacy .compat script (#5812)
Artur Pata6b1821362f09
diff --git a/tracker/installation_support/verifier-v2.js b/tracker/installation_support/verifier-v2.jsindex bdf9ff97ff..a6aa5c185e 100644--- a/tracker/installation_support/verifier-v2.js+++ b/tracker/installation_support/verifier-v2.js@@ -54,12 +54,40 @@ async function verifyPlausibleInstallation(options) {stopRecording()- const interceptedTestEvent = getInterceptedFetch('verification-agent-test')+ let interceptedTestEvent = getInterceptedFetch('verification-agent-test')if (!interceptedTestEvent) {log(`No test event request was among intercepted requests`)}+ // this can be removed once most sites have migrated to v2 and WP plugin is migrated to v2+ if (+ !interceptedTestEvent &&+ [200, 202].includes(testEvent.callbackResult?.status)+ ) {+ log(+ `The callback result indicates a successful request, assuming legacy .compat installation that uses XMLHttpRequest`+ )+ const firstLegacySnippet = document.querySelector(+ 'script[data-domain][src]'+ )+ if (firstLegacySnippet) {+ // legacy installations may list multiple domains in a comma-separated list+ const domainString = firstLegacySnippet.getAttribute('data-domain')+ const firstDomain = domainString && domainString.split(',').shift()++ interceptedTestEvent = {+ request: {+ normalizedBody: {+ __legacyCompatInstallation: true,+ domain: firstDomain+ }+ },+ response: { status: testEvent.callbackResult.status }+ }+ }+ }+const diagnostics = {disallowedByCsp,trackerIsInHtml,diff --git a/tracker/test/installation_support/verifier-v2.spec.ts b/tracker/test/installation_support/verifier-v2.spec.tsindex 2895dbf9a5..b20ee7ad3d 100644--- a/tracker/test/installation_support/verifier-v2.spec.ts+++ b/tracker/test/installation_support/verifier-v2.spec.ts@@ -834,6 +834,64 @@ test.describe('installed plausible esm variant', () => {})})+test.describe('installed legacy .compat script', () => {+ test('with masked events endpoint', async ({ page }, { testId }) => {+ await mockManyRequests({+ page,+ path: `https://example.com/any/masked/events/endpoint`,+ awaitedRequestCount: 1,+ fulfill: {+ status: 202,+ contentType: 'text/plain',+ body: 'ok'+ }+ })++ const { url } = await initializePageDynamically(page, {+ testId,+ scriptConfig: /* HTML */ `<script+ id="plausible"+ data-domain="example.com"+ data-api="https://example.com/any/masked/events/endpoint"+ src="/tracker/js/plausible.compat.local.manual.js"+ ></script>`,+ bodyContent: ''+ })++ const response = await page.goto(url)+ const responseHeaders = response?.headers() ?? {}++ const result = await executeVerifyV2(page, {+ ...DEFAULT_VERIFICATION_OPTIONS,+ responseHeaders+ })++ expect(result).toEqual({+ data: {+ attempts: 1,+ completed: true,+ trackerIsInHtml: false,+ plausibleIsInitialized: true,+ plausibleIsOnWindow: true,+ disallowedByCsp: false,+ plausibleVersion: version,+ plausibleVariant: undefined,+ testEvent: {+ callbackResult: {+ status: 202+ },+ normalizedBody: {+ __legacyCompatInstallation: true,+ domain: 'example.com'+ },+ responseStatus: 202+ },+ cookiesConsentResult: incompleteCookiesConsentResult+ }+ })+ })+})+test.describe('opts in on cookie banners', () => {for (const { url, expectedCookiesConsentResult } of [{