Slide 1

Slide 1 text

Thinking metrics on
 React apps @jcemer

Slide 2

Slide 2 text

I work on GloboPlay.
 globo.com

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

React Router 2.0 & Server side render & Client side user login

Slide 6

Slide 6 text

1. How can we 
 track our traffic with Google Analytics?

Slide 7

Slide 7 text

Slide 8

Slide 8 text

@PureRender class PageView extends Component { static propTypes = { location: PropTypes.object.isRequired } componentDidMount() { const { action, state } = this.props.location trackPageView(action, state) } componentDidUpdate() { /* */ } }

Slide 9

Slide 9 text

2. How can we 
 analyse custom data?

Slide 10

Slide 10 text

Global metrics data:
 user account info & app version

Slide 11

Slide 11 text

Slide 12

Slide 12 text

function handleStateChangeOnClient(vars) { setMetricsDataLayer(vars) } export default withSideEffect( reducePropsToState, handleStateChangeOnClient )(DocumentMetrics) https://github.com/ gaearon/react-side-effect

Slide 13

Slide 13 text

3. How can we track the user navigation flow?

Slide 14

Slide 14 text

Playlist Recommendation

Slide 15

Slide 15 text

Component metrics:
 playlist or
 other lists

Slide 16

Slide 16 text

is a list of is a list of

Slide 17

Slide 17 text

is a list of is a list of

Slide 18

Slide 18 text

https://facebook.github.io/ react/docs/context.html

Slide 19

Slide 19 text

class Video extends Component { static contextTypes = { linkMetrics: PropTypes.object } render() { const state = { metrics: this.context.linkMetrics } return /* ... */ } }

Slide 20

Slide 20 text

* redux should be 
 an option too

Slide 21

Slide 21 text

Components React side effect Context

Slide 22

Slide 22 text

Thank you! @jcemer