Skip to content

Commit 682d9d5

Browse files
committed
1.3.0 - Support for timings
1 parent 45c3a05 commit 682d9d5

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@ const myRoute = {
127127
*/
128128
```
129129

130+
### trackTiming (timingCategory, timingVar, timingValue, timingLabel = null)
131+
```javascript
132+
/**
133+
* Track an user timing to measure periods of time.
134+
*
135+
* @param {string} timingCategory - A string for categorizing all user timing variables into logical groups (e.g. 'JS Dependencies').
136+
* @param {string} timingVar - A string to identify the variable being recorded (e.g. 'load').
137+
* @param {number} timingValue - The number of milliseconds in elapsed time to report to Google Analytics (e.g. 20).
138+
* @param {string|null} timingLabel - A string that can be used to add flexibility in visualizing user timings in the reports (e.g. 'Google CDN').
139+
*/
140+
```
130141
### injectGlobalDimension (dimensionNumber, value)
131142
```javascript
132143
/**

dist/vue-analytics.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-ua",
3-
"version": "1.2.3",
3+
"version": "1.3.0",
44
"description": "Help for Google Universal Analytics in Vue application",
55
"main": "./dist/vue-analytics.min.js",
66
"author": "Andréas \"ScreamZ\" Hanss",

src/AnalyticsPlugin.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)