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

Track stats for automatic block conversion #2205

Merged
merged 14 commits into from Aug 4, 2017

Conversation

Projects
None yet
2 participants
@nylen
Member

nylen commented Aug 3, 2017

Follow-up to #2135. That PR uses a technique which we should probably try to avoid unless absolutely necessary: transparently converting one block type into another when loading a post.

Let's track how often this happens to get more understanding of how it behaves in real-world usage.

This requires moving stat tracking out of the editor module and into the utils module because otherwise this change would create a circular dependency (blocks → editor → blocks). See previous discussion at #2140 (comment).

Show outdated Hide outdated webpack.config.js
'utils',
'components',

This comment has been minimized.

@nylen

nylen Aug 3, 2017

Member

blocks now depends on utils, so utils should be loaded first. Output from the script at #965:

'blocks' depends on 'components'
'blocks' depends on 'element'
'blocks' depends on 'i18n'
'blocks' depends on 'utils'
'components' depends on 'element'
'components' depends on 'i18n'
'components' depends on 'utils'
'editor' depends on 'blocks'
'editor' depends on 'components'
'editor' depends on 'date'
'editor' depends on 'element'
'editor' depends on 'i18n'
'editor' depends on 'utils'

Suggested load order:

element
i18n
utils
components
blocks
date
editor
@nylen

nylen Aug 3, 2017

Member

blocks now depends on utils, so utils should be loaded first. Output from the script at #965:

'blocks' depends on 'components'
'blocks' depends on 'element'
'blocks' depends on 'i18n'
'blocks' depends on 'utils'
'components' depends on 'element'
'components' depends on 'i18n'
'components' depends on 'utils'
'editor' depends on 'blocks'
'editor' depends on 'components'
'editor' depends on 'date'
'editor' depends on 'element'
'editor' depends on 'i18n'
'editor' depends on 'utils'

Suggested load order:

element
i18n
utils
components
blocks
date
editor

This comment has been minimized.

@youknowriad

youknowriad Aug 4, 2017

Contributor

I think the order is defined by the dependencies definition in the PHP side, isn't it?

@youknowriad

youknowriad Aug 4, 2017

Contributor

I think the order is defined by the dependencies definition in the PHP side, isn't it?

This comment has been minimized.

@nylen

nylen Aug 4, 2017

Member

At one point, this was important to get right in the webpack config because otherwise it would break the test build. It seems this is no longer the case since we moved to Jest. I'll update accordingly.

@nylen

nylen Aug 4, 2017

Member

At one point, this was important to get right in the webpack config because otherwise it would break the test build. It seems this is no longer the case since we moved to Jest. I'll update accordingly.

Show outdated Hide outdated editor/enable-tracking-prompt/index.js
return {
bumpStat,
};
},

This comment has been minimized.

@nylen

nylen Aug 4, 2017

Member

This needs a better solution (probably a higher-order component), but it was the easiest way I could think of to allow mocking the bumpStat function.

@nylen

nylen Aug 4, 2017

Member

This needs a better solution (probably a higher-order component), but it was the easiest way I could think of to allow mocking the bumpStat function.

This comment has been minimized.

@youknowriad

youknowriad Aug 4, 2017

Contributor

Can't we use jest.mock? this feels weird.

@youknowriad

youknowriad Aug 4, 2017

Contributor

Can't we use jest.mock? this feels weird.

This comment has been minimized.

@nylen

nylen Aug 4, 2017

Member

Well, so does jest.mock 😄

I'll try it again though.

@nylen

nylen Aug 4, 2017

Member

Well, so does jest.mock 😄

I'll try it again though.

@codecov

This comment has been minimized.

Show comment
Hide comment
@codecov

codecov bot Aug 4, 2017

Codecov Report

Merging #2205 into master will increase coverage by 0.4%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #2205     +/-   ##
=========================================
+ Coverage   23.83%   24.24%   +0.4%     
=========================================
  Files         142      142             
  Lines        4459     4459             
  Branches      756      756             
=========================================
+ Hits         1063     1081     +18     
+ Misses       2866     2853     -13     
+ Partials      530      525      -5
Impacted Files Coverage Δ
components/button/index.js 90.9% <ø> (ø) ⬆️
editor/enable-tracking-prompt/index.js 100% <ø> (+12.5%) ⬆️
utils/tracking.js 91.3% <ø> (ø)
editor/modes/visual-editor/block-list.js 0% <0%> (ø) ⬆️
editor/inserter/index.js 0% <0%> (ø) ⬆️
blocks/api/parser.js 100% <100%> (ø) ⬆️
components/popover/index.js 65.21% <0%> (+65.21%) ⬆️

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 87e46bd...be220b6. Read the comment docs.

codecov bot commented Aug 4, 2017

Codecov Report

Merging #2205 into master will increase coverage by 0.4%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #2205     +/-   ##
=========================================
+ Coverage   23.83%   24.24%   +0.4%     
=========================================
  Files         142      142             
  Lines        4459     4459             
  Branches      756      756             
=========================================
+ Hits         1063     1081     +18     
+ Misses       2866     2853     -13     
+ Partials      530      525      -5
Impacted Files Coverage Δ
components/button/index.js 90.9% <ø> (ø) ⬆️
editor/enable-tracking-prompt/index.js 100% <ø> (+12.5%) ⬆️
utils/tracking.js 91.3% <ø> (ø)
editor/modes/visual-editor/block-list.js 0% <0%> (ø) ⬆️
editor/inserter/index.js 0% <0%> (ø) ⬆️
blocks/api/parser.js 100% <100%> (ø) ⬆️
components/popover/index.js 65.21% <0%> (+65.21%) ⬆️

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 87e46bd...be220b6. Read the comment docs.

@nylen

This comment has been minimized.

Show comment
Hide comment
@nylen

nylen Aug 4, 2017

Member

@youknowriad you can see my attempts above at getting Jest mocking to work for testing the call to bumpStat here. It didn't go well - Jest mocks are almost undocumented and I couldn't get it to work. Let's just save that for another day.

Maybe we should switch to refx for analytics: components dispatch a BUMP_STAT action, and this action has an effect of bumping the given stat.

Member

nylen commented Aug 4, 2017

@youknowriad you can see my attempts above at getting Jest mocking to work for testing the call to bumpStat here. It didn't go well - Jest mocks are almost undocumented and I couldn't get it to work. Let's just save that for another day.

Maybe we should switch to refx for analytics: components dispatch a BUMP_STAT action, and this action has an effect of bumping the given stat.

tracking.bumpStat = jest.fn();
document.addEventListener = jest.fn( ( event, cb ) => {
eventMap[ event ] = cb;
} );

This comment has been minimized.

@nylen

nylen Aug 4, 2017

Member

This approach is from airbnb/enzyme#426 (comment).

@nylen

nylen Aug 4, 2017

Member

This approach is from airbnb/enzyme#426 (comment).

@nylen nylen merged commit d482b4f into master Aug 4, 2017

3 checks passed

codecov/project 24.24% (+0.4%) compared to 87e46bd
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@nylen nylen deleted the update/track-auto-converted-blocks branch Aug 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment