-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[1.0] Fixes 1317 Google Analytics plugin; updates attachHistory listener logic #1318
Changes from 4 commits
bc505a6
eadbfb5
b4e2c8c
10e7cd3
ddccb5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[{*.json, *.svg}] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# Matches the exact package.json, or *rc | ||
[{package.json,*.yml,*rc}] | ||
indent_style = space | ||
indent_size = 2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
exports.onRouteUpdate = function(location) { | ||
exports.onRouteUpdate = function({ location }) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added destructuring, I guess I misread the plugin docs regarding the |
||
// Don't track while developing. | ||
if (process.env.NODE_ENV === `production`) { | ||
ga(`set`, `page`, location.pathname) | ||
ga(`set`, `page`, (location || {}).pathname) | ||
ga(`send`, `pageview`) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -77,11 +77,13 @@ window.___navigateTo = navigateTo | |||
const history = createHistory() | ||||
|
||||
function attachToHistory(history) { | ||||
window.___history = history | ||||
if(!window.___history) { | ||||
window.___history = history | ||||
|
||||
history.listen((location, action) => { | ||||
apiRunner(`onRouteUpdate`, { location, action }) | ||||
}) | ||||
history.listen((location, action) => { | ||||
apiRunner(`onRouteUpdate`, { location, action }) | ||||
}) | ||||
} | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated, also noticed that this same code exists within: gatsby/packages/gatsby/src/cache-dir/root.js Line 104 in 08bddd9
But the production-app.js file is the root cause There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, root.js is for the development version of Gatsby. It should be fixed too but since you're not generally tracking yourself in development it's not as urgent. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well I went ahead and adjusted it too! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perfect :-) Thanks! Pulling this in now! |
||||
} | ||||
|
||||
function shouldUpdateScroll(prevRouterProps, { location: { pathname } }) { | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah nice!