-
Notifications
You must be signed in to change notification settings - Fork 1
Simplified version that doesn't break the deploy. #215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
35f9c74
Simplified version that doesn't break the deploy.
f616620
Fix SonarQube issues.
755cd17
Implement CodeRabbit suggestions.
914f42d
Fix dependencies from @apostrophecms/seo that we don't need.
06d8735
Implement CodeRabbit suggestions: 2nd round.
c0b222d
Fix local errors.
000de2d
Implement CodeRabbit suggestions: 3nd round.
afccd0a
Merge branch 'main' into 409-feature/integrate-gtm-bug-fix
killev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| const sanitizeGtmId = function (id) { | ||
| const value = String(id || '') | ||
| .trim() | ||
| .toUpperCase(); | ||
| // Strict GTM container format, e.g., "GTM-XXXXXXX" | ||
| if (/^GTM-[\dA-Z]+$/u.test(value)) { | ||
| return value; | ||
| } | ||
| return ''; | ||
| }; | ||
|
|
||
| const resolveGtmId = function (req, options) { | ||
| const fromGlobal = req?.data?.global?.seoGoogleTagManager; | ||
| const fromOptions = options?.googleTagManager?.id; | ||
| const candidate = | ||
| (fromGlobal && String(fromGlobal).trim()) || | ||
| (fromOptions && String(fromOptions).trim()); | ||
| return sanitizeGtmId(candidate); | ||
| }; | ||
|
|
||
| module.exports = { sanitizeGtmId, resolveGtmId }; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <!-- Google Tag Manager (noscript) --> | ||
| <noscript><iframe src="https://www.googletagmanager.com/ns.html?id={{ data.gtmId }}" | ||
| height="0" width="0" style="display:none;visibility:hidden" title="Google Tag Manager"></iframe></noscript> | ||
| <!-- End Google Tag Manager (noscript) --> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <!-- Google Tag Manager --> | ||
| <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': | ||
| new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], | ||
| j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= | ||
| 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); | ||
| })(window,document,'script','dataLayer','{{ data.gtmId }}');</script> | ||
| <!-- End Google Tag Manager --> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,3 @@ | ||
| {% if data.gtmId %} | ||
| <!-- Google Tag Manager (noscript) --> | ||
| <noscript><iframe src="https://www.googletagmanager.com/ns.html?id={{ data.gtmId }}" | ||
| height="0" width="0" style="display:none;visibility:hidden" title="Google Tag Manager"></iframe></noscript> | ||
| <!-- End Google Tag Manager (noscript) --> | ||
| {% render '@apostrophecms/seo:gtmBody', data %} | ||
| {% endif %} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,3 @@ | ||
| {% if data.gtmId %} | ||
| <!-- Google Tag Manager --> | ||
| <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': | ||
| new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], | ||
| j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= | ||
| 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); | ||
| })(window,document,'script','dataLayer','{{ data.gtmId }}');</script> | ||
| <!-- End Google Tag Manager --> | ||
| {% render '@apostrophecms/seo:gtmHead', data %} | ||
| {% endif %} |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.