analytica.click 0.0.427 → 0.0.428

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 y=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var j=(e,r)=>{for(var t in r)y(e,t,{get:r[t],enumerable:!0})},ee=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Z(r))!v.call(e,o)&&o!==t&&y(e,o,{get:()=>r[o],enumerable:!(n=Y(r,o))||n.enumerable});return e};var re=e=>ee(y({},"__esModule",{value:!0}),e);var De={};j(De,{page:()=>be,track:()=>X});module.exports=re(De);var m=require("ag-common/dist/common/helpers/log"),g=require("ag-common/dist/ui/helpers/callOpenApi");var te="https://api.analytica.click".replace(/\/+$/,""),ne=e=>typeof Blob<"u"&&e instanceof Blob,l=class{constructor(r=new T){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(r.query));let o=typeof FormData<"u"&&r.body instanceof FormData||r.body instanceof URLSearchParams||ne(r.body)?r.body:JSON.stringify(r.body),a=Object.assign({},this.configuration.headers,r.headers),c={method:r.method,headers:a,body:o,credentials:this.configuration.credentials,...t};return{url:n,init:c}}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 T=class{constructor(r={}){this.configuration=r}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:te}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||x}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 x(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(c=>encodeURIComponent(String(c))).join(`&${encodeURIComponent(n)}=`);return`${encodeURIComponent(n)}=${a}`}return o instanceof Date?`${encodeURIComponent(n)}=${encodeURIComponent(o.toISOString())}`:o instanceof Object?x(o,n):`${encodeURIComponent(n)}=${encodeURIComponent(String(o))}`}).filter(t=>t.length>0).join("&")}var p=class{constructor(r,t=n=>n){this.raw=r;this.transformer=t}async value(){return this.transformer(await this.raw.json())}},s=class{constructor(r){this.raw=r}async value(){}};function w(e){if(e!==void 0)return e===null?null:{PKsB64:e.PKsB64}}function A(e){if(e!==void 0)return e===null?null:{key:e.key,account:e.account}}function N(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,browser:e.browser,count:e.count,category:e.category}}function O(e){if(e!==void 0)return e===null?null:{site:e.site}}function P(e){return ae(e,!1)}function ae(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 d(e){return ue(e,!1)}function ue(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 J(e){return ce(e,!1)}function ce(e,r){return e==null?e:{accounts:e.accounts.map(d),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 E(e){if(e!==void 0)return e===null?null:{email:e.email,key:e.key,account:e.account}}function b(e){return pe(e,!1)}function pe(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 D(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 F(e){return de(e,!1)}function de(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 q(e){if(e!==void 0)return e===null?null:{site:e.site}}function k(e){if(e!==void 0)return e===null?null:{key:e.key,data:I(e.data)}}function I(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 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:{eventName:e.eventName,pageLocation:e.pageLocation,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage}}function B(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,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 G(e){return me(e,!1)}function me(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 ge(e,!1)}function ge(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 H(e){return ye(e,!1)}function ye(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(_):void 0,topResolutions:i(e,"topResolutions")?e.topResolutions.map(W):void 0,topQueries:i(e,"topQueries")?e.topQueries.map(U):void 0,topLocations:i(e,"topLocations")?e.topLocations.map($):void 0,topBrowsers:i(e,"topBrowsers")?e.topBrowsers.map(Q):void 0,topEvents:i(e,"topEvents")?e.topEvents.map(M):void 0,topLanguages:i(e,"topLanguages")?e.topLanguages.map(z):void 0,topErrors:i(e,"topErrors")?e.topErrors.map(C):void 0}}function Q(e){return Te(e,!1)}function Te(e,r){return e==null?e:{browser:e.browser,count:e.count}}function C(e){return Re(e,!1)}function Re(e,r){return e==null?e:{href:e.href,count:e.count}}function M(e){return he(e,!1)}function he(e,r){return e==null?e:{eventName:e.eventName,count:e.count}}function z(e){return Se(e,!1)}function Se(e,r){return e==null?e:{language:e.language,count:e.count}}function $(e){return xe(e,!1)}function xe(e,r){return e==null?e:{countryRegion:e.countryRegion,count:e.count}}function U(e){return we(e,!1)}function we(e,r){return e==null?e:{pathName:e.pathName,count:e.count}}function _(e){return Ae(e,!1)}function Ae(e,r){return e==null?e:{referrer:e.referrer,count:e.count}}function W(e){return Ne(e,!1)}function Ne(e,r){return e==null?e:{resolution:e.resolution,count:e.count}}function h(e){return Oe(e,!1)}function Oe(e,r){return e==null?e:{account:e.account,email:e.email,site:e.site,datetime:e.datetime,category:e.category,totals:R(e.totals),queries:e.queries.map(R)}}function R(e){return Pe(e,!1)}function Pe(e,r){return e==null?e:{clicks:e.clicks,impressions:e.impressions,position:e.position,query:e.query}}function S(e){return Je(e,!1)}function Je(e,r){return e==null?e:{details:i(e,"details")?d(e.details):void 0,browsers:i(e,"browsers")?e.browsers.map(N):void 0,events:i(e,"events")?e.events.map(P):void 0,locations:i(e,"locations")?e.locations.map(D):void 0,queries:i(e,"queries")?e.queries.map(B):void 0,referrers:i(e,"referrers")?e.referrers.map(G):void 0,resolutions:i(e,"resolutions")?e.resolutions.map(V):void 0,languages:i(e,"languages")?e.languages.map(b):void 0,rollups:i(e,"rollups")?e.rollups.map(H):void 0,errors:i(e,"errors")?e.errors.map(F):void 0,google:i(e,"google")?e.google.map(h):void 0,bing:i(e,"bing")?e.bing.map(h):void 0}}var f=class extends l{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 p(o,a=>J(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 s(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:w(r.archiveErrors)},t);return new s(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:A(r.bingIntegration)},t);return new s(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 p(a,c=>c.map(S))}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 p(a,c=>S(c))}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:E(r.googleIntegration)},t);return new s(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(k)},t);return new s(a)}async postErrors(r,t){await this.postErrorsRaw(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",method:"POST",headers:o,query:n,body:L(r.postSiteTrack)},t);return new s(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:O(r.deleteAccount)},t);return new s(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:q(r.postAccount)},t);return new s(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 f(r),logout:()=>window.location.reload(),refreshToken:async()=>{}})}var X=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click",eventName:t})=>{let n={eventName:t};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}),typeof window<"u"&&window?.location?.hostname==="localhost")return(0,m.debug)(`local page ignored: ${JSON.stringify(n)}, to ${r}`),{};let o=await Ee({apiUrl:r,headers:{authorization:""},func:a=>a.postPageTrackRaw({postSiteTrack:{key:e,data:n}})});return o.error?((0,m.warn)("tracking error:"+JSON.stringify(o.error,null,2)),{error:JSON.stringify(o.error,null,2)}):{}},be=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click"})=>X({analyticaToken:e,overrideBaseUrl:r,eventName:"PAGE"});0&&(module.exports={page,track});
1
+ "use strict";var y=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var j=(e,r)=>{for(var t in r)y(e,t,{get:r[t],enumerable:!0})},ee=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Z(r))!v.call(e,o)&&o!==t&&y(e,o,{get:()=>r[o],enumerable:!(n=Y(r,o))||n.enumerable});return e};var re=e=>ee(y({},"__esModule",{value:!0}),e);var De={};j(De,{page:()=>be,track:()=>X});module.exports=re(De);var m=require("ag-common/dist/common/helpers/log"),g=require("ag-common/dist/ui/helpers/callOpenApi");var te="https://api.analytica.click".replace(/\/+$/,""),ne=e=>typeof Blob<"u"&&e instanceof Blob,l=class{constructor(r=new T){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||R)(r.query));let o=typeof FormData<"u"&&r.body instanceof FormData||r.body instanceof URLSearchParams||ne(r.body)?r.body:JSON.stringify(r.body),a=Object.assign({},this.configuration.headers,r.headers),c={method:r.method,headers:a,body:o,credentials:this.configuration.credentials,...t};return{url:n,init:c}}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 T=class{constructor(r={}){this.configuration=r}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:te}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 n=r+(r.length?`[${t}]`:t),o=e[t];if(o instanceof Array){let a=o.map(c=>encodeURIComponent(String(c))).join(`&${encodeURIComponent(n)}=`);return`${encodeURIComponent(n)}=${a}`}return o instanceof Date?`${encodeURIComponent(n)}=${encodeURIComponent(o.toISOString())}`:o instanceof Object?R(o,n):`${encodeURIComponent(n)}=${encodeURIComponent(String(o))}`}).filter(t=>t.length>0).join("&")}var p=class{constructor(r,t=n=>n){this.raw=r;this.transformer=t}async value(){return this.transformer(await this.raw.json())}},s=class{constructor(r){this.raw=r}async value(){}};function w(e){if(e!==void 0)return e===null?null:{PKsB64:e.PKsB64}}function A(e){if(e!==void 0)return e===null?null:{key:e.key,account:e.account}}function N(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,browser:e.browser,count:e.count,category:e.category}}function O(e){if(e!==void 0)return e===null?null:{site:e.site}}function P(e){return ae(e,!1)}function ae(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 d(e){return ue(e,!1)}function ue(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 J(e){return ce(e,!1)}function ce(e,r){return e==null?e:{accounts:e.accounts.map(d),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 E(e){if(e!==void 0)return e===null?null:{email:e.email,key:e.key,account:e.account}}function b(e){return pe(e,!1)}function pe(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 D(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 F(e){return de(e,!1)}function de(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 q(e){if(e!==void 0)return e===null?null:{site:e.site}}function k(e){if(e!==void 0)return e===null?null:{key:e.key,data:I(e.data)}}function I(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 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:{eventName:e.eventName,pageLocation:e.pageLocation,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage}}function B(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,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 G(e){return me(e,!1)}function me(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 ge(e,!1)}function ge(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 H(e){return ye(e,!1)}function ye(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(_):void 0,topResolutions:i(e,"topResolutions")?e.topResolutions.map(W):void 0,topQueries:i(e,"topQueries")?e.topQueries.map(U):void 0,topLocations:i(e,"topLocations")?e.topLocations.map($):void 0,topBrowsers:i(e,"topBrowsers")?e.topBrowsers.map(Q):void 0,topEvents:i(e,"topEvents")?e.topEvents.map(M):void 0,topLanguages:i(e,"topLanguages")?e.topLanguages.map(z):void 0,topErrors:i(e,"topErrors")?e.topErrors.map(C):void 0}}function Q(e){return Te(e,!1)}function Te(e,r){return e==null?e:{browser:e.browser,count:e.count}}function C(e){return Re(e,!1)}function Re(e,r){return e==null?e:{href:e.href,count:e.count}}function M(e){return he(e,!1)}function he(e,r){return e==null?e:{eventName:e.eventName,count:e.count}}function z(e){return Se(e,!1)}function Se(e,r){return e==null?e:{language:e.language,count:e.count}}function $(e){return xe(e,!1)}function xe(e,r){return e==null?e:{countryRegion:e.countryRegion,count:e.count}}function U(e){return we(e,!1)}function we(e,r){return e==null?e:{pathName:e.pathName,count:e.count}}function _(e){return Ae(e,!1)}function Ae(e,r){return e==null?e:{referrer:e.referrer,count:e.count}}function W(e){return Ne(e,!1)}function Ne(e,r){return e==null?e:{resolution:e.resolution,count:e.count}}function S(e){return Oe(e,!1)}function Oe(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 Pe(e,!1)}function Pe(e,r){return e==null?e:{clicks:e.clicks,impressions:e.impressions,position:e.position,query:e.query}}function x(e){return Je(e,!1)}function Je(e,r){return e==null?e:{details:i(e,"details")?d(e.details):void 0,browsers:i(e,"browsers")?e.browsers.map(N):void 0,events:i(e,"events")?e.events.map(P):void 0,locations:i(e,"locations")?e.locations.map(D):void 0,queries:i(e,"queries")?e.queries.map(B):void 0,referrers:i(e,"referrers")?e.referrers.map(G):void 0,resolutions:i(e,"resolutions")?e.resolutions.map(V):void 0,languages:i(e,"languages")?e.languages.map(b):void 0,rollups:i(e,"rollups")?e.rollups.map(H):void 0,errors:i(e,"errors")?e.errors.map(F):void 0,google:i(e,"google")?e.google.map(S):void 0,bing:i(e,"bing")?e.bing.map(S):void 0}}var f=class extends l{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 p(o,a=>J(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 s(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:w(r.archiveErrors)},t);return new s(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:A(r.bingIntegration)},t);return new s(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 p(a,c=>c.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 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 p(a,c=>x(c))}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:E(r.googleIntegration)},t);return new s(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(k)},t);return new s(a)}async postErrors(r,t){await this.postErrorsRaw(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",method:"POST",headers:o,query:n,body:L(r.postSiteTrack)},t);return new s(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:O(r.deleteAccount)},t);return new s(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:q(r.postAccount)},t);return new s(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 f(r),logout:()=>window.location.reload(),refreshToken:async()=>{}})}var X=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click",eventName:t})=>{let n={eventName:t};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}),typeof window<"u"&&window?.location?.hostname==="localhost")return(0,m.debug)(`local page ignored: ${JSON.stringify(n)}, to ${r}`),{};let o=await Ee({apiUrl:r,headers:{authorization:""},func:a=>a.postPageTrackRaw({postSiteTrack:{key:e,data:n}})});return o.error?((0,m.warn)("tracking error:"+JSON.stringify(o.error,null,2)),{error:JSON.stringify(o.error,null,2)}):{}},be=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click"})=>X({analyticaToken:e,overrideBaseUrl:r,eventName:"PAGE"});0&&(module.exports={page,track});
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- 'use client';"use strict";var Ee=Object.create;var h=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var be=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty;var De=(e,r)=>{for(var t in r)h(e,t,{get:r[t],enumerable:!0})},C=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Je(r))!ke.call(e,o)&&o!==t&&h(e,o,{get:()=>r[o],enumerable:!(n=Pe(r,o))||n.enumerable});return e};var b=(e,r,t)=>(t=e!=null?Ee(be(e)):{},C(r||!e||!e.__esModule?h(t,"default",{value:e,enumerable:!0}):t,e)),Fe=e=>C(h({},"__esModule",{value:!0}),e);var mr={};De(mr,{AnalyticaConfigContext:()=>m,AnalyticaConfigProvider:()=>ur,ErrorBoundary:()=>dr,errorTrack:()=>d,page:()=>G,tokenMissing:()=>R,track:()=>J,useTrack:()=>fr});module.exports=Fe(mr);var O=require("react");var L=require("ag-common/dist/common/helpers/log"),A=require("ag-common/dist/ui/helpers/callOpenApi");var qe="https://api.analytica.click".replace(/\/+$/,""),Ie=e=>typeof Blob<"u"&&e instanceof Blob,S=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(r.query));let o=typeof FormData<"u"&&r.body instanceof FormData||r.body instanceof URLSearchParams||Ie(r.body)?r.body:JSON.stringify(r.body),a=Object.assign({},this.configuration.headers,r.headers),u={method:r.method,headers:a,body:o,credentials:this.configuration.credentials,...t};return{url:n,init:u}}clone(){let r=this.constructor,t=new r(this.configuration);return t.middleware=this.middleware.slice(),t}},s=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:qe}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||V}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 V(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(u=>encodeURIComponent(String(u))).join(`&${encodeURIComponent(n)}=`);return`${encodeURIComponent(n)}=${a}`}return o instanceof Date?`${encodeURIComponent(n)}=${encodeURIComponent(o.toISOString())}`:o instanceof Object?V(o,n):`${encodeURIComponent(n)}=${encodeURIComponent(String(o))}`}).filter(t=>t.length>0).join("&")}var l=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 H(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 M(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,browser:e.browser,count:e.count,category:e.category}}function U(e){if(e!==void 0)return e===null?null:{site:e.site}}function z(e){return Ke(e,!1)}function Ke(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 w(e){return Ge(e,!1)}function Ge(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){return Ve(e,!1)}function Ve(e,r){return e==null?e:{accounts:e.accounts.map(w),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 W(e){if(e!==void 0)return e===null?null:{email:e.email,key:e.key,account:e.account}}function X(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,language:e.language,count:e.count,category:e.category}}function _(e){return Qe(e,!1)}function Qe(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 Y(e){return Me(e,!1)}function Me(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 Z(e){if(e!==void 0)return e===null?null:{site:e.site}}function v(e){if(e!==void 0)return e===null?null:{key:e.key,data:j(e.data)}}function j(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 ee(e){if(e!==void 0)return e===null?null:{key:e.key,data:re(e.data)}}function re(e){if(e!==void 0)return e===null?null:{eventName:e.eventName,pageLocation:e.pageLocation,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage}}function te(e){return Ue(e,!1)}function Ue(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 ne(e){return ze(e,!1)}function ze(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 oe(e){return $e(e,!1)}function $e(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 ie(e){return We(e,!1)}function We(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(le):void 0,topResolutions:i(e,"topResolutions")?e.topResolutions.map(fe):void 0,topQueries:i(e,"topQueries")?e.topQueries.map(de):void 0,topLocations:i(e,"topLocations")?e.topLocations.map(pe):void 0,topBrowsers:i(e,"topBrowsers")?e.topBrowsers.map(ae):void 0,topEvents:i(e,"topEvents")?e.topEvents.map(ue):void 0,topLanguages:i(e,"topLanguages")?e.topLanguages.map(ce):void 0,topErrors:i(e,"topErrors")?e.topErrors.map(se):void 0}}function ae(e){return Xe(e,!1)}function Xe(e,r){return e==null?e:{browser:e.browser,count:e.count}}function se(e){return _e(e,!1)}function _e(e,r){return e==null?e:{href:e.href,count:e.count}}function ue(e){return Ye(e,!1)}function Ye(e,r){return e==null?e:{eventName:e.eventName,count:e.count}}function ce(e){return Ze(e,!1)}function Ze(e,r){return e==null?e:{language:e.language,count:e.count}}function pe(e){return ve(e,!1)}function ve(e,r){return e==null?e:{countryRegion:e.countryRegion,count:e.count}}function de(e){return je(e,!1)}function je(e,r){return e==null?e:{pathName:e.pathName,count:e.count}}function le(e){return er(e,!1)}function er(e,r){return e==null?e:{referrer:e.referrer,count:e.count}}function fe(e){return rr(e,!1)}function rr(e,r){return e==null?e:{resolution:e.resolution,count:e.count}}function F(e){return tr(e,!1)}function tr(e,r){return e==null?e:{account:e.account,email:e.email,site:e.site,datetime:e.datetime,category:e.category,totals:D(e.totals),queries:e.queries.map(D)}}function D(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 q(e){return or(e,!1)}function or(e,r){return e==null?e:{details:i(e,"details")?w(e.details):void 0,browsers:i(e,"browsers")?e.browsers.map(M):void 0,events:i(e,"events")?e.events.map(z):void 0,locations:i(e,"locations")?e.locations.map(_):void 0,queries:i(e,"queries")?e.queries.map(te):void 0,referrers:i(e,"referrers")?e.referrers.map(ne):void 0,resolutions:i(e,"resolutions")?e.resolutions.map(oe):void 0,languages:i(e,"languages")?e.languages.map(X):void 0,rollups:i(e,"rollups")?e.rollups.map(ie):void 0,errors:i(e,"errors")?e.errors.map(Y):void 0,google:i(e,"google")?e.google.map(F):void 0,bing:i(e,"bing")?e.bing.map(F):void 0}}var f=class extends S{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 l(o,a=>$(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 s("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 s("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:H(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 s("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: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 s("minDate","Required parameter requestParameters.minDate was null or undefined when calling getTrackingAllSites.");if(r.maxDate===null||r.maxDate===void 0)throw new s("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 l(a,u=>u.map(q))}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 s("id","Required parameter requestParameters.id was null or undefined when calling getTrackingSite.");if(r.minDate===null||r.minDate===void 0)throw new s("minDate","Required parameter requestParameters.minDate was null or undefined when calling getTrackingSite.");if(r.maxDate===null||r.maxDate===void 0)throw new s("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 l(a,u=>q(u))}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 s("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:W(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 s("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(v)},t);return new c(a)}async postErrors(r,t){await this.postErrorsRaw(r,t)}async postPageTrackRaw(r,t){if(r.postSiteTrack===null||r.postSiteTrack===void 0)throw new s("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",method:"POST",headers:o,query:n,body:ee(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 s("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:U(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 s("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:Z(r.postAccount)},t);return new c(a)}async sitePost(r,t){await this.sitePostRaw(r,t)}};var I=require("ag-common/dist/common/helpers/hashCode"),T=require("ag-common/dist/common/helpers/log");function me(e){return e?e.match(/^"?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}"?$/)?((0,T.info)("ignoring react devtools message"),!1):e===JSON.stringify([{}])?((0,T.info)("empty message payload?"),!1):!0:((0,T.info)("no message?"),!1)}var ge=(e="")=>{let r="";try{let t=JSON.parse(e);Array.isArray(t)&&t[0]?.match(/^\[?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}\]?$/)?((0,T.info)("removing date from hash"),t[0]="(date)",r=(0,I.hashCode)(JSON.stringify(t))):r=t.message??t.name??t.description??void 0}catch{}return r||(r=(0,I.hashCode)(e)?.toString()??""),r};var ye=(e,r)=>{let t=[],n={},o=0;return Object.entries(e).forEach(([a,u])=>{o<r?t.push(u):n[a]=u,o+=1}),{part:t,rest:n}};function Te(e){return(0,A.callOpenApi)({...e,func:r=>(0,A.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new f(r),logout:()=>window.location.reload(),refreshToken:async()=>{}})}var ir=typeof window<"u"&&window?.location?.hostname==="localhost",p={},x,B,Re=async()=>{try{if(Object.keys(p).length>100){let n=Object.keys(p)[0],o=p[n],a=await Te({headers:{authorization:""},apiUrl:B,func:u=>u.postErrorsRaw({postError:[{key:o.key,data:{...o.data,message:`error overload!: ${o.data.message??"?"}`}}]})});if(p={},a.error)throw a.error;return{}}let{part:e,rest:r}=ye(p,10);p=r;let t=await Te({headers:{authorization:""},apiUrl:B,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{p.length?x=setTimeout(Re,1e3):x=void 0}},d=async({data:e,overrideBaseUrl:r="https://api.analytica.click"})=>{if(ir)return(0,L.debug)(`local error tracking ignored:${e.data.message} ${JSON.stringify(e)}, to ${r}`),{};if(!me(e?.data?.message))return{};(0,L.debug)("error track",e.data.message,JSON.stringify(e));let t=ge(e.data.message);return p[t]=e,B=r,x||(x=setTimeout(Re,500)),{}};var Se=require("react/jsx-runtime"),ar={analyticaToken:void 0,overrideBaseUrl:void 0},m=(0,O.createContext)(ar),he=!1;function sr(e){if(!e.analyticaToken||he)return;he=!0;let r=window.console.error;window.console.error=(...n)=>{d({data:{data:{href:window.location.href,message:JSON.stringify(n)},key:e.analyticaToken},overrideBaseUrl:e.overrideBaseUrl}),r(...n)};let t=window.console.warn;window.console.warn=(...n)=>{d({data:{data:{href:window.location.href,message:JSON.stringify(n)},key:e.analyticaToken},overrideBaseUrl:e.overrideBaseUrl}),t(...n)}}var ur=({children:e,values:r})=>((0,O.useEffect)(()=>{sr(r)},[]),(0,Se.jsx)(m.Provider,{value:r,children:e}));var Ae=require("ag-common/dist/common/helpers/log");var we=b(require("@emotion/styled")),xe=require("ag-common/dist/ui/components/Modal"),g=b(require("react")),cr=we.default.div`
1
+ 'use client';"use strict";var Ee=Object.create;var h=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var be=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty;var De=(e,r)=>{for(var t in r)h(e,t,{get:r[t],enumerable:!0})},V=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Je(r))!ke.call(e,o)&&o!==t&&h(e,o,{get:()=>r[o],enumerable:!(n=Pe(r,o))||n.enumerable});return e};var b=(e,r,t)=>(t=e!=null?Ee(be(e)):{},V(r||!e||!e.__esModule?h(t,"default",{value:e,enumerable:!0}):t,e)),Fe=e=>V(h({},"__esModule",{value:!0}),e);var mr={};De(mr,{AnalyticaConfigContext:()=>m,AnalyticaConfigProvider:()=>ur,ErrorBoundary:()=>dr,errorTrack:()=>d,page:()=>C,tokenMissing:()=>R,track:()=>J,useTrack:()=>fr});module.exports=Fe(mr);var O=require("react");var B=require("ag-common/dist/common/helpers/log"),A=require("ag-common/dist/ui/helpers/callOpenApi");var qe="https://api.analytica.click".replace(/\/+$/,""),Ie=e=>typeof Blob<"u"&&e instanceof Blob,S=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||Ie(r.body)?r.body:JSON.stringify(r.body),a=Object.assign({},this.configuration.headers,r.headers),u={method:r.method,headers:a,body:o,credentials:this.configuration.credentials,...t};return{url:n,init:u}}clone(){let r=this.constructor,t=new r(this.configuration);return t.middleware=this.middleware.slice(),t}},s=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:qe}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(u=>encodeURIComponent(String(u))).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 l=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 H(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 M(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,browser:e.browser,count:e.count,category:e.category}}function U(e){if(e!==void 0)return e===null?null:{site:e.site}}function z(e){return Ke(e,!1)}function Ke(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 w(e){return Ge(e,!1)}function Ge(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){return Ve(e,!1)}function Ve(e,r){return e==null?e:{accounts:e.accounts.map(w),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 W(e){if(e!==void 0)return e===null?null:{email:e.email,key:e.key,account:e.account}}function X(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,language:e.language,count:e.count,category:e.category}}function _(e){return Qe(e,!1)}function Qe(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 Y(e){return Me(e,!1)}function Me(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 Z(e){if(e!==void 0)return e===null?null:{site:e.site}}function v(e){if(e!==void 0)return e===null?null:{key:e.key,data:j(e.data)}}function j(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 ee(e){if(e!==void 0)return e===null?null:{key:e.key,data:re(e.data)}}function re(e){if(e!==void 0)return e===null?null:{eventName:e.eventName,pageLocation:e.pageLocation,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage}}function te(e){return Ue(e,!1)}function Ue(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 ne(e){return ze(e,!1)}function ze(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 oe(e){return $e(e,!1)}function $e(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 ie(e){return We(e,!1)}function We(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(le):void 0,topResolutions:i(e,"topResolutions")?e.topResolutions.map(fe):void 0,topQueries:i(e,"topQueries")?e.topQueries.map(de):void 0,topLocations:i(e,"topLocations")?e.topLocations.map(pe):void 0,topBrowsers:i(e,"topBrowsers")?e.topBrowsers.map(ae):void 0,topEvents:i(e,"topEvents")?e.topEvents.map(ue):void 0,topLanguages:i(e,"topLanguages")?e.topLanguages.map(ce):void 0,topErrors:i(e,"topErrors")?e.topErrors.map(se):void 0}}function ae(e){return Xe(e,!1)}function Xe(e,r){return e==null?e:{browser:e.browser,count:e.count}}function se(e){return _e(e,!1)}function _e(e,r){return e==null?e:{href:e.href,count:e.count}}function ue(e){return Ye(e,!1)}function Ye(e,r){return e==null?e:{eventName:e.eventName,count:e.count}}function ce(e){return Ze(e,!1)}function Ze(e,r){return e==null?e:{language:e.language,count:e.count}}function pe(e){return ve(e,!1)}function ve(e,r){return e==null?e:{countryRegion:e.countryRegion,count:e.count}}function de(e){return je(e,!1)}function je(e,r){return e==null?e:{pathName:e.pathName,count:e.count}}function le(e){return er(e,!1)}function er(e,r){return e==null?e:{referrer:e.referrer,count:e.count}}function fe(e){return rr(e,!1)}function rr(e,r){return e==null?e:{resolution:e.resolution,count:e.count}}function q(e){return tr(e,!1)}function tr(e,r){return e==null?e:{account:e.account,email:e.email,site:e.site,datetime:e.datetime,category:e.category,totals:F(e.totals),queries:e.queries.map(F)}}function F(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 I(e){return or(e,!1)}function or(e,r){return e==null?e:{details:i(e,"details")?w(e.details):void 0,browsers:i(e,"browsers")?e.browsers.map(M):void 0,events:i(e,"events")?e.events.map(z):void 0,locations:i(e,"locations")?e.locations.map(_):void 0,queries:i(e,"queries")?e.queries.map(te):void 0,referrers:i(e,"referrers")?e.referrers.map(ne):void 0,resolutions:i(e,"resolutions")?e.resolutions.map(oe):void 0,languages:i(e,"languages")?e.languages.map(X):void 0,rollups:i(e,"rollups")?e.rollups.map(ie):void 0,errors:i(e,"errors")?e.errors.map(Y):void 0,google:i(e,"google")?e.google.map(q):void 0,bing:i(e,"bing")?e.bing.map(q):void 0}}var f=class extends S{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 l(o,a=>$(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 s("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 s("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:H(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 s("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: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 s("minDate","Required parameter requestParameters.minDate was null or undefined when calling getTrackingAllSites.");if(r.maxDate===null||r.maxDate===void 0)throw new s("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 l(a,u=>u.map(I))}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 s("id","Required parameter requestParameters.id was null or undefined when calling getTrackingSite.");if(r.minDate===null||r.minDate===void 0)throw new s("minDate","Required parameter requestParameters.minDate was null or undefined when calling getTrackingSite.");if(r.maxDate===null||r.maxDate===void 0)throw new s("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 l(a,u=>I(u))}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 s("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:W(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 s("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(v)},t);return new c(a)}async postErrors(r,t){await this.postErrorsRaw(r,t)}async postPageTrackRaw(r,t){if(r.postSiteTrack===null||r.postSiteTrack===void 0)throw new s("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",method:"POST",headers:o,query:n,body:ee(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 s("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:U(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 s("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:Z(r.postAccount)},t);return new c(a)}async sitePost(r,t){await this.sitePostRaw(r,t)}};var L=require("ag-common/dist/common/helpers/hashCode"),T=require("ag-common/dist/common/helpers/log");function me(e){return e?e.match(/^"?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}"?$/)?((0,T.info)("ignoring react devtools message"),!1):e===JSON.stringify([{}])?((0,T.info)("empty message payload?"),!1):!0:((0,T.info)("no message?"),!1)}var ge=(e="")=>{let r="";try{let t=JSON.parse(e);Array.isArray(t)&&t[0]?.match(/^\[?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}\]?$/)?((0,T.info)("removing date from hash"),t[0]="(date)",r=(0,L.hashCode)(JSON.stringify(t))):r=t.message??t.name??t.description??void 0}catch{}return r||(r=(0,L.hashCode)(e)?.toString()??""),r};var ye=(e,r)=>{let t=[],n={},o=0;return Object.entries(e).forEach(([a,u])=>{o<r?t.push(u):n[a]=u,o+=1}),{part:t,rest:n}};function Te(e){return(0,A.callOpenApi)({...e,func:r=>(0,A.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new f(r),logout:()=>window.location.reload(),refreshToken:async()=>{}})}var ir=typeof window<"u"&&window?.location?.hostname==="localhost",p={},x,K,Re=async()=>{try{if(Object.keys(p).length>100){let n=Object.keys(p)[0],o=p[n],a=await Te({headers:{authorization:""},apiUrl:K,func:u=>u.postErrorsRaw({postError:[{key:o.key,data:{...o.data,message:`error overload!: ${o.data.message??"?"}`}}]})});if(p={},a.error)throw a.error;return{}}let{part:e,rest:r}=ye(p,10);p=r;let t=await Te({headers:{authorization:""},apiUrl:K,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{p.length?x=setTimeout(Re,1e3):x=void 0}},d=async({data:e,overrideBaseUrl:r="https://api.analytica.click"})=>{if(ir)return(0,B.debug)(`local error tracking ignored:${e.data.message} ${JSON.stringify(e)}, to ${r}`),{};if(!me(e?.data?.message))return{};(0,B.debug)("error track",e.data.message,JSON.stringify(e));let t=ge(e.data.message);return p[t]=e,K=r,x||(x=setTimeout(Re,500)),{}};var Se=require("react/jsx-runtime"),ar={analyticaToken:void 0,overrideBaseUrl:void 0},m=(0,O.createContext)(ar),he=!1;function sr(e){if(!e.analyticaToken||he)return;he=!0;let r=window.console.error;window.console.error=(...n)=>{d({data:{data:{href:window.location.href,message:JSON.stringify(n)},key:e.analyticaToken},overrideBaseUrl:e.overrideBaseUrl}),r(...n)};let t=window.console.warn;window.console.warn=(...n)=>{d({data:{data:{href:window.location.href,message:JSON.stringify(n)},key:e.analyticaToken},overrideBaseUrl:e.overrideBaseUrl}),t(...n)}}var ur=({children:e,values:r})=>((0,O.useEffect)(()=>{sr(r)},[]),(0,Se.jsx)(m.Provider,{value:r,children:e}));var Ae=require("ag-common/dist/common/helpers/log");var we=b(require("@emotion/styled")),xe=require("ag-common/dist/ui/components/Modal"),g=b(require("react")),cr=we.default.div`
2
2
  font-size: 2rem;
3
- `,N=class extends g.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&&{stack:r?.stack},...t&&{href:t}}}}render(){let{hasError:r}=this.state,{children:t,notify:n}=this.props;return r?(n&&n(r),g.default.createElement(xe.Modal,{open:!0,setOpen:()=>{}},g.default.createElement(cr,null,"A fatal error has occurred - the admin has been notified.",g.default.createElement("button",{type:"button",onClick:()=>window.location.reload()},"Press here to restart app")))):t}};var y=b(require("react"));var R=e=>`[Analytica.${e}] Please load analytica token in AnalyticaConfigProvider to use this component`;var K=require("react/jsx-runtime");async function pr({ev:e,analyticaToken:r,filterBrowserError:t}){if(t&&t(e)===!1)return;let n=e?.message||e?.error,{href:o}=window.location,a=e?.stack,u=e?.filename;await d({data:{key:r,data:{message:n,stack:a,filename:u,href:o}}})}var dr=({children:e,filterBrowserError:r})=>{let{analyticaToken:t}=(0,y.useContext)(m);return(0,y.useEffect)(()=>{let n=o=>pr({ev:o,analyticaToken:t,filterBrowserError:r});return t&&window.addEventListener("error",n),()=>{window.removeEventListener("error",n)}},[t,r]),t?(0,K.jsx)(N,{notify:async n=>{let{href:o}=window.location;await d({data:{key:t,data:{...n,href:o}}})},children:e}):((0,Ae.warn)(R("ErrorBoundary")),(0,K.jsx)(y.default.Fragment,{children:e}))};var Oe=require("ag-common/dist/common/helpers/log"),Ne=require("react");var E=require("ag-common/dist/common/helpers/log"),P=require("ag-common/dist/ui/helpers/callOpenApi");function lr(e){return(0,P.callOpenApi)({...e,func:r=>(0,P.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new f(r),logout:()=>window.location.reload(),refreshToken:async()=>{}})}var J=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click",eventName:t})=>{let n={eventName:t};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}),typeof window<"u"&&window?.location?.hostname==="localhost")return(0,E.debug)(`local page ignored: ${JSON.stringify(n)}, to ${r}`),{};let o=await lr({apiUrl:r,headers:{authorization:""},func:a=>a.postPageTrackRaw({postSiteTrack:{key:e,data:n}})});return o.error?((0,E.warn)("tracking error:"+JSON.stringify(o.error,null,2)),{error:JSON.stringify(o.error,null,2)}):{}},G=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click"})=>J({analyticaToken:e,overrideBaseUrl:r,eventName:"PAGE"});var fr=()=>{let{analyticaToken:e,overrideBaseUrl:r}=(0,Ne.useContext)(m);if(!e){(0,Oe.warn)(R("useTrack"));let t=async()=>({error:"no token"});return{page:t,track:t}}return{page:t=>G({...t,analyticaToken:e,overrideBaseUrl:r}),track:t=>J({...t,analyticaToken:e,overrideBaseUrl:r})}};0&&(module.exports={AnalyticaConfigContext,AnalyticaConfigProvider,ErrorBoundary,errorTrack,page,tokenMissing,track,useTrack});
3
+ `,N=class extends g.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&&{stack:r?.stack},...t&&{href:t}}}}render(){let{hasError:r}=this.state,{children:t,notify:n}=this.props;return r?(n&&n(r),g.default.createElement(xe.Modal,{open:!0,setOpen:()=>{}},g.default.createElement(cr,null,"A fatal error has occurred - the admin has been notified.",g.default.createElement("button",{type:"button",onClick:()=>window.location.reload()},"Press here to restart app")))):t}};var y=b(require("react"));var R=e=>`[Analytica.${e}] Please load analytica token in AnalyticaConfigProvider to use this component`;var G=require("react/jsx-runtime");async function pr({ev:e,analyticaToken:r,filterBrowserError:t}){if(t&&t(e)===!1)return;let n=e?.message||e?.error,{href:o}=window.location,a=e?.stack,u=e?.filename;await d({data:{key:r,data:{message:n,stack:a,filename:u,href:o}}})}var dr=({children:e,filterBrowserError:r})=>{let{analyticaToken:t}=(0,y.useContext)(m);return(0,y.useEffect)(()=>{let n=o=>pr({ev:o,analyticaToken:t,filterBrowserError:r});return t&&window.addEventListener("error",n),()=>{window.removeEventListener("error",n)}},[t,r]),t?(0,G.jsx)(N,{notify:async n=>{let{href:o}=window.location;await d({data:{key:t,data:{...n,href:o}}})},children:e}):((0,Ae.warn)(R("ErrorBoundary")),(0,G.jsx)(y.default.Fragment,{children:e}))};var Oe=require("ag-common/dist/common/helpers/log"),Ne=require("react");var E=require("ag-common/dist/common/helpers/log"),P=require("ag-common/dist/ui/helpers/callOpenApi");function lr(e){return(0,P.callOpenApi)({...e,func:r=>(0,P.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new f(r),logout:()=>window.location.reload(),refreshToken:async()=>{}})}var J=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click",eventName:t})=>{let n={eventName:t};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}),typeof window<"u"&&window?.location?.hostname==="localhost")return(0,E.debug)(`local page ignored: ${JSON.stringify(n)}, to ${r}`),{};let o=await lr({apiUrl:r,headers:{authorization:""},func:a=>a.postPageTrackRaw({postSiteTrack:{key:e,data:n}})});return o.error?((0,E.warn)("tracking error:"+JSON.stringify(o.error,null,2)),{error:JSON.stringify(o.error,null,2)}):{}},C=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click"})=>J({analyticaToken:e,overrideBaseUrl:r,eventName:"PAGE"});var fr=()=>{let{analyticaToken:e,overrideBaseUrl:r}=(0,Ne.useContext)(m);if(!e){(0,Oe.warn)(R("useTrack"));let t=async()=>({error:"no token"});return{page:t,track:t}}return{page:t=>C({...t,analyticaToken:e,overrideBaseUrl:r}),track:t=>J({...t,analyticaToken:e,overrideBaseUrl:r})}};0&&(module.exports={AnalyticaConfigContext,AnalyticaConfigProvider,ErrorBoundary,errorTrack,page,tokenMissing,track,useTrack});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "analytica.click",
3
- "version": "0.0.427",
3
+ "version": "0.0.428",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -11,7 +11,7 @@
11
11
  "@emotion/styled": "^11",
12
12
  "@types/jsonwebtoken": "^9",
13
13
  "@types/react": "^18",
14
- "ag-common": "^0.0.597",
14
+ "ag-common": "^0.0.599",
15
15
  "axios": "^1",
16
16
  "cross-env": "^7",
17
17
  "esbuild": "^0.19",