[1.12] Channel-aware GTM (backport of #152) - #153
Draft
gabiudrescu wants to merge 3 commits into
Draft
Conversation
Backport of feature/channel-aware-gtm (Sylius 2.x) to the 1.x line. - Configuration: optional gtm.channels.<code> with per-channel id, enabled toggle, and per-feature overrides - ChannelFeatureResolver: runtime per-feature gate via ChannelContext - ChannelGtmListener: kernel.request → setId/enable/disable on the GoogleTagManager service for the resolved channel - Existing listeners (Environment/AddRoute/Context) take resolver as optional last constructor arg — BC-safe - Twig: gtm_channel_allows() function and inline gate on events_javascript.html.twig (no Twig Hooks in 1.x — the existing Sonata block event listener keeps the template hookable) Existing setups behave identically — no config change required. CI: tolerate vestigial cert/webserver/DB steps; add --no-security-blocking for composer install since 1.12 transitive deps carry advisories already accepted in production shops. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
PHPUnit mock returned false for un-stubbed isMasterRequest() on Symfony 5.x RequestEvent (where the method still exists), causing the listeners to bail out early under tests. Prefer isMainRequest when available and fall back to isMasterRequest otherwise — single call, single check, behaves correctly across SF 5.2/5.4/6.x. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The isMasterRequest ignore is only needed on Symfony 6 (where the method is removed); on SF 5 the method exists so the ignore is unused and the strict reporter fails the build. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sylius 1.12 backport of the 2.x proposal in #152 — opening as a parallel draft so the 1.x line isn't left behind. Happy to redirect on shape.
What it does
Same surface as #152: optional
gtm.channels.<code>with per-channelid,enabled, and per-feature overrides. Resolved atkernel.requestvia Sylius'sChannelContextInterface. Existing setups behave identically.1.x-specific adjustments
gtm_channel_allows()Twig function; existing Sonata block event listener keeps the template hookable.src/Resources/config/*.ymllayout (notconfig/*.yaml).isMainRequest, falls back toisMasterRequest(SF 5.2 → 6.x).reportUnmatchedIgnoredErrors: falseso the SF6-only isMasterRequest ignore doesn't fail SF5 jobs; vestigial cert/webserver/DB steps markedcontinue-on-error;--no-security-blockingon composer install (1.12 transitive deps carry advisories already accepted in production shops).Tests / CI
4/4 matrix jobs green on the fork (PHP 8.0/8.1 × SF ^5.2/^6.0, Sylius ~1.12.0).
Why a separate 1.x PR
Our production shop is on 1.12 and we'd value having this available on both lines. If only the 2.x version (#152) makes sense to you, we'll maintain the fork — no pressure.
cc @lchrusciel (Commerce Weavers) for visibility.