UNPKG

genrank

Version:

AI-powered visitor tracking and analytics for Generative Engine Optimization (GEO). Track and analyze how AI search engines and LLMs interact with your content.

2 lines (1 loc) 3.02 kB
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("axios")):"function"==typeof define&&define.amd?define(["exports","axios"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).VisitorTracker={},e.axios)}(this,(function(e,r){"use strict";function t(e,r,t,n){return new(t||(t=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var r;e.done?o(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(s,a)}c((n=n.apply(e,r||[])).next())}))}function n(e,r){var t,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(t=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=r.call(e,i)}catch(e){a=[6,e],n=0}finally{t=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}"function"==typeof SuppressedError&&SuppressedError;var o=function(){function e(){this.apiEndpoint="https://7emnecwqs3vgnx7b2jykxn43p40ctvln.lambda-url.ca-central-1.on.aws/",this.isBrowser="undefined"!=typeof window}return e.prototype.trackVisit=function(){return t(this,void 0,void 0,(function(){var e,t,o,i,s,a,c;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),e=(new Date).toISOString(),t=void 0,o=void 0,i=void 0,this.isBrowser?(t=window.navigator.userAgent,o=document.referrer,i=window.location.href):(t="Node.js/".concat(process.version),o=null,i="nodejs://"+process.cwd()),s={timestamp:e,userAgent:t,referrer:o,page:i},console.log("VisitorTracker ➡️ sending event:",s),[4,r.post(this.apiEndpoint,s,{headers:{"Content-Type":"application/json"}})];case 1:return a=n.sent(),console.log("VisitorTracker ✅ response:",a.data),[2,a.data];case 2:throw(c=n.sent()).response?(console.error("VisitorTracker ❌ response data:",c.response.data),console.error("VisitorTracker ❌ status:",c.response.status)):c.request?console.error("VisitorTracker ❌ no response received:",c.request):console.error("VisitorTracker ❌ request setup error:",c.message),c;case 3:return[2]}}))}))},e}();"undefined"!=typeof window&&(window.VisitorTracker=o),e.VisitorTracker=o}));