-
Notifications
You must be signed in to change notification settings - Fork 337
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
re-add segment metadata fix #1086 fix #1047 #1088
Conversation
# Conflicts: # src/universal/components/SocketRoute/SocketRoute.js # src/universal/modules/userDashboard/components/UserDashboard/UserDashboard.js # yarn.lock fix Draft.css import
# Conflicts: # src/universal/components/SocketRoute/SocketRoute.js # src/universal/modules/userDashboard/components/UserDashboard/UserDashboard.js # yarn.lock fix Draft.css import
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.
Looks great. I suggested a variable name change, but other than that, the code changes look great. Going to run systems tests now...
<AsyncRoute | ||
mod={() => System.import('universal/components/NotFound/NotFound')} | ||
/> | ||
<AsyncRoute isPrivate path="(/me|/meeting|/newteam|/team)" mod={socketRoute} /> |
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.
This looks so ✨ clean and shiny✨ !
|
||
AsyncRoute.propTypes = { | ||
bottom: PropTypes.bool, |
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.
I'm racking my brain to think of a more descriptive name than bottom. Something that wraps the context that "I'm involved in routing" while still being descriptive. Perhaps, leafRoute
would be better?
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.
yeah, i like that.
alternatively, since we have more leaves than not, should we have an isAbstract
on everything that isn't a leaf?
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.
Yeah, I like isAbstract
. That's cool.
I'd suggest at this line it be:
isAbstractRoute={isAbstract}
so it's clearer in bundle Bundle
just what that prop is from.
*/ | ||
updateAnalyticsPage(dispatch, lastPage, nextPage); | ||
} | ||
componentWillReceiveProps() { |
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.
Can you tell me a bit more about this? Why do this instead of setState, for example?
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, I see:
finally, this creates a previousLocation singleton that is passed in as context in ActionContainer. This is necessary because segment wants to know the referrer AND the params. Params are not established until it hits the bottom of the routing tree. sending them back to the top a la redux would not work because that would cause a new render cycle, which means lastPage == nextPage. So, sending down the lastPage (now called lastPath since it is a pathname) is necessary.
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.
This should probably be a comment in the code itself
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.
yeah, big gotcha on moving the global from the router (v3) to the context (v4).
Test Cycle TemplateIt:
|
Test Cycle 1It:
|
I'm seeing a few things to look into:
|
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.
Two things to look into:
-
Check why production builds are failing with
Draft.css
file inProjectEditor
-
Redeploy to
development
branch and check segment performance using Segment's debug console
Then, I'll retest!
@@ -11,6 +11,7 @@ import withKeyboardShortcuts from './withKeyboardShortcuts'; | |||
import withLinks from './withLinks'; | |||
import withSuggestions from './withSuggestions'; | |||
import entitizeText from 'universal/utils/draftjs/entitizeText'; | |||
import './Draft.css'; |
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.
This css file fails a production build. See: https://circleci.com/gh/ParabolInc/action/2904
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.
oh silly me i bet i didn't add it to the prod webpack config
change !bottom to isAbstract for routes add comment explaining previousLocation context
Test Cycle 2It:
|
Ok, we're getting real close now. When you look at the segment event feed, the page title within the segment is for the previous page event. |
Ah shit, I'm guess it's related to this old comment of mine: https://github.com/ParabolInc/action/pull/1088/files#diff-8593bb6594d23b08eb1eb9045737df40L48 |
this.loadMod(nextProps); | ||
} | ||
if (!isAbstractRoute) { |
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.
Can this safely be refactored into cDU @mattkrick?
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.
doh! i'm not grabbing it from context here...
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.
er wait...that's right... hmmm why does moving it to cDU help?
Yeah, you were right that wrapping helmet was the only logical way forward. We still have to call requestIdleCallback to ensure that the children render (and thus change the title) but now title changes happen in sync when the children render. Overall not too ugly |
Test Cycle 3It:
|
Test Cycle 4It:
|
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.
Ok, I caught one little buggy where the name
parameter was being passed as undefined
. Fixed it, and now the code looks GTG.
exact={exact} path={path} | ||
render={({history, location, match}) => ( | ||
<Bundle | ||
isAbstractRoute={isAbstract} |
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.
👍
Tests passed! |
test:
First, this solves #1047 by reusing the same function instead of creating a new function inside the render cycle.
Next, this replaces the internal
extra
withextraProps
. withextra
, we assumed that the props that react-router gave our async route would not change throughout versions. that's not right. now, react-router can continue to add fields & we don't need to worry about them since our props are passed through explicitly.Then, we add a
bottom
param toAsyncRoute
that is a flag to signify that there are no more abstract routes below that one.finally, this creates a
previousLocation
singleton that is passed in as context in ActionContainer. This is necessary because segment wants to know the referrer AND the params. Params are not established until it hits the bottom of the routing tree. sending them back to the top a la redux would not work because that would cause a new render cycle, which means lastPage == nextPage. So, sending down the lastPage (now called lastPath since it is a pathname) is necessary.