diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index c80b69bc2a4..8c4a477fe9f 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -116,6 +116,8 @@ jobs: working-directory: docs env: DEPLOY_TARGET: ${{ github.event_name == 'workflow_dispatch' && inputs.deploy_target || 'custom' }} + ENABLE_ANALYTICS: ${{ github.ref == 'refs/heads/main' && (github.event_name != 'workflow_dispatch' || + inputs.deploy_target == 'custom') }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: verify deploy output diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index deb4ba47093..524c6459878 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -14,6 +14,7 @@ import starlightContextualMenu from 'starlight-contextual-menu'; // so the same source can be deployed to either target. const deployTarget = process.env.DEPLOY_TARGET ?? 'custom'; const isGhPages = deployTarget === 'ghpages'; +const enableAnalytics = process.env.ENABLE_ANALYTICS === 'true'; const base = isGhPages ? '/InvokeAI' : ''; const withBase = (/** @type {string} */ path) => (isGhPages ? `${base}${path}` : path); @@ -80,22 +81,23 @@ export default defineConfig({ editLink: { baseUrl: 'https://github.com/invoke-ai/InvokeAI/edit/main/docs', }, - head: isGhPages - ? [ - { - tag: 'script', - attrs: { - async: true, - src: 'https://plausible.tracking.events/js/pa-BHcumuOemKz4XIQeWkTn4.js', + head: + enableAnalytics && !isGhPages + ? [ + { + tag: 'script', + attrs: { + async: true, + src: 'https://plausible.tracking.events/js/pa-BHcumuOemKz4XIQeWkTn4.js', + }, }, - }, - { - tag: 'script', - content: - 'window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)},plausible.init=plausible.init||function(i){plausible.o=i||{}};plausible.init()', - }, - ] - : [], + { + tag: 'script', + content: + 'window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)},plausible.init=plausible.init||function(i){plausible.o=i||{}};plausible.init()', + }, + ] + : [], defaultLocale: 'root', locales: { root: {