Reworked inline tracking script so CSP doesn't block it on the checkout. #139
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.
See #119
On recent Magento versions with a strict CSP policy (which is the default) on checkout and in backoffice when creating orders, some inline javascript refuses to execute if it doesn't has a nonce assigned to it. This PR introduces that.
Further remarks:
tracking.phtmlandpowerstep_script.phtmlones here, as our shop only seems to load these file on the checkout and not the othersmasterbecause we needed a patch in our shop, but I see thistracking.phtmlfile has already changed on themasterbranch, so this will conflict. I'm not willing to spend more time into this at this point as this is highly complicatedSecureHtmlRendererclass was only introduced in Magento 2.4.0, so in case you guys still support older Magento shops you'll have to first check if that class exists before trying to use it and if the class doesn't exist, just output the script as-is.