analytica.click 0.0.516 → 0.0.517

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
- "use strict";var x=Object.defineProperty;var Re=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var Se=Object.prototype.hasOwnProperty;var xe=(e,r)=>{for(var t in r)x(e,t,{get:r[t],enumerable:!0})},we=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of he(r))!Se.call(e,n)&&n!==t&&x(e,n,{get:()=>r[n],enumerable:!(o=Re(r,n))||o.enumerable});return e};var Oe=e=>we(x({},"__esModule",{value:!0}),e);var er={};xe(er,{errorTrack:()=>je});module.exports=Oe(er);var Ti=require("cross-fetch/polyfill"),m=require("ag-common/dist/common/helpers/log"),ge=require("ag-common/dist/common/helpers/string/contains"),R=require("ag-common/dist/ui/helpers/callOpenApi");var Ne="https://api.analytica.click".replace(/\/+$/,""),Ae=e=>typeof Blob<"u"&&e instanceof Blob,g=class{constructor(r=new w){this.configuration=r;this.fetchApi=async(r,t)=>{let o={url:r,init:t};for(let a of this.middleware)a.pre&&(o=await a.pre({fetch:this.fetchApi,...o})||o);let n=await(this.configuration.fetchApi||fetch)(o.url,o.init);for(let a of this.middleware)a.post&&(n=await a.post({fetch:this.fetchApi,url:o.url,init:o.init,response:n.clone()})||n);return n};this.middleware=r.middleware||[]}withMiddleware(...r){let t=this.clone();return t.middleware=t.middleware.concat(...r),t}withPreMiddleware(...r){let t=r.map(o=>({pre:o}));return this.withMiddleware(...t)}withPostMiddleware(...r){let t=r.map(o=>({post:o}));return this.withMiddleware(...t)}async request(r,t){let{url:o,init:n}=this.createFetchParams(r,t),a=await this.fetchApi(o,n);if(a.status>=200&&a.status<300)return a;throw a}createFetchParams(r,t){let o=this.configuration.basePath+r.path;r.query!==void 0&&Object.keys(r.query).length!==0&&(o+="?"+(this.configuration.queryParamsStringify||O)(r.query));let n=typeof FormData<"u"&&r.body instanceof FormData||r.body instanceof URLSearchParams||Ae(r.body)?r.body:JSON.stringify(r.body),a=Object.assign({},this.configuration.headers,r.headers),s={method:r.method,headers:a,body:n,credentials:this.configuration.credentials,...t};return{url:o,init:s}}clone(){let r=this.constructor,t=new r(this.configuration);return t.middleware=this.middleware.slice(),t}},u=class extends Error{constructor(t,o){super(o);this.field=t;this.name="RequiredError"}};var w=class{constructor(r={}){this.configuration=r}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Ne}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||O}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){let r=this.configuration.apiKey;if(r)return typeof r=="function"?r:()=>r}get accessToken(){let r=this.configuration.accessToken;if(r)return typeof r=="function"?r:async()=>r}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}};function i(e,r){let t=e[r];return t!=null}function O(e,r=""){return Object.keys(e).map(t=>{let o=r+(r.length?`[${t}]`:t),n=e[t];if(n instanceof Array){let a=n.map(s=>encodeURIComponent(String(s))).join(`&${encodeURIComponent(o)}=`);return`${encodeURIComponent(o)}=${a}`}return n instanceof Date?`${encodeURIComponent(o)}=${encodeURIComponent(n.toISOString())}`:n instanceof Object?O(n,o):`${encodeURIComponent(o)}=${encodeURIComponent(String(n))}`}).filter(t=>t.length>0).join("&")}var f=class{constructor(r,t=o=>o){this.raw=r;this.transformer=t}async value(){return this.transformer(await this.raw.json())}},c=class{constructor(r){this.raw=r}async value(){}};function D(e){if(e!==void 0)return e===null?null:{PKsB64:e.PKsB64}}function q(e){if(e!==void 0)return e===null?null:{key:e.key,account:e.account}}function k(e){return Je(e,!1)}function Je(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,browser:e.browser,count:e.count,category:e.category}}function I(e){if(e!==void 0)return e===null?null:{site:e.site}}function L(e){return Ee(e,!1)}function Ee(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,site:e.site,eventName:e.eventName,datetime:e.datetime,count:e.count,category:e.category}}function K(e){return be(e,!1)}function be(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,fingerprint:e.fingerprint,count:e.count,category:e.category}}function y(e){return Fe(e,!1)}function Fe(e,r){return e==null?e:{site:e.site,account:e.account,apiKey:e.apiKey,adminApiKey:e.adminApiKey,favicon:i(e,"favicon")?e.favicon:void 0}}function H(e){return qe(e,!1)}function qe(e,r){return e==null?e:{accounts:e.accounts.map(y),googleEmail:i(e,"googleEmail")?e.googleEmail:void 0,googleKey:i(e,"googleKey")?e.googleKey:void 0,bingKey:i(e,"bingKey")?e.bingKey:void 0,bingAccount:i(e,"bingAccount")?e.bingAccount:void 0}}function V(e){if(e!==void 0)return e===null?null:{email:e.email,key:e.key,account:e.account}}function B(e){return ke(e,!1)}function ke(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,responseTimeMs:e.responseTimeMs,success:e.success}}function G(e){return Ie(e,!1)}function Ie(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,language:e.language,count:e.count,category:e.category}}function M(e){return Le(e,!1)}function Le(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,countryRegion:e.countryRegion,category:e.category,count:e.count}}function Q(e){return Ke(e,!1)}function Ke(e,r){return e==null?e:{PK:e.PK,messageHash:i(e,"messageHash")?e.messageHash:void 0,site:e.site,account:e.account,message:i(e,"message")?e.message:void 0,name:i(e,"name")?e.name:void 0,stack:i(e,"stack")?e.stack:void 0,href:e.href,filename:i(e,"filename")?e.filename:void 0,datetime:e.datetime,archived:i(e,"archived")?e.archived:void 0,count:e.count,category:e.category}}function C(e){if(e!==void 0)return e===null?null:{site:e.site}}function z(e){if(e!==void 0)return e===null?null:{key:e.key,data:$(e.data)}}function $(e){if(e!==void 0)return e===null?null:{message:e.message,name:e.name,stack:e.stack,href:e.href,filename:e.filename}}function U(e){if(e!==void 0)return e===null?null:{key:e.key,data:_(e.data)}}function _(e){if(e!==void 0)return e===null?null:{eventName:e.eventName,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage,browserFingerprint:e.browserFingerprint}}function W(e){if(e!==void 0)return e===null?null:{key:e.key,data:X(e.data)}}function X(e){if(e!==void 0)return e===null?null:{pageLocation:e.pageLocation,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage,browserFingerprint:e.browserFingerprint}}function Y(e){return He(e,!1)}function He(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,pathName:e.pathName,search:i(e,"search")?e.search:void 0,hash:i(e,"hash")?e.hash:void 0,count:e.count,category:e.category}}function Z(e){return Ve(e,!1)}function Ve(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,referrer:e.referrer,count:e.count,category:e.category}}function v(e){return Be(e,!1)}function Be(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,resolution:e.resolution,count:e.count,category:e.category}}function j(e){return Ge(e,!1)}function Ge(e,r){return e==null?e:{account:e.account,site:e.site,datetime:e.datetime,category:e.category,topReferrers:i(e,"topReferrers")?e.topReferrers.map(se):void 0,topResolutions:i(e,"topResolutions")?e.topResolutions.map(ue):void 0,topFingerprints:i(e,"topFingerprints")?e.topFingerprints.map(ne):void 0,topQueries:i(e,"topQueries")?e.topQueries.map(ae):void 0,topLocations:i(e,"topLocations")?e.topLocations.map(ie):void 0,topBrowsers:i(e,"topBrowsers")?e.topBrowsers.map(ee):void 0,topEvents:i(e,"topEvents")?e.topEvents.map(te):void 0,topLanguages:i(e,"topLanguages")?e.topLanguages.map(oe):void 0,topErrors:i(e,"topErrors")?e.topErrors.map(re):void 0,averageResponseTimeMs:i(e,"averageResponseTimeMs")?e.averageResponseTimeMs:void 0}}function ee(e){return Me(e,!1)}function Me(e,r){return e==null?e:{browser:e.browser,count:e.count}}function re(e){return Qe(e,!1)}function Qe(e,r){return e==null?e:{href:e.href,count:e.count}}function te(e){return Ce(e,!1)}function Ce(e,r){return e==null?e:{eventName:e.eventName,count:e.count}}function ne(e){return ze(e,!1)}function ze(e,r){return e==null?e:{fingerprint:e.fingerprint,count:e.count}}function oe(e){return $e(e,!1)}function $e(e,r){return e==null?e:{language:e.language,count:e.count}}function ie(e){return Ue(e,!1)}function Ue(e,r){return e==null?e:{countryRegion:e.countryRegion,count:e.count}}function ae(e){return _e(e,!1)}function _e(e,r){return e==null?e:{pathName:e.pathName,count:e.count}}function se(e){return We(e,!1)}function We(e,r){return e==null?e:{referrer:e.referrer,count:e.count}}function ue(e){return Xe(e,!1)}function Xe(e,r){return e==null?e:{resolution:e.resolution,count:e.count}}function A(e){return Ye(e,!1)}function Ye(e,r){return e==null?e:{account:e.account,email:e.email,site:e.site,datetime:e.datetime,category:e.category,totals:N(e.totals),queries:e.queries.map(N)}}function N(e){return Ze(e,!1)}function Ze(e,r){return e==null?e:{clicks:e.clicks,impressions:e.impressions,position:e.position,query:e.query}}function P(e){return ve(e,!1)}function ve(e,r){return e==null?e:{accountDetails:i(e,"accountDetails")?y(e.accountDetails):void 0,browsers:i(e,"browsers")?e.browsers.map(k):void 0,events:i(e,"events")?e.events.map(L):void 0,locations:i(e,"locations")?e.locations.map(M):void 0,queries:i(e,"queries")?e.queries.map(Y):void 0,referrers:i(e,"referrers")?e.referrers.map(Z):void 0,resolutions:i(e,"resolutions")?e.resolutions.map(v):void 0,fingerprints:i(e,"fingerprints")?e.fingerprints.map(K):void 0,health:i(e,"health")?e.health.map(B):void 0,languages:i(e,"languages")?e.languages.map(G):void 0,rollups:i(e,"rollups")?e.rollups.map(j):void 0,errors:i(e,"errors")?e.errors.map(Q):void 0,google:i(e,"google")?e.google.map(A):void 0,bing:i(e,"bing")?e.bing.map(A):void 0}}var T=class extends g{async accountGetRaw(r){let t={},o={};this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let n=await this.request({path:"/account",method:"GET",headers:o,query:t},r);return new f(n,a=>H(a))}async accountGet(r){return await(await this.accountGetRaw(r)).value()}async archiveErrorRaw(r,t){if(r.id===null||r.id===void 0)throw new u("id","Required parameter requestParameters.id was null or undefined when calling archiveError.");let o={},n={};this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/errors/{id}".replace("{id}",encodeURIComponent(String(r.id))),method:"DELETE",headers:n,query:o},t);return new c(a)}async archiveError(r,t){await this.archiveErrorRaw(r,t)}async archiveErrorsRaw(r,t){if(r.archiveErrors===null||r.archiveErrors===void 0)throw new u("archiveErrors","Required parameter requestParameters.archiveErrors was null or undefined when calling archiveErrors.");let o={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/errors",method:"DELETE",headers:n,query:o,body:D(r.archiveErrors)},t);return new c(a)}async archiveErrors(r,t){await this.archiveErrorsRaw(r,t)}async bingIntegrationPostRaw(r,t){if(r.bingIntegration===null||r.bingIntegration===void 0)throw new u("bingIntegration","Required parameter requestParameters.bingIntegration was null or undefined when calling bingIntegrationPost.");let o={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/integrations/bing",method:"POST",headers:n,query:o,body:q(r.bingIntegration)},t);return new c(a)}async bingIntegrationPost(r,t){await this.bingIntegrationPostRaw(r,t)}async getTrackingAllSitesRaw(r,t){if(r.minDate===null||r.minDate===void 0)throw new u("minDate","Required parameter requestParameters.minDate was null or undefined when calling getTrackingAllSites.");if(r.maxDate===null||r.maxDate===void 0)throw new u("maxDate","Required parameter requestParameters.maxDate was null or undefined when calling getTrackingAllSites.");let o={};r.minDate!==void 0&&(o.minDate=r.minDate),r.maxDate!==void 0&&(o.maxDate=r.maxDate);let n={};this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/site/tracking",method:"GET",headers:n,query:o},t);return new f(a,s=>s.map(P))}async getTrackingAllSites(r,t){return await(await this.getTrackingAllSitesRaw(r,t)).value()}async getTrackingSiteRaw(r,t){if(r.id===null||r.id===void 0)throw new u("id","Required parameter requestParameters.id was null or undefined when calling getTrackingSite.");if(r.minDate===null||r.minDate===void 0)throw new u("minDate","Required parameter requestParameters.minDate was null or undefined when calling getTrackingSite.");if(r.maxDate===null||r.maxDate===void 0)throw new u("maxDate","Required parameter requestParameters.maxDate was null or undefined when calling getTrackingSite.");let o={};r.minDate!==void 0&&(o.minDate=r.minDate),r.maxDate!==void 0&&(o.maxDate=r.maxDate);let n={};this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/site/tracking/{id}".replace("{id}",encodeURIComponent(String(r.id))),method:"GET",headers:n,query:o},t);return new f(a,s=>P(s))}async getTrackingSite(r,t){return await(await this.getTrackingSiteRaw(r,t)).value()}async googleIntegrationPostRaw(r,t){if(r.googleIntegration===null||r.googleIntegration===void 0)throw new u("googleIntegration","Required parameter requestParameters.googleIntegration was null or undefined when calling googleIntegrationPost.");let o={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/integrations/google",method:"POST",headers:n,query:o,body:V(r.googleIntegration)},t);return new c(a)}async googleIntegrationPost(r,t){await this.googleIntegrationPostRaw(r,t)}async postErrorsRaw(r,t){if(r.postError===null||r.postError===void 0)throw new u("postError","Required parameter requestParameters.postError was null or undefined when calling postErrors.");let o={},n={};n["Content-Type"]="application/json";let a=await this.request({path:"/errors",method:"POST",headers:n,query:o,body:r.postError.map(z)},t);return new c(a)}async postErrors(r,t){await this.postErrorsRaw(r,t)}async postEventRaw(r,t){if(r.postEvent===null||r.postEvent===void 0)throw new u("postEvent","Required parameter requestParameters.postEvent was null or undefined when calling postEvent.");let o={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/site/event",method:"POST",headers:n,query:o,body:U(r.postEvent)},t);return new c(a)}async postEvent(r,t){await this.postEventRaw(r,t)}async postPageTrackRaw(r,t){if(r.postSiteTrack===null||r.postSiteTrack===void 0)throw new u("postSiteTrack","Required parameter requestParameters.postSiteTrack was null or undefined when calling postPageTrack.");let o={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/site/tracking",method:"POST",headers:n,query:o,body:W(r.postSiteTrack)},t);return new c(a)}async postPageTrack(r,t){await this.postPageTrackRaw(r,t)}async siteDeleteRaw(r,t){if(r.deleteAccount===null||r.deleteAccount===void 0)throw new u("deleteAccount","Required parameter requestParameters.deleteAccount was null or undefined when calling siteDelete.");let o={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/site",method:"DELETE",headers:n,query:o,body:I(r.deleteAccount)},t);return new c(a)}async siteDelete(r,t){await this.siteDeleteRaw(r,t)}async sitePostRaw(r,t){if(r.postAccount===null||r.postAccount===void 0)throw new u("postAccount","Required parameter requestParameters.postAccount was null or undefined when calling sitePost.");let o={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/site",method:"POST",headers:n,query:o,body:C(r.postAccount)},t);return new c(a)}async sitePost(r,t){await this.sitePostRaw(r,t)}};var J=require("ag-common/dist/common/helpers/hashCode"),d=require("ag-common/dist/common/helpers/log"),ce=require("ag-common/dist/common/helpers/object");function pe(e){return e?e.match(/^"?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}"?$/)?((0,d.info)("ignoring react devtools message"),!1):e===JSON.stringify([{}])?((0,d.info)("empty message payload?"),!1):!0:((0,d.info)("no message?"),!1)}var le=e=>{try{let r=/^\[?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}\]?$/gim,t=/(at \S+?) \(\S+\)\s/gim,o=/^((%[cs])+\s*)+$/gim,n=/^color:/gim,a=[],s=e.message;(0,ce.isJson)(s)?a=JSON.parse(s):a=[s];let h=a.findIndex(p=>p.match(o)),S=a.findIndex(p=>p.match(n));h>=0&&S>=0&&S===h+1&&(a=a.filter((p,Te)=>![h,S].includes(Te))),a=a.map(p=>p.includes(".js:")||p.includes("node_modules")?p.replace(t,"$1 (stacktrace)"):p.replace(r,"[date]")),s=JSON.stringify(a);let F=(0,J.hashCode)(s).toString();return(0,d.debug)("got errorKey=",s,F),F}catch{return(0,J.hashCode)(e.message).toString()}};var fe=(e,r)=>{let t=[],o={},n=0;return Object.entries(e).forEach(([a,s])=>{n<r?t.push(s):o[a]=s,n+=1}),{part:t,rest:o}};function de(e){return(0,R.callOpenApi)({...e,func:r=>(0,R.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new T(r),logout:()=>typeof window<"u"?window.location.reload():()=>{},refreshToken:async()=>{}})}var me=typeof window<"u"&&window.location.hostname==="localhost",l={},E,b,ye=async()=>{try{if(Object.keys(l).length>100){let o=Object.keys(l)[0],n=l[o],a=await de({headers:{authorization:""},apiUrl:b,func:s=>s.postErrorsRaw({postError:[{key:n.key,data:{...n.data,message:`error overload!: ${n.data.message||"?"}`}}]})});if(l={},a.error)throw a.error;return{}}let{part:e,rest:r}=fe(l,10);l=r;let t=await de({headers:{authorization:""},apiUrl:b,func:o=>o.postErrorsRaw({postError:e})});if(t.error)throw t.error}catch(e){let r=e,t=r;return{error:r?.error?.message??t.message}}finally{Object.keys(l).length>0?E=setTimeout(ye,1e3):E=void 0}},je=async({data:e,overrideBaseUrl:r="https://api.analytica.click",ignoreBrowserErrors:t=["will be removed","performing full reload","tracking error","fetch RSC payload","perform a full reload","warnings#debug_enabled"],devMode:o})=>{if(r||(r="https://api.analytica.click"),r.startsWith("/")&&typeof window>"u"&&(r="https://api.analytica.click"),t.length>0){let a=(0,ge.containsInsensitive)(e.data.message,...t);if(a){(0,m.debug)("ignoring error, contains=",a);return}}if(me&&o)(0,m.debug)("allowing local error tracking due to devmode=true");else if(me)return(0,m.debug)(`local error tracking ignored:${e.data.message} ${JSON.stringify(e)}, to ${r}`),{};if(!pe(e.data.message))return{};(0,m.debug)("error track",e.data.message,JSON.stringify(e));let n=le(e.data);return l[n]=e,b=r,E??=setTimeout(ye,500),{}};0&&(module.exports={errorTrack});
1
+ "use strict";var d=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var J=(e,r)=>{for(var o in r)d(e,o,{get:r[o],enumerable:!0})},N=(e,r,o,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of j(r))!x.call(e,s)&&s!==o&&d(e,s,{get:()=>r[s],enumerable:!(n=P(r,s))||n.enumerable});return e};var R=e=>N(d({},"__esModule",{value:!0}),e);var C={};J(C,{errorTrack:()=>H});module.exports=R(C);var I=require("cross-fetch/polyfill"),f=require("ag-common/dist/common/helpers/log"),S=require("ag-common/dist/common/helpers/string/contains");var p=require("ag-common/dist/common/helpers/hashCode"),g=require("ag-common/dist/common/helpers/log"),k=require("ag-common/dist/common/helpers/object");function T(e){return e?e.match(/^"?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}"?$/)?((0,g.info)("ignoring react devtools message"),!1):e===JSON.stringify([{}])?((0,g.info)("empty message payload?"),!1):!0:((0,g.info)("no message?"),!1)}var b=e=>{try{let r=/^\[?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}\]?$/gim,o=/(at \S+?) \(\S+\)\s/gim,n=/^((%[cs])+\s*)+$/gim,s=/^color:/gim,t=[],a=e.message;(0,k.isJson)(a)?t=JSON.parse(a):t=[a];let l=t.findIndex(i=>i.match(n)),m=t.findIndex(i=>i.match(s));l>=0&&m>=0&&m===l+1&&(t=t.filter((i,$)=>![l,m].includes($))),t=t.map(i=>i.includes(".js:")||i.includes("node_modules")?i.replace(o,"$1 (stacktrace)"):i.replace(r,"[date]")),a=JSON.stringify(t);let h=(0,p.hashCode)(a).toString();return(0,g.debug)("got errorKey=",a,h),h}catch{return(0,p.hashCode)(e.message).toString()}};var w=(e,r)=>{let o=[],n={},s=0;return Object.entries(e).forEach(([t,a])=>{s<r?o.push(a):n[t]=a,s+=1}),{part:o,rest:n}};var O=typeof window<"u"&&window.location.hostname==="localhost",c={},u,y,E=async()=>{try{if(Object.keys(c).length>100){let n=Object.keys(c)[0],s=c[n],t=await fetch(`${y}/errors`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify([{key:s.key,data:{...s.data,message:`error overload!: ${s.data.message||"?"}`}}])});if(c={},!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return{}}let{part:e,rest:r}=w(c,10);c=r;let o=await fetch(`${y}/errors`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify(e)});if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`)}catch(e){let r=e;return{error:r?.message??r.message}}finally{Object.keys(c).length>0?u=setTimeout(E,1e3):u=void 0}},H=async({data:e,overrideBaseUrl:r="https://analytica.click/api",ignoreBrowserErrors:o=["will be removed","performing full reload","tracking error","fetch RSC payload","perform a full reload","warnings#debug_enabled"],devMode:n})=>{if(r||(r="https://analytica.click/api"),r.startsWith("/")&&typeof window>"u"&&(r="https://analytica.click/api"),o.length>0){let t=(0,S.containsInsensitive)(e.data.message,...o);if(t){(0,f.debug)("ignoring error, contains=",t);return}}if(O&&n)(0,f.debug)("allowing local error tracking due to devmode=true");else if(O)return(0,f.debug)(`local error tracking ignored:${e.data.message} ${JSON.stringify(e)}, to ${r}`),{};if(!T(e.data.message))return{};(0,f.debug)("error track",e.data.message,JSON.stringify(e));let s=b(e.data);return c[s]=e,y=r,u??=setTimeout(E,500),{}};0&&(module.exports={errorTrack});
@@ -1 +1 @@
1
- "use strict";var y=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.prototype.hasOwnProperty;var ie=(e,r)=>{for(var t in r)y(e,t,{get:r[t],enumerable:!0})},ae=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of ne(r))!oe.call(e,n)&&n!==t&&y(e,n,{get:()=>r[n],enumerable:!(o=te(r,n))||o.enumerable});return e};var ue=e=>ae(y({},"__esModule",{value:!0}),e);var Be={};ie(Be,{event:()=>He,page:()=>Ve});module.exports=ue(Be);var ei=require("cross-fetch/polyfill"),p=require("ag-common/dist/common/helpers/log"),g=require("ag-common/dist/ui/helpers/callOpenApi");var se="https://api.analytica.click".replace(/\/+$/,""),ce=e=>typeof Blob<"u"&&e instanceof Blob,l=class{constructor(r=new T){this.configuration=r;this.fetchApi=async(r,t)=>{let o={url:r,init:t};for(let a of this.middleware)a.pre&&(o=await a.pre({fetch:this.fetchApi,...o})||o);let n=await(this.configuration.fetchApi||fetch)(o.url,o.init);for(let a of this.middleware)a.post&&(n=await a.post({fetch:this.fetchApi,url:o.url,init:o.init,response:n.clone()})||n);return n};this.middleware=r.middleware||[]}withMiddleware(...r){let t=this.clone();return t.middleware=t.middleware.concat(...r),t}withPreMiddleware(...r){let t=r.map(o=>({pre:o}));return this.withMiddleware(...t)}withPostMiddleware(...r){let t=r.map(o=>({post:o}));return this.withMiddleware(...t)}async request(r,t){let{url:o,init:n}=this.createFetchParams(r,t),a=await this.fetchApi(o,n);if(a.status>=200&&a.status<300)return a;throw a}createFetchParams(r,t){let o=this.configuration.basePath+r.path;r.query!==void 0&&Object.keys(r.query).length!==0&&(o+="?"+(this.configuration.queryParamsStringify||R)(r.query));let n=typeof FormData<"u"&&r.body instanceof FormData||r.body instanceof URLSearchParams||ce(r.body)?r.body:JSON.stringify(r.body),a=Object.assign({},this.configuration.headers,r.headers),s={method:r.method,headers:a,body:n,credentials:this.configuration.credentials,...t};return{url:o,init:s}}clone(){let r=this.constructor,t=new r(this.configuration);return t.middleware=this.middleware.slice(),t}},u=class extends Error{constructor(t,o){super(o);this.field=t;this.name="RequiredError"}};var T=class{constructor(r={}){this.configuration=r}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:se}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||R}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){let r=this.configuration.apiKey;if(r)return typeof r=="function"?r:()=>r}get accessToken(){let r=this.configuration.accessToken;if(r)return typeof r=="function"?r:async()=>r}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}};function i(e,r){let t=e[r];return t!=null}function R(e,r=""){return Object.keys(e).map(t=>{let o=r+(r.length?`[${t}]`:t),n=e[t];if(n instanceof Array){let a=n.map(s=>encodeURIComponent(String(s))).join(`&${encodeURIComponent(o)}=`);return`${encodeURIComponent(o)}=${a}`}return n instanceof Date?`${encodeURIComponent(o)}=${encodeURIComponent(n.toISOString())}`:n instanceof Object?R(n,o):`${encodeURIComponent(o)}=${encodeURIComponent(String(n))}`}).filter(t=>t.length>0).join("&")}var d=class{constructor(r,t=o=>o){this.raw=r;this.transformer=t}async value(){return this.transformer(await this.raw.json())}},c=class{constructor(r){this.raw=r}async value(){}};function w(e){if(e!==void 0)return e===null?null:{PKsB64:e.PKsB64}}function N(e){if(e!==void 0)return e===null?null:{key:e.key,account:e.account}}function O(e){return de(e,!1)}function de(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,browser:e.browser,count:e.count,category:e.category}}function P(e){if(e!==void 0)return e===null?null:{site:e.site}}function A(e){return le(e,!1)}function le(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,site:e.site,eventName:e.eventName,datetime:e.datetime,count:e.count,category:e.category}}function J(e){return fe(e,!1)}function fe(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,fingerprint:e.fingerprint,count:e.count,category:e.category}}function f(e){return me(e,!1)}function me(e,r){return e==null?e:{site:e.site,account:e.account,apiKey:e.apiKey,adminApiKey:e.adminApiKey,favicon:i(e,"favicon")?e.favicon:void 0}}function E(e){return ye(e,!1)}function ye(e,r){return e==null?e:{accounts:e.accounts.map(f),googleEmail:i(e,"googleEmail")?e.googleEmail:void 0,googleKey:i(e,"googleKey")?e.googleKey:void 0,bingKey:i(e,"bingKey")?e.bingKey:void 0,bingAccount:i(e,"bingAccount")?e.bingAccount:void 0}}function b(e){if(e!==void 0)return e===null?null:{email:e.email,key:e.key,account:e.account}}function F(e){return Te(e,!1)}function Te(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,responseTimeMs:e.responseTimeMs,success:e.success}}function D(e){return Re(e,!1)}function Re(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,language:e.language,count:e.count,category:e.category}}function q(e){return he(e,!1)}function he(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,countryRegion:e.countryRegion,category:e.category,count:e.count}}function k(e){return Se(e,!1)}function Se(e,r){return e==null?e:{PK:e.PK,messageHash:i(e,"messageHash")?e.messageHash:void 0,site:e.site,account:e.account,message:i(e,"message")?e.message:void 0,name:i(e,"name")?e.name:void 0,stack:i(e,"stack")?e.stack:void 0,href:e.href,filename:i(e,"filename")?e.filename:void 0,datetime:e.datetime,archived:i(e,"archived")?e.archived:void 0,count:e.count,category:e.category}}function I(e){if(e!==void 0)return e===null?null:{site:e.site}}function L(e){if(e!==void 0)return e===null?null:{key:e.key,data:K(e.data)}}function K(e){if(e!==void 0)return e===null?null:{message:e.message,name:e.name,stack:e.stack,href:e.href,filename:e.filename}}function H(e){if(e!==void 0)return e===null?null:{key:e.key,data:V(e.data)}}function V(e){if(e!==void 0)return e===null?null:{eventName:e.eventName,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage,browserFingerprint:e.browserFingerprint}}function B(e){if(e!==void 0)return e===null?null:{key:e.key,data:G(e.data)}}function G(e){if(e!==void 0)return e===null?null:{pageLocation:e.pageLocation,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage,browserFingerprint:e.browserFingerprint}}function M(e){return xe(e,!1)}function xe(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,pathName:e.pathName,search:i(e,"search")?e.search:void 0,hash:i(e,"hash")?e.hash:void 0,count:e.count,category:e.category}}function Q(e){return we(e,!1)}function we(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,referrer:e.referrer,count:e.count,category:e.category}}function C(e){return Ne(e,!1)}function Ne(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,resolution:e.resolution,count:e.count,category:e.category}}function z(e){return Oe(e,!1)}function Oe(e,r){return e==null?e:{account:e.account,site:e.site,datetime:e.datetime,category:e.category,topReferrers:i(e,"topReferrers")?e.topReferrers.map(v):void 0,topResolutions:i(e,"topResolutions")?e.topResolutions.map(j):void 0,topFingerprints:i(e,"topFingerprints")?e.topFingerprints.map(W):void 0,topQueries:i(e,"topQueries")?e.topQueries.map(Z):void 0,topLocations:i(e,"topLocations")?e.topLocations.map(Y):void 0,topBrowsers:i(e,"topBrowsers")?e.topBrowsers.map($):void 0,topEvents:i(e,"topEvents")?e.topEvents.map(_):void 0,topLanguages:i(e,"topLanguages")?e.topLanguages.map(X):void 0,topErrors:i(e,"topErrors")?e.topErrors.map(U):void 0,averageResponseTimeMs:i(e,"averageResponseTimeMs")?e.averageResponseTimeMs:void 0}}function $(e){return Pe(e,!1)}function Pe(e,r){return e==null?e:{browser:e.browser,count:e.count}}function U(e){return Ae(e,!1)}function Ae(e,r){return e==null?e:{href:e.href,count:e.count}}function _(e){return Je(e,!1)}function Je(e,r){return e==null?e:{eventName:e.eventName,count:e.count}}function W(e){return Ee(e,!1)}function Ee(e,r){return e==null?e:{fingerprint:e.fingerprint,count:e.count}}function X(e){return be(e,!1)}function be(e,r){return e==null?e:{language:e.language,count:e.count}}function Y(e){return Fe(e,!1)}function Fe(e,r){return e==null?e:{countryRegion:e.countryRegion,count:e.count}}function Z(e){return De(e,!1)}function De(e,r){return e==null?e:{pathName:e.pathName,count:e.count}}function v(e){return qe(e,!1)}function qe(e,r){return e==null?e:{referrer:e.referrer,count:e.count}}function j(e){return ke(e,!1)}function ke(e,r){return e==null?e:{resolution:e.resolution,count:e.count}}function S(e){return Ie(e,!1)}function Ie(e,r){return e==null?e:{account:e.account,email:e.email,site:e.site,datetime:e.datetime,category:e.category,totals:h(e.totals),queries:e.queries.map(h)}}function h(e){return Le(e,!1)}function Le(e,r){return e==null?e:{clicks:e.clicks,impressions:e.impressions,position:e.position,query:e.query}}function x(e){return Ke(e,!1)}function Ke(e,r){return e==null?e:{accountDetails:i(e,"accountDetails")?f(e.accountDetails):void 0,browsers:i(e,"browsers")?e.browsers.map(O):void 0,events:i(e,"events")?e.events.map(A):void 0,locations:i(e,"locations")?e.locations.map(q):void 0,queries:i(e,"queries")?e.queries.map(M):void 0,referrers:i(e,"referrers")?e.referrers.map(Q):void 0,resolutions:i(e,"resolutions")?e.resolutions.map(C):void 0,fingerprints:i(e,"fingerprints")?e.fingerprints.map(J):void 0,health:i(e,"health")?e.health.map(F):void 0,languages:i(e,"languages")?e.languages.map(D):void 0,rollups:i(e,"rollups")?e.rollups.map(z):void 0,errors:i(e,"errors")?e.errors.map(k):void 0,google:i(e,"google")?e.google.map(S):void 0,bing:i(e,"bing")?e.bing.map(S):void 0}}var m=class extends l{async accountGetRaw(r){let t={},o={};this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let n=await this.request({path:"/account",method:"GET",headers:o,query:t},r);return new d(n,a=>E(a))}async accountGet(r){return await(await this.accountGetRaw(r)).value()}async archiveErrorRaw(r,t){if(r.id===null||r.id===void 0)throw new u("id","Required parameter requestParameters.id was null or undefined when calling archiveError.");let o={},n={};this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/errors/{id}".replace("{id}",encodeURIComponent(String(r.id))),method:"DELETE",headers:n,query:o},t);return new c(a)}async archiveError(r,t){await this.archiveErrorRaw(r,t)}async archiveErrorsRaw(r,t){if(r.archiveErrors===null||r.archiveErrors===void 0)throw new u("archiveErrors","Required parameter requestParameters.archiveErrors was null or undefined when calling archiveErrors.");let o={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/errors",method:"DELETE",headers:n,query:o,body:w(r.archiveErrors)},t);return new c(a)}async archiveErrors(r,t){await this.archiveErrorsRaw(r,t)}async bingIntegrationPostRaw(r,t){if(r.bingIntegration===null||r.bingIntegration===void 0)throw new u("bingIntegration","Required parameter requestParameters.bingIntegration was null or undefined when calling bingIntegrationPost.");let o={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/integrations/bing",method:"POST",headers:n,query:o,body:N(r.bingIntegration)},t);return new c(a)}async bingIntegrationPost(r,t){await this.bingIntegrationPostRaw(r,t)}async getTrackingAllSitesRaw(r,t){if(r.minDate===null||r.minDate===void 0)throw new u("minDate","Required parameter requestParameters.minDate was null or undefined when calling getTrackingAllSites.");if(r.maxDate===null||r.maxDate===void 0)throw new u("maxDate","Required parameter requestParameters.maxDate was null or undefined when calling getTrackingAllSites.");let o={};r.minDate!==void 0&&(o.minDate=r.minDate),r.maxDate!==void 0&&(o.maxDate=r.maxDate);let n={};this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/site/tracking",method:"GET",headers:n,query:o},t);return new d(a,s=>s.map(x))}async getTrackingAllSites(r,t){return await(await this.getTrackingAllSitesRaw(r,t)).value()}async getTrackingSiteRaw(r,t){if(r.id===null||r.id===void 0)throw new u("id","Required parameter requestParameters.id was null or undefined when calling getTrackingSite.");if(r.minDate===null||r.minDate===void 0)throw new u("minDate","Required parameter requestParameters.minDate was null or undefined when calling getTrackingSite.");if(r.maxDate===null||r.maxDate===void 0)throw new u("maxDate","Required parameter requestParameters.maxDate was null or undefined when calling getTrackingSite.");let o={};r.minDate!==void 0&&(o.minDate=r.minDate),r.maxDate!==void 0&&(o.maxDate=r.maxDate);let n={};this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/site/tracking/{id}".replace("{id}",encodeURIComponent(String(r.id))),method:"GET",headers:n,query:o},t);return new d(a,s=>x(s))}async getTrackingSite(r,t){return await(await this.getTrackingSiteRaw(r,t)).value()}async googleIntegrationPostRaw(r,t){if(r.googleIntegration===null||r.googleIntegration===void 0)throw new u("googleIntegration","Required parameter requestParameters.googleIntegration was null or undefined when calling googleIntegrationPost.");let o={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/integrations/google",method:"POST",headers:n,query:o,body:b(r.googleIntegration)},t);return new c(a)}async googleIntegrationPost(r,t){await this.googleIntegrationPostRaw(r,t)}async postErrorsRaw(r,t){if(r.postError===null||r.postError===void 0)throw new u("postError","Required parameter requestParameters.postError was null or undefined when calling postErrors.");let o={},n={};n["Content-Type"]="application/json";let a=await this.request({path:"/errors",method:"POST",headers:n,query:o,body:r.postError.map(L)},t);return new c(a)}async postErrors(r,t){await this.postErrorsRaw(r,t)}async postEventRaw(r,t){if(r.postEvent===null||r.postEvent===void 0)throw new u("postEvent","Required parameter requestParameters.postEvent was null or undefined when calling postEvent.");let o={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/site/event",method:"POST",headers:n,query:o,body:H(r.postEvent)},t);return new c(a)}async postEvent(r,t){await this.postEventRaw(r,t)}async postPageTrackRaw(r,t){if(r.postSiteTrack===null||r.postSiteTrack===void 0)throw new u("postSiteTrack","Required parameter requestParameters.postSiteTrack was null or undefined when calling postPageTrack.");let o={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/site/tracking",method:"POST",headers:n,query:o,body:B(r.postSiteTrack)},t);return new c(a)}async postPageTrack(r,t){await this.postPageTrackRaw(r,t)}async siteDeleteRaw(r,t){if(r.deleteAccount===null||r.deleteAccount===void 0)throw new u("deleteAccount","Required parameter requestParameters.deleteAccount was null or undefined when calling siteDelete.");let o={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/site",method:"DELETE",headers:n,query:o,body:P(r.deleteAccount)},t);return new c(a)}async siteDelete(r,t){await this.siteDeleteRaw(r,t)}async sitePostRaw(r,t){if(r.postAccount===null||r.postAccount===void 0)throw new u("postAccount","Required parameter requestParameters.postAccount was null or undefined when calling sitePost.");let o={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/site",method:"POST",headers:n,query:o,body:I(r.postAccount)},t);return new c(a)}async sitePost(r,t){await this.sitePostRaw(r,t)}};function ee(e){return(0,g.callOpenApi)({...e,func:r=>(0,g.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new m(r),logout:()=>typeof window<"u"?window.location.reload():()=>{},refreshToken:async()=>{}})}var He=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click",eventName:t,devMode:o,valueOverrides:n})=>{let a={eventName:t,browserFingerprint:n?.browserFingerprint};if(!o&&typeof window<"u"&&window.location.hostname==="localhost")return(0,p.debug)(`local page ignored: ${JSON.stringify(a)}, to ${r}`),{};let s=await ee({apiUrl:r,headers:{authorization:""},func:re=>re.postEventRaw({postEvent:{key:e,data:a}})});return s.error?((0,p.warn)("tracking error:"+JSON.stringify(s.error,null,2)),{error:JSON.stringify(s.error,null,2)}):{}},Ve=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click",devMode:t,valueOverrides:o})=>{let n={pageLocation:"",browserFingerprint:o?.browserFingerprint};if(typeof window<"u"&&(n={...n,pageLocation:window.location.href,browserResolution:`${window.screen.width}:${window.screen.height}`}),typeof document<"u"&&(n={...n,pageReferrer:document.referrer,pageTitle:document.title}),typeof navigator<"u"&&(n={...n,browserLanguage:navigator.language}),!t&&typeof window<"u"&&window.location.hostname==="localhost")return(0,p.debug)(`local page ignored: ${JSON.stringify(n)}, to ${r}`),{};if(!n.pageLocation)return(0,p.warn)("no pageLocation"),{};let a=await ee({apiUrl:r,headers:{authorization:""},func:s=>s.postPageTrackRaw({postSiteTrack:{key:e,data:n}})});return a.error?((0,p.warn)("tracking error:"+JSON.stringify(a.error,null,2)),{error:JSON.stringify(a.error,null,2)}):{}};0&&(module.exports={event,page});
1
+ "use strict";var g=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var w=(t,r)=>{for(var a in r)g(t,a,{get:r[a],enumerable:!0})},u=(t,r,a,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of f(r))!d.call(t,e)&&e!==a&&g(t,e,{get:()=>r[e],enumerable:!(s=p(r,e))||s.enumerable});return t};var y=t=>u(g({},"__esModule",{value:!0}),t);var m={};w(m,{event:()=>h,page:()=>l});module.exports=y(m);var T=require("cross-fetch/polyfill"),n=require("ag-common/dist/common/helpers/log"),h=async({analyticaToken:t,overrideBaseUrl:r="https://analytica.click/api",eventName:a,devMode:s,valueOverrides:e})=>{let i={eventName:a,browserFingerprint:e?.browserFingerprint};if(!s&&typeof window<"u"&&window.location.hostname==="localhost")return(0,n.debug)(`local page ignored: ${JSON.stringify(i)}, to ${r}`),{};try{let o=await fetch(`${r}/site/event`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:t,data:i})});if(!o.ok){let c=await o.text();return(0,n.warn)("tracking error:"+c),{error:c}}}catch(o){let c=o instanceof Error?o.message:"Unknown error";return(0,n.warn)("tracking error:"+c),{error:c}}return{}},l=async({analyticaToken:t,overrideBaseUrl:r="https://analytica.click/api",devMode:a,valueOverrides:s})=>{let e={pageLocation:"",browserFingerprint:s?.browserFingerprint};if(typeof window<"u"&&(e={...e,pageLocation:window.location.href,browserResolution:`${window.screen.width}:${window.screen.height}`}),typeof document<"u"&&(e={...e,pageReferrer:document.referrer,pageTitle:document.title}),typeof navigator<"u"&&(e={...e,browserLanguage:navigator.language}),!a&&typeof window<"u"&&window.location.hostname==="localhost")return(0,n.debug)(`local page ignored: ${JSON.stringify(e)}, to ${r}`),{};if(!e.pageLocation)return(0,n.warn)("no pageLocation"),{};try{let i=await fetch(`${r}/site/tracking`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:t,data:e})});if(!i.ok){let o=await i.text();return(0,n.warn)("tracking error:"+o),{error:o}}}catch(i){let o=i instanceof Error?i.message:"Unknown error";return(0,n.warn)("tracking error:"+o),{error:o}}return{}};0&&(module.exports={event,page});
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- 'use client';"use strict";var $e=Object.create;var x=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var _e=Object.getPrototypeOf,Xe=Object.prototype.hasOwnProperty;var Ye=(e,r)=>{for(var t in r)x(e,t,{get:r[t],enumerable:!0})},$=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of We(r))!Xe.call(e,o)&&o!==t&&x(e,o,{get:()=>r[o],enumerable:!(n=Ue(r,o))||n.enumerable});return e};var Ze=(e,r,t)=>(t=e!=null?$e(_e(e)):{},$(r||!e||!e.__esModule?x(t,"default",{value:e,enumerable:!0}):t,e)),ve=e=>$(x({},"__esModule",{value:!0}),e);var kr={};Ye(kr,{AnalyticaClickProvider:()=>br,AnalyticaConfigContext:()=>T,errorTrack:()=>f,event:()=>M,page:()=>Q,tokenMissing:()=>S,useAnalytica:()=>Fr});module.exports=ve(kr);var Ve=require("react");var E=require("ag-common/dist/common/helpers/log"),J=Ze(require("react"));var De=require("react");var _i=require("cross-fetch/polyfill"),h=require("ag-common/dist/common/helpers/log"),Fe=require("ag-common/dist/common/helpers/string/contains"),P=require("ag-common/dist/ui/helpers/callOpenApi");var je="https://api.analytica.click".replace(/\/+$/,""),er=e=>typeof Blob<"u"&&e instanceof Blob,O=class{constructor(r=new k){this.configuration=r;this.fetchApi=async(r,t)=>{let n={url:r,init:t};for(let a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o=await(this.configuration.fetchApi||fetch)(n.url,n.init);for(let a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o};this.middleware=r.middleware||[]}withMiddleware(...r){let t=this.clone();return t.middleware=t.middleware.concat(...r),t}withPreMiddleware(...r){let t=r.map(n=>({pre:n}));return this.withMiddleware(...t)}withPostMiddleware(...r){let t=r.map(n=>({post:n}));return this.withMiddleware(...t)}async request(r,t){let{url:n,init:o}=this.createFetchParams(r,t),a=await this.fetchApi(n,o);if(a.status>=200&&a.status<300)return a;throw a}createFetchParams(r,t){let n=this.configuration.basePath+r.path;r.query!==void 0&&Object.keys(r.query).length!==0&&(n+="?"+(this.configuration.queryParamsStringify||D)(r.query));let o=typeof FormData<"u"&&r.body instanceof FormData||r.body instanceof URLSearchParams||er(r.body)?r.body:JSON.stringify(r.body),a=Object.assign({},this.configuration.headers,r.headers),s={method:r.method,headers:a,body:o,credentials:this.configuration.credentials,...t};return{url:n,init:s}}clone(){let r=this.constructor,t=new r(this.configuration);return t.middleware=this.middleware.slice(),t}},u=class extends Error{constructor(t,n){super(n);this.field=t;this.name="RequiredError"}};var k=class{constructor(r={}){this.configuration=r}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:je}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||D}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){let r=this.configuration.apiKey;if(r)return typeof r=="function"?r:()=>r}get accessToken(){let r=this.configuration.accessToken;if(r)return typeof r=="function"?r:async()=>r}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}};function i(e,r){let t=e[r];return t!=null}function D(e,r=""){return Object.keys(e).map(t=>{let n=r+(r.length?`[${t}]`:t),o=e[t];if(o instanceof Array){let a=o.map(s=>encodeURIComponent(String(s))).join(`&${encodeURIComponent(n)}=`);return`${encodeURIComponent(n)}=${a}`}return o instanceof Date?`${encodeURIComponent(n)}=${encodeURIComponent(o.toISOString())}`:o instanceof Object?D(o,n):`${encodeURIComponent(n)}=${encodeURIComponent(String(o))}`}).filter(t=>t.length>0).join("&")}var m=class{constructor(r,t=n=>n){this.raw=r;this.transformer=t}async value(){return this.transformer(await this.raw.json())}},c=class{constructor(r){this.raw=r}async value(){}};function U(e){if(e!==void 0)return e===null?null:{PKsB64:e.PKsB64}}function W(e){if(e!==void 0)return e===null?null:{key:e.key,account:e.account}}function _(e){return tr(e,!1)}function tr(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,browser:e.browser,count:e.count,category:e.category}}function X(e){if(e!==void 0)return e===null?null:{site:e.site}}function Y(e){return nr(e,!1)}function nr(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,site:e.site,eventName:e.eventName,datetime:e.datetime,count:e.count,category:e.category}}function Z(e){return or(e,!1)}function or(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,fingerprint:e.fingerprint,count:e.count,category:e.category}}function A(e){return ir(e,!1)}function ir(e,r){return e==null?e:{site:e.site,account:e.account,apiKey:e.apiKey,adminApiKey:e.adminApiKey,favicon:i(e,"favicon")?e.favicon:void 0}}function v(e){return sr(e,!1)}function sr(e,r){return e==null?e:{accounts:e.accounts.map(A),googleEmail:i(e,"googleEmail")?e.googleEmail:void 0,googleKey:i(e,"googleKey")?e.googleKey:void 0,bingKey:i(e,"bingKey")?e.bingKey:void 0,bingAccount:i(e,"bingAccount")?e.bingAccount:void 0}}function j(e){if(e!==void 0)return e===null?null:{email:e.email,key:e.key,account:e.account}}function ee(e){return ur(e,!1)}function ur(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,responseTimeMs:e.responseTimeMs,success:e.success}}function re(e){return cr(e,!1)}function cr(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,language:e.language,count:e.count,category:e.category}}function te(e){return pr(e,!1)}function pr(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,countryRegion:e.countryRegion,category:e.category,count:e.count}}function ne(e){return fr(e,!1)}function fr(e,r){return e==null?e:{PK:e.PK,messageHash:i(e,"messageHash")?e.messageHash:void 0,site:e.site,account:e.account,message:i(e,"message")?e.message:void 0,name:i(e,"name")?e.name:void 0,stack:i(e,"stack")?e.stack:void 0,href:e.href,filename:i(e,"filename")?e.filename:void 0,datetime:e.datetime,archived:i(e,"archived")?e.archived:void 0,count:e.count,category:e.category}}function oe(e){if(e!==void 0)return e===null?null:{site:e.site}}function ie(e){if(e!==void 0)return e===null?null:{key:e.key,data:ae(e.data)}}function ae(e){if(e!==void 0)return e===null?null:{message:e.message,name:e.name,stack:e.stack,href:e.href,filename:e.filename}}function se(e){if(e!==void 0)return e===null?null:{key:e.key,data:ue(e.data)}}function ue(e){if(e!==void 0)return e===null?null:{eventName:e.eventName,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage,browserFingerprint:e.browserFingerprint}}function ce(e){if(e!==void 0)return e===null?null:{key:e.key,data:pe(e.data)}}function pe(e){if(e!==void 0)return e===null?null:{pageLocation:e.pageLocation,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage,browserFingerprint:e.browserFingerprint}}function fe(e){return lr(e,!1)}function lr(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,pathName:e.pathName,search:i(e,"search")?e.search:void 0,hash:i(e,"hash")?e.hash:void 0,count:e.count,category:e.category}}function le(e){return dr(e,!1)}function dr(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,referrer:e.referrer,count:e.count,category:e.category}}function de(e){return mr(e,!1)}function mr(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,resolution:e.resolution,count:e.count,category:e.category}}function me(e){return gr(e,!1)}function gr(e,r){return e==null?e:{account:e.account,site:e.site,datetime:e.datetime,category:e.category,topReferrers:i(e,"topReferrers")?e.topReferrers.map(xe):void 0,topResolutions:i(e,"topResolutions")?e.topResolutions.map(Oe):void 0,topFingerprints:i(e,"topFingerprints")?e.topFingerprints.map(Re):void 0,topQueries:i(e,"topQueries")?e.topQueries.map(we):void 0,topLocations:i(e,"topLocations")?e.topLocations.map(Se):void 0,topBrowsers:i(e,"topBrowsers")?e.topBrowsers.map(ge):void 0,topEvents:i(e,"topEvents")?e.topEvents.map(Te):void 0,topLanguages:i(e,"topLanguages")?e.topLanguages.map(he):void 0,topErrors:i(e,"topErrors")?e.topErrors.map(ye):void 0,averageResponseTimeMs:i(e,"averageResponseTimeMs")?e.averageResponseTimeMs:void 0}}function ge(e){return yr(e,!1)}function yr(e,r){return e==null?e:{browser:e.browser,count:e.count}}function ye(e){return Tr(e,!1)}function Tr(e,r){return e==null?e:{href:e.href,count:e.count}}function Te(e){return Rr(e,!1)}function Rr(e,r){return e==null?e:{eventName:e.eventName,count:e.count}}function Re(e){return hr(e,!1)}function hr(e,r){return e==null?e:{fingerprint:e.fingerprint,count:e.count}}function he(e){return Sr(e,!1)}function Sr(e,r){return e==null?e:{language:e.language,count:e.count}}function Se(e){return wr(e,!1)}function wr(e,r){return e==null?e:{countryRegion:e.countryRegion,count:e.count}}function we(e){return xr(e,!1)}function xr(e,r){return e==null?e:{pathName:e.pathName,count:e.count}}function xe(e){return Or(e,!1)}function Or(e,r){return e==null?e:{referrer:e.referrer,count:e.count}}function Oe(e){return Ar(e,!1)}function Ar(e,r){return e==null?e:{resolution:e.resolution,count:e.count}}function I(e){return Pr(e,!1)}function Pr(e,r){return e==null?e:{account:e.account,email:e.email,site:e.site,datetime:e.datetime,category:e.category,totals:q(e.totals),queries:e.queries.map(q)}}function q(e){return Nr(e,!1)}function Nr(e,r){return e==null?e:{clicks:e.clicks,impressions:e.impressions,position:e.position,query:e.query}}function L(e){return Er(e,!1)}function Er(e,r){return e==null?e:{accountDetails:i(e,"accountDetails")?A(e.accountDetails):void 0,browsers:i(e,"browsers")?e.browsers.map(_):void 0,events:i(e,"events")?e.events.map(Y):void 0,locations:i(e,"locations")?e.locations.map(te):void 0,queries:i(e,"queries")?e.queries.map(fe):void 0,referrers:i(e,"referrers")?e.referrers.map(le):void 0,resolutions:i(e,"resolutions")?e.resolutions.map(de):void 0,fingerprints:i(e,"fingerprints")?e.fingerprints.map(Z):void 0,health:i(e,"health")?e.health.map(ee):void 0,languages:i(e,"languages")?e.languages.map(re):void 0,rollups:i(e,"rollups")?e.rollups.map(me):void 0,errors:i(e,"errors")?e.errors.map(ne):void 0,google:i(e,"google")?e.google.map(I):void 0,bing:i(e,"bing")?e.bing.map(I):void 0}}var g=class extends O{async accountGetRaw(r){let t={},n={};this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let o=await this.request({path:"/account",method:"GET",headers:n,query:t},r);return new m(o,a=>v(a))}async accountGet(r){return await(await this.accountGetRaw(r)).value()}async archiveErrorRaw(r,t){if(r.id===null||r.id===void 0)throw new u("id","Required parameter requestParameters.id was null or undefined when calling archiveError.");let n={},o={};this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/errors/{id}".replace("{id}",encodeURIComponent(String(r.id))),method:"DELETE",headers:o,query:n},t);return new c(a)}async archiveError(r,t){await this.archiveErrorRaw(r,t)}async archiveErrorsRaw(r,t){if(r.archiveErrors===null||r.archiveErrors===void 0)throw new u("archiveErrors","Required parameter requestParameters.archiveErrors was null or undefined when calling archiveErrors.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/errors",method:"DELETE",headers:o,query:n,body:U(r.archiveErrors)},t);return new c(a)}async archiveErrors(r,t){await this.archiveErrorsRaw(r,t)}async bingIntegrationPostRaw(r,t){if(r.bingIntegration===null||r.bingIntegration===void 0)throw new u("bingIntegration","Required parameter requestParameters.bingIntegration was null or undefined when calling bingIntegrationPost.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/integrations/bing",method:"POST",headers:o,query:n,body:W(r.bingIntegration)},t);return new c(a)}async bingIntegrationPost(r,t){await this.bingIntegrationPostRaw(r,t)}async getTrackingAllSitesRaw(r,t){if(r.minDate===null||r.minDate===void 0)throw new u("minDate","Required parameter requestParameters.minDate was null or undefined when calling getTrackingAllSites.");if(r.maxDate===null||r.maxDate===void 0)throw new u("maxDate","Required parameter requestParameters.maxDate was null or undefined when calling getTrackingAllSites.");let n={};r.minDate!==void 0&&(n.minDate=r.minDate),r.maxDate!==void 0&&(n.maxDate=r.maxDate);let o={};this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/site/tracking",method:"GET",headers:o,query:n},t);return new m(a,s=>s.map(L))}async getTrackingAllSites(r,t){return await(await this.getTrackingAllSitesRaw(r,t)).value()}async getTrackingSiteRaw(r,t){if(r.id===null||r.id===void 0)throw new u("id","Required parameter requestParameters.id was null or undefined when calling getTrackingSite.");if(r.minDate===null||r.minDate===void 0)throw new u("minDate","Required parameter requestParameters.minDate was null or undefined when calling getTrackingSite.");if(r.maxDate===null||r.maxDate===void 0)throw new u("maxDate","Required parameter requestParameters.maxDate was null or undefined when calling getTrackingSite.");let n={};r.minDate!==void 0&&(n.minDate=r.minDate),r.maxDate!==void 0&&(n.maxDate=r.maxDate);let o={};this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/site/tracking/{id}".replace("{id}",encodeURIComponent(String(r.id))),method:"GET",headers:o,query:n},t);return new m(a,s=>L(s))}async getTrackingSite(r,t){return await(await this.getTrackingSiteRaw(r,t)).value()}async googleIntegrationPostRaw(r,t){if(r.googleIntegration===null||r.googleIntegration===void 0)throw new u("googleIntegration","Required parameter requestParameters.googleIntegration was null or undefined when calling googleIntegrationPost.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/integrations/google",method:"POST",headers:o,query:n,body:j(r.googleIntegration)},t);return new c(a)}async googleIntegrationPost(r,t){await this.googleIntegrationPostRaw(r,t)}async postErrorsRaw(r,t){if(r.postError===null||r.postError===void 0)throw new u("postError","Required parameter requestParameters.postError was null or undefined when calling postErrors.");let n={},o={};o["Content-Type"]="application/json";let a=await this.request({path:"/errors",method:"POST",headers:o,query:n,body:r.postError.map(ie)},t);return new c(a)}async postErrors(r,t){await this.postErrorsRaw(r,t)}async postEventRaw(r,t){if(r.postEvent===null||r.postEvent===void 0)throw new u("postEvent","Required parameter requestParameters.postEvent was null or undefined when calling postEvent.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/site/event",method:"POST",headers:o,query:n,body:se(r.postEvent)},t);return new c(a)}async postEvent(r,t){await this.postEventRaw(r,t)}async postPageTrackRaw(r,t){if(r.postSiteTrack===null||r.postSiteTrack===void 0)throw new u("postSiteTrack","Required parameter requestParameters.postSiteTrack was null or undefined when calling postPageTrack.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/site/tracking",method:"POST",headers:o,query:n,body:ce(r.postSiteTrack)},t);return new c(a)}async postPageTrack(r,t){await this.postPageTrackRaw(r,t)}async siteDeleteRaw(r,t){if(r.deleteAccount===null||r.deleteAccount===void 0)throw new u("deleteAccount","Required parameter requestParameters.deleteAccount was null or undefined when calling siteDelete.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/site",method:"DELETE",headers:o,query:n,body:X(r.deleteAccount)},t);return new c(a)}async siteDelete(r,t){await this.siteDeleteRaw(r,t)}async sitePostRaw(r,t){if(r.postAccount===null||r.postAccount===void 0)throw new u("postAccount","Required parameter requestParameters.postAccount was null or undefined when calling sitePost.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/site",method:"POST",headers:o,query:n,body:oe(r.postAccount)},t);return new c(a)}async sitePost(r,t){await this.sitePostRaw(r,t)}};var K=require("ag-common/dist/common/helpers/hashCode"),y=require("ag-common/dist/common/helpers/log"),Ae=require("ag-common/dist/common/helpers/object");function Pe(e){return e?e.match(/^"?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}"?$/)?((0,y.info)("ignoring react devtools message"),!1):e===JSON.stringify([{}])?((0,y.info)("empty message payload?"),!1):!0:((0,y.info)("no message?"),!1)}var Ne=e=>{try{let r=/^\[?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}\]?$/gim,t=/(at \S+?) \(\S+\)\s/gim,n=/^((%[cs])+\s*)+$/gim,o=/^color:/gim,a=[],s=e.message;(0,Ae.isJson)(s)?a=JSON.parse(s):a=[s];let R=a.findIndex(p=>p.match(n)),F=a.findIndex(p=>p.match(o));R>=0&&F>=0&&F===R+1&&(a=a.filter((p,ze)=>![R,F].includes(ze))),a=a.map(p=>p.includes(".js:")||p.includes("node_modules")?p.replace(t,"$1 (stacktrace)"):p.replace(r,"[date]")),s=JSON.stringify(a);let z=(0,K.hashCode)(s).toString();return(0,y.debug)("got errorKey=",s,z),z}catch{return(0,K.hashCode)(e.message).toString()}};var Ee=(e,r)=>{let t=[],n={},o=0;return Object.entries(e).forEach(([a,s])=>{o<r?t.push(s):n[a]=s,o+=1}),{part:t,rest:n}};function Je(e){return(0,P.callOpenApi)({...e,func:r=>(0,P.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new g(r),logout:()=>typeof window<"u"?window.location.reload():()=>{},refreshToken:async()=>{}})}var be=typeof window<"u"&&window.location.hostname==="localhost",l={},B,H,ke=async()=>{try{if(Object.keys(l).length>100){let n=Object.keys(l)[0],o=l[n],a=await Je({headers:{authorization:""},apiUrl:H,func:s=>s.postErrorsRaw({postError:[{key:o.key,data:{...o.data,message:`error overload!: ${o.data.message||"?"}`}}]})});if(l={},a.error)throw a.error;return{}}let{part:e,rest:r}=Ee(l,10);l=r;let t=await Je({headers:{authorization:""},apiUrl:H,func:n=>n.postErrorsRaw({postError:e})});if(t.error)throw t.error}catch(e){let r=e,t=r;return{error:r?.error?.message??t.message}}finally{Object.keys(l).length>0?B=setTimeout(ke,1e3):B=void 0}},f=async({data:e,overrideBaseUrl:r="https://api.analytica.click",ignoreBrowserErrors:t=["will be removed","performing full reload","tracking error","fetch RSC payload","perform a full reload","warnings#debug_enabled"],devMode:n})=>{if(r||(r="https://api.analytica.click"),r.startsWith("/")&&typeof window>"u"&&(r="https://api.analytica.click"),t.length>0){let a=(0,Fe.containsInsensitive)(e.data.message,...t);if(a){(0,h.debug)("ignoring error, contains=",a);return}}if(be&&n)(0,h.debug)("allowing local error tracking due to devmode=true");else if(be)return(0,h.debug)(`local error tracking ignored:${e.data.message} ${JSON.stringify(e)}, to ${r}`),{};if(!Pe(e.data.message))return{};(0,h.debug)("error track",e.data.message,JSON.stringify(e));let o=Ne(e.data);return l[o]=e,H=r,B??=setTimeout(ke,500),{}};async function C({ev:e,values:r}){if(!r.analyticaToken)return;let t={message:e.message,href:window.location.href,filename:e.filename,name:"",stack:e.error.stack};await f({...r,data:{key:r.analyticaToken,data:t}})}function qe(e){(0,De.useEffect)(()=>{let r=t=>C({ev:t,values:e});if(e.analyticaToken)return window.addEventListener("error",r),()=>{try{window.removeEventListener("error",r)}catch{}}},[])}var Ie=require("react");function Le(e){(0,Ie.useEffect)(()=>{if(window.consoleset||!e.analyticaToken)return;window.consoleset=!0;let r=window.console.error;window.console.error=(...n)=>{f({...e,data:{data:{href:window.location.href,message:JSON.stringify(n)},key:e.analyticaToken}}),r(...n)};let t=window.console.warn;window.console.warn=(...n)=>{f({...e,data:{data:{href:window.location.href,message:JSON.stringify(n)},key:e.analyticaToken}}),t(...n)}},[])}var S=e=>`[Analytica.${e}] Please load analytica token in AnalyticaClickProvider to use this component`;function Ke(e){if(global.nodeset||typeof window<"u"||!e.analyticaToken)return;global.nodeset=!0;let r=global.console.error;global.console.error=(...n)=>{f({...e,data:{data:{href:"server",message:JSON.stringify(n)},key:e.analyticaToken}}),r(...n)};let t=global.console.warn;global.console.warn=(...n)=>{f({...e,data:{data:{href:"server",message:JSON.stringify(n)},key:e.analyticaToken}}),t(...n)}}var Be=require("ag-common/dist/ui/components/Modal"),He=require("react"),w=require("react/jsx-runtime"),Jr={fontSize:"2rem"},N=class extends He.Component{constructor(r){super(r),this.state={hasError:void 0},this.seenError=!1}static getDerivedStateFromError(r){let t=typeof window<"u"&&window.location.href;return{hasError:{...r,message:r?.message??r,...r?.stack&&{error:{stack:r?.stack}},...t&&{href:t}}}}render(){let{hasError:r}=this.state,{children:t,notify:n}=this.props;return r?(n&&n(r),(0,w.jsx)(Be.Modal,{open:!0,setOpen:()=>{},children:(0,w.jsxs)("div",{style:Jr,children:["A fatal error has occurred - the admin has been notified.",(0,w.jsx)("button",{type:"button",onClick:()=>window.location.reload(),children:"Press here to restart app"})]})})):t}};var V=require("react/jsx-runtime"),Ce=({children:e})=>{let r=(0,J.useContext)(T);return Le(r),qe(r),Ke(r),(0,E.debug)("installed analytica.click error handlers"),r.analyticaToken?(0,V.jsx)(N,{notify:t=>C({ev:t,values:r}),children:e}):((0,E.warn)(S("ErrorBoundary")),(0,V.jsx)(J.default.Fragment,{children:e}))};var G=require("react/jsx-runtime"),T=(0,Ve.createContext)(void 0),br=({children:e,values:r})=>(0,G.jsx)(T.Provider,{value:r,children:(0,G.jsx)(Ce,{children:e})});var Sa=require("cross-fetch/polyfill"),d=require("ag-common/dist/common/helpers/log"),b=require("ag-common/dist/ui/helpers/callOpenApi");function Ge(e){return(0,b.callOpenApi)({...e,func:r=>(0,b.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new g(r),logout:()=>typeof window<"u"?window.location.reload():()=>{},refreshToken:async()=>{}})}var M=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click",eventName:t,devMode:n,valueOverrides:o})=>{let a={eventName:t,browserFingerprint:o?.browserFingerprint};if(!n&&typeof window<"u"&&window.location.hostname==="localhost")return(0,d.debug)(`local page ignored: ${JSON.stringify(a)}, to ${r}`),{};let s=await Ge({apiUrl:r,headers:{authorization:""},func:R=>R.postEventRaw({postEvent:{key:e,data:a}})});return s.error?((0,d.warn)("tracking error:"+JSON.stringify(s.error,null,2)),{error:JSON.stringify(s.error,null,2)}):{}},Q=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click",devMode:t,valueOverrides:n})=>{let o={pageLocation:"",browserFingerprint:n?.browserFingerprint};if(typeof window<"u"&&(o={...o,pageLocation:window.location.href,browserResolution:`${window.screen.width}:${window.screen.height}`}),typeof document<"u"&&(o={...o,pageReferrer:document.referrer,pageTitle:document.title}),typeof navigator<"u"&&(o={...o,browserLanguage:navigator.language}),!t&&typeof window<"u"&&window.location.hostname==="localhost")return(0,d.debug)(`local page ignored: ${JSON.stringify(o)}, to ${r}`),{};if(!o.pageLocation)return(0,d.warn)("no pageLocation"),{};let a=await Ge({apiUrl:r,headers:{authorization:""},func:s=>s.postPageTrackRaw({postSiteTrack:{key:e,data:o}})});return a.error?((0,d.warn)("tracking error:"+JSON.stringify(a.error,null,2)),{error:JSON.stringify(a.error,null,2)}):{}};var Me=require("ag-common/dist/common/helpers/log"),Qe=require("react");var Fr=()=>{let e=(0,Qe.useContext)(T);if(!e.analyticaToken){(0,Me.warn)(S("useAnalytica"));let r=async()=>({error:"no token"});return{event:r,page:r}}return{event:r=>M({...r,...e}),page:r=>Q({...r,...e})}};0&&(module.exports={AnalyticaClickProvider,AnalyticaConfigContext,errorTrack,event,page,tokenMissing,useAnalytica});
1
+ 'use client';"use strict";var Z=Object.create;var w=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var rr=Object.getPrototypeOf,er=Object.prototype.hasOwnProperty;var or=(r,e)=>{for(var o in e)w(r,o,{get:e[o],enumerable:!0})},A=(r,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of V(e))!er.call(r,n)&&n!==o&&w(r,n,{get:()=>e[n],enumerable:!(t=U(e,n))||t.enumerable});return r};var tr=(r,e,o)=>(o=r!=null?Z(rr(r)):{},A(e||!r||!r.__esModule?w(o,"default",{value:r,enumerable:!0}):o,r)),nr=r=>A(w({},"__esModule",{value:!0}),r);var cr={};or(cr,{AnalyticaClickProvider:()=>ir,AnalyticaConfigContext:()=>p,errorTrack:()=>f,event:()=>S,page:()=>I,tokenMissing:()=>y,useAnalytica:()=>sr});module.exports=nr(cr);var q=require("react");var k=require("ag-common/dist/common/helpers/log"),E=tr(require("react"));var F=require("react");var lr=require("cross-fetch/polyfill"),g=require("ag-common/dist/common/helpers/log"),D=require("ag-common/dist/common/helpers/string/contains");var v=require("ag-common/dist/common/helpers/hashCode"),l=require("ag-common/dist/common/helpers/log"),N=require("ag-common/dist/common/helpers/object");function R(r){return r?r.match(/^"?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}"?$/)?((0,l.info)("ignoring react devtools message"),!1):r===JSON.stringify([{}])?((0,l.info)("empty message payload?"),!1):!0:((0,l.info)("no message?"),!1)}var J=r=>{try{let e=/^\[?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}\]?$/gim,o=/(at \S+?) \(\S+\)\s/gim,t=/^((%[cs])+\s*)+$/gim,n=/^color:/gim,a=[],i=r.message;(0,N.isJson)(i)?a=JSON.parse(i):a=[i];let s=a.findIndex(c=>c.match(t)),T=a.findIndex(c=>c.match(n));s>=0&&T>=0&&T===s+1&&(a=a.filter((c,Y)=>![s,T].includes(Y))),a=a.map(c=>c.includes(".js:")||c.includes("node_modules")?c.replace(o,"$1 (stacktrace)"):c.replace(e,"[date]")),i=JSON.stringify(a);let $=(0,v.hashCode)(i).toString();return(0,l.debug)("got errorKey=",i,$),$}catch{return(0,v.hashCode)(r.message).toString()}};var M=(r,e)=>{let o=[],t={},n=0;return Object.entries(r).forEach(([a,i])=>{n<e?o.push(i):t[a]=i,n+=1}),{part:o,rest:t}};var B=typeof window<"u"&&window.location.hostname==="localhost",d={},x,C,L=async()=>{try{if(Object.keys(d).length>100){let t=Object.keys(d)[0],n=d[t],a=await fetch(`${C}/errors`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify([{key:n.key,data:{...n.data,message:`error overload!: ${n.data.message||"?"}`}}])});if(d={},!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return{}}let{part:r,rest:e}=M(d,10);d=e;let o=await fetch(`${C}/errors`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify(r)});if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`)}catch(r){let e=r;return{error:e?.message??e.message}}finally{Object.keys(d).length>0?x=setTimeout(L,1e3):x=void 0}},f=async({data:r,overrideBaseUrl:e="https://analytica.click/api",ignoreBrowserErrors:o=["will be removed","performing full reload","tracking error","fetch RSC payload","perform a full reload","warnings#debug_enabled"],devMode:t})=>{if(e||(e="https://analytica.click/api"),e.startsWith("/")&&typeof window>"u"&&(e="https://analytica.click/api"),o.length>0){let a=(0,D.containsInsensitive)(r.data.message,...o);if(a){(0,g.debug)("ignoring error, contains=",a);return}}if(B&&t)(0,g.debug)("allowing local error tracking due to devmode=true");else if(B)return(0,g.debug)(`local error tracking ignored:${r.data.message} ${JSON.stringify(r)}, to ${e}`),{};if(!R(r.data.message))return{};(0,g.debug)("error track",r.data.message,JSON.stringify(r));let n=J(r.data);return d[n]=r,C=e,x??=setTimeout(L,500),{}};async function b({ev:r,values:e}){if(!e.analyticaToken)return;let o={message:r.message,href:window.location.href,filename:r.filename,name:"",stack:r.error.stack};await f({...e,data:{key:e.analyticaToken,data:o}})}function z(r){(0,F.useEffect)(()=>{let e=o=>b({ev:o,values:r});if(r.analyticaToken)return window.addEventListener("error",e),()=>{try{window.removeEventListener("error",e)}catch{}}},[])}var H=require("react");function j(r){(0,H.useEffect)(()=>{if(window.consoleset||!r.analyticaToken)return;window.consoleset=!0;let e=window.console.error;window.console.error=(...t)=>{f({...r,data:{data:{href:window.location.href,message:JSON.stringify(t)},key:r.analyticaToken}}),e(...t)};let o=window.console.warn;window.console.warn=(...t)=>{f({...r,data:{data:{href:window.location.href,message:JSON.stringify(t)},key:r.analyticaToken}}),o(...t)}},[])}var y=r=>`[Analytica.${r}] Please load analytica token in AnalyticaClickProvider to use this component`;function K(r){if(global.nodeset||typeof window<"u"||!r.analyticaToken)return;global.nodeset=!0;let e=global.console.error;global.console.error=(...t)=>{f({...r,data:{data:{href:"server",message:JSON.stringify(t)},key:r.analyticaToken}}),e(...t)};let o=global.console.warn;global.console.warn=(...t)=>{f({...r,data:{data:{href:"server",message:JSON.stringify(t)},key:r.analyticaToken}}),o(...t)}}var W=require("ag-common/dist/ui/components/Modal"),_=require("react"),u=require("react/jsx-runtime"),ar={fontSize:"2rem"},h=class extends _.Component{constructor(e){super(e),this.state={hasError:void 0},this.seenError=!1}static getDerivedStateFromError(e){let o=typeof window<"u"&&window.location.href;return{hasError:{...e,message:e?.message??e,...e?.stack&&{error:{stack:e?.stack}},...o&&{href:o}}}}render(){let{hasError:e}=this.state,{children:o,notify:t}=this.props;return e?(t&&t(e),(0,u.jsx)(W.Modal,{open:!0,setOpen:()=>{},children:(0,u.jsxs)("div",{style:ar,children:["A fatal error has occurred - the admin has been notified.",(0,u.jsx)("button",{type:"button",onClick:()=>window.location.reload(),children:"Press here to restart app"})]})})):o}};var O=require("react/jsx-runtime"),X=({children:r})=>{let e=(0,E.useContext)(p);return j(e),z(e),K(e),(0,k.debug)("installed analytica.click error handlers"),e.analyticaToken?(0,O.jsx)(h,{notify:o=>b({ev:o,values:e}),children:r}):((0,k.warn)(y("ErrorBoundary")),(0,O.jsx)(E.default.Fragment,{children:r}))};var P=require("react/jsx-runtime"),p=(0,q.createContext)(void 0),ir=({children:r,values:e})=>(0,P.jsx)(p.Provider,{value:e,children:(0,P.jsx)(X,{children:r})});var Dr=require("cross-fetch/polyfill"),m=require("ag-common/dist/common/helpers/log"),S=async({analyticaToken:r,overrideBaseUrl:e="https://analytica.click/api",eventName:o,devMode:t,valueOverrides:n})=>{let a={eventName:o,browserFingerprint:n?.browserFingerprint};if(!t&&typeof window<"u"&&window.location.hostname==="localhost")return(0,m.debug)(`local page ignored: ${JSON.stringify(a)}, to ${e}`),{};try{let i=await fetch(`${e}/site/event`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:r,data:a})});if(!i.ok){let s=await i.text();return(0,m.warn)("tracking error:"+s),{error:s}}}catch(i){let s=i instanceof Error?i.message:"Unknown error";return(0,m.warn)("tracking error:"+s),{error:s}}return{}},I=async({analyticaToken:r,overrideBaseUrl:e="https://analytica.click/api",devMode:o,valueOverrides:t})=>{let n={pageLocation:"",browserFingerprint:t?.browserFingerprint};if(typeof window<"u"&&(n={...n,pageLocation:window.location.href,browserResolution:`${window.screen.width}:${window.screen.height}`}),typeof document<"u"&&(n={...n,pageReferrer:document.referrer,pageTitle:document.title}),typeof navigator<"u"&&(n={...n,browserLanguage:navigator.language}),!o&&typeof window<"u"&&window.location.hostname==="localhost")return(0,m.debug)(`local page ignored: ${JSON.stringify(n)}, to ${e}`),{};if(!n.pageLocation)return(0,m.warn)("no pageLocation"),{};try{let a=await fetch(`${e}/site/tracking`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:r,data:n})});if(!a.ok){let i=await a.text();return(0,m.warn)("tracking error:"+i),{error:i}}}catch(a){let i=a instanceof Error?a.message:"Unknown error";return(0,m.warn)("tracking error:"+i),{error:i}}return{}};var G=require("ag-common/dist/common/helpers/log"),Q=require("react");var sr=()=>{let r=(0,Q.useContext)(p);if(!r.analyticaToken){(0,G.warn)(y("useAnalytica"));let e=async()=>({error:"no token"});return{event:e,page:e}}return{event:e=>S({...e,...r}),page:e=>I({...e,...r})}};0&&(module.exports={AnalyticaClickProvider,AnalyticaConfigContext,errorTrack,event,page,tokenMissing,useAnalytica});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "analytica.click",
3
- "version": "0.0.516",
3
+ "version": "0.0.517",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",