Comparing version 2.3.0 to 2.3.1
@@ -15,3 +15,3 @@ (function(){var f,aa="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)},k="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this;function ba(){ba=function(){};k.Symbol||(k.Symbol=ca)}var da=0;function ca(a){return"jscomp_symbol_"+(a||"")+da++} | ||
function C(a,b){var c=window.GoogleAnalyticsObject||"ga";window[c]=window[c]||function(a){for(var b=[],d=0;d<arguments.length;++d)b[d-0]=arguments[d];(window[c].q=window[c].q||[]).push(b)};window.gaDevIds=window.gaDevIds||[];0>window.gaDevIds.indexOf("i5iSjo")&&window.gaDevIds.push("i5iSjo");window[c]("provide",a,b);window.gaplugins=window.gaplugins||{};window.gaplugins[a.charAt(0).toUpperCase()+a.slice(1)]=b}var D={S:1,T:2,U:3,W:4,X:5,Y:6,Z:7,$:8,aa:9,V:10},G=Object.keys(D).length; | ||
function H(a,b){a.set("\x26_av","2.3.0");var c=a.get("\x26_au"),c=parseInt(c||"0",16).toString(2);if(c.length<G)for(var d=G-c.length;d;)c="0"+c,d--;b=G-b;c=c.substr(0,b)+1+c.substr(b+1);a.set("\x26_au",parseInt(c||"0",2).toString(16))}function I(a,b){H(a,D.S);this.a=z({},b);this.i=a;this.b=this.a.stripQuery&&this.a.queryDimensionIndex?"dimension"+this.a.queryDimensionIndex:null;this.f=this.f.bind(this);this.c=this.c.bind(this);b=this.f;v(x(a,"get"),b);b=this.c;v(x(a,"buildHitTask"),b)} | ||
function H(a,b){a.set("\x26_av","2.3.1");var c=a.get("\x26_au"),c=parseInt(c||"0",16).toString(2);if(c.length<G)for(var d=G-c.length;d;)c="0"+c,d--;b=G-b;c=c.substr(0,b)+1+c.substr(b+1);a.set("\x26_au",parseInt(c||"0",2).toString(16))}function I(a,b){H(a,D.S);this.a=z({},b);this.i=a;this.b=this.a.stripQuery&&this.a.queryDimensionIndex?"dimension"+this.a.queryDimensionIndex:null;this.f=this.f.bind(this);this.c=this.c.bind(this);b=this.f;v(x(a,"get"),b);b=this.c;v(x(a,"buildHitTask"),b)} | ||
I.prototype.f=function(a){var b=this;return function(c){if("page"==c||c==b.b){var d={location:a("location"),page:a("page")};return ua(b,d)[c]}return a(c)}};I.prototype.c=function(a){var b=this;return function(c){var d=ua(b,{location:c.get("location"),page:c.get("page")});c.set(d,null,!0);a(c)}}; | ||
@@ -46,7 +46,7 @@ function ua(a,b){var c=t(b.page||b.location),d=c.pathname;if(a.a.indexFilename){var e=d.split("/");a.a.indexFilename==e[e.length-1]&&(e[e.length-1]="",d=e.join("/"))}"remove"==a.a.trailingSlash?d=d.replace(/\/+$/,""):"add"==a.a.trailingSlash&&(/\.\w+$/.test(d)||"/"==d.substr(-1)||(d+="/"));d={page:d+(a.a.stripQuery?"":c.search)};b.location&&(d.location=b.location);a.b&&(d[a.b]=c.search.slice(1)||"(not set)");return"function"==typeof a.a.urlFieldsFilter?(b=a.a.urlFieldsFilter(d,t),c={},c.page=b.page, | ||
function Ka(a,b){H(a,D.Z);if(document.visibilityState){this.a=z({sessionTimeout:U,visibleThreshold:5E3,sendInitialPageview:!1,fieldsObj:{}},b);this.b=a;this.i=this.f=null;this.s=!1;this.v=this.v.bind(this);this.o=this.o.bind(this);this.G=this.G.bind(this);this.N=this.N.bind(this);this.c=Q(a.get("trackingId"),"plugins/page-visibility-tracker");b=this.N;var c=this.c;(c.a.externalSet=c.a.externalSet||[]).push(b);this.m=new T(a,this.a.sessionTimeout,this.a.timeZone);b=this.v;v(x(a,"set"),b);window.addEventListener("unload", | ||
this.G);document.addEventListener("visibilitychange",this.o);"visible"==document.visibilityState?(this.a.sendInitialPageview&&(La(this,{da:!0}),this.s=!0),this.o()):this.a.sendInitialPageview&&this.a.pageLoadMetricIndex&&(a={},a=(a.transport="beacon",a.eventCategory="Page Visibility",a.eventAction="page load",a.eventLabel="(not set)",a["metric"+this.a.pageLoadMetricIndex]=1,a.nonInteraction=!0,a),this.b.send("event",y(a,this.a.fieldsObj,this.b,this.a.hitFilter)))}}f=Ka.prototype; | ||
this.G);document.addEventListener("visibilitychange",this.o);"visible"==document.visibilityState?(this.a.sendInitialPageview&&(La(this,{da:!0}),this.s=!0),this.o()):this.a.sendInitialPageview&&this.a.pageLoadsMetricIndex&&(a={},a=(a.transport="beacon",a.eventCategory="Page Visibility",a.eventAction="page load",a.eventLabel="(not set)",a["metric"+this.a.pageLoadsMetricIndex]=1,a.nonInteraction=!0,a),this.b.send("event",y(a,this.a.fieldsObj,this.b,this.a.hitFilter)))}}f=Ka.prototype; | ||
f.o=function(){var a=this;if("visible"==document.visibilityState||"hidden"==document.visibilityState){var b=Ma(this,this.c.get()),c={time:+new Date,state:document.visibilityState,pageId:Z};!this.s&&this.a.sendInitialPageview&&"visible"==document.visibilityState&&(La(this),this.s=!0);this.i&&"hidden"==document.visibilityState&&clearTimeout(this.i);this.m.isExpired()?"hidden"==this.f&&"visible"==document.visibilityState?(clearTimeout(this.i),this.i=setTimeout(function(){a.c.set(c);La(a,{hitTime:c.time})}, | ||
this.a.visibleThreshold)):"hidden"==document.visibilityState&&za(this.c):(b.pageId==Z&&"visible"==b.state&&Na(this,b),this.c.set(c));this.f=document.visibilityState}};function Ma(a,b){"visible"==a.f&&"hidden"==b.state&&b.pageId!=Z&&(b.state="visible",b.pageId=Z,a.c.set(b));return b} | ||
function Na(a,b,c){c=(c?c:{}).hitTime;var d={hitTime:c},d=(d?d:{}).hitTime;(b=b.time&&!a.m.isExpired()?(d||+new Date)-b.time:0)&&b>=a.a.visibleThreshold&&(b=Math.round(b/1E3),d={transport:"beacon",nonInteraction:!0,eventCategory:"Page Visibility",eventAction:"track",eventValue:b,eventLabel:"(not set)"},c&&(d.queueTime=+new Date-c),a.a.visibleMetricIndex&&(d["metric"+a.a.visibleMetricIndex]=b),a.b.send("event",y(d,a.a.fieldsObj,a.b,a.a.hitFilter)))} | ||
function La(a,b){var c=b?b:{};b=c.hitTime;var c=c.da,d={transport:"beacon"};b&&(d.queueTime=+new Date-b);c&&(d["metric"+a.a.pageLoadMetricIndex]=1);a.b.send("pageview",y(d,a.a.fieldsObj,a.b,a.a.hitFilter))}f.v=function(a){var b=this;return function(c,d){var e={},e=B(c)?c:(e[c]=d,e);e.page&&e.page!==b.b.get("page")&&"visible"==b.f&&b.o();a(c,d)}};f.N=function(a,b){a.time!=b.time&&b.pageId==Z&&"visible"==b.state&&Na(this,b,{hitTime:a.time})};f.G=function(){"hidden"!=this.f&&this.o()}; | ||
function La(a,b){var c=b?b:{};b=c.hitTime;var c=c.da,d={transport:"beacon"};b&&(d.queueTime=+new Date-b);c&&(d["metric"+a.a.pageLoadsMetricIndex]=1);a.b.send("pageview",y(d,a.a.fieldsObj,a.b,a.a.hitFilter))}f.v=function(a){var b=this;return function(c,d){var e={},e=B(c)?c:(e[c]=d,e);e.page&&e.page!==b.b.get("page")&&"visible"==b.f&&b.o();a(c,d)}};f.N=function(a,b){a.time!=b.time&&b.pageId==Z&&"visible"==b.state&&Na(this,b,{hitTime:a.time})};f.G=function(){"hidden"!=this.f&&this.o()}; | ||
f.remove=function(){this.c.j();this.m.j();var a=this.v;w(x(this.b,"set"),a);window.removeEventListener("unload",this.G);document.removeEventListener("visibilitychange",this.o)};C("pageVisibilityTracker",Ka); | ||
@@ -53,0 +53,0 @@ function Oa(a,b){H(a,D.$);window.addEventListener&&(this.a=z({fieldsObj:{},hitFilter:null},b),this.b=a,this.u=this.u.bind(this),this.J=this.J.bind(this),this.D=this.D.bind(this),this.A=this.A.bind(this),this.B=this.B.bind(this),this.F=this.F.bind(this),"complete"!=document.readyState?window.addEventListener("load",this.u):this.u())}f=Oa.prototype; |
@@ -5,2 +5,6 @@ # Changelog | ||
### 2.3.1 (2017-04-09) | ||
- Rename misspelled `pageloadMetricIndex` option to `pageloadsMetricIndex` | ||
### 2.3.0 (2017-04-07) | ||
@@ -7,0 +11,0 @@ |
@@ -42,3 +42,3 @@ # `pageVisibilityTracker` | ||
**Note:** you can set the [`pageLoadMetricIndex`](#options) option to track page loads (via a [custom metric](https://support.google.com/analytics/answer/2709828)) separately from pageviews in the event you also want to know how often your pages are loaded. | ||
**Note:** you can set the [`pageLoadsMetricIndex`](#options) option to track page loads (via a [custom metric](https://support.google.com/analytics/answer/2709828)) separately from pageviews in the event you also want to know how often your pages are loaded. | ||
@@ -114,3 +114,3 @@ ## Usage | ||
<tr valign="top"> | ||
<td><code>pageLoadMetricIndex</code></td> | ||
<td><code>pageLoadsMetricIndex</code></td> | ||
<td><code>number</code></td> | ||
@@ -201,3 +201,3 @@ <td> | ||
If the `pageLoadMetricIndex` option is set in addition to the `sendInitialPageview` option (and the page was loaded in the visible state), a pageview is sent with the following default field values: | ||
If the `pageLoadsMetricIndex` option is set in addition to the `sendInitialPageview` option (and the page was loaded in the visible state), a pageview is sent with the following default field values: | ||
@@ -214,3 +214,3 @@ <table> | ||
<tr valign="top"> | ||
<td><code>metric<pageLoadMetricIndex></code></td> | ||
<td><code>metric<pageLoadsMetricIndex></code></td> | ||
<td><code>1</code></td> | ||
@@ -220,3 +220,3 @@ </tr> | ||
If the `sendInitialPageview` and `pageLoadMetricIndex` options are set, and the page was loaded in a background tab, an event is sent with the following default field values: | ||
If the `sendInitialPageview` and `pageLoadsMetricIndex` options are set, and the page was loaded in a background tab, an event is sent with the following default field values: | ||
@@ -241,3 +241,3 @@ <table> | ||
<tr valign="top"> | ||
<td><code>metric<pageLoadMetricIndex></code></td> | ||
<td><code>metric<pageLoadsMetricIndex></code></td> | ||
<td><code>1</code></td> | ||
@@ -307,3 +307,3 @@ </tr> | ||
If you want to track page load (in addition to pageviews) as well as the total (or average) time a user spends in the visible state on your site, you can do so via [custom metrics](https://support.google.com/analytics/answer/2709828) and the `pageLoadMetricIndex` and `visibleMetricIndex` options. | ||
If you want to track page load (in addition to pageviews) as well as the total (or average) time a user spends in the visible state on your site, you can do so via [custom metrics](https://support.google.com/analytics/answer/2709828) and the `pageLoadsMetricIndex` and `visibleMetricIndex` options. | ||
@@ -313,3 +313,3 @@ ```js | ||
sendInitialPageview: true, | ||
pageLoadMetricIndex: 1, | ||
pageLoadsMetricIndex: 1, | ||
visibleMetricIndex: 2, | ||
@@ -316,0 +316,0 @@ timeZone: 'America/Los_Angeles', |
@@ -18,3 +18,3 @@ /** | ||
export const VERSION = '2.3.0'; | ||
export const VERSION = '2.3.1'; | ||
export const DEV_ID = 'i5iSjo'; | ||
@@ -21,0 +21,0 @@ |
@@ -8,3 +8,3 @@ /** | ||
* sendInitialPageview: (boolean), | ||
* pageLoadMetricIndex: (number|undefined), | ||
* pageLoadsMetricIndex: (number|undefined), | ||
* visibleMetricIndex: (number|undefined), | ||
@@ -11,0 +11,0 @@ * fieldsObj: (!Object), |
@@ -55,3 +55,3 @@ /** | ||
sendInitialPageview: false, | ||
// pageLoadMetricIndex: undefined, | ||
// pageLoadsMetricIndex: undefined, | ||
// visibleMetricIndex: undefined, | ||
@@ -252,3 +252,3 @@ fieldsObj: {}, | ||
sendPageload() { | ||
if (this.opts.sendInitialPageview && this.opts.pageLoadMetricIndex) { | ||
if (this.opts.sendInitialPageview && this.opts.pageLoadsMetricIndex) { | ||
/** @type {FieldsObj} */ | ||
@@ -260,3 +260,3 @@ const defaultFields = { | ||
eventLabel: NULL_DIMENSION, | ||
['metric' + this.opts.pageLoadMetricIndex]: 1, | ||
['metric' + this.opts.pageLoadsMetricIndex]: 1, | ||
nonInteraction: true, | ||
@@ -282,4 +282,8 @@ }; | ||
const defaultFields = {transport: 'beacon'}; | ||
if (hitTime) defaultFields.queueTime = now() - hitTime; | ||
if (isPageLoad) defaultFields['metric' + this.opts.pageLoadMetricIndex] = 1; | ||
if (hitTime) { | ||
defaultFields.queueTime = now() - hitTime; | ||
} | ||
if (isPageLoad) { | ||
defaultFields['metric' + this.opts.pageLoadsMetricIndex] = 1; | ||
} | ||
@@ -286,0 +290,0 @@ this.tracker.send('pageview', |
{ | ||
"name": "autotrack", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"description": "Automatic and enhanced Google Analytics tracking for common user interactions on the web", | ||
@@ -5,0 +5,0 @@ "main": "lib", |
@@ -283,3 +283,3 @@ /** | ||
it('sends a page load metric when pageLoadMetricIndex is set', function() { | ||
it('sends a page load metric when pageLoadsMetricIndex is set', function() { | ||
if (!browserSupportsTabs()) return this.skip(); | ||
@@ -290,3 +290,3 @@ | ||
visibleThreshold: 0, | ||
pageLoadMetricIndex: 1, | ||
pageLoadsMetricIndex: 1, | ||
}; | ||
@@ -323,3 +323,3 @@ | ||
visibleThreshold: 0, | ||
pageLoadMetricIndex: 1, | ||
pageLoadsMetricIndex: 1, | ||
}; | ||
@@ -372,3 +372,3 @@ | ||
visibleThreshold: 0, | ||
pageLoadMetricIndex: 1, | ||
pageLoadsMetricIndex: 1, | ||
}; | ||
@@ -375,0 +375,0 @@ |
@@ -75,3 +75,3 @@ /** | ||
sendInitialPageview: false, | ||
pageLoadMetricIndex: 1, | ||
pageLoadsMetricIndex: 1, | ||
visibleMetricIndex: 2, | ||
@@ -78,0 +78,0 @@ fieldsObj: {nonInteraction: true}, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
730483
10625
8873