- Capture analytics from synthetic events and gather performance metrics
- Transform React components
Last active
December 28, 2015 20:32
-
-
Save jstrimpel/9e2a04622a1b015c8a26 to your computer and use it in GitHub Desktop.
babel analytics, performance plugins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"presets": ["es2015", "react"], | |
"plugins": ["analytics", "performance"] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Performance from 'performance'; | |
import Analytics from 'analytics'; | |
<Performance environment={{'ci'}}> | |
<Analytics> | |
<App /> | |
</Analytics> | |
</Performance> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from 'react'; | |
class Hello extends Component { | |
componentDidMount() { | |
console.log('component did mount'); | |
} | |
onClick(e) { | |
console.log(e); | |
} | |
render () { | |
return <div onClick={this.clickHandler}></div> | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from 'react'; | |
class Hello extends Component { | |
componentWillMount() { | |
if (this.context.performance && typeof this.context.performance === 'function') { | |
this.performance('component_will_mount'); | |
} | |
} | |
componentDidMount() { | |
if (this.context.performance && typeof this.context.performance === 'function') { | |
this.performance('component_did_mount'); | |
} | |
this._componentDidMount(); | |
} | |
_componentDidMount() { | |
console.log('component did mount'); | |
} | |
componentWillUnmount() { | |
if (this.context.performance && typeof this.context.performance === 'function') { | |
this.performance('component_will_unmount'); | |
} | |
this._componentDidMount(); | |
} | |
clickHandler(e) { | |
console.log(e); | |
} | |
_clickHandler(e) { | |
if (this.context.analytics && typeof this.context.analytics === 'function') { | |
this.context.analytics(e) | |
} | |
this.onClick(e); | |
} | |
render () { | |
return <div onClick={this._clickHandler}></div> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment