Skip to content

Commit

Permalink
Merge pull request Automattic#13382 from Automattic/add/reader/tag-ev…
Browse files Browse the repository at this point in the history
…entprops-on-tag-stream

Reader Analytics: Add eventprop `tag` for Tag stream events
  • Loading branch information
aaronyan authored Apr 28, 2017
2 parents aaa0103 + c41ecac commit c4e5e9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions client/reader/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ export function recordTrack( eventName, eventProperties ) {
eventProperties = Object.assign( { subscription_count: subCount }, eventProperties );
}

if ( location === 'topic_page' && ! eventProperties.hasOwnProperty( 'tag' ) ) {
const tag = decodeURIComponent( window.location.pathname.split( '/tag/' ).pop() );
eventProperties = Object.assign( { tag: tag }, eventProperties );
}

if ( process.env.NODE_ENV !== 'production' ) {
if ( 'blog_id' in eventProperties && 'post_id' in eventProperties && ! ( 'is_jetpack' in eventProperties ) ) {
console.warn( 'consider using recordTrackForPost...', eventName, eventProperties ); //eslint-disable-line no-console
Expand Down
6 changes: 3 additions & 3 deletions client/reader/tag-stream/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ const TagStream = React.createClass( {
},

toggleFollowing() {
const { tag, decodedTag, unfollowTag, followTag } = this.props;
const { decodedTag, unfollowTag, followTag } = this.props;
const isFollowing = this.isSubscribed(); // this is the current state, not the new state
const toggleAction = isFollowing ? unfollowTag : followTag;
toggleAction( decodedTag );
recordAction( isFollowing ? 'unfollowed_topic' : 'followed_topic' );
recordGaEvent( isFollowing ? 'Clicked Unfollow Topic' : 'Clicked Follow Topic', tag );
recordGaEvent( isFollowing ? 'Clicked Unfollow Topic' : 'Clicked Follow Topic', decodedTag );
recordTrack( isFollowing ? 'calypso_reader_reader_tag_unfollowed' : 'calypso_reader_reader_tag_followed', {
tag
tag: decodedTag
} );
},

Expand Down

0 comments on commit c4e5e9b

Please sign in to comment.