File size: 1,671 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
import i18n from 'i18n-calypso';
import moment from 'moment';
import { gaRecordEvent } from 'calypso/lib/analytics/ga';
import { bumpStat } from 'calypso/lib/analytics/mc';
import { recordPageView } from 'calypso/lib/analytics/page-view';
import { recordTrack } from 'calypso/reader/stats';
import { setDocumentHeadTitle as setTitle } from 'calypso/state/document-head/actions';
export function trackPageLoad( path, title, readerView ) {
recordPageView( path, title );
bumpStat( 'reader_views', readerView === 'full_post' ? readerView : readerView + '_load' );
}
export function getStartDate( context ) {
if ( context.query && context.query.at ) {
const startDate = moment( context.query.at );
return startDate.isValid() ? startDate.toISOString() : null;
}
return null;
}
export function trackScrollPage( path, title, category, readerView, pageNum ) {
gaRecordEvent( category, 'Loaded Next Page', 'page', pageNum );
recordTrack( 'calypso_reader_infinite_scroll_performed', {
path: path,
page: pageNum,
section: readerView,
} );
recordPageView( path, title );
bumpStat( 'reader_views', readerView + '_scroll' );
}
export function trackUpdatesLoaded( key ) {
bumpStat( 'reader_views', key + '_load_new' );
gaRecordEvent( 'Reader', 'Clicked Load New Posts', key );
recordTrack( 'calypso_reader_load_new_posts', {
section: key,
} );
}
export function setPageTitle( context, title ) {
// @todo Auto-converted from the setTitle action. Please use <DocumentHead> instead.
context.store.dispatch(
setTitle(
i18n.translate( '%s ‹ Reader', {
args: title,
comment: '%s is the section name. For example: "My Likes"',
} )
)
);
}
|