diff --git a/dist/esnext/Lib.js b/dist/esnext/Lib.js index b11ba1b..80859a7 100644 --- a/dist/esnext/Lib.js +++ b/dist/esnext/Lib.js @@ -1,4 +1,4 @@ -import { isInBrowser, isLocalhost, isAutomated, getLocale, getTimezone, getReferrer, getUTMCampaign, getUTMMedium, getUTMSource, getPath, } from './utils'; +import { isInBrowser, isLocalhost, isAutomated, getLocale, getTimezone, getReferrer, getUTMCampaign, getUTMMedium, getUTMSource, getUTMTerm, getUTMContent, getPath, } from './utils'; export const defaultActions = { stop() { }, }; @@ -89,6 +89,8 @@ export class Lib { so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), + te: getUTMTerm(), + co: getUTMContent(), }; await this.sendRequest('custom', data); } @@ -219,6 +221,8 @@ export class Lib { so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), + te: getUTMTerm(), + co: getUTMContent(), prev, ...payload, }; diff --git a/dist/esnext/Lib.js.map b/dist/esnext/Lib.js.map index 151ac6a..502b40a 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,OAAO,GACR,MAAM,SAAS,CAAA;AAyJhB,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,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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/utils.d.ts b/dist/esnext/utils.d.ts index b61df71..3290e57 100644 --- a/dist/esnext/utils.d.ts +++ b/dist/esnext/utils.d.ts @@ -11,6 +11,8 @@ export declare const getReferrer: () => string | undefined; export declare const getUTMSource: () => string | undefined; export declare const getUTMMedium: () => string | undefined; export declare const getUTMCampaign: () => string | undefined; +export declare const getUTMTerm: () => string | undefined; +export declare const getUTMContent: () => string | undefined; /** * Function used to track the current page (path) of the application. * Will work in cases where the path looks like: diff --git a/dist/esnext/utils.js b/dist/esnext/utils.js index c8083aa..7ba6e10 100644 --- a/dist/esnext/utils.js +++ b/dist/esnext/utils.js @@ -5,6 +5,8 @@ const findInSearch = (exp) => { const utmSourceRegex = /[?&](ref|source|utm_source)=([^?&]+)/; const utmCampaignRegex = /[?&](utm_campaign)=([^?&]+)/; const utmMediumRegex = /[?&](utm_medium)=([^?&]+)/; +const utmTermRegex = /[?&](utm_term)=([^?&]+)/; +const utmContentRegex = /[?&](utm_content)=([^?&]+)/; export const isInBrowser = () => { return typeof window !== 'undefined'; }; @@ -31,6 +33,8 @@ export const getReferrer = () => { export const getUTMSource = () => findInSearch(utmSourceRegex); export const getUTMMedium = () => findInSearch(utmMediumRegex); export const getUTMCampaign = () => findInSearch(utmCampaignRegex); +export const getUTMTerm = () => findInSearch(utmTermRegex); +export const getUTMContent = () => findInSearch(utmContentRegex); /** * Function used to track the current page (path) of the application. * Will work in cases where the path looks like: diff --git a/dist/esnext/utils.js.map b/dist/esnext/utils.js.map index 06cb677..c320b5c 100644 --- a/dist/esnext/utils.js.map +++ b/dist/esnext/utils.js.map @@ -1 +1 @@ -{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAKA,MAAM,YAAY,GAAG,CAAC,GAAW,EAAsB,EAAE;IACvD,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACtC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,SAAS,CAAA;AACrC,CAAC,CAAA;AAED,MAAM,cAAc,GAAG,sCAAsC,CAAA;AAC7D,MAAM,gBAAgB,GAAG,6BAA6B,CAAA;AACtD,MAAM,cAAc,GAAG,2BAA2B,CAAA;AAElD,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,OAAO,OAAO,MAAM,KAAK,WAAW,CAAA;AACtC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,OAAO,QAAQ,EAAE,QAAQ,KAAK,WAAW,IAAI,QAAQ,EAAE,QAAQ,KAAK,WAAW,IAAI,QAAQ,EAAE,QAAQ,KAAK,EAAE,CAAA;AAC9G,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,OAAO,SAAS,EAAE,SAAS,CAAA;AAC7B,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,OAAO,OAAO,SAAS,CAAC,SAAS,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAA;AACjG,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,IAAI,C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AC,QAAQ,CAAC,IAAI,CAAA;QACzF,MAAM,IAAI,UAAU,CAAA;IACtB,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAC5C,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;QAClG,MAAM,IAAI,YAAY,CAAA;IACxB,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/swetrix.cjs.js b/dist/swetrix.cjs.js index af63816..7e82cc0 100644 --- a/dist/swetrix.cjs.js +++ b/dist/swetrix.cjs.js @@ -78,6 +78,8 @@ var findInSearch = function (exp) { var utmSourceRegex = /[?&](ref|source|utm_source)=([^?&]+)/; var utmCampaignRegex = /[?&](utm_campaign)=([^?&]+)/; var utmMediumRegex = /[?&](utm_medium)=([^?&]+)/; +var utmTermRegex = /[?&](utm_term)=([^?&]+)/; +var utmContentRegex = /[?&](utm_content)=([^?&]+)/; var isInBrowser = function () { return typeof window !== 'undefined'; }; @@ -104,6 +106,8 @@ var getReferrer = function () { var getUTMSource = function () { return findInSearch(utmSourceRegex); }; var getUTMMedium = function () { return findInSearch(utmMediumRegex); }; var getUTMCampaign = function () { return findInSearch(utmCampaignRegex); }; +var getUTMTerm = function () { return findInSearch(utmTermRegex); }; +var getUTMContent = function () { return findInSearch(utmContentRegex); }; /** * Function used to track the current page (path) of the application. * Will work in cases where the path looks like: @@ -216,7 +220,7 @@ var Lib = /** @class */ (function () { if (!this.canTrack()) { return [2 /*return*/]; } - data = __assign(__assign({}, event), { pid: this.projectID, pg: this.activePage, lc: getLocale(), tz: getTimezone(), ref: getReferrer(), so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign() }); + data = __assign(__assign({}, event), { pid: this.projectID, pg: this.activePage, lc: getLocale(), tz: getTimezone(), ref: getReferrer(), so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), te: getUTMTerm(), co: getUTMContent() }); return [4 /*yield*/, this.sendRequest('custom', data)]; case 1: _a.sent(); @@ -350,7 +354,7 @@ var Lib = /** @class */ (function () { perf: perf, unique: unique, }; - var pvPayload = __assign({ lc: getLocale(), tz: getTimezone(), ref: getReferrer(), so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), prev: prev }, payload); + var pvPayload = __assign({ lc: getLocale(), tz: getTimezone(), ref: getReferrer(), so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), te: getUTMTerm(), co: getUTMContent(), prev: prev }, payload); if (evokeCallback && ((_a = this.pageViewsOptions) === null || _a === void 0 ? void 0 : _a.callback)) { var callbackResult = this.pageViewsOptions.callback(pvPayload); if (callbackResult === false) { diff --git a/dist/swetrix.es5.js b/dist/swetrix.es5.js index d47b45a..80007e2 100644 --- a/dist/swetrix.es5.js +++ b/dist/swetrix.es5.js @@ -74,6 +74,8 @@ var findInSearch = function (exp) { var utmSourceRegex = /[?&](ref|source|utm_source)=([^?&]+)/; var utmCampaignRegex = /[?&](utm_campaign)=([^?&]+)/; var utmMediumRegex = /[?&](utm_medium)=([^?&]+)/; +var utmTermRegex = /[?&](utm_term)=([^?&]+)/; +var utmContentRegex = /[?&](utm_content)=([^?&]+)/; var isInBrowser = function () { return typeof window !== 'undefined'; }; @@ -100,6 +102,8 @@ var getReferrer = function () { var getUTMSource = function () { return findInSearch(utmSourceRegex); }; var getUTMMedium = function () { return findInSearch(utmMediumRegex); }; var getUTMCampaign = function () { return findInSearch(utmCampaignRegex); }; +var getUTMTerm = function () { return findInSearch(utmTermRegex); }; +var getUTMContent = function () { return findInSearch(utmContentRegex); }; /** * Function used to track the current page (path) of the application. * Will work in cases where the path looks like: @@ -212,7 +216,7 @@ var Lib = /** @class */ (function () { if (!this.canTrack()) { return [2 /*return*/]; } - data = __assign(__assign({}, event), { pid: this.projectID, pg: this.activePage, lc: getLocale(), tz: getTimezone(), ref: getReferrer(), so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign() }); + data = __assign(__assign({}, event), { pid: this.projectID, pg: this.activePage, lc: getLocale(), tz: getTimezone(), ref: getReferrer(), so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), te: getUTMTerm(), co: getUTMContent() }); return [4 /*yield*/, this.sendRequest('custom', data)]; case 1: _a.sent(); @@ -346,7 +350,7 @@ var Lib = /** @class */ (function () { perf: perf, unique: unique, }; - var pvPayload = __assign({ lc: getLocale(), tz: getTimezone(), ref: getReferrer(), so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), prev: prev }, payload); + var pvPayload = __assign({ lc: getLocale(), tz: getTimezone(), ref: getReferrer(), so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), te: getUTMTerm(), co: getUTMContent(), prev: prev }, payload); if (evokeCallback && ((_a = this.pageViewsOptions) === null || _a === void 0 ? void 0 : _a.callback)) { var callbackResult = this.pageViewsOptions.callback(pvPayload); if (callbackResult === false) { diff --git a/dist/swetrix.js b/dist/swetrix.js index fff24a2..a90e590 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)},m.prototype.trackErrors=function(t){var e=this;return this.errorListenerExists||!this.canTrack()?v:(this.errorsOptions=t,window.addEventListener("error",this.captureError),this.errorListenerExists=!0,{stop:function(){window.removeEventListener("error",e.captureError)}})},m.prototype.submitError=function(t,e){var n={pid:this.projectID},r=i({pg:this.activePage||p({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)},m.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()}),[4,this.sendRequest("custom",e)]):[2];case 1:return t.sent(),[2]}})})},m.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=p({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):v},m.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}):{}},m.prototype.heartbeat=function(){var t;(null!=(t=this.pageViewsOptions)&&t.heartbeatOnBackground||"hidden"!==document.visibilityState)&&(t={pid:this.projectID},this.sendRequest("hb",t))},m.prototype.trackPathChange=function(){var t;this.pageData&&(t=p({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)},m.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},m.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))},m.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(),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)},m.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)},m.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]}})})},m);function m(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 g(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):v},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(v)})},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(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})}); diff --git a/dist/swetrix.orig.js b/dist/swetrix.orig.js index aded7aa..e685b77 100644 --- a/dist/swetrix.orig.js +++ b/dist/swetrix.orig.js @@ -80,6 +80,8 @@ var utmSourceRegex = /[?&](ref|source|utm_source)=([^?&]+)/; var utmCampaignRegex = /[?&](utm_campaign)=([^?&]+)/; var utmMediumRegex = /[?&](utm_medium)=([^?&]+)/; + var utmTermRegex = /[?&](utm_term)=([^?&]+)/; + var utmContentRegex = /[?&](utm_content)=([^?&]+)/; var isInBrowser = function () { return typeof window !== 'undefined'; }; @@ -106,6 +108,8 @@ var getUTMSource = function () { return findInSearch(utmSourceRegex); }; var getUTMMedium = function () { return findInSearch(utmMediumRegex); }; var getUTMCampaign = function () { return findInSearch(utmCampaignRegex); }; + var getUTMTerm = function () { return findInSearch(utmTermRegex); }; + var getUTMContent = function () { return findInSearch(utmContentRegex); }; /** * Function used to track the current page (path) of the application. * Will work in cases where the path looks like: @@ -218,7 +222,7 @@ if (!this.canTrack()) { return [2 /*return*/]; } - data = __assign(__assign({}, event), { pid: this.projectID, pg: this.activePage, lc: getLocale(), tz: getTimezone(), ref: getReferrer(), so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign() }); + data = __assign(__assign({}, event), { pid: this.projectID, pg: this.activePage, lc: getLocale(), tz: getTimezone(), ref: getReferrer(), so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), te: getUTMTerm(), co: getUTMContent() }); return [4 /*yield*/, this.sendRequest('custom', data)]; case 1: _a.sent(); @@ -352,7 +356,7 @@ perf: perf, unique: unique, }; - var pvPayload = __assign({ lc: getLocale(), tz: getTimezone(), ref: getReferrer(), so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), prev: prev }, payload); + var pvPayload = __assign({ lc: getLocale(), tz: getTimezone(), ref: getReferrer(), so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), te: getUTMTerm(), co: getUTMContent(), prev: prev }, payload); if (evokeCallback && ((_a = this.pageViewsOptions) === null || _a === void 0 ? void 0 : _a.callback)) { var callbackResult = this.pageViewsOptions.callback(pvPayload); if (callbackResult === false) { diff --git a/package.json b/package.json index b7b6931..c657b27 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "swetrix", - "version": "3.3.0", + "version": "3.4.0", "description": "The JavaScript analytics client for Swetrix Analytics", "main": "dist/swetrix.cjs.js", "module": "dist/swetrix.es5.js", diff --git a/src/Lib.ts b/src/Lib.ts index 69a717a..9303cf5 100644 --- a/src/Lib.ts +++ b/src/Lib.ts @@ -8,6 +8,8 @@ import { getUTMCampaign, getUTMMedium, getUTMSource, + getUTMTerm, + getUTMContent, getPath, } from './utils' @@ -276,6 +278,8 @@ export class Lib { so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), + te: getUTMTerm(), + co: getUTMContent(), } await this.sendRequest('custom', data) } @@ -441,6 +445,8 @@ export class Lib { so: getUTMSource(), me: getUTMMedium(), ca: getUTMCampaign(), + te: getUTMTerm(), + co: getUTMContent(), prev, ...payload, } diff --git a/src/utils.ts b/src/utils.ts index 35542bc..e8d9360 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -11,6 +11,8 @@ const findInSearch = (exp: RegExp): string | undefined => { const utmSourceRegex = /[?&](ref|source|utm_source)=([^?&]+)/ const utmCampaignRegex = /[?&](utm_campaign)=([^?&]+)/ const utmMediumRegex = /[?&](utm_medium)=([^?&]+)/ +const utmTermRegex = /[?&](utm_term)=([^?&]+)/ +const utmContentRegex = /[?&](utm_content)=([^?&]+)/ export const isInBrowser = () => { return typeof window !== 'undefined' @@ -46,6 +48,10 @@ export const getUTMMedium = () => findInSearch(utmMediumRegex) export const getUTMCampaign = () => findInSearch(utmCampaignRegex) +export const getUTMTerm = () => findInSearch(utmTermRegex) + +export const getUTMContent = () => findInSearch(utmContentRegex) + /** * Function used to track the current page (path) of the application. * Will work in cases where the path looks like: