📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Changed logging endpoint
Blue Mousee48d460fbbc7
diff --git a/dist/analytics.cjs.js b/dist/analytics.cjs.jsindex 87fef1ada..aaf3c9d1a 100644--- a/dist/analytics.cjs.js+++ b/dist/analytics.cjs.js@@ -66,7 +66,7 @@ var getPath = function () {return location.pathname || '';};-var host = 'http://localhost:5005/log';+var host = 'https://api.swetrix.com/log';var Lib = /** @class */ (function () {function Lib(projectID, options) {this.projectID = projectID;@@ -128,7 +128,7 @@ var Lib = /** @class */ (function () {Lib.prototype.debug = function (message) {var _a;if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.debug) {- console.log('[Analytics]', message);+ console.log('[Swetrix]', message);}};Lib.prototype.canTrack = function () {diff --git a/dist/analytics.es5.js b/dist/analytics.es5.jsindex 2bbf13bac..32ce9dcba 100644--- a/dist/analytics.es5.js+++ b/dist/analytics.es5.js@@ -62,7 +62,7 @@ var getPath = function () {return location.pathname || '';};-var host = 'http://localhost:5005/log';+var host = 'https://api.swetrix.com/log';var Lib = /** @class */ (function () {function Lib(projectID, options) {this.projectID = projectID;@@ -124,7 +124,7 @@ var Lib = /** @class */ (function () {Lib.prototype.debug = function (message) {var _a;if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.debug) {- console.log('[Analytics]', message);+ console.log('[Swetrix]', message);}};Lib.prototype.canTrack = function () {diff --git a/dist/analytics.umd.js b/dist/analytics.umd.jsindex 648b20771..cab7ec6ff 100644--- a/dist/analytics.umd.js+++ b/dist/analytics.umd.js@@ -68,7 +68,7 @@return location.pathname || '';};- var host = 'http://localhost:5005/log';+ var host = 'https://api.swetrix.com/log';var Lib = /** @class */ (function () {function Lib(projectID, options) {this.projectID = projectID;@@ -130,7 +130,7 @@Lib.prototype.debug = function (message) {var _a;if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.debug) {- console.log('[Analytics]', message);+ console.log('[Swetrix]', message);}};Lib.prototype.canTrack = function () {diff --git a/dist/esnext/Lib.js b/dist/esnext/Lib.jsindex 437b9fee0..63dcc920e 100644--- a/dist/esnext/Lib.js+++ b/dist/esnext/Lib.js@@ -1,5 +1,5 @@import { isInBrowser, isLocalhost, isAutomated, getLocale, getTimezone, getReferrer, getUTMCampaign, getUTMMedium, getUTMSource, getPath, } from './utils';-const host = 'http://localhost:5005/log';+const host = 'https://api.swetrix.com/log';export class Lib {constructor(projectID, options) {this.projectID = projectID;@@ -63,7 +63,7 @@ export class Lib {}debug(message) {if (this.options?.debug) {- console.log('[Analytics]', message);+ console.log('[Swetrix]', message);}}canTrack() {diff --git a/dist/esnext/Lib.js.map b/dist/esnext/Lib.js.mapindex 112514c25..0e51b8371 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,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAC1E,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,GACpD,MAAM,SAAS,CAAA;AA2ChB,MAAM,IAAI,GAAG,2BAA2B,CAAA;AAExC,MAAM,OAAO,GAAG;IAGd,YAAoB,SAAiB,EAAU,OAAoB;QAA/C,cAAS,GAAT,SAAS,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAa;QAF3D,aAAQ,GAAoB,IAAI,CAAA;IAIxC,CAAC;IAED,wBAAwB;IACxB,KAAK,CAAC,KAAwB;QAC5B,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE;YACpB,OAAM;SACP;QAED,MAAM,IAAI,GAAG;YACX,GAAG,EAAE,IAAI,CAAC,SAAS;YACnB,GAAG,KAA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b;QAED,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,EAAE;YACzC,OAAO,KAAK,CAAA;SACb;QAED,IAAI,WAAW,EAAE,EAAE;YACjB,IAAI,CAAC,KAAK,CAAC,0DAA0D,CAAC,CAAA;YACtE,OAAO,KAAK,CAAA;SACb;QAED,OAAO,IAAI,CAAA;IACb,CAAC;IAEO,UAAU,CAAC,IAAY;QAC7B,OAAO,KAAK,CAAC,IAAI,EAAE;YACjB,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,QAAQ,EAAE,kBAAkB;gBAC5B,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAA;IACJ,CAAC;IAEO,YAAY,CAAC,IAAY;QAC/B,OAAO,KAAK,CAAC,GAAG,IAAI,SAAS,EAAE;YAC7B,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,QAAQ,EAAE,kBAAkB;gBAC5B,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAA;IACJ,CAAC;CACF"}\ No newline at end of filediff --git a/dist/swetrix.js b/dist/swetrix.jsindex 24e479dfa..34ff390cd 100644--- a/dist/swetrix.js+++ b/dist/swetrix.js@@ -1 +1 @@-!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o((t="undefined"!=typeof globalThis?globalThis:t||self).swetrix={})}(this,function(n){"use strict";function o(t){return(t=location.search.match(t))&&t[2]||void 0}function e(){return location.pathname||""}var i=function(){return(i=Object.assign||function(t){for(var o,n=1,e=arguments.length;n<e;n++)for(var i in o=arguments[n])Object.prototype.hasOwnProperty.call(o,i)&&(t[i]=o[i]);return t}).apply(this,arguments)},a=/[?&](ref|source|utm_source)=([^?&]+)/,r=/[?&](utm_campaign)=([^?&]+)/,c=/[?&](utm_medium)=([^?&]+)/,s="http://localhost:5005/log",u=(t.prototype.track=function(t){this.canTrack()&&(t=i({pid:this.projectID},t),this.submitCustom(t))},t.prototype.trackPageViews=function(t){if(this.canTrack()){if(this.pageData)return this.pageData.actions;var o=setInterval(this.trackPathChange,1e3),n=e();this.pageData={path:n,actions:{stop:function(){return clearInterval(o)}}},this.trackPage(n)}},t.prototype.trackPathChange=function(){var t;this.pageData&&(t=e(),this.pageData.path!==t&&this.trackPage(t))},t.prototype.trackPage=function(t){this.pageData&&(this.pageData.path=t,t={pid:this.projectID,lc:void 0!==navigator.languages?navigator.languages[0]:navigator.language,tz:function(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}(),ref:document.referrer||void 0,so:o(a),me:o(c),ca:o(r),pg:t},this.submitData(t))},t.prototype.debug=function(t){var o;null!==(o=this.options)&&void 0!==o&&o.debug&&console.log("[Analytics]",t)},t.prototype.canTrack=function(){var t,o;return"undefined"==typeof window?(this.debug("Tracking disabled: script does not run in browser environment."),!1):null!==(t=this.options)&&void 0!==t&&t.respectDNT&&"1"===(null===(o=window.navigator)||void 0===o?void 0:o.doNotTrack)?(this.debug("Tracking disabled: respecting user's 'Do Not Track' preference."),!1):!!(null!==(o=this.options)&&void 0!==o&&o.debug||"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||(this.debug("Tracking disabled: navigation is automated by WebDriver."),!1))},t.prototype.submitData=function(t){return fetch(s,{method:"post",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)})},t.prototype.submitCustom=function(t){return fetch(s+"/custom",{method:"post",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)})},t);function t(t,o){this.projectID=t,this.options=o,this.pageData=null}n.LIB_INSTANCE=null,n.init=function(t,o){return n.LIB_INSTANCE||(n.LIB_INSTANCE=new u(t,o)),n.LIB_INSTANCE},n.track=function(t){n.LIB_INSTANCE&&n.LIB_INSTANCE.track(t)},n.trackViews=function(t){n.LIB_INSTANCE&&n.LIB_INSTANCE.trackPageViews(t)},Object.defineProperty(n,"__esModule",{value:!0})});+!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o((t="undefined"!=typeof globalThis?globalThis:t||self).swetrix={})}(this,function(n){"use strict";function o(t){return(t=location.search.match(t))&&t[2]||void 0}function e(){return location.pathname||""}var i=function(){return(i=Object.assign||function(t){for(var o,n=1,e=arguments.length;n<e;n++)for(var i in o=arguments[n])Object.prototype.hasOwnProperty.call(o,i)&&(t[i]=o[i]);return t}).apply(this,arguments)},a=/[?&](ref|source|utm_source)=([^?&]+)/,r=/[?&](utm_campaign)=([^?&]+)/,c=/[?&](utm_medium)=([^?&]+)/,s="https://api.swetrix.com/log",u=(t.prototype.track=function(t){this.canTrack()&&(t=i({pid:this.projectID},t),this.submitCustom(t))},t.prototype.trackPageViews=function(t){if(this.canTrack()){if(this.pageData)return this.pageData.actions;var o=setInterval(this.trackPathChange,1e3),n=e();this.pageData={path:n,actions:{stop:function(){return clearInterval(o)}}},this.trackPage(n)}},t.prototype.trackPathChange=function(){var t;this.pageData&&(t=e(),this.pageData.path!==t&&this.trackPage(t))},t.prototype.trackPage=function(t){this.pageData&&(this.pageData.path=t,t={pid:this.projectID,lc:void 0!==navigator.languages?navigator.languages[0]:navigator.language,tz:function(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}(),ref:document.referrer||void 0,so:o(a),me:o(c),ca:o(r),pg:t},this.submitData(t))},t.prototype.debug=function(t){var o;null!==(o=this.options)&&void 0!==o&&o.debug&&console.log("[Swetrix]",t)},t.prototype.canTrack=function(){var t,o;return"undefined"==typeof window?(this.debug("Tracking disabled: script does not run in browser environment."),!1):null!==(t=this.options)&&void 0!==t&&t.respectDNT&&"1"===(null===(o=window.navigator)||void 0===o?void 0:o.doNotTrack)?(this.debug("Tracking disabled: respecting user's 'Do Not Track' preference."),!1):!!(null!==(o=this.options)&&void 0!==o&&o.debug||"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||(this.debug("Tracking disabled: navigation is automated by WebDriver."),!1))},t.prototype.submitData=function(t){return fetch(s,{method:"post",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)})},t.prototype.submitCustom=function(t){return fetch(s+"/custom",{method:"post",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)})},t);function t(t,o){this.projectID=t,this.options=o,this.pageData=null}n.LIB_INSTANCE=null,n.init=function(t,o){return n.LIB_INSTANCE||(n.LIB_INSTANCE=new u(t,o)),n.LIB_INSTANCE},n.track=function(t){n.LIB_INSTANCE&&n.LIB_INSTANCE.track(t)},n.trackViews=function(t){n.LIB_INSTANCE&&n.LIB_INSTANCE.trackPageViews(t)},Object.defineProperty(n,"__esModule",{value:!0})});diff --git a/src/Lib.ts b/src/Lib.tsindex 1479eebf7..6f39425af 100644--- a/src/Lib.ts+++ b/src/Lib.ts@@ -44,7 +44,7 @@ export interface PageViewsOptions {}-const host = 'http://localhost:5005/log'+const host = 'https://api.swetrix.com/log'export class Lib {private pageData: PageData | null = null