From 21fe40a8aa94db1726b9d607ebc06de927e0a85b Mon Sep 17 00:00:00 2001 From: Blue Mouse Date: Sat, 26 Oct 2024 21:15:43 +0100 Subject: [PATCH] Build --- dist/esnext/Lib.d.ts | 2 -- dist/esnext/Lib.js | 30 ------------------------------ dist/esnext/Lib.js.map | 2 +- dist/esnext/index.d.ts | 4 ++-- dist/esnext/index.js | 6 +++--- dist/esnext/index.js.map | 2 +- dist/swetrix.cjs.js | 37 ++++--------------------------------- dist/swetrix.es5.js | 37 ++++--------------------------------- dist/swetrix.js | 2 +- dist/swetrix.orig.js | 37 ++++--------------------------------- 10 files changed, 20 insertions(+), 139 deletions(-) diff --git a/dist/esnext/Lib.d.ts b/dist/esnext/Lib.d.ts index 0f998f1..3ab07a7 100644 --- a/dist/esnext/Lib.d.ts +++ b/dist/esnext/Lib.d.ts @@ -35,7 +35,6 @@ export interface IPageViewPayload { te: string | undefined; co: string | undefined; pg: string | null | undefined; - prev: string | null | undefined; /** Pageview-related metadata object with string values. */ meta?: { [key: string]: string; @@ -147,7 +146,6 @@ export declare class Lib { getPerformanceStats(): IPerfPayload | {}; private heartbeat; private trackPathChange; - private getPreviousPage; private trackPage; submitPageView(payload: Partial, unique: boolean, perf: IPerfPayload | {}, evokeCallback?: boolean): void; private canTrack; diff --git a/dist/esnext/Lib.js b/dist/esnext/Lib.js index 80859a7..4805062 100644 --- a/dist/esnext/Lib.js +++ b/dist/esnext/Lib.js @@ -171,34 +171,6 @@ export class Lib { this.trackPage(newPath, false); } } - getPreviousPage() { - // Assuming that this function is called in trackPage and this.activePage is not overwritten by new value yet - // That method of getting previous page works for SPA websites - if (this.activePage) { - return this.activePage; - } - // Checking if URL is supported by the browser (for example, IE11 does not support it) - if (typeof URL === 'function') { - // That method of getting previous page works for websites with page reloads - const referrer = getReferrer(); - if (!referrer) { - return null; - } - const { host } = location; - try { - const url = new URL(referrer); - const { host: refHost, pathname } = url; - if (host !== refHost) { - return null; - } - return pathname; - } - catch { - return null; - } - } - return null; - } trackPage(pg, unique = false) { if (!this.pageData) return; @@ -208,7 +180,6 @@ export class Lib { this.submitPageView({ pg }, unique, perf, true); } submitPageView(payload, unique, perf, evokeCallback) { - const prev = this.getPreviousPage(); const privateData = { pid: this.projectID, perf, @@ -223,7 +194,6 @@ export class Lib { ca: getUTMCampaign(), te: getUTMTerm(), co: getUTMContent(), - prev, ...payload, }; if (evokeCallback && this.pageViewsOptions?.callback) { diff --git a/dist/esnext/Lib.js.map b/dist/esnext/Lib.js.map index 36b83ea..636e459 100644 --- a/dist/esnext/Lib.js.map +++ b/dist/esnext/Lib.js.map @@ -1 +1 @@ -{"version":3,"file":"Lib.js","sourceRoot":"","sources":["../../src/Lib.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,WAAW,EACX,WAAW,EACX,SAAS,EACT,WAAW,EACX,WAAW,EACX,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,aAAa,EACb,OAAO,GACR,MAAM,SAAS,CAAA;AA2JhB,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,KAAI,CAAC;CACV,CAAA;AAED,MAAM,gBAAgB,GAAG,6BAA6B,CAAA;AAEtD,MAAM,OAAO,GAAG;IAQd,YAAoB,SAAiB,EAAU,OAAoB;QAA/C,cAAS,GAAT,SAAS,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAa;QAP3D,aAAQ,GAAoB,IAAI,CAAA;QAChC,qBAAgB,GAAwC,IAAI,CAAA;QAC5D,kBAAa,GAAoC,IAAI,CAAA;QACrD,uBAAkB,GAAY,KAAK,CAAA;QACnC,eAAU,GAAkB,IAAI,CAAA;QAChC,wBAAmB,GAAG,KAAK,CAAA;QAGjC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACtD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC1C,IAAI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WAAW,EAAE;YACd,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,IAAI,MAAM,CAAC,SAAS,EAAE,UAAU,KAAK,GAAG,CAAC;YAClE,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,CAAC;YACzC,WAAW,EAAE,EACb,CAAC;YACD,OAAO,KAAK,CAAA;QACd,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;IAEO,KAAK,CAAC,WAAW,CAAC,IAAY,EAAE,IAAY;QAClD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,MAAM,IAAI,gBAAgB,CAAA;QACrD,MAAM,KAAK,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,EAAE;YAC7B,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAA;IACJ,CAAC;CACF"} \ No newline at end of file diff --git a/dist/esnext/index.d.ts b/dist/esnext/index.d.ts index c963bb5..bcce709 100644 --- a/dist/esnext/index.d.ts +++ b/dist/esnext/index.d.ts @@ -44,11 +44,11 @@ export declare function trackError(payload: IErrorEventPayload): void; * * @deprecated This function is deprecated and will be removed soon, please use the `pageview` instead. * @param pg Path of the page to track (this will be sent to the Swetrix API and displayed in the dashboard). - * @param prev Path of the previous page. + * @param _prev Path of the previous page (deprecated and ignored). * @param unique If set to `true`, only 1 event with the same ID will be saved per user session. * @returns void */ -export declare function trackPageview(pg: string, prev?: string, unique?: boolean): void; +export declare function trackPageview(pg: string, _prev?: string, unique?: boolean): void; export interface IPageviewOptions { payload: Partial; unique?: boolean; diff --git a/dist/esnext/index.js b/dist/esnext/index.js index f2c68a0..fb4db69 100644 --- a/dist/esnext/index.js +++ b/dist/esnext/index.js @@ -79,14 +79,14 @@ export function trackError(payload) { * * @deprecated This function is deprecated and will be removed soon, please use the `pageview` instead. * @param pg Path of the page to track (this will be sent to the Swetrix API and displayed in the dashboard). - * @param prev Path of the previous page. + * @param _prev Path of the previous page (deprecated and ignored). * @param unique If set to `true`, only 1 event with the same ID will be saved per user session. * @returns void */ -export function trackPageview(pg, prev, unique) { +export function trackPageview(pg, _prev, unique) { if (!LIB_INSTANCE) return; - LIB_INSTANCE.submitPageView({ pg, prev: prev || null }, Boolean(unique), {}); + LIB_INSTANCE.submitPageView({ pg }, Boolean(unique), {}); } export function pageview(options) { if (!LIB_INSTANCE) diff --git a/dist/esnext/index.js.map b/dist/esnext/index.js.map index b392568..4563a4d 100644 --- a/dist/esnext/index.js.map +++ b/dist/esnext/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EAOH,cAAc,GAGf,MAAM,OAAO,CAAA;AAEd,MAAM,CAAC,IAAI,YAAY,GAAe,IAAI,CAAA;AAE1C;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAC,GAAW,EAAE,OAAoB;IACpD,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,YAAY,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IACtC,CAAC;IAED,OAAO,YAAY,CAAA;AACrB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,KAAwB;IAClD,IAAI,CAAC,YAAY;QAAE,OAAM;IAEzB,MAAM,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;AACjC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,OAA0B;IACnD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO,CAAC,cAAc,CAAC,CAAA;YACvB,OAAM;QACR,CAAC;QAED,8GAA8G;QAC9G,IAAI,OAAO,QAAQ,KAAK,WAAW,I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AED,OAAO,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;AAC1C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,OAA2B;IACpD,IAAI,CAAC,YAAY;QAAE,OAAM;IAEzB,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;AAC1C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,EAAU,EAAE,KAAc,EAAE,MAAgB;IACxE,IAAI,CAAC,YAAY;QAAE,OAAM;IAEzB,YAAY,CAAC,cAAc,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAA;AAC1D,CAAC;AAOD,MAAM,UAAU,QAAQ,CAAC,OAAyB;IAChD,IAAI,CAAC,YAAY;QAAE,OAAM;IAEzB,YAAY,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAA;AAC3E,CAAC"} \ No newline at end of file diff --git a/dist/swetrix.cjs.js b/dist/swetrix.cjs.js index 7e82cc0..89625ab 100644 --- a/dist/swetrix.cjs.js +++ b/dist/swetrix.cjs.js @@ -309,34 +309,6 @@ var Lib = /** @class */ (function () { this.trackPage(newPath, false); } }; - Lib.prototype.getPreviousPage = function () { - // Assuming that this function is called in trackPage and this.activePage is not overwritten by new value yet - // That method of getting previous page works for SPA websites - if (this.activePage) { - return this.activePage; - } - // Checking if URL is supported by the browser (for example, IE11 does not support it) - if (typeof URL === 'function') { - // That method of getting previous page works for websites with page reloads - var referrer = getReferrer(); - if (!referrer) { - return null; - } - var host = location.host; - try { - var url = new URL(referrer); - var refHost = url.host, pathname = url.pathname; - if (host !== refHost) { - return null; - } - return pathname; - } - catch (_a) { - return null; - } - } - return null; - }; Lib.prototype.trackPage = function (pg, unique) { if (unique === void 0) { unique = false; } if (!this.pageData) @@ -348,13 +320,12 @@ var Lib = /** @class */ (function () { }; Lib.prototype.submitPageView = function (payload, unique, perf, evokeCallback) { var _a; - var prev = this.getPreviousPage(); var privateData = { pid: this.projectID, perf: perf, unique: unique, }; - var pvPayload = __assign({ lc: getLocale(), tz: getTimezone(), ref: getReferrer(), so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), te: getUTMTerm(), co: getUTMContent(), prev: prev }, payload); + var pvPayload = __assign({ lc: getLocale(), tz: getTimezone(), ref: getReferrer(), so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), te: getUTMTerm(), co: getUTMContent() }, payload); if (evokeCallback && ((_a = this.pageViewsOptions) === null || _a === void 0 ? void 0 : _a.callback)) { var callbackResult = this.pageViewsOptions.callback(pvPayload); if (callbackResult === false) { @@ -493,14 +464,14 @@ function trackError(payload) { * * @deprecated This function is deprecated and will be removed soon, please use the `pageview` instead. * @param pg Path of the page to track (this will be sent to the Swetrix API and displayed in the dashboard). - * @param prev Path of the previous page. + * @param _prev Path of the previous page (deprecated and ignored). * @param unique If set to `true`, only 1 event with the same ID will be saved per user session. * @returns void */ -function trackPageview(pg, prev, unique) { +function trackPageview(pg, _prev, unique) { if (!exports.LIB_INSTANCE) return; - exports.LIB_INSTANCE.submitPageView({ pg: pg, prev: prev || null }, Boolean(unique), {}); + exports.LIB_INSTANCE.submitPageView({ pg: pg }, Boolean(unique), {}); } function pageview(options) { if (!exports.LIB_INSTANCE) diff --git a/dist/swetrix.es5.js b/dist/swetrix.es5.js index 80007e2..6b5384c 100644 --- a/dist/swetrix.es5.js +++ b/dist/swetrix.es5.js @@ -305,34 +305,6 @@ var Lib = /** @class */ (function () { this.trackPage(newPath, false); } }; - Lib.prototype.getPreviousPage = function () { - // Assuming that this function is called in trackPage and this.activePage is not overwritten by new value yet - // That method of getting previous page works for SPA websites - if (this.activePage) { - return this.activePage; - } - // Checking if URL is supported by the browser (for example, IE11 does not support it) - if (typeof URL === 'function') { - // That method of getting previous page works for websites with page reloads - var referrer = getReferrer(); - if (!referrer) { - return null; - } - var host = location.host; - try { - var url = new URL(referrer); - var refHost = url.host, pathname = url.pathname; - if (host !== refHost) { - return null; - } - return pathname; - } - catch (_a) { - return null; - } - } - return null; - }; Lib.prototype.trackPage = function (pg, unique) { if (unique === void 0) { unique = false; } if (!this.pageData) @@ -344,13 +316,12 @@ var Lib = /** @class */ (function () { }; Lib.prototype.submitPageView = function (payload, unique, perf, evokeCallback) { var _a; - var prev = this.getPreviousPage(); var privateData = { pid: this.projectID, perf: perf, unique: unique, }; - var pvPayload = __assign({ lc: getLocale(), tz: getTimezone(), ref: getReferrer(), so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), te: getUTMTerm(), co: getUTMContent(), prev: prev }, payload); + var pvPayload = __assign({ lc: getLocale(), tz: getTimezone(), ref: getReferrer(), so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), te: getUTMTerm(), co: getUTMContent() }, payload); if (evokeCallback && ((_a = this.pageViewsOptions) === null || _a === void 0 ? void 0 : _a.callback)) { var callbackResult = this.pageViewsOptions.callback(pvPayload); if (callbackResult === false) { @@ -489,14 +460,14 @@ function trackError(payload) { * * @deprecated This function is deprecated and will be removed soon, please use the `pageview` instead. * @param pg Path of the page to track (this will be sent to the Swetrix API and displayed in the dashboard). - * @param prev Path of the previous page. + * @param _prev Path of the previous page (deprecated and ignored). * @param unique If set to `true`, only 1 event with the same ID will be saved per user session. * @returns void */ -function trackPageview(pg, prev, unique) { +function trackPageview(pg, _prev, unique) { if (!LIB_INSTANCE) return; - LIB_INSTANCE.submitPageView({ pg: pg, prev: prev || null }, Boolean(unique), {}); + LIB_INSTANCE.submitPageView({ pg: pg }, Boolean(unique), {}); } function pageview(options) { if (!LIB_INSTANCE) diff --git a/dist/swetrix.js b/dist/swetrix.js index a90e590..6aa65b6 100644 --- a/dist/swetrix.js +++ b/dist/swetrix.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).swetrix={})}(this,function(r){"use strict";var i=function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;ns[0]&&e[1]Math.random()||this.submitError({filename:t.filename,lineno:t.lineno,colno:t.colno,name:(null==(e=t.error)?void 0:e.name)||"Error",message:(null==(e=t.error)?void 0:e.message)||t.message},!0)},E.prototype.trackErrors=function(t){var e=this;return this.errorListenerExists||!this.canTrack()?w:(this.errorsOptions=t,window.addEventListener("error",this.captureError),this.errorListenerExists=!0,{stop:function(){window.removeEventListener("error",e.captureError)}})},E.prototype.submitError=function(t,e){var n={pid:this.projectID},r=i({pg:this.activePage||f({hash:null==(r=this.pageViewsOptions)?void 0:r.hash,search:null==(r=this.pageViewsOptions)?void 0:r.search}),lc:a(),tz:s()},t);if(e&&null!=(t=this.errorsOptions)&&t.callback){e=this.errorsOptions.callback(r);if(!1===e)return;e&&"object"==typeof e&&Object.assign(r,e)}Object.assign(r,n),this.sendRequest("error",r)},E.prototype.track=function(n){return t(this,void 0,void 0,function(){var e;return o(this,function(t){switch(t.label){case 0:return this.canTrack()?(e=i(i({},n),{pid:this.projectID,pg:this.activePage,lc:a(),tz:s(),ref:c(),so:u(),me:l(),ca:h(),te:p(),co:d()}),[4,this.sendRequest("custom",e)]):[2];case 1:return t.sent(),[2]}})})},E.prototype.trackPageViews=function(t){var e,n,r;return this.canTrack()?(this.pageData||(null!=(this.pageViewsOptions=t)&&t.unique||(e=setInterval(this.trackPathChange,2e3)),setTimeout(this.heartbeat,3e3),n=setInterval(this.heartbeat,28e3),r=f({hash:null==t?void 0:t.hash,search:null==t?void 0:t.search}),this.pageData={path:r,actions:{stop:function(){clearInterval(e),clearInterval(n)}}},this.trackPage(r,null==t?void 0:t.unique)),this.pageData.actions):w},E.prototype.getPerformanceStats=function(){var t;return this.canTrack()&&!this.perfStatsCollected&&null!=(t=window.performance)&&t.getEntriesByType&&(t=window.performance.getEntriesByType("navigation")[0])?(this.perfStatsCollected=!0,{dns:t.domainLookupEnd-t.domainLookupStart,tls:t.secureConnectionStart?t.requestStart-t.secureConnectionStart:0,conn:t.secureConnectionStart?t.secureConnectionStart-t.connectStart:t.connectEnd-t.connectStart,response:t.responseEnd-t.responseStart,render:t.domComplete-t.domContentLoadedEventEnd,dom_load:t.domContentLoadedEventEnd-t.responseEnd,page_load:t.loadEventStart,ttfb:t.responseStart-t.requestStart}):{}},E.prototype.heartbeat=function(){var t;(null!=(t=this.pageViewsOptions)&&t.heartbeatOnBackground||"hidden"!==document.visibilityState)&&(t={pid:this.projectID},this.sendRequest("hb",t))},E.prototype.trackPathChange=function(){var t;this.pageData&&(t=f({hash:null==(t=this.pageViewsOptions)?void 0:t.hash,search:null==(t=this.pageViewsOptions)?void 0:t.search}),this.pageData.path!==t)&&this.trackPage(t,!1)},E.prototype.getPreviousPage=function(){if(this.activePage)return this.activePage;if("function"==typeof URL){var t=c();if(!t)return null;var e=location.host;try{var n=new URL(t),r=n.host,o=n.pathname;return e!==r?null:o}catch(t){}}return null},E.prototype.trackPage=function(t,e){var n;void 0===e&&(e=!1),this.pageData&&(this.pageData.path=t,n=this.getPerformanceStats(),this.activePage=t,this.submitPageView({pg:t},e,n,!0))},E.prototype.submitPageView=function(t,e,n,r){var o=this.getPreviousPage(),n={pid:this.projectID,perf:n,unique:e},e=i({lc:a(),tz:s(),ref:c(),so:u(),me:l(),ca:h(),te:p(),co:d(),prev:o},t);if(r&&null!=(o=this.pageViewsOptions)&&o.callback){t=this.pageViewsOptions.callback(e);if(!1===t)return;t&&"object"==typeof t&&Object.assign(e,t)}Object.assign(e,n),this.sendRequest("",e)},E.prototype.canTrack=function(){var t;return!(null!=(t=this.options)&&t.disabled||"undefined"==typeof window||null!=(t=this.options)&&t.respectDNT&&"1"===(null==(t=window.navigator)?void 0:t.doNotTrack)||(null==(t=this.options)||!t.devMode)&&("localhost"===(null===location||void 0===location?void 0:location.hostname)||"127.0.0.1"===(null===location||void 0===location?void 0:location.hostname)||""===(null===location||void 0===location?void 0:location.hostname))||null!==navigator&&void 0!==navigator&&navigator.webdriver)},E.prototype.sendRequest=function(n,r){return t(this,void 0,void 0,function(){var e;return o(this,function(t){switch(t.label){case 0:return e=(null==(e=this.options)?void 0:e.apiURL)||"https://api.swetrix.com/log",[4,fetch("".concat(e,"/").concat(n),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})];case 1:return t.sent(),[2]}})})},E);function E(t,e){this.projectID=t,this.options=e,this.pageData=null,this.pageViewsOptions=null,this.errorsOptions=null,this.perfStatsCollected=!1,this.activePage=null,this.errorListenerExists=!1,this.trackPathChange=this.trackPathChange.bind(this),this.heartbeat=this.heartbeat.bind(this),this.captureError=this.captureError.bind(this)}r.LIB_INSTANCE=null,r.init=function(t,e){return r.LIB_INSTANCE||(r.LIB_INSTANCE=new y(t,e)),r.LIB_INSTANCE},r.pageview=function(t){r.LIB_INSTANCE&&r.LIB_INSTANCE.submitPageView(t.payload,Boolean(t.unique),{})},r.track=function(e){return t(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return r.LIB_INSTANCE?[4,r.LIB_INSTANCE.track(e)]:[2];case 1:return t.sent(),[2]}})})},r.trackError=function(t){r.LIB_INSTANCE&&r.LIB_INSTANCE.submitError(t,!1)},r.trackErrors=function(t){return r.LIB_INSTANCE?r.LIB_INSTANCE.trackErrors(t):w},r.trackPageview=function(t,e,n){r.LIB_INSTANCE&&r.LIB_INSTANCE.submitPageView({pg:t,prev:e||null},Boolean(n),{})},r.trackViews=function(e){return new Promise(function(t){r.LIB_INSTANCE?"undefined"==typeof document||"complete"===document.readyState?t(r.LIB_INSTANCE.trackPageViews(e)):window.addEventListener("load",function(){t(r.LIB_INSTANCE.trackPageViews(e))}):t(w)})},Object.defineProperty(r,"__esModule",{value:!0})}); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).swetrix={})}(this,function(o){"use strict";var r=function(){return(r=Object.assign||function(t){for(var e,n=1,o=arguments.length;ns[0]&&e[1]Math.random()||this.submitError({filename:t.filename,lineno:t.lineno,colno:t.colno,name:(null==(e=t.error)?void 0:e.name)||"Error",message:(null==(e=t.error)?void 0:e.message)||t.message},!0)},E.prototype.trackErrors=function(t){var e=this;return this.errorListenerExists||!this.canTrack()?w:(this.errorsOptions=t,window.addEventListener("error",this.captureError),this.errorListenerExists=!0,{stop:function(){window.removeEventListener("error",e.captureError)}})},E.prototype.submitError=function(t,e){var n={pid:this.projectID},o=r({pg:this.activePage||f({hash:null==(o=this.pageViewsOptions)?void 0:o.hash,search:null==(o=this.pageViewsOptions)?void 0:o.search}),lc:a(),tz:s()},t);if(e&&null!=(t=this.errorsOptions)&&t.callback){e=this.errorsOptions.callback(o);if(!1===e)return;e&&"object"==typeof e&&Object.assign(o,e)}Object.assign(o,n),this.sendRequest("error",o)},E.prototype.track=function(n){return t(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return this.canTrack()?(e=r(r({},n),{pid:this.projectID,pg:this.activePage,lc:a(),tz:s(),ref:c(),so:u(),me:l(),ca:h(),te:p(),co:d()}),[4,this.sendRequest("custom",e)]):[2];case 1:return t.sent(),[2]}})})},E.prototype.trackPageViews=function(t){var e,n,o;return this.canTrack()?(this.pageData||(null!=(this.pageViewsOptions=t)&&t.unique||(e=setInterval(this.trackPathChange,2e3)),setTimeout(this.heartbeat,3e3),n=setInterval(this.heartbeat,28e3),o=f({hash:null==t?void 0:t.hash,search:null==t?void 0:t.search}),this.pageData={path:o,actions:{stop:function(){clearInterval(e),clearInterval(n)}}},this.trackPage(o,null==t?void 0:t.unique)),this.pageData.actions):w},E.prototype.getPerformanceStats=function(){var t;return this.canTrack()&&!this.perfStatsCollected&&null!=(t=window.performance)&&t.getEntriesByType&&(t=window.performance.getEntriesByType("navigation")[0])?(this.perfStatsCollected=!0,{dns:t.domainLookupEnd-t.domainLookupStart,tls:t.secureConnectionStart?t.requestStart-t.secureConnectionStart:0,conn:t.secureConnectionStart?t.secureConnectionStart-t.connectStart:t.connectEnd-t.connectStart,response:t.responseEnd-t.responseStart,render:t.domComplete-t.domContentLoadedEventEnd,dom_load:t.domContentLoadedEventEnd-t.responseEnd,page_load:t.loadEventStart,ttfb:t.responseStart-t.requestStart}):{}},E.prototype.heartbeat=function(){var t;(null!=(t=this.pageViewsOptions)&&t.heartbeatOnBackground||"hidden"!==document.visibilityState)&&(t={pid:this.projectID},this.sendRequest("hb",t))},E.prototype.trackPathChange=function(){var t;this.pageData&&(t=f({hash:null==(t=this.pageViewsOptions)?void 0:t.hash,search:null==(t=this.pageViewsOptions)?void 0:t.search}),this.pageData.path!==t)&&this.trackPage(t,!1)},E.prototype.trackPage=function(t,e){var n;void 0===e&&(e=!1),this.pageData&&(this.pageData.path=t,n=this.getPerformanceStats(),this.activePage=t,this.submitPageView({pg:t},e,n,!0))},E.prototype.submitPageView=function(t,e,n,o){n={pid:this.projectID,perf:n,unique:e},e=r({lc:a(),tz:s(),ref:c(),so:u(),me:l(),ca:h(),te:p(),co:d()},t);if(o&&null!=(t=this.pageViewsOptions)&&t.callback){o=this.pageViewsOptions.callback(e);if(!1===o)return;o&&"object"==typeof o&&Object.assign(e,o)}Object.assign(e,n),this.sendRequest("",e)},E.prototype.canTrack=function(){var t;return!(null!=(t=this.options)&&t.disabled||"undefined"==typeof window||null!=(t=this.options)&&t.respectDNT&&"1"===(null==(t=window.navigator)?void 0:t.doNotTrack)||(null==(t=this.options)||!t.devMode)&&("localhost"===(null===location||void 0===location?void 0:location.hostname)||"127.0.0.1"===(null===location||void 0===location?void 0:location.hostname)||""===(null===location||void 0===location?void 0:location.hostname))||null!==navigator&&void 0!==navigator&&navigator.webdriver)},E.prototype.sendRequest=function(n,o){return t(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return e=(null==(e=this.options)?void 0:e.apiURL)||"https://api.swetrix.com/log",[4,fetch("".concat(e,"/").concat(n),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})];case 1:return t.sent(),[2]}})})},E);function E(t,e){this.projectID=t,this.options=e,this.pageData=null,this.pageViewsOptions=null,this.errorsOptions=null,this.perfStatsCollected=!1,this.activePage=null,this.errorListenerExists=!1,this.trackPathChange=this.trackPathChange.bind(this),this.heartbeat=this.heartbeat.bind(this),this.captureError=this.captureError.bind(this)}o.LIB_INSTANCE=null,o.init=function(t,e){return o.LIB_INSTANCE||(o.LIB_INSTANCE=new y(t,e)),o.LIB_INSTANCE},o.pageview=function(t){o.LIB_INSTANCE&&o.LIB_INSTANCE.submitPageView(t.payload,Boolean(t.unique),{})},o.track=function(e){return t(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return o.LIB_INSTANCE?[4,o.LIB_INSTANCE.track(e)]:[2];case 1:return t.sent(),[2]}})})},o.trackError=function(t){o.LIB_INSTANCE&&o.LIB_INSTANCE.submitError(t,!1)},o.trackErrors=function(t){return o.LIB_INSTANCE?o.LIB_INSTANCE.trackErrors(t):w},o.trackPageview=function(t,e,n){o.LIB_INSTANCE&&o.LIB_INSTANCE.submitPageView({pg:t},Boolean(n),{})},o.trackViews=function(e){return new Promise(function(t){o.LIB_INSTANCE?"undefined"==typeof document||"complete"===document.readyState?t(o.LIB_INSTANCE.trackPageViews(e)):window.addEventListener("load",function(){t(o.LIB_INSTANCE.trackPageViews(e))}):t(w)})},Object.defineProperty(o,"__esModule",{value:!0})}); diff --git a/dist/swetrix.orig.js b/dist/swetrix.orig.js index e685b77..18c9831 100644 --- a/dist/swetrix.orig.js +++ b/dist/swetrix.orig.js @@ -311,34 +311,6 @@ this.trackPage(newPath, false); } }; - Lib.prototype.getPreviousPage = function () { - // Assuming that this function is called in trackPage and this.activePage is not overwritten by new value yet - // That method of getting previous page works for SPA websites - if (this.activePage) { - return this.activePage; - } - // Checking if URL is supported by the browser (for example, IE11 does not support it) - if (typeof URL === 'function') { - // That method of getting previous page works for websites with page reloads - var referrer = getReferrer(); - if (!referrer) { - return null; - } - var host = location.host; - try { - var url = new URL(referrer); - var refHost = url.host, pathname = url.pathname; - if (host !== refHost) { - return null; - } - return pathname; - } - catch (_a) { - return null; - } - } - return null; - }; Lib.prototype.trackPage = function (pg, unique) { if (unique === void 0) { unique = false; } if (!this.pageData) @@ -350,13 +322,12 @@ }; Lib.prototype.submitPageView = function (payload, unique, perf, evokeCallback) { var _a; - var prev = this.getPreviousPage(); var privateData = { pid: this.projectID, perf: perf, unique: unique, }; - var pvPayload = __assign({ lc: getLocale(), tz: getTimezone(), ref: getReferrer(), so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), te: getUTMTerm(), co: getUTMContent(), prev: prev }, payload); + var pvPayload = __assign({ lc: getLocale(), tz: getTimezone(), ref: getReferrer(), so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), te: getUTMTerm(), co: getUTMContent() }, payload); if (evokeCallback && ((_a = this.pageViewsOptions) === null || _a === void 0 ? void 0 : _a.callback)) { var callbackResult = this.pageViewsOptions.callback(pvPayload); if (callbackResult === false) { @@ -495,14 +466,14 @@ * * @deprecated This function is deprecated and will be removed soon, please use the `pageview` instead. * @param pg Path of the page to track (this will be sent to the Swetrix API and displayed in the dashboard). - * @param prev Path of the previous page. + * @param _prev Path of the previous page (deprecated and ignored). * @param unique If set to `true`, only 1 event with the same ID will be saved per user session. * @returns void */ - function trackPageview(pg, prev, unique) { + function trackPageview(pg, _prev, unique) { if (!exports.LIB_INSTANCE) return; - exports.LIB_INSTANCE.submitPageView({ pg: pg, prev: prev || null }, Boolean(unique), {}); + exports.LIB_INSTANCE.submitPageView({ pg: pg }, Boolean(unique), {}); } function pageview(options) { if (!exports.LIB_INSTANCE)