Closed chalofa closed 4 years ago
@DonSchado looks like you are pretty active with this Google Analytics tracker... if you can take a look at this PR, I would appreciate it...
probably way easier to see without all those whitespace changes: https://github.com/railslove/rack-tracker/pull/149/files?w=1
I don't get the diff... is this just a change of indentation? Or also a scope change?
I don't get the diff... is this just a change of indentation? Or also a scope change?
@DonSchado basically, wrap the whole <script>
tag inside the top if tracker
...
hm wasn't that already fixed here: https://github.com/railslove/rack-tracker/commit/f3d4e65dee9527136c7613940f5cee16fba91f88 ? Sorry I'm confused
hm wasn't that already fixed here: f3d4e65 ? Sorry I'm confused
@DonSchado nope, the indentation is totally messed up, see this image:
I added some indentation so it's easier to see the nested ifs, and move the whole template inside the if tracker
conditional, so if no tracker is defined, it won't render those events that are outside that conditional
Ah I see. Thanks for taking the time! Very appreciated :)
with Rails 6, in the system tests, I'm seeing all these Google Analytics extra events as page content:
Not exactly sure what Rails change caused this issue, but before Rails v6, the tests rendered those GA events as:
Rails 5.2:
(note the lack of the GA snippet, but at least, everything is wrapped in a
<script>
tagin Rails 6:
there's no
<script>
that wraps that JS code, and therefore, the browser just shows it as visible text...the change in this PR ensures that if there's no GA
tracker
, nothing will be rendered (which is the workaround that I'm using right now to avoid this: ensuringrack-tracker
is disabled for the test environment)