@amplitude/plugin-page-view-tracking-browser 0.3.2-beta.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +3 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/scripts/amplitude-min.js +1 -15
- package/lib/scripts/amplitude-min.js.gz +0 -0
- package/lib/scripts/amplitude-min.umd.js +1 -15
- package/lib/scripts/amplitude-min.umd.js.gz +0 -0
- package/package.json +5 -5
package/lib/cjs/index.d.ts
CHANGED
package/lib/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,KAAK,MAAM,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,IAAI,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,KAAK,KAAK,MAAM,8BAA8B,CAAC"}
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.Types = exports.pageViewTrackingPlugin = void 0;
|
|
2
|
+
exports.Types = exports.plugin = exports.pageViewTrackingPlugin = void 0;
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
4
|
var page_view_tracking_1 = require("./page-view-tracking");
|
|
5
5
|
Object.defineProperty(exports, "pageViewTrackingPlugin", { enumerable: true, get: function () { return page_view_tracking_1.pageViewTrackingPlugin; } });
|
|
6
|
+
var page_view_tracking_2 = require("./page-view-tracking");
|
|
7
|
+
Object.defineProperty(exports, "plugin", { enumerable: true, get: function () { return page_view_tracking_2.pageViewTrackingPlugin; } });
|
|
6
8
|
exports.Types = (0, tslib_1.__importStar)(require("./typings/page-view-tracking"));
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAA8D;AAArD,4HAAA,sBAAsB,OAAA;AAC/B,mFAAsD","sourcesContent":["export { pageViewTrackingPlugin } from './page-view-tracking';\nexport * as Types from './typings/page-view-tracking';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAA8D;AAArD,4HAAA,sBAAsB,OAAA;AAC/B,2DAAwE;AAA/D,4GAAA,sBAAsB,OAAU;AACzC,mFAAsD","sourcesContent":["export { pageViewTrackingPlugin } from './page-view-tracking';\nexport { pageViewTrackingPlugin as plugin } from './page-view-tracking';\nexport * as Types from './typings/page-view-tracking';\n"]}
|
package/lib/esm/index.d.ts
CHANGED
package/lib/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,KAAK,MAAM,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,IAAI,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,KAAK,KAAK,MAAM,8BAA8B,CAAC"}
|
package/lib/esm/index.js
CHANGED
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,IAAI,MAAM,EAAE,MAAM,sBAAsB,CAAC;yBACjD,8BAA8B;oBAAzC,KAAK","sourcesContent":["export { pageViewTrackingPlugin } from './page-view-tracking';\nexport { pageViewTrackingPlugin as plugin } from './page-view-tracking';\nexport * as Types from './typings/page-view-tracking';\n"]}
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
var
|
|
2
|
-
/*! *****************************************************************************
|
|
3
|
-
Copyright (c) Microsoft Corporation.
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted.
|
|
7
|
-
|
|
8
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function c(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((r=r.apply(e,t||[])).next())}))}function r(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}function i(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function o(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}var a,c,u,l,d=function(){return"undefined"!=typeof window&&window.location&&window.location.search?window.location.search.substring(1).split("&").filter(Boolean).reduce((function(e,t){var n=t.split("=",2),r=p(n[0]),i=p(n[1]);return i?(e[r]=i,e):e}),{}):{}},p=function(e){void 0===e&&(e="");try{return decodeURIComponent(e)}catch(e){return""}},s={utm_source:void 0,utm_medium:void 0,utm_campaign:void 0,utm_term:void 0,utm_content:void 0,referrer:void 0,referring_domain:void 0,dclid:void 0,gclid:void 0,fbclid:void 0,ko_click_id:void 0,msclkid:void 0,ttclid:void 0,twclid:void 0},f=function(){function e(){}return e.prototype.parse=function(){return n(this,void 0,void 0,(function(){return r(this,(function(e){return[2,t(t(t(t({},s),this.getUtmParam()),this.getReferrer()),this.getClickIds())]}))}))},e.prototype.getUtmParam=function(){var e=d();return{utm_source:e.utm_source,utm_medium:e.utm_medium,utm_campaign:e.utm_campaign,utm_term:e.utm_term,utm_content:e.utm_content}},e.prototype.getReferrer=function(){var e,t,n={referrer:void 0,referring_domain:void 0};try{n.referrer=document.referrer||void 0,n.referring_domain=null!==(t=null===(e=n.referrer)||void 0===e?void 0:e.split("/")[2])&&void 0!==t?t:void 0}catch(e){}return n},e.prototype.getClickIds=function(){var e,t=d();return(e={}).dclid=t.dclid,e.fbclid=t.fbclid,e.gclid=t.gclid,e.ko_click_id=t.ko_click_id,e.msclkid=t.msclkid,e.ttclid=t.ttclid,e.twclid=t.twclid,e},e}();!function(e){e.SET="$set",e.SET_ONCE="$setOnce",e.ADD="$add",e.APPEND="$append",e.PREPEND="$prepend",e.REMOVE="$remove",e.PREINSERT="$preInsert",e.POSTINSERT="$postInsert",e.UNSET="$unset",e.CLEAR_ALL="$clearAll"}(a||(a={})),function(e){e.REVENUE_PRODUCT_ID="$productId",e.REVENUE_QUANTITY="$quantity",e.REVENUE_PRICE="$price",e.REVENUE_TYPE="$revenueType",e.REVENUE="$revenue"}(c||(c={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(u||(u={})),function(e){e.BEFORE="before",e.ENRICHMENT="enrichment",e.DESTINATION="destination"}(l||(l={}));var v=function(e){var t={};for(var n in e){var r=e[n];r&&(t[n]=r)}return t},y=function(){return n(void 0,void 0,void 0,(function(){var e,i;return r(this,(function(o){switch(o.label){case 0:return i={event_type:"Page View"},e=[{}],[4,n(void 0,void 0,void 0,(function(){var e;return r(this,(function(t){switch(t.label){case 0:return e=v,[4,(new f).parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}}))}))];case 1:return i.event_properties=t.apply(void 0,[t.apply(void 0,e.concat([o.sent()])),{page_domain:"undefined"!=typeof location&&location.hostname||"",page_location:"undefined"!=typeof location&&location.href||"",page_path:"undefined"!=typeof location&&location.pathname||"",page_title:"undefined"!=typeof document&&document.title||"",page_url:"undefined"!=typeof location&&location.href.split("?")[0]||""}]),[2,i]}}))}))},g=function(e){if("$identify"===e.event_type&&e.user_properties){var t=e.user_properties,n=t[a.SET]||{},r=t[a.UNSET]||{},c=o(o([],i(Object.keys(n)),!1),i(Object.keys(r)),!1);return Object.keys(s).every((function(e){return c.includes(e)}))}return!1},m=function(e,t,n){return"pathOnly"===e?t.split("?")[0]!==n.split("?")[0]:t!==n},h=Object.freeze({__proto__:null});return e.Types=h,e.pageViewTrackingPlugin=function(e,o){void 0===o&&(o={});var a=void 0,c=function(){return void 0===o.trackOn||"function"==typeof o.trackOn&&o.trackOn()},u=null,d=function(){return n(void 0,void 0,void 0,(function(){var t,n,i;return r(this,(function(r){switch(r.label){case 0:return t=location.href,m(o.trackHistoryChanges,t,u||"")&&c()?(null==a||a.log("Tracking page view event"),i=(n=e).track,[4,y()]):[3,2];case 1:i.apply(n,[r.sent()]),r.label=2;case 2:return u=t,[2]}}))}))},p={name:"page-view-tracking",type:l.ENRICHMENT,setup:function(t){return n(void 0,void 0,void 0,(function(){var n,u,l,p;return r(this,(function(r){switch(r.label){case 0:return(a=t.loggerProvider).log("Installing @amplitude/plugin-page-view-tracking-browser"),o.trackOn=(null===(l=t.attribution)||void 0===l?void 0:l.trackPageViews)?"attribution":o.trackOn,(null===(p=t.attribution)||void 0===p?void 0:p.trackPageViews)&&(a.warn("@amplitude/plugin-page-view-tracking-browser overrides page view tracking behavior defined in @amplitude/analytics-browser"),t.attribution.trackPageViews=!1),o.trackHistoryChanges&&(window.addEventListener("popstate",(function(){d()})),window.history.pushState=new Proxy(window.history.pushState,{apply:function(e,t,n){var r=i(n,3),o=r[0],a=r[1],c=r[2];return d(),e.apply(t,[o,a,c])}})),c()?(a.log("Tracking page view event"),u=(n=e).track,[4,y()]):[3,2];case 1:u.apply(n,[r.sent()]),r.label=2;case 2:return[2]}}))}))},execute:function(e){return n(void 0,void 0,void 0,(function(){var n;return r(this,(function(r){switch(r.label){case 0:return"attribution"===o.trackOn&&g(e)?(null==a||a.log("Enriching campaign event to page view event with campaign parameters"),[4,y()]):[3,2];case 1:n=r.sent(),e.event_type=n.event_type,e.event_properties=t(t({},e.event_properties),n.event_properties),r.label=2;case 2:return[2,e]}}))}))}};return p.__trackHistoryPageView=d,p},Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|
|
1
|
+
var pageViewTracking=function(e){"use strict";var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function c(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((r=r.apply(e,t||[])).next())}))}function r(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}function i(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function o(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}var a,c,u,l,d=function(){return"undefined"!=typeof window&&window.location&&window.location.search?window.location.search.substring(1).split("&").filter(Boolean).reduce((function(e,t){var n=t.split("=",2),r=p(n[0]),i=p(n[1]);return i?(e[r]=i,e):e}),{}):{}},p=function(e){void 0===e&&(e="");try{return decodeURIComponent(e)}catch(e){return""}},s={utm_source:void 0,utm_medium:void 0,utm_campaign:void 0,utm_term:void 0,utm_content:void 0,referrer:void 0,referring_domain:void 0,dclid:void 0,gclid:void 0,fbclid:void 0,ko_click_id:void 0,msclkid:void 0,ttclid:void 0,twclid:void 0},f=function(){function e(){}return e.prototype.parse=function(){return n(this,void 0,void 0,(function(){return r(this,(function(e){return[2,t(t(t(t({},s),this.getUtmParam()),this.getReferrer()),this.getClickIds())]}))}))},e.prototype.getUtmParam=function(){var e=d();return{utm_source:e.utm_source,utm_medium:e.utm_medium,utm_campaign:e.utm_campaign,utm_term:e.utm_term,utm_content:e.utm_content}},e.prototype.getReferrer=function(){var e,t,n={referrer:void 0,referring_domain:void 0};try{n.referrer=document.referrer||void 0,n.referring_domain=null!==(t=null===(e=n.referrer)||void 0===e?void 0:e.split("/")[2])&&void 0!==t?t:void 0}catch(e){}return n},e.prototype.getClickIds=function(){var e,t=d();return(e={}).dclid=t.dclid,e.fbclid=t.fbclid,e.gclid=t.gclid,e.ko_click_id=t.ko_click_id,e.msclkid=t.msclkid,e.ttclid=t.ttclid,e.twclid=t.twclid,e},e}();!function(e){e.SET="$set",e.SET_ONCE="$setOnce",e.ADD="$add",e.APPEND="$append",e.PREPEND="$prepend",e.REMOVE="$remove",e.PREINSERT="$preInsert",e.POSTINSERT="$postInsert",e.UNSET="$unset",e.CLEAR_ALL="$clearAll"}(a||(a={})),function(e){e.REVENUE_PRODUCT_ID="$productId",e.REVENUE_QUANTITY="$quantity",e.REVENUE_PRICE="$price",e.REVENUE_TYPE="$revenueType",e.REVENUE="$revenue"}(c||(c={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(u||(u={})),function(e){e.BEFORE="before",e.ENRICHMENT="enrichment",e.DESTINATION="destination"}(l||(l={}));var v=function(e){var t={};for(var n in e){var r=e[n];r&&(t[n]=r)}return t},y=function(e,o){void 0===o&&(o={});var a=void 0,c=function(){return void 0===o.trackOn||"function"==typeof o.trackOn&&o.trackOn()},u=null,d=function(){return n(void 0,void 0,void 0,(function(){var t,n,i;return r(this,(function(r){switch(r.label){case 0:return t=location.href,m(o.trackHistoryChanges,t,u||"")&&c()?(null==a||a.log("Tracking page view event"),i=(n=e).track,[4,g()]):[3,2];case 1:i.apply(n,[r.sent()]),r.label=2;case 2:return u=t,[2]}}))}))},p={name:"page-view-tracking",type:l.ENRICHMENT,setup:function(t){return n(void 0,void 0,void 0,(function(){var n,u,l,p;return r(this,(function(r){switch(r.label){case 0:return(a=t.loggerProvider).log("Installing @amplitude/plugin-page-view-tracking-browser"),o.trackOn=(null===(l=t.attribution)||void 0===l?void 0:l.trackPageViews)?"attribution":o.trackOn,(null===(p=t.attribution)||void 0===p?void 0:p.trackPageViews)&&(a.warn("@amplitude/plugin-page-view-tracking-browser overrides page view tracking behavior defined in @amplitude/analytics-browser"),t.attribution.trackPageViews=!1),o.trackHistoryChanges&&(window.addEventListener("popstate",(function(){d()})),window.history.pushState=new Proxy(window.history.pushState,{apply:function(e,t,n){var r=i(n,3),o=r[0],a=r[1],c=r[2];return d(),e.apply(t,[o,a,c])}})),c()?(a.log("Tracking page view event"),u=(n=e).track,[4,g()]):[3,2];case 1:u.apply(n,[r.sent()]),r.label=2;case 2:return[2]}}))}))},execute:function(e){return n(void 0,void 0,void 0,(function(){var n;return r(this,(function(r){switch(r.label){case 0:return"attribution"===o.trackOn&&h(e)?(null==a||a.log("Enriching campaign event to page view event with campaign parameters"),[4,g()]):[3,2];case 1:n=r.sent(),e.event_type=n.event_type,e.event_properties=t(t({},e.event_properties),n.event_properties),r.label=2;case 2:return[2,e]}}))}))}};return p.__trackHistoryPageView=d,p},g=function(){return n(void 0,void 0,void 0,(function(){var e,i;return r(this,(function(o){switch(o.label){case 0:return i={event_type:"Page View"},e=[{}],[4,n(void 0,void 0,void 0,(function(){var e;return r(this,(function(t){switch(t.label){case 0:return e=v,[4,(new f).parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}}))}))];case 1:return i.event_properties=t.apply(void 0,[t.apply(void 0,e.concat([o.sent()])),{page_domain:"undefined"!=typeof location&&location.hostname||"",page_location:"undefined"!=typeof location&&location.href||"",page_path:"undefined"!=typeof location&&location.pathname||"",page_title:"undefined"!=typeof document&&document.title||"",page_url:"undefined"!=typeof location&&location.href.split("?")[0]||""}]),[2,i]}}))}))},h=function(e){if("$identify"===e.event_type&&e.user_properties){var t=e.user_properties,n=t[a.SET]||{},r=t[a.UNSET]||{},c=o(o([],i(Object.keys(n)),!1),i(Object.keys(r)),!1);return Object.keys(s).every((function(e){return c.includes(e)}))}return!1},m=function(e,t,n){return"pathOnly"===e?t.split("?")[0]!==n.split("?")[0]:t!==n},_=Object.freeze({__proto__:null});return e.Types=_,e.pageViewTrackingPlugin=y,e.plugin=y,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|
|
Binary file
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).amplitude={})}(this,(function(e){"use strict";
|
|
2
|
-
/*! *****************************************************************************
|
|
3
|
-
Copyright (c) Microsoft Corporation.
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted.
|
|
7
|
-
|
|
8
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function c(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((r=r.apply(e,t||[])).next())}))}function r(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}function i(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function o(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}var a,c,u,l,d=function(){return"undefined"!=typeof window&&window.location&&window.location.search?window.location.search.substring(1).split("&").filter(Boolean).reduce((function(e,t){var n=t.split("=",2),r=p(n[0]),i=p(n[1]);return i?(e[r]=i,e):e}),{}):{}},p=function(e){void 0===e&&(e="");try{return decodeURIComponent(e)}catch(e){return""}},s={utm_source:void 0,utm_medium:void 0,utm_campaign:void 0,utm_term:void 0,utm_content:void 0,referrer:void 0,referring_domain:void 0,dclid:void 0,gclid:void 0,fbclid:void 0,ko_click_id:void 0,msclkid:void 0,ttclid:void 0,twclid:void 0},f=function(){function e(){}return e.prototype.parse=function(){return n(this,void 0,void 0,(function(){return r(this,(function(e){return[2,t(t(t(t({},s),this.getUtmParam()),this.getReferrer()),this.getClickIds())]}))}))},e.prototype.getUtmParam=function(){var e=d();return{utm_source:e.utm_source,utm_medium:e.utm_medium,utm_campaign:e.utm_campaign,utm_term:e.utm_term,utm_content:e.utm_content}},e.prototype.getReferrer=function(){var e,t,n={referrer:void 0,referring_domain:void 0};try{n.referrer=document.referrer||void 0,n.referring_domain=null!==(t=null===(e=n.referrer)||void 0===e?void 0:e.split("/")[2])&&void 0!==t?t:void 0}catch(e){}return n},e.prototype.getClickIds=function(){var e,t=d();return(e={}).dclid=t.dclid,e.fbclid=t.fbclid,e.gclid=t.gclid,e.ko_click_id=t.ko_click_id,e.msclkid=t.msclkid,e.ttclid=t.ttclid,e.twclid=t.twclid,e},e}();!function(e){e.SET="$set",e.SET_ONCE="$setOnce",e.ADD="$add",e.APPEND="$append",e.PREPEND="$prepend",e.REMOVE="$remove",e.PREINSERT="$preInsert",e.POSTINSERT="$postInsert",e.UNSET="$unset",e.CLEAR_ALL="$clearAll"}(a||(a={})),function(e){e.REVENUE_PRODUCT_ID="$productId",e.REVENUE_QUANTITY="$quantity",e.REVENUE_PRICE="$price",e.REVENUE_TYPE="$revenueType",e.REVENUE="$revenue"}(c||(c={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(u||(u={})),function(e){e.BEFORE="before",e.ENRICHMENT="enrichment",e.DESTINATION="destination"}(l||(l={}));var v=function(e){var t={};for(var n in e){var r=e[n];r&&(t[n]=r)}return t},y=function(){return n(void 0,void 0,void 0,(function(){var e,i;return r(this,(function(o){switch(o.label){case 0:return i={event_type:"Page View"},e=[{}],[4,n(void 0,void 0,void 0,(function(){var e;return r(this,(function(t){switch(t.label){case 0:return e=v,[4,(new f).parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}}))}))];case 1:return i.event_properties=t.apply(void 0,[t.apply(void 0,e.concat([o.sent()])),{page_domain:"undefined"!=typeof location&&location.hostname||"",page_location:"undefined"!=typeof location&&location.href||"",page_path:"undefined"!=typeof location&&location.pathname||"",page_title:"undefined"!=typeof document&&document.title||"",page_url:"undefined"!=typeof location&&location.href.split("?")[0]||""}]),[2,i]}}))}))},g=function(e){if("$identify"===e.event_type&&e.user_properties){var t=e.user_properties,n=t[a.SET]||{},r=t[a.UNSET]||{},c=o(o([],i(Object.keys(n)),!1),i(Object.keys(r)),!1);return Object.keys(s).every((function(e){return c.includes(e)}))}return!1},h=function(e,t,n){return"pathOnly"===e?t.split("?")[0]!==n.split("?")[0]:t!==n},m=Object.freeze({__proto__:null});e.Types=m,e.pageViewTrackingPlugin=function(e,o){void 0===o&&(o={});var a=void 0,c=function(){return void 0===o.trackOn||"function"==typeof o.trackOn&&o.trackOn()},u=null,d=function(){return n(void 0,void 0,void 0,(function(){var t,n,i;return r(this,(function(r){switch(r.label){case 0:return t=location.href,h(o.trackHistoryChanges,t,u||"")&&c()?(null==a||a.log("Tracking page view event"),i=(n=e).track,[4,y()]):[3,2];case 1:i.apply(n,[r.sent()]),r.label=2;case 2:return u=t,[2]}}))}))},p={name:"page-view-tracking",type:l.ENRICHMENT,setup:function(t){return n(void 0,void 0,void 0,(function(){var n,u,l,p;return r(this,(function(r){switch(r.label){case 0:return(a=t.loggerProvider).log("Installing @amplitude/plugin-page-view-tracking-browser"),o.trackOn=(null===(l=t.attribution)||void 0===l?void 0:l.trackPageViews)?"attribution":o.trackOn,(null===(p=t.attribution)||void 0===p?void 0:p.trackPageViews)&&(a.warn("@amplitude/plugin-page-view-tracking-browser overrides page view tracking behavior defined in @amplitude/analytics-browser"),t.attribution.trackPageViews=!1),o.trackHistoryChanges&&(window.addEventListener("popstate",(function(){d()})),window.history.pushState=new Proxy(window.history.pushState,{apply:function(e,t,n){var r=i(n,3),o=r[0],a=r[1],c=r[2];return d(),e.apply(t,[o,a,c])}})),c()?(a.log("Tracking page view event"),u=(n=e).track,[4,y()]):[3,2];case 1:u.apply(n,[r.sent()]),r.label=2;case 2:return[2]}}))}))},execute:function(e){return n(void 0,void 0,void 0,(function(){var n;return r(this,(function(r){switch(r.label){case 0:return"attribution"===o.trackOn&&g(e)?(null==a||a.log("Enriching campaign event to page view event with campaign parameters"),[4,y()]):[3,2];case 1:n=r.sent(),e.event_type=n.event_type,e.event_properties=t(t({},e.event_properties),n.event_properties),r.label=2;case 2:return[2,e]}}))}))}};return p.__trackHistoryPageView=d,p},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).amplitude={})}(this,(function(e){"use strict";var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function c(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((r=r.apply(e,t||[])).next())}))}function r(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}function i(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function o(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}var a,c,u,l,d=function(){return"undefined"!=typeof window&&window.location&&window.location.search?window.location.search.substring(1).split("&").filter(Boolean).reduce((function(e,t){var n=t.split("=",2),r=p(n[0]),i=p(n[1]);return i?(e[r]=i,e):e}),{}):{}},p=function(e){void 0===e&&(e="");try{return decodeURIComponent(e)}catch(e){return""}},s={utm_source:void 0,utm_medium:void 0,utm_campaign:void 0,utm_term:void 0,utm_content:void 0,referrer:void 0,referring_domain:void 0,dclid:void 0,gclid:void 0,fbclid:void 0,ko_click_id:void 0,msclkid:void 0,ttclid:void 0,twclid:void 0},f=function(){function e(){}return e.prototype.parse=function(){return n(this,void 0,void 0,(function(){return r(this,(function(e){return[2,t(t(t(t({},s),this.getUtmParam()),this.getReferrer()),this.getClickIds())]}))}))},e.prototype.getUtmParam=function(){var e=d();return{utm_source:e.utm_source,utm_medium:e.utm_medium,utm_campaign:e.utm_campaign,utm_term:e.utm_term,utm_content:e.utm_content}},e.prototype.getReferrer=function(){var e,t,n={referrer:void 0,referring_domain:void 0};try{n.referrer=document.referrer||void 0,n.referring_domain=null!==(t=null===(e=n.referrer)||void 0===e?void 0:e.split("/")[2])&&void 0!==t?t:void 0}catch(e){}return n},e.prototype.getClickIds=function(){var e,t=d();return(e={}).dclid=t.dclid,e.fbclid=t.fbclid,e.gclid=t.gclid,e.ko_click_id=t.ko_click_id,e.msclkid=t.msclkid,e.ttclid=t.ttclid,e.twclid=t.twclid,e},e}();!function(e){e.SET="$set",e.SET_ONCE="$setOnce",e.ADD="$add",e.APPEND="$append",e.PREPEND="$prepend",e.REMOVE="$remove",e.PREINSERT="$preInsert",e.POSTINSERT="$postInsert",e.UNSET="$unset",e.CLEAR_ALL="$clearAll"}(a||(a={})),function(e){e.REVENUE_PRODUCT_ID="$productId",e.REVENUE_QUANTITY="$quantity",e.REVENUE_PRICE="$price",e.REVENUE_TYPE="$revenueType",e.REVENUE="$revenue"}(c||(c={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(u||(u={})),function(e){e.BEFORE="before",e.ENRICHMENT="enrichment",e.DESTINATION="destination"}(l||(l={}));var v=function(e){var t={};for(var n in e){var r=e[n];r&&(t[n]=r)}return t},y=function(e,o){void 0===o&&(o={});var a=void 0,c=function(){return void 0===o.trackOn||"function"==typeof o.trackOn&&o.trackOn()},u=null,d=function(){return n(void 0,void 0,void 0,(function(){var t,n,i;return r(this,(function(r){switch(r.label){case 0:return t=location.href,m(o.trackHistoryChanges,t,u||"")&&c()?(null==a||a.log("Tracking page view event"),i=(n=e).track,[4,g()]):[3,2];case 1:i.apply(n,[r.sent()]),r.label=2;case 2:return u=t,[2]}}))}))},p={name:"page-view-tracking",type:l.ENRICHMENT,setup:function(t){return n(void 0,void 0,void 0,(function(){var n,u,l,p;return r(this,(function(r){switch(r.label){case 0:return(a=t.loggerProvider).log("Installing @amplitude/plugin-page-view-tracking-browser"),o.trackOn=(null===(l=t.attribution)||void 0===l?void 0:l.trackPageViews)?"attribution":o.trackOn,(null===(p=t.attribution)||void 0===p?void 0:p.trackPageViews)&&(a.warn("@amplitude/plugin-page-view-tracking-browser overrides page view tracking behavior defined in @amplitude/analytics-browser"),t.attribution.trackPageViews=!1),o.trackHistoryChanges&&(window.addEventListener("popstate",(function(){d()})),window.history.pushState=new Proxy(window.history.pushState,{apply:function(e,t,n){var r=i(n,3),o=r[0],a=r[1],c=r[2];return d(),e.apply(t,[o,a,c])}})),c()?(a.log("Tracking page view event"),u=(n=e).track,[4,g()]):[3,2];case 1:u.apply(n,[r.sent()]),r.label=2;case 2:return[2]}}))}))},execute:function(e){return n(void 0,void 0,void 0,(function(){var n;return r(this,(function(r){switch(r.label){case 0:return"attribution"===o.trackOn&&h(e)?(null==a||a.log("Enriching campaign event to page view event with campaign parameters"),[4,g()]):[3,2];case 1:n=r.sent(),e.event_type=n.event_type,e.event_properties=t(t({},e.event_properties),n.event_properties),r.label=2;case 2:return[2,e]}}))}))}};return p.__trackHistoryPageView=d,p},g=function(){return n(void 0,void 0,void 0,(function(){var e,i;return r(this,(function(o){switch(o.label){case 0:return i={event_type:"Page View"},e=[{}],[4,n(void 0,void 0,void 0,(function(){var e;return r(this,(function(t){switch(t.label){case 0:return e=v,[4,(new f).parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}}))}))];case 1:return i.event_properties=t.apply(void 0,[t.apply(void 0,e.concat([o.sent()])),{page_domain:"undefined"!=typeof location&&location.hostname||"",page_location:"undefined"!=typeof location&&location.href||"",page_path:"undefined"!=typeof location&&location.pathname||"",page_title:"undefined"!=typeof document&&document.title||"",page_url:"undefined"!=typeof location&&location.href.split("?")[0]||""}]),[2,i]}}))}))},h=function(e){if("$identify"===e.event_type&&e.user_properties){var t=e.user_properties,n=t[a.SET]||{},r=t[a.UNSET]||{},c=o(o([],i(Object.keys(n)),!1),i(Object.keys(r)),!1);return Object.keys(s).every((function(e){return c.includes(e)}))}return!1},m=function(e,t,n){return"pathOnly"===e?t.split("?")[0]!==n.split("?")[0]:t!==n},_=Object.freeze({__proto__:null});e.Types=_,e.pageViewTrackingPlugin=y,e.plugin=y,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amplitude/plugin-page-view-tracking-browser",
|
|
3
|
-
"version": "0.3.2
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Amplitude Inc",
|
|
6
6
|
"homepage": "https://github.com/amplitude/Amplitude-TypeScript",
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"url": "https://github.com/amplitude/Amplitude-TypeScript/issues"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@amplitude/analytics-client-common": "^0.2.2
|
|
40
|
-
"@amplitude/analytics-types": "^0.10.3
|
|
39
|
+
"@amplitude/analytics-client-common": "^0.2.2",
|
|
40
|
+
"@amplitude/analytics-types": "^0.10.3",
|
|
41
41
|
"tslib": "^2.3.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@amplitude/analytics-browser": "^1.5.1
|
|
44
|
+
"@amplitude/analytics-browser": "^1.5.1",
|
|
45
45
|
"@rollup/plugin-commonjs": "^21.0.2",
|
|
46
46
|
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
47
47
|
"@rollup/plugin-typescript": "^8.3.1",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"files": [
|
|
54
54
|
"lib"
|
|
55
55
|
],
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "66ea9159b61cc2f234b2978116025e5b55af21d2"
|
|
57
57
|
}
|