@amplitude/plugin-page-view-tracking-browser 2.3.20 → 2.3.21
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.
|
@@ -1 +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";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 u(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,a)}c((r=r.apply(e,t||[])).next())}))}function r(e,t){var n,r,i,o
|
|
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 u(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,a)}c((r=r.apply(e,t||[])).next())}))}function r(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=a(0),u.throw=a(1),u.return=a(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,a[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function i(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),u=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)u.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 u}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))}"function"==typeof SuppressedError&&SuppressedError;var u,a,c,l=function(){var e="ampIntegrationContext";return"undefined"!=typeof globalThis&&void 0!==globalThis[e]?globalThis[e]:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0},d=function(){var e,t=l();return(null===(e=null==t?void 0:t.location)||void 0===e?void 0:e.search)?t.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""}},f="dclid",s="fbclid",v="gbraid",y="gclid",m="ko_click_id",g="li_fat_id",h="msclkid",_="rtd_cid",b="ttclid",E="twclid",w="wbraid",T={utm_campaign:void 0,utm_content:void 0,utm_id:void 0,utm_medium:void 0,utm_source:void 0,utm_term:void 0,referrer:void 0,referring_domain:void 0,dclid:void 0,gbraid:void 0,gclid:void 0,fbclid:void 0,ko_click_id:void 0,li_fat_id:void 0,msclkid:void 0,rtd_cid:void 0,ttclid:void 0,twclid:void 0,wbraid:void 0},P=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({},T),this.getUtmParam()),this.getReferrer()),this.getClickIds())]}))}))},e.prototype.getUtmParam=function(){var e=d();return{utm_campaign:e.utm_campaign,utm_content:e.utm_content,utm_id:e.utm_id,utm_medium:e.utm_medium,utm_source:e.utm_source,utm_term:e.utm_term}},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={})[f]=t[f],e[s]=t[s],e[v]=t[v],e[y]=t[y],e[m]=t[m],e[g]=t[g],e[h]=t[h],e[_]=t[_],e[b]=t[b],e[E]=t[E],e[w]=t[w],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"}(u||(u={})),function(e){e.REVENUE_PRODUCT_ID="$productId",e.REVENUE_QUANTITY="$quantity",e.REVENUE_PRICE="$price",e.REVENUE_TYPE="$revenueType",e.REVENUE_CURRENCY="$currency",e.REVENUE="$revenue"}(a||(a={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(c||(c={}));var R=function(e){var t={};for(var n in e){var r=e[n];r&&(t[n]=r)}return t},k=function(e){var o;void 0===e&&(e={});var u,a,c=l(),d=void 0,p=e.trackOn,f=e.trackHistoryChanges,s=e.eventType,v=void 0===s?"[Amplitude] Page Viewed":s,y=function(e){var t=e;try{t=decodeURI(e)}catch(e){null==d||d.error("Malformed URI sequence: ",e)}return t},m=function(){return n(void 0,void 0,void 0,(function(){var e,n,i;return r(this,(function(r){switch(r.label){case 0:return e=y("undefined"!=typeof location&&location.href||""),i={event_type:v},n=[{}],[4,I()];case 1:return[2,(i.event_properties=t.apply(void 0,[t.apply(void 0,n.concat([r.sent()])),{"[Amplitude] Page Domain":"undefined"!=typeof location&&location.hostname||"","[Amplitude] Page Location":e,"[Amplitude] Page Path":"undefined"!=typeof location&&y(location.pathname)||"","[Amplitude] Page Title":"undefined"!=typeof document&&document.title||"","[Amplitude] Page URL":e.split("?")[0]}]),i)]}}))}))},g=function(){return void 0===p||"function"==typeof p&&p()},h="undefined"!=typeof location?location.href:null,_=function(){return n(void 0,void 0,void 0,(function(){var e,t,n,i;return r(this,(function(r){switch(r.label){case 0:return e=location.href,t=$(f,e,h||"")&&g(),h=e,t?(null==d||d.log("Tracking page view event"),null!=o?[3,1]:[3,3]):[3,4];case 1:return i=(n=o).track,[4,m()];case 2:i.apply(n,[r.sent()]),r.label=3;case 3:r.label=4;case 4:return[2]}}))}))},b=function(){_()},E={name:"@amplitude/plugin-page-view-tracking-browser",type:"enrichment",setup:function(e,t){return n(void 0,void 0,void 0,(function(){var n,l;return r(this,(function(r){switch(r.label){case 0:return o=t,a=e,(d=e.loggerProvider).log("Installing @amplitude/plugin-page-view-tracking-browser"),c&&(c.addEventListener("popstate",b),u=c.history.pushState,c.history.pushState=new Proxy(c.history.pushState,{apply:function(e,t,n){var r=i(n,3),o=r[0],u=r[1],a=r[2];e.apply(t,[o,u,a]),_()}})),g()?(d.log("Tracking page view event"),l=(n=o).track,[4,m()]):[3,2];case 1:l.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"===p&&U(e)?(null==d||d.log("Enriching campaign event to page view event with campaign parameters"),[4,m()]):[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 a&&e.event_type===v&&(a.pageCounter=a.pageCounter?a.pageCounter+1:1,e.event_properties=t(t({},e.event_properties),{"[Amplitude] Page Counter":a.pageCounter})),[2,e]}}))}))},teardown:function(){return n(void 0,void 0,void 0,(function(){return r(this,(function(e){return c&&(c.removeEventListener("popstate",b),u&&(c.history.pushState=u)),[2]}))}))}};return E},I=function(){return n(void 0,void 0,void 0,(function(){var e;return r(this,(function(t){switch(t.label){case 0:return e=R,[4,(new P).parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}}))}))},U=function(e){if("$identify"===e.event_type&&e.user_properties){var t=e.user_properties,n=t[u.SET]||{},r=t[u.UNSET]||{},a=o(o([],i(Object.keys(n)),!1),i(Object.keys(r)),!1);return Object.keys(T).every((function(e){return a.includes(e)}))}return!1},$=function(e,t,n){if("pathOnly"===e){if(""==n)return!0;var r=new URL(t),i=new URL(n);return r.origin+r.pathname!==i.origin+i.pathname}return t!==n};e.pageViewTrackingPlugin=k,e.plugin=k,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": "2.3.
|
|
3
|
+
"version": "2.3.21",
|
|
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": "^2.3.
|
|
39
|
+
"@amplitude/analytics-client-common": "^2.3.18",
|
|
40
40
|
"@amplitude/analytics-types": "^2.9.1",
|
|
41
41
|
"tslib": "^2.4.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@amplitude/analytics-browser": "^2.
|
|
44
|
+
"@amplitude/analytics-browser": "^2.17.0",
|
|
45
45
|
"@rollup/plugin-commonjs": "^23.0.4",
|
|
46
46
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
47
47
|
"@rollup/plugin-typescript": "^10.0.1",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"files": [
|
|
54
54
|
"lib"
|
|
55
55
|
],
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "e2543ba386a7769cfada0111af31668807366292"
|
|
57
57
|
}
|