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

Reader: Add stats tracking with Tracks #1244

Merged
merged 3 commits into from
Dec 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/reader/comments/form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ var PostCommentForm = React.createClass( {

stats.recordAction( 'posted_comment' );
stats.recordGaEvent( 'Clicked Post Comment Button' );
stats.recordTrack( 'calypso_reader_article_commented_on' );

this.resetCommentText();

Expand Down
6 changes: 6 additions & 0 deletions client/reader/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function trackScrollPage( path, title, category, readerView, pageNum ) {
debug( 'scroll [%s], [%s], [%s], [%d]', path, title, category, pageNum );

analytics.ga.recordEvent( category, 'Loaded Next Page', 'page', pageNum );
analytics.tracks.recordEvent( 'calypso_reader_infinite_scroll_performed' );
analytics.pageView.record( path, title );
analytics.mc.bumpStat( {
newdash_pageviews: 'scroll',
Expand Down Expand Up @@ -137,6 +138,7 @@ module.exports = {
ensureStoreLoading( feedStore );

trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey );
analytics.tracks.recordEvent( 'calypso_reader_blog_preview' );

React.render(
React.createElement( FeedStream, {
Expand Down Expand Up @@ -169,6 +171,7 @@ module.exports = {
ensureStoreLoading( feedStore );

trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey );
analytics.tracks.recordEvent( 'calypso_reader_blog_preview' );

React.render(
React.createElement( SiteStream, {
Expand Down Expand Up @@ -282,6 +285,7 @@ module.exports = {
ensureStoreLoading( tagStore );

trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey );
analytics.tracks.recordEvent( 'calypso_reader_tag_loaded' );

React.render(
React.createElement( TagStream, {
Expand Down Expand Up @@ -313,6 +317,7 @@ module.exports = {
ensureStoreLoading( listStore );

trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey );
analytics.tracks.recordEvent( 'calypso_reader_list_loaded' );

React.render(
React.createElement( ListStream, {
Expand Down Expand Up @@ -521,6 +526,7 @@ module.exports = {
ensureStoreLoading( feedStore );

trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey );
analytics.tracks.recordEvent( 'calypso_reader_discover_viewed' );

React.render(
React.createElement( SiteStream, {
Expand Down
2 changes: 2 additions & 0 deletions client/reader/full-post/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ FullPostContainer = React.createClass( {
readerPageView( site.get( 'ID' ), site.get( 'URL' ), post.ID, site.get( 'is_private' ) );
this.hasSentPageView = true;
}

analytics.tracks.recordEvent( 'calypso_reader_article_opened' );
},

// Add change listeners to stores
Expand Down
1 change: 1 addition & 0 deletions client/reader/like-button/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var ReaderLikeButton = React.createClass( {
recordLikeToggle: function( liked ) {
stats.recordAction( liked ? 'liked_post' : 'unliked_post' );
stats.recordGaEvent( liked ? 'Clicked Like Post' : 'Clicked Unlike Post' );
stats.recordTrack( liked ? 'calypso_reader_article_liked' : 'calypso_reader_article_unliked' );
},

render: function() {
Expand Down
6 changes: 5 additions & 1 deletion client/reader/list-stream/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ var FollowingStream = require( 'reader/following-stream' ),
ReaderLists = require( 'lib/reader-lists/lists' ),
ReaderListActions = require( 'lib/reader-lists/actions' ),
ReaderListSubscriptions = require( 'lib/reader-lists/subscriptions' ),
StreamHeader = require( 'reader/stream-header' );
StreamHeader = require( 'reader/stream-header' ),
stats = require( 'reader/stats' );

var FeedStream = React.createClass( {

Expand Down Expand Up @@ -73,6 +74,9 @@ var FeedStream = React.createClass( {
toggleFollowing: function( isFollowing ) {
var list = ReaderLists.get( this.props.list.owner, this.props.list.slug );
ReaderListActions[ isFollowing ? 'follow' : 'unfollow' ]( list.owner, list.slug );
stats.recordAction( isFollowing ? 'followed_list' : 'unfollowed_list' );
stats.recordGaEvent( isFollowing ? 'Clicked Follow List' : 'Clicked Unfollow List', this.props.list.owner + ':' + this.props.list.slug );
stats.recordTrack( isFollowing ? 'calypso_reader_reader_list_followed' : 'calypso_reader_reader_list_unfollowed' );
},

render: function() {
Expand Down
13 changes: 7 additions & 6 deletions client/reader/sidebar/sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,13 @@ module.exports = React.createClass( {
event.preventDefault();
tag = React.findDOMNode( this.refs.addTagInput ).value;
subscription = Tags.getSubscription( TagActions.slugify( tag ) );
stats.recordAction( 'followed_topic' );
stats.recordGaEvent( 'Clicked Follow Topic', tag );
if ( subscription ) {
this.highlightNewTag( subscription );
} else {
TagActions.follow( tag );
stats.recordAction( 'followed_topic' );
stats.recordGaEvent( 'Clicked Follow Topic', tag );
stats.recordTrack( 'calypso_reader_reader_tag_followed' )
}
},

Expand Down Expand Up @@ -296,14 +297,14 @@ module.exports = React.createClass( {
}

{
config.isEnabled( 'reader/recommendations' ) ?
( <li className={ this.itemLinkClassStartsWithOneOf( [ '/recommendations', '/tags' ], { 'sidebar-streams__recommendations': true } ) }>
config.isEnabled( 'reader/recommendations' )
? ( <li className={ this.itemLinkClassStartsWithOneOf( [ '/recommendations', '/tags' ], { 'sidebar-streams__recommendations': true } ) }>
<a href="/recommendations">
<svg className="gridicon menu-link-icon" version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 24 24"><g><path d="M7.189,12.664l0.624-0.046l0.557-0.409l0.801-1.115l0.578-1.228l0.357-0.91l0.223-0.523l0.267-0.432 l0.49-0.409l0.578-0.5l0.445-0.682l0.267-1.046l0.29-1.934V3.159L12.931,3l0.467,0.046l0.534,0.227l0.49,0.363L14.8,4.25 l0.177,0.75V5.66l-0.088,0.865l-0.223,0.615l-0.378,0.75l-0.2,0.5l-0.246,0.546l-0.133,0.5v0.432l0.111,0.273l2.38-0.023 l1.135,0.069l0.823,0.113l0.49,0.159l0.288,0.319l0.424,0.523l0.156,0.454v0.319l-0.09,0.296l-0.2,0.227l-0.29,0.5l0.111,0.296 l0.223,0.409l0.201,0.204l0.111,0.364l-0.09,0.273l-0.267,0.296l-0.267,0.34l-0.111,0.364l0.088,0.319l0.157,0.363l0.11,0.342v0.25 l-0.11,0.363l-0.223,0.273l-0.313,0.296l-0.223,0.273l-0.088,0.273v0.319l0.023,0.409l-0.111,0.25l-0.313,0.342l-0.4,0.363 c0,0-0.156,0.137-0.378,0.25c-0.223,0.114-0.868,0.273-0.868,0.273l-0.846,0.091l-1.868-0.023l-1.937-0.091l-1.379-0.159 l-2.916-0.523L7.189,12.664z M3,13.986c0-0.939,0.761-1.7,1.702-1.7c0.939,0,1.702,0.762,1.702,1.7v4.596 c0,0.939-0.762,1.7-1.702,1.7C3.761,20.283,3,19.52,3,18.582V13.986z"/></g></svg>
<span className="menu-link-text">{ this.translate( 'Recommendations' ) }</span>
</a>
</li> ) :
( <li className={ this.itemLinkClass( '/recommendations', { 'sidebar-streams__recommendations': true } ) }>
</li> )
: ( <li className={ this.itemLinkClass( '/recommendations', { 'sidebar-streams__recommendations': true } ) }>
<a href="https://wordpress.com/recommendations/" rel="external">
<Gridicon icon="star-outline" />
<span className="menu-link-text">{ this.translate( 'Recommended Blogs' ) }</span>
Expand Down
8 changes: 7 additions & 1 deletion client/reader/stats.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mc, ga } from 'analytics';
import { mc, ga, tracks } from 'analytics';

export function recordAction( action ) {
mc.bumpStat( 'reader_actions', action );
Expand Down Expand Up @@ -53,8 +53,14 @@ function getLocation() {

export function recordFollow() {
mc.bumpStat( 'reader_follows', getLocation() );
tracks.recordEvent( 'calypso_reader_site_followed' );
}

export function recordUnfollow() {
mc.bumpStat( 'reader_unfollows', getLocation() );
tracks.recordEvent( 'calypso_reader_site_unfollowed' );
}

export function recordTrack( eventName, eventProperties ) {
tracks.recordEvent( eventName, eventProperties );
}
6 changes: 5 additions & 1 deletion client/reader/tag-stream/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ var FollowingStream = require( 'reader/following-stream' ),
ReaderTags = require( 'lib/reader-tags/tags' ),
ReaderTagActions = require( 'lib/reader-tags/actions' ),
TagSubscriptions = require( 'lib/reader-tags/subscriptions' ),
StreamHeader = require( 'reader/stream-header' );
StreamHeader = require( 'reader/stream-header' ),
stats = require( 'reader/stats' );

var FeedStream = React.createClass( {

Expand Down Expand Up @@ -64,6 +65,9 @@ var FeedStream = React.createClass( {
toggleFollowing: function( isFollowing ) {
var tag = ReaderTags.get( this.props.tag );
ReaderTagActions[ isFollowing ? 'follow' : 'unfollow' ]( tag );
stats.recordAction( isFollowing ? 'followed_topic' : 'unfollowed_topic' );
stats.recordGaEvent( isFollowing ? 'Clicked Follow Topic' : 'Clicked Unfollow Topic', tag );
stats.recordTrack( isFollowing ? 'calypso_reader_reader_tag_followed' : 'calypso_reader_reader_tag_unfollowed' );
},

render: function() {
Expand Down