@@ -21,7 +21,7 @@ export default class AnalyticsPlugin {
2121 */
2222 trackEvent ( category , action = null , label = null , value = null ) {
2323 // TODO : FieldObject is full syntax, refactor this at one moment
24- logDebug ( 'Dispatching event' , { category, action, label, value} )
24+ logDebug ( 'Dispatching event' , { category, action, label, value } )
2525
2626 ga ( 'send' , 'event' , category , action , label , value )
2727 }
@@ -36,6 +36,29 @@ export default class AnalyticsPlugin {
3636 ga ( 'send' , 'exception' , { 'exDescription' : description , 'exFatal' : isFatal } ) ;
3737 }
3838
39+ /**
40+ * Track an user timing to measure periods of time.
41+ *
42+ * @param {string } timingCategory - A string for categorizing all user timing variables into logical groups (e.g. 'JS Dependencies').
43+ * @param {string } timingVar - A string to identify the variable being recorded (e.g. 'load').
44+ * @param {number } timingValue - The number of milliseconds in elapsed time to report to Google Analytics (e.g. 20).
45+ * @param {string|null } timingLabel - A string that can be used to add flexibility in visualizing user timings in the reports (e.g. 'Google CDN').
46+ */
47+ trackTiming ( timingCategory , timingVar , timingValue , timingLabel = null ) {
48+ let conf = {
49+ hitType : 'timing' ,
50+ timingCategory,
51+ timingVar,
52+ timingValue
53+ }
54+ if ( timingLabel ) {
55+ conf . timingLabel = timingLabel ;
56+ }
57+
58+ logDebug ( 'Dispatching timing' , conf )
59+ ga ( 'send' , conf ) ;
60+ }
61+
3962 /**
4063 * Inject a new GlobalDimension that will be sent every time.
4164 *
0 commit comments