Skip to content
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

Merged
merged 14 commits into from
Jun 29, 2017
Merged

re-add segment metadata fix #1086 fix #1047 #1088

merged 14 commits into from
Jun 29, 2017

Conversation

mattkrick
Copy link
Member

@mattkrick mattkrick commented Jun 17, 2017

test:

  • check the sent packets & make sure the call to segment is getting there with all the data (namely params)
  • make sure title is correct after a refresh (ie hit refresh on /me)
  • make sure title is correct after updating a component (ie click between teams)

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 with extraProps. with extra, 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 to AsyncRoute 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.

@codecov
Copy link

codecov bot commented Jun 17, 2017

Codecov Report

Merging #1088 into master will increase coverage by 11.86%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #1088       +/-   ##
==========================================
+ Coverage   45.13%     57%   +11.86%     
==========================================
  Files         173     130       -43     
  Lines        2612    1807      -805     
  Branches      408     250      -158     
==========================================
- Hits         1179    1030      -149     
+ Misses       1169     653      -516     
+ Partials      264     124      -140
Impacted Files Coverage Δ
src/universal/styles/withStyles.js 20% <0%> (-35%) ⬇️
src/universal/components/Button/Button.js
.../universal/decorators/boundedModal/boundedModal.js
src/universal/utils/getDraftCoords.js
src/universal/styles/helpers/cardRootStyles.js
...rsal/components/ProjectEditor/getAnchorLocation.js
src/universal/utils/draftjs/splitBlock.js
...versal/components/ProjectEditor/withSuggestions.js
...versal/components/MentionBase/mentionBaseStyles.js
src/universal/components/Avatar/Avatar.js
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 80797c4...1173540. Read the comment docs.

# Conflicts:
#	src/universal/components/SocketRoute/SocketRoute.js
#	src/universal/modules/userDashboard/components/UserDashboard/UserDashboard.js
#	yarn.lock

fix Draft.css import
@mattkrick mattkrick changed the title fix #1086 fix #1047 without sCU fix #1086 fix #1047 without sCU [merge after Draftjs] Jun 19, 2017
# Conflicts:
#	src/universal/components/SocketRoute/SocketRoute.js
#	src/universal/modules/userDashboard/components/UserDashboard/UserDashboard.js
#	yarn.lock

fix Draft.css import
@mattkrick mattkrick changed the base branch from master to staging June 27, 2017 00:29
@mattkrick mattkrick changed the base branch from staging to master June 27, 2017 00:29
@mattkrick mattkrick changed the title fix #1086 fix #1047 without sCU [merge after Draftjs] re-add segment metadata fix #1086 fix #1047 Jun 27, 2017
jordanh
jordanh previously approved these changes Jun 27, 2017
Copy link
Contributor

@jordanh jordanh left a 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} />
Copy link
Contributor

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,
Copy link
Contributor

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?

Copy link
Member Author

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?

Copy link
Contributor

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() {
Copy link
Contributor

@jordanh jordanh Jun 27, 2017

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?

Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Member Author

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).

@jordanh
Copy link
Contributor

jordanh commented Jun 27, 2017

Test Cycle Template

It:

  • sends a page event navigating from My Dashboard to a team
  • sends a page event navigating from a team to that team's settings
  • sends a page event navigating from Team Settings to My Dashboard
  • sends a page events for all steps in a meeting

@jordanh
Copy link
Contributor

jordanh commented Jun 27, 2017

Test Cycle 1

It:

  • sends a page event navigating from My Dashboard to a team
  • sends a page event navigating from a team to that team's settings
  • sends a page event navigating from Team Settings to My Dashboard
  • sends a page events for all steps in a meeting

@jordanh
Copy link
Contributor

jordanh commented Jun 27, 2017

I'm seeing a few things to look into:

  • The sidebar state doesn't update correctly when I am navigated on a Team Dashboard and I then navigate to My Dashboard

  • Not all dispatched segmentEventPage events are making it up to segment (I'll look into this one)...

@jordanh jordanh dismissed their stale review June 27, 2017 20:16

About to make new review

Copy link
Contributor

@jordanh jordanh left a 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:

  1. Check why production builds are failing with Draft.css file in ProjectEditor

  2. 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';
Copy link
Contributor

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

Copy link
Member Author

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
@jordanh
Copy link
Contributor

jordanh commented Jun 27, 2017

Test Cycle 2

It:

  • sends a page event navigating from My Dashboard to a team
  • sends a page event navigating from a team to that team's settings
  • sends a page event navigating from Team Settings to My Dashboard
  • sends a page events for all steps in a meeting

@jordanh
Copy link
Contributor

jordanh commented Jun 27, 2017

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.

@jordanh
Copy link
Contributor

jordanh commented Jun 27, 2017

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) {
Copy link
Contributor

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?

Copy link
Member Author

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...

Copy link
Member Author

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?

@mattkrick
Copy link
Member Author

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

@jordanh
Copy link
Contributor

jordanh commented Jun 29, 2017

Test Cycle 3

It:

  • sends a page event navigating from My Dashboard to a team
  • sends a page event navigating from a team to that team's settings
  • sends a page event navigating from Team Settings to My Dashboard
  • sends a page events for all steps in a meeting

@jordanh
Copy link
Contributor

jordanh commented Jun 29, 2017

Test Cycle 4

It:

  • sends a page event navigating from My Dashboard to a team
  • sends a page event navigating from a team to that team's settings
  • sends a page event navigating from Team Settings to My Dashboard
  • sends a page events for all steps in a meeting

Copy link
Contributor

@jordanh jordanh left a 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}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jordanh
Copy link
Contributor

jordanh commented Jun 29, 2017

Tests passed!

@jordanh jordanh merged commit 662a6d3 into master Jun 29, 2017
@jordanh jordanh deleted the segment-hotfix branch June 29, 2017 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants