From 8c883fd290452af57fe8fc82c3de266109f0b738 Mon Sep 17 00:00:00 2001 From: Felix Scholze Date: Sun, 5 May 2024 20:35:14 +0200 Subject: [PATCH] feat: add partytown integration --- README.md | 1 + src/index.ts | 1 + src/matomo.ts | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 37694ca..0b51b71 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ yarn add astro-matomo | `trackerUrl?` | `string` | Defaults to matomo.php | | `srcUrl?` | `string` | Defaults to matomo.js | | `debug?` | `boolean` | Activate debug mode | +| `partytown?` | `boolean` | Activate [Partytown](https://partytown.builder.io/) | ## Example usage diff --git a/src/index.ts b/src/index.ts index 01f9d69..1374e48 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,6 +12,7 @@ export type MatomoOptions = disableCookies?: boolean; preconnect?: boolean; debug?: boolean; + partytown?: boolean; } | undefined; diff --git a/src/matomo.ts b/src/matomo.ts index 12d22f3..3792526 100644 --- a/src/matomo.ts +++ b/src/matomo.ts @@ -37,7 +37,7 @@ export function initMatomo(options: MatomoOptions): void { s = d.getElementsByTagName("script")[0]; g.id = "matomo-script"; - g.type = "text/javascript"; + g.type = `text/${options?.partytown ? "partytown" : "javascript"}`; g.async = true; g.defer = true; g.src = u + (options?.srcUrl || "matomo.js");