Skip to content

Commit

Permalink
1.3.0 - Support for timings
Browse files Browse the repository at this point in the history
  • Loading branch information
ScreamZ committed Mar 15, 2017
1 parent 45c3a05 commit 682d9d5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@ const myRoute = {
*/
```

### trackTiming (timingCategory, timingVar, timingValue, timingLabel = null)
```javascript
/**
* Track an user timing to measure periods of time.
*
* @param {string} timingCategory - A string for categorizing all user timing variables into logical groups (e.g. 'JS Dependencies').
* @param {string} timingVar - A string to identify the variable being recorded (e.g. 'load').
* @param {number} timingValue - The number of milliseconds in elapsed time to report to Google Analytics (e.g. 20).
* @param {string|null} timingLabel - A string that can be used to add flexibility in visualizing user timings in the reports (e.g. 'Google CDN').
*/
```
### injectGlobalDimension (dimensionNumber, value)
```javascript
/**
Expand Down
2 changes: 1 addition & 1 deletion dist/vue-analytics.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-ua",
"version": "1.2.3",
"version": "1.3.0",
"description": "Help for Google Universal Analytics in Vue application",
"main": "./dist/vue-analytics.min.js",
"author": "Andréas \"ScreamZ\" Hanss",
Expand Down
25 changes: 24 additions & 1 deletion src/AnalyticsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class AnalyticsPlugin {
*/
trackEvent (category, action = null, label = null, value = null) {
// TODO : FieldObject is full syntax, refactor this at one moment
logDebug('Dispatching event', { category, action, label, value})
logDebug('Dispatching event', { category, action, label, value })

ga('send', 'event', category, action, label, value)
}
Expand All @@ -36,6 +36,29 @@ export default class AnalyticsPlugin {
ga('send', 'exception', { 'exDescription': description, 'exFatal': isFatal });
}

/**
* Track an user timing to measure periods of time.
*
* @param {string} timingCategory - A string for categorizing all user timing variables into logical groups (e.g. 'JS Dependencies').
* @param {string} timingVar - A string to identify the variable being recorded (e.g. 'load').
* @param {number} timingValue - The number of milliseconds in elapsed time to report to Google Analytics (e.g. 20).
* @param {string|null} timingLabel - A string that can be used to add flexibility in visualizing user timings in the reports (e.g. 'Google CDN').
*/
trackTiming (timingCategory, timingVar, timingValue, timingLabel = null) {
let conf = {
hitType: 'timing',
timingCategory,
timingVar,
timingValue
}
if (timingLabel) {
conf.timingLabel = timingLabel;
}

logDebug('Dispatching timing', conf)
ga('send', conf);
}

/**
* Inject a new GlobalDimension that will be sent every time.
*
Expand Down

0 comments on commit 682d9d5

Please sign in to comment.