Closed yom-ko closed 6 years ago
While looking through the GA docs on IP Anonymization the bundled output when 'anonymizeIp': true
should be ga('set', 'anonymizeIp', true)
.
After looking through with @m-allanson, the bug looks most likely in: https://github.com/gatsbyjs/gatsby/blob/bf3208ddc02c240302fff5b112343d715c69a0ca/packages/gatsby-plugin-google-analytics/src/gatsby-ssr.js#L47-L53 Placing more emphasis on the condition and return statements in the ternary operator.
Could you send in a PR @yom-ko ?
Sorry for the late response. Yeah, I will try to make and send a proper PR.
Description
In gatsby-config.js, in the plugin options, when anonymize option is explicitly set to
false
, ie:the following code is added to the bundled analytics snippet:
ga('set', 'anonymizeIp', 1);
I guess, in this case, there should not be any code setting the anonymizeIp feature at all in the bundled snippet. Moreover, as far as I know, the
1
value can be potentially interpreted astrue
, which would enable the IP anonymization (instead of disabling it).Steps to reproduce
anonymize: false
gatsby build
/yarn build
command.Expected result
The source code would have the GA snippet with no mention of the anonymizeIp feature.
Actual result
The source code will have the GA snippet with
ga('set', 'anonymizeIp', 1);
statement.Environment
System: OS: Windows 10 CPU: x64 Intel(R) Core(TM) i5 CPU M 560 @ 2.67GHz Binaries: Yarn: 1.7.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.1.0 - C:\Program Files\nodejs\npm.CMD
File contents (if changed)
gatsby-config.js
:package.json
:gatsby-node.js
:gatsby-browser.js
: N/Agatsby-ssr.js
: N/A