Skip to content

Fix incomplete ALLURE_NO_ANALYTICS opt-out in report html template#3332

Merged
baev merged 2 commits into
allure-framework:mainfrom
grootstebozewolf:fix/analytics-opt-out-html-template
May 11, 2026
Merged

Fix incomplete ALLURE_NO_ANALYTICS opt-out in report html template#3332
baev merged 2 commits into
allure-framework:mainfrom
grootstebozewolf:fix/analytics-opt-out-html-template

Conversation

@grootstebozewolf
Copy link
Copy Markdown
Contributor

@grootstebozewolf grootstebozewolf commented May 10, 2026

Context

The <#if analyticsDisable == false> guard in allure-generator/src/main/resources/tpl/index.html.ftl only wrapped the external gtag.js <script> tag. The inline block that calls

gtag('config', 'G-FVWC4GKEYS', { allureVersion, reportUuid, single_file })

ran unconditionally — even when the user had set ALLURE_NO_ANALYTICS=1. Without gtag.js loaded the data goes nowhere, so user-visible behavior didn't change, but the opt-out leaked report metadata into a window.dataLayer that any co-located script (a future plugin, an embed, a downstream HTML processor) could read, and it left a global gtag() function defined on the disabled path.

This PR extends the guard to wrap both scripts so ALLURE_NO_ANALYTICS removes the entire analytics surface from the rendered report.

While here, ReportWebGeneratorTest#shouldDisableAnalytics is strengthened to also assert the measurement id (G-FVWC4GKEYS) and dataLayer are absent from the generated HTML. The previous single-string check on googletagmanager would have passed even with the leak, which is why the gap went unnoticed.

Checklist

The <#if analyticsDisable == false> guard in index.html.ftl wrapped
only the external gtag.js <script> tag. The inline block that calls
gtag('config', 'G-FVWC4GKEYS', { allureVersion, reportUuid, single_file })
ran unconditionally, populating window.dataLayer and defining the
gtag() function even when analytics were disabled via
ALLURE_NO_ANALYTICS.

With gtag.js absent the data went nowhere, so behavior was harmless,
but the opt-out leaked report metadata into a dataLayer that any
co-located script could read. Extend the guard to wrap both scripts
so ALLURE_NO_ANALYTICS removes the entire analytics surface from the
rendered report.

Strengthen ReportWebGeneratorTest#shouldDisableAnalytics to also
assert the measurement id and dataLayer are absent, which the
previous googletagmanager-only check did not catch.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@baev baev added the type:improvement Change that improves some user experience but can't be considered as a new feature label May 11, 2026
@grootstebozewolf grootstebozewolf requested a review from baev May 11, 2026 09:54
@baev baev merged commit ab5da57 into allure-framework:main May 11, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme:generator type:improvement Change that improves some user experience but can't be considered as a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants