@amplitude/plugin-page-url-enrichment-browser 0.5.10 → 0.5.11
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,n,r=function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};function o(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function u(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,u)}l((r=r.apply(e,t||[])).next())})}function i(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(l){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,l])}}}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}
|
|
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,n,r=function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};function o(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function u(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,u)}l((r=r.apply(e,t||[])).next())})}function i(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(l){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,l])}}}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}"function"==typeof SuppressedError&&SuppressedError,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"}(t||(t={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(n||(n={}));var u,l=function(e,t){var n=e;try{n=decodeURI(e)}catch(e){null==t||t.error("Malformed URI sequence: ",e)}return n},c=function(){function e(e){this.storage=e}return e.prototype.isEnabled=function(){return o(this,void 0,void 0,function(){var t,n,r;return i(this,function(o){switch(o.label){case 0:if(!this.storage)return[2,!1];t=String(Date.now()),n=new e(this.storage),r="AMP_TEST",o.label=1;case 1:return o.trys.push([1,4,5,7]),[4,n.set(r,t)];case 2:return o.sent(),[4,n.get(r)];case 3:return[2,o.sent()===t];case 4:return o.sent(),[2,!1];case 5:return[4,n.remove(r)];case 6:return o.sent(),[7];case 7:return[2]}})})},e.prototype.get=function(e){return o(this,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getRaw(e)];case 1:return(t=n.sent())?[2,JSON.parse(t)]:[2,void 0];case 2:return n.sent(),console.error("[Amplitude] Error: Could not get value from storage"),[2,void 0];case 3:return[2]}})})},e.prototype.getRaw=function(e){var t;return o(this,void 0,void 0,function(){return i(this,function(n){return[2,(null===(t=this.storage)||void 0===t?void 0:t.getItem(e))||void 0]})})},e.prototype.set=function(e,t){var n;return o(this,void 0,void 0,function(){return i(this,function(r){try{null===(n=this.storage)||void 0===n||n.setItem(e,JSON.stringify(t))}catch(e){}return[2]})})},e.prototype.remove=function(e){var t;return o(this,void 0,void 0,function(){return i(this,function(n){try{null===(t=this.storage)||void 0===t||t.removeItem(e)}catch(e){}return[2]})})},e.prototype.reset=function(){var e;return o(this,void 0,void 0,function(){return i(this,function(t){try{null===(e=this.storage)||void 0===e||e.clear()}catch(e){}return[2]})})},e}(),s="*****",f=/\b(?:\d[ -]*?){13,16}\b/,d=/(\d{3}-?\d{2}-?\d{4})/g,p=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,v=function(e,t){var n,r;if(void 0===t&&(t=[]),"string"!=typeof e)return"";var o=e;o=(o=(o=o.replace(f,s)).replace(d,s)).replace(p,s);try{for(var i=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(t),a=i.next();!a.done;a=i.next()){var u=a.value;try{o=o.replace(u,s)}catch(e){}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return o},h=function(e){if("undefined"==typeof document||!document.title)return"";var t=document.querySelector("title");return t&&t.hasAttribute("data-amp-mask")?s:e?e(document.title):document.title},y="AMP_CURRENT_PAGE",g="AMP_PREVIOUS_PAGE",m="AMP_URL_INFO";!function(e){e.Direct="direct",e.Internal="internal",e.External="external"}(u||(u={}));var b=new Set([n.IDENTIFY,n.GROUP_IDENTIFY,n.REVENUE]),E=function(e){var t,n=(void 0===e?{}:e).internalDomains,s=void 0===n?[]:n,f=(t="ampIntegrationContext","undefined"!=typeof globalThis&&void 0!==globalThis[t]?globalThis[t]:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0),d=void 0,p=!1,E=void 0,w=!1,S=!1,A=function(e){var t="undefined"!=typeof location&&location.hostname||"",n=e?function(e){var t;try{var n=l(e,E);t=new URL(n).hostname}catch(e){null==E||E.error("Could not parse URL: ",e)}return t}(e):void 0;if(!n)return u.Direct;var r=s.some(function(e){return-1!==t.indexOf(e)}),o=s.some(function(e){return-1!==n.indexOf(e)});return t===n||o&&r?u.Internal:u.External},_=function(){o(void 0,void 0,void 0,function(){var e,t,n,r,o;return i(this,function(i){switch(i.label){case 0:return d&&p?[4,d.get(m)]:[3,3];case 1:return e=i.sent(),t=l("undefined"!=typeof location&&location.href||""),n=(null==e?void 0:e[y])||"",r=void 0,r=t===n?(null==e?void 0:e[g])||"":n||document.referrer||"",[4,d.set(m,(o={},o[y]=t,o[g]=r,o))];case 2:i.sent(),i.label=3;case 3:return[2]}})})},R={name:"@amplitude/plugin-page-url-enrichment-browser",type:"enrichment",setup:function(e,t){return o(void 0,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return(E=e.loggerProvider).log("Installing @amplitude/plugin-page-url-enrichment-browser"),S=!0,f?[4,(d=new c(f.sessionStorage)).isEnabled()]:[3,2];case 1:p=t.sent(),f.addEventListener("popstate",_),w||(f.history.pushState=new Proxy(f.history.pushState,{apply:function(e,t,n){var r=a(n,3),o=r[0],i=r[1],u=r[2];e.apply(t,[o,i,u]),S&&_()}}),f.history.replaceState=new Proxy(f.history.replaceState,{apply:function(e,t,n){var r=a(n,3),o=r[0],i=r[1],u=r[2];e.apply(t,[o,i,u]),S&&_()}}),w=!0),t.label=2;case 2:return[2]}})})},execute:function(e){return o(void 0,void 0,void 0,function(){var t,n,o,a,u;return i(this,function(i){switch(i.label){case 0:return t=l("undefined"!=typeof location&&location.href||""),d&&p?[4,d.get(m)]:[3,5];case 1:return(null==(n=i.sent())?void 0:n[y])?[3,3]:[4,d.set(m,(u={},u[y]=t,u[g]=document.referrer||"",u))];case 2:i.sent(),i.label=3;case 3:return[4,d.get(m)];case 4:if(o=i.sent(),a="",o&&(a=o[g]||""),b.has(e.event_type))return[2,e];e.event_properties=r(r({},e.event_properties||{}),{"[Amplitude] Page Domain":P(e,"[Amplitude] Page Domain","undefined"!=typeof location&&location.hostname||""),"[Amplitude] Page Location":P(e,"[Amplitude] Page Location",t),"[Amplitude] Page Path":P(e,"[Amplitude] Page Path","undefined"!=typeof location&&l(location.pathname)||""),"[Amplitude] Page Title":P(e,"[Amplitude] Page Title",h(v)),"[Amplitude] Page URL":P(e,"[Amplitude] Page URL",t.split("?")[0]),"[Amplitude] Previous Page Location":a,"[Amplitude] Previous Page Type":A(a)}),i.label=5;case 5:return[2,e]}})})},teardown:function(){return o(void 0,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return f&&(f.removeEventListener("popstate",_),S=!1),d&&p?[4,d.set(m,{})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})}};return R};function P(e,t,n){return e.event_properties||(e.event_properties={}),void 0===e.event_properties[t]?n:e.event_properties[t]}e.CURRENT_PAGE_STORAGE_KEY=y,e.PREVIOUS_PAGE_STORAGE_KEY=g,e.URL_INFO_STORAGE_KEY=m,e.pageUrlEnrichmentPlugin=E,e.plugin=E,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amplitude/plugin-page-url-enrichment-browser",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Amplitude Inc",
|
|
6
6
|
"homepage": "https://github.com/amplitude/Amplitude-TypeScript",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"tslib": "^2.4.1",
|
|
25
|
-
"@amplitude/analytics-core": "2.35.
|
|
25
|
+
"@amplitude/analytics-core": "2.35.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@rollup/plugin-commonjs": "^23.0.4",
|