analytica.click 0.0.450 → 0.0.452
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 w=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var me=Object.prototype.hasOwnProperty;var ge=(e,r)=>{for(var t in r)w(e,t,{get:r[t],enumerable:!0})},ye=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of fe(r))!me.call(e,n)&&n!==t&&w(e,n,{get:()=>r[n],enumerable:!(o=de(r,n))||o.enumerable});return e};var Te=e=>ye(w({},"__esModule",{value:!0}),e);var $e={};ge($e,{errorTrack:()=>ze});module.exports=Te($e);var m=require("ag-common/dist/common/helpers/log"),h=require("ag-common/dist/ui/helpers/callOpenApi");var Re="https://api.analytica.click".replace(/\/+$/,""),he=e=>typeof Blob<"u"&&e instanceof Blob,g=class{constructor(r=new A){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||he(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 A=class{constructor(r={}){this.configuration=r}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Re}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 F(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 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,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 we(e,!1)}function we(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 y(e){return Ae(e,!1)}function Ae(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 K(e){return Ne(e,!1)}function Ne(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 B(e){if(e!==void 0)return e===null?null:{email:e.email,key:e.key,account:e.account}}function G(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 V(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,countryRegion:e.countryRegion,category:e.category,count:e.count}}function H(e){return Ee(e,!1)}function Ee(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 C(e){if(e!==void 0)return e===null?null:{key:e.key,data:M(e.data)}}function M(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 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:{eventName:e.eventName,pageLocation:e.pageLocation,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage}}function U(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,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 _(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,referrer:e.referrer,count:e.count,category:e.category}}function W(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,resolution:e.resolution,count:e.count,category:e.category}}function X(e){return qe(e,!1)}function qe(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(te):void 0,topResolutions:i(e,"topResolutions")?e.topResolutions.map(ne):void 0,topQueries:i(e,"topQueries")?e.topQueries.map(re):void 0,topLocations:i(e,"topLocations")?e.topLocations.map(ee):void 0,topBrowsers:i(e,"topBrowsers")?e.topBrowsers.map(Y):void 0,topEvents:i(e,"topEvents")?e.topEvents.map(v):void 0,topLanguages:i(e,"topLanguages")?e.topLanguages.map(j):void 0,topErrors:i(e,"topErrors")?e.topErrors.map(Z):void 0}}function Y(e){return ke(e,!1)}function ke(e,r){return e==null?e:{browser:e.browser,count:e.count}}function Z(e){return Ie(e,!1)}function Ie(e,r){return e==null?e:{href:e.href,count:e.count}}function v(e){return Le(e,!1)}function Le(e,r){return e==null?e:{eventName:e.eventName,count:e.count}}function j(e){return Ke(e,!1)}function Ke(e,r){return e==null?e:{language:e.language,count:e.count}}function ee(e){return Be(e,!1)}function Be(e,r){return e==null?e:{countryRegion:e.countryRegion,count:e.count}}function re(e){return Ge(e,!1)}function Ge(e,r){return e==null?e:{pathName:e.pathName,count:e.count}}function te(e){return Ve(e,!1)}function Ve(e,r){return e==null?e:{referrer:e.referrer,count:e.count}}function ne(e){return He(e,!1)}function He(e,r){return e==null?e:{resolution:e.resolution,count:e.count}}function P(e){return Qe(e,!1)}function Qe(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 Ce(e,!1)}function Ce(e,r){return e==null?e:{clicks:e.clicks,impressions:e.impressions,position:e.position,query:e.query}}function J(e){return Me(e,!1)}function Me(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(V):void 0,queries:i(e,"queries")?e.queries.map(U):void 0,referrers:i(e,"referrers")?e.referrers.map(_):void 0,resolutions:i(e,"resolutions")?e.resolutions.map(W):void 0,languages:i(e,"languages")?e.languages.map(G):void 0,rollups:i(e,"rollups")?e.rollups.map(X):void 0,errors:i(e,"errors")?e.errors.map(H):void 0,google:i(e,"google")?e.google.map(P):void 0,bing:i(e,"bing")?e.bing.map(P):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=>K(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:F(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(J))}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=>J(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(C)},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 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",method:"POST",headers:n,query:o,body:z(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:Q(r.postAccount)},t);return new c(a)}async sitePost(r,t){await this.sitePostRaw(r,t)}};var E=require("ag-common/dist/common/helpers/hashCode"),l=require("ag-common/dist/common/helpers/log"),oe=require("ag-common/dist/common/helpers/object");function ie(e){return e?e.match(/^"?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}"?$/)?((0,l.info)("ignoring react devtools message"),!1):e===JSON.stringify([{}])?((0,l.info)("empty message payload?"),!1):!0:((0,l.info)("no message?"),!1)}var ae=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,oe.isJson)(s)?a=JSON.parse(s):a=[s];let S=a.findIndex(p=>p.match(o)),x=a.findIndex(p=>p.match(n));S>=0&&x>=0&&x===S+1&&(a=a.filter((p,le)=>![S,x].includes(le))),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 D=(0,E.hashCode)(s)?.toString()??"";return(0,l.debug)("got errorKey=",s,D),D}catch(r){return(0,l.error)("error getting errorkey",r),(0,E.hashCode)(e.message)?.toString()??""}};var se=(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 ue(e){return(0,h.callOpenApi)({...e,func:r=>(0,h.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new T(r),logout:()=>window.location.reload(),refreshToken:async()=>{}})}var ce=typeof window<"u"&&window?.location?.hostname==="localhost",d={},R,b,pe=async()=>{try{if(Object.keys(d).length>100){let o=Object.keys(d)[0],n=d[o],a=await ue({headers:{authorization:""},apiUrl:b,func:s=>s.postErrorsRaw({postError:[{key:n.key,data:{...n.data,message:`error overload!: ${n.data.message??"?"}`}}]})});if(d={},a.error)throw a.error;return{}}let{part:e,rest:r}=se(d,10);d=r;let t=await ue({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{d.length?R=setTimeout(pe,1e3):R=void 0}},ze=async({data:e,overrideBaseUrl:r="https://api.analytica.click",ignoreBrowserErrors:t,devMode:o})=>{if(r||(r="https://api.analytica.click"),t&&t.length>0){let a=t.find(s=>e.data.message.includes(s));if(a){(0,m.debug)("ignoring error, contains=",a);return}}if(ce&&o)(0,m.debug)("allowing local error tracking due to devmode=true");else if(ce)return(0,m.debug)(`local error tracking ignored:${e.data.message} ${JSON.stringify(e)}, to ${r}`),{};if(!ie(e?.data?.message))return{};(0,m.debug)("error track",e.data.message,JSON.stringify(e));let n=ae(e.data);return d[n]=e,b=r,R||(R=setTimeout(pe,500)),{}};0&&(module.exports={errorTrack});
|
1
|
+
"use strict";var w=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var ye=Object.prototype.hasOwnProperty;var Te=(e,r)=>{for(var t in r)w(e,t,{get:r[t],enumerable:!0})},Re=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of ge(r))!ye.call(e,n)&&n!==t&&w(e,n,{get:()=>r[n],enumerable:!(o=me(r,n))||o.enumerable});return e};var he=e=>Re(w({},"__esModule",{value:!0}),e);var _e={};Te(_e,{errorTrack:()=>Ue});module.exports=he(_e);var m=require("ag-common/dist/common/helpers/log"),h=require("ag-common/dist/ui/helpers/callOpenApi");var Se="https://api.analytica.click".replace(/\/+$/,""),xe=e=>typeof Blob<"u"&&e instanceof Blob,g=class{constructor(r=new P){this.configuration=r;this.fetchApi=async(r,t)=>{let o={url:r,init:t};for(let i of this.middleware)i.pre&&(o=await i.pre({fetch:this.fetchApi,...o})||o);let n=await(this.configuration.fetchApi||fetch)(o.url,o.init);for(let i of this.middleware)i.post&&(n=await i.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),i=await this.fetchApi(o,n);if(i.status>=200&&i.status<300)return i;throw i}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||xe(r.body)?r.body:JSON.stringify(r.body),i=Object.assign({},this.configuration.headers,r.headers),s={method:r.method,headers:i,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 P=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||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 a(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 i=n.map(s=>encodeURIComponent(String(s))).join(`&${encodeURIComponent(o)}=`);return`${encodeURIComponent(o)}=${i}`}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 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 F(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 Pe(e,!1)}function Pe(e,r){return e==null?e:{account:a(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 Oe(e,!1)}function Oe(e,r){return e==null?e:{account:a(e,"account")?e.account:void 0,site:e.site,eventName:e.eventName,datetime:e.datetime,count:e.count,category:e.category}}function y(e){return Ae(e,!1)}function Ae(e,r){return e==null?e:{site:e.site,account:e.account,apiKey:e.apiKey,adminApiKey:e.adminApiKey,favicon:a(e,"favicon")?e.favicon:void 0}}function K(e){return Ee(e,!1)}function Ee(e,r){return e==null?e:{accounts:e.accounts.map(y),googleEmail:a(e,"googleEmail")?e.googleEmail:void 0,googleKey:a(e,"googleKey")?e.googleKey:void 0,bingKey:a(e,"bingKey")?e.bingKey:void 0,bingAccount:a(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 Je(e,!1)}function Je(e,r){return e==null?e:{account:a(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,language:e.language,count:e.count,category:e.category}}function G(e){return be(e,!1)}function be(e,r){return e==null?e:{account:a(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,countryRegion:e.countryRegion,category:e.category,count:e.count}}function H(e){return De(e,!1)}function De(e,r){return e==null?e:{PK:e.PK,messageHash:a(e,"messageHash")?e.messageHash:void 0,site:e.site,account:e.account,message:a(e,"message")?e.message:void 0,name:a(e,"name")?e.name:void 0,stack:a(e,"stack")?e.stack:void 0,href:e.href,filename:a(e,"filename")?e.filename:void 0,datetime:e.datetime,archived:a(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 C(e){if(e!==void 0)return e===null?null:{key:e.key,data:M(e.data)}}function M(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 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:{eventName:e.eventName,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage}}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:{pageLocation:e.pageLocation,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage}}function W(e){return Fe(e,!1)}function Fe(e,r){return e==null?e:{account:a(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,pathName:e.pathName,search:a(e,"search")?e.search:void 0,hash:a(e,"hash")?e.hash:void 0,count:e.count,category:e.category}}function X(e){return qe(e,!1)}function qe(e,r){return e==null?e:{account:a(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,referrer:e.referrer,count:e.count,category:e.category}}function Y(e){return ke(e,!1)}function ke(e,r){return e==null?e:{account:a(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 Ie(e,!1)}function Ie(e,r){return e==null?e:{account:e.account,site:e.site,datetime:e.datetime,category:e.category,topReferrers:a(e,"topReferrers")?e.topReferrers.map(oe):void 0,topResolutions:a(e,"topResolutions")?e.topResolutions.map(ie):void 0,topQueries:a(e,"topQueries")?e.topQueries.map(ne):void 0,topLocations:a(e,"topLocations")?e.topLocations.map(te):void 0,topBrowsers:a(e,"topBrowsers")?e.topBrowsers.map(v):void 0,topEvents:a(e,"topEvents")?e.topEvents.map(ee):void 0,topLanguages:a(e,"topLanguages")?e.topLanguages.map(re):void 0,topErrors:a(e,"topErrors")?e.topErrors.map(j):void 0}}function v(e){return Le(e,!1)}function Le(e,r){return e==null?e:{browser:e.browser,count:e.count}}function j(e){return Ke(e,!1)}function Ke(e,r){return e==null?e:{href:e.href,count:e.count}}function ee(e){return Ve(e,!1)}function Ve(e,r){return e==null?e:{eventName:e.eventName,count:e.count}}function re(e){return Be(e,!1)}function Be(e,r){return e==null?e:{language:e.language,count:e.count}}function te(e){return Ge(e,!1)}function Ge(e,r){return e==null?e:{countryRegion:e.countryRegion,count:e.count}}function ne(e){return He(e,!1)}function He(e,r){return e==null?e:{pathName:e.pathName,count:e.count}}function oe(e){return Qe(e,!1)}function Qe(e,r){return e==null?e:{referrer:e.referrer,count:e.count}}function ie(e){return Ce(e,!1)}function Ce(e,r){return e==null?e:{resolution:e.resolution,count:e.count}}function N(e){return Me(e,!1)}function Me(e,r){return e==null?e:{account:e.account,email:e.email,site:e.site,datetime:e.datetime,category:e.category,totals:A(e.totals),queries:e.queries.map(A)}}function A(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 E(e){return $e(e,!1)}function $e(e,r){return e==null?e:{accountDetails:a(e,"accountDetails")?y(e.accountDetails):void 0,browsers:a(e,"browsers")?e.browsers.map(k):void 0,events:a(e,"events")?e.events.map(L):void 0,locations:a(e,"locations")?e.locations.map(G):void 0,queries:a(e,"queries")?e.queries.map(W):void 0,referrers:a(e,"referrers")?e.referrers.map(X):void 0,resolutions:a(e,"resolutions")?e.resolutions.map(Y):void 0,languages:a(e,"languages")?e.languages.map(B):void 0,rollups:a(e,"rollups")?e.rollups.map(Z):void 0,errors:a(e,"errors")?e.errors.map(H):void 0,google:a(e,"google")?e.google.map(N):void 0,bing:a(e,"bing")?e.bing.map(N):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 d(n,i=>K(i))}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 i=await this.request({path:"/errors/{id}".replace("{id}",encodeURIComponent(String(r.id))),method:"DELETE",headers:n,query:o},t);return new c(i)}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 i=await this.request({path:"/errors",method:"DELETE",headers:n,query:o,body:F(r.archiveErrors)},t);return new c(i)}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 i=await this.request({path:"/account/integrations/bing",method:"POST",headers:n,query:o,body:q(r.bingIntegration)},t);return new c(i)}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 i=await this.request({path:"/site/tracking",method:"GET",headers:n,query:o},t);return new d(i,s=>s.map(E))}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 i=await this.request({path:"/site/tracking/{id}".replace("{id}",encodeURIComponent(String(r.id))),method:"GET",headers:n,query:o},t);return new d(i,s=>E(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 i=await this.request({path:"/account/integrations/google",method:"POST",headers:n,query:o,body:V(r.googleIntegration)},t);return new c(i)}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 i=await this.request({path:"/errors",method:"POST",headers:n,query:o,body:r.postError.map(C)},t);return new c(i)}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 i=await this.request({path:"/site/event",method:"POST",headers:n,query:o,body:z(r.postEvent)},t);return new c(i)}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 i=await this.request({path:"/site/tracking",method:"POST",headers:n,query:o,body:U(r.postSiteTrack)},t);return new c(i)}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 i=await this.request({path:"/account/site",method:"DELETE",headers:n,query:o,body:I(r.deleteAccount)},t);return new c(i)}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 i=await this.request({path:"/account/site",method:"POST",headers:n,query:o,body:Q(r.postAccount)},t);return new c(i)}async sitePost(r,t){await this.sitePostRaw(r,t)}};var J=require("ag-common/dist/common/helpers/hashCode"),f=require("ag-common/dist/common/helpers/log"),ae=require("ag-common/dist/common/helpers/object");function se(e){return e?e.match(/^"?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}"?$/)?((0,f.info)("ignoring react devtools message"),!1):e===JSON.stringify([{}])?((0,f.info)("empty message payload?"),!1):!0:((0,f.info)("no message?"),!1)}var ue=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,i=[],s=e.message;(0,ae.isJson)(s)?i=JSON.parse(s):i=[s];let S=i.findIndex(p=>p.match(o)),x=i.findIndex(p=>p.match(n));S>=0&&x>=0&&x===S+1&&(i=i.filter((p,fe)=>![S,x].includes(fe))),i=i.map(p=>p.includes(".js:")||p.includes("node_modules")?p.replace(t,"$1 (stacktrace)"):p.replace(r,"[date]")),s=JSON.stringify(i);let D=(0,J.hashCode)(s)?.toString()??"";return(0,f.debug)("got errorKey=",s,D),D}catch{return(0,J.hashCode)(e.message)?.toString()??""}};var ce=(e,r)=>{let t=[],o={},n=0;return Object.entries(e).forEach(([i,s])=>{n<r?t.push(s):o[i]=s,n+=1}),{part:t,rest:o}};function pe(e){return(0,h.callOpenApi)({...e,func:r=>(0,h.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new T(r),logout:()=>window.location.reload(),refreshToken:async()=>{}})}var le=typeof window<"u"&&window?.location?.hostname==="localhost",l={},R,b,de=async()=>{try{if(Object.keys(l).length>100){let o=Object.keys(l)[0],n=l[o],i=await pe({headers:{authorization:""},apiUrl:b,func:s=>s.postErrorsRaw({postError:[{key:n.key,data:{...n.data,message:`error overload!: ${n.data.message??"?"}`}}]})});if(l={},i.error)throw i.error;return{}}let{part:e,rest:r}=ce(l,10);l=r;let t=await pe({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{l.length?R=setTimeout(de,1e3):R=void 0}},Ue=async({data:e,overrideBaseUrl:r="https://api.analytica.click",ignoreBrowserErrors:t=["will be removed","performing full reload"],devMode:o})=>{if(r||(r="https://api.analytica.click"),t&&t.length>0){let i=t.find(s=>e.data.message.includes(s));if(i){(0,m.debug)("ignoring error, contains=",i);return}}if(le&&o)(0,m.debug)("allowing local error tracking due to devmode=true");else if(le)return(0,m.debug)(`local error tracking ignored:${e.data.message} ${JSON.stringify(e)}, to ${r}`),{};if(!se(e?.data?.message))return{};(0,m.debug)("error track",e.data.message,JSON.stringify(e));let n=ue(e.data);return l[n]=e,b=r,R||(R=setTimeout(de,500)),{}};0&&(module.exports={errorTrack});
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var y=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var re=(e,r)=>{for(var t in r)y(e,t,{get:r[t],enumerable:!0})},te=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of j(r))!ee.call(e,o)&&o!==t&&y(e,o,{get:()=>r[o],enumerable:!(n=v(r,o))||n.enumerable});return e};var ne=e=>te(y({},"__esModule",{value:!0}),e);var qe={};re(qe,{event:()=>De,page:()=>Fe});module.exports=ne(qe);var p=require("ag-common/dist/common/helpers/log"),g=require("ag-common/dist/ui/helpers/callOpenApi");var oe="https://api.analytica.click".replace(/\/+$/,""),ie=e=>typeof Blob<"u"&&e instanceof Blob,d=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||ie(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:oe}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 l=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 P(e){if(e!==void 0)return e===null?null:{key:e.key,account:e.account}}function A(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,browser:e.browser,count:e.count,category:e.category}}function N(e){if(e!==void 0)return e===null?null:{site:e.site}}function O(e){return se(e,!1)}function se(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 f(e){return ce(e,!1)}function ce(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 le(e,!1)}function le(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 J(e){if(e!==void 0)return e===null?null:{email:e.email,key:e.key,account:e.account}}function b(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,language:e.language,count:e.count,category:e.category}}function D(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,countryRegion:e.countryRegion,category:e.category,count:e.count}}function F(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 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,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage}}function B(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:{pageLocation:e.pageLocation,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage}}function G(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,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 H(e){return ye(e,!1)}function ye(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 Q(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,resolution:e.resolution,count:e.count,category:e.category}}function C(e){return Re(e,!1)}function Re(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(X):void 0,topResolutions:i(e,"topResolutions")?e.topResolutions.map(Y):void 0,topQueries:i(e,"topQueries")?e.topQueries.map(W):void 0,topLocations:i(e,"topLocations")?e.topLocations.map(_):void 0,topBrowsers:i(e,"topBrowsers")?e.topBrowsers.map(M):void 0,topEvents:i(e,"topEvents")?e.topEvents.map($):void 0,topLanguages:i(e,"topLanguages")?e.topLanguages.map(U):void 0,topErrors:i(e,"topErrors")?e.topErrors.map(z):void 0}}function M(e){return he(e,!1)}function he(e,r){return e==null?e:{browser:e.browser,count:e.count}}function z(e){return Se(e,!1)}function Se(e,r){return e==null?e:{href:e.href,count:e.count}}function $(e){return xe(e,!1)}function xe(e,r){return e==null?e:{eventName:e.eventName,count:e.count}}function U(e){return we(e,!1)}function we(e,r){return e==null?e:{language:e.language,count:e.count}}function _(e){return Pe(e,!1)}function Pe(e,r){return e==null?e:{countryRegion:e.countryRegion,count:e.count}}function W(e){return Ae(e,!1)}function Ae(e,r){return e==null?e:{pathName:e.pathName,count:e.count}}function X(e){return Ne(e,!1)}function Ne(e,r){return e==null?e:{referrer:e.referrer,count:e.count}}function Y(e){return Oe(e,!1)}function Oe(e,r){return e==null?e:{resolution:e.resolution,count:e.count}}function S(e){return Ee(e,!1)}function Ee(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 Je(e,!1)}function Je(e,r){return e==null?e:{clicks:e.clicks,impressions:e.impressions,position:e.position,query:e.query}}function x(e){return be(e,!1)}function be(e,r){return e==null?e:{accountDetails:i(e,"accountDetails")?f(e.accountDetails):void 0,browsers:i(e,"browsers")?e.browsers.map(A):void 0,events:i(e,"events")?e.events.map(O):void 0,locations:i(e,"locations")?e.locations.map(D):void 0,queries:i(e,"queries")?e.queries.map(G):void 0,referrers:i(e,"referrers")?e.referrers.map(H):void 0,resolutions:i(e,"resolutions")?e.resolutions.map(Q):void 0,languages:i(e,"languages")?e.languages.map(b):void 0,rollups:i(e,"rollups")?e.rollups.map(C):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 m=class extends d{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=>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 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:P(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 l(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 l(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:J(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 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:L(r.postEvent)},t);return new s(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:B(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:N(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 Z(e){return(0,g.callOpenApi)({...e,func:r=>(0,g.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new m(r),logout:()=>window.location.reload(),refreshToken:async()=>{}})}var De=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click",eventName:t,devMode:n})=>{let o={eventName:t};if(!n&&typeof window<"u"&&window?.location?.hostname==="localhost")return(0,p.debug)(`local page ignored: ${JSON.stringify(o)}, to ${r}`),{};let a=await Z({apiUrl:r,headers:{authorization:""},func:c=>c.postEventRaw({postEvent:{key:e,data:o}})});return a.error?((0,p.warn)("tracking error:"+JSON.stringify(a.error,null,2)),{error:JSON.stringify(a.error,null,2)}):{}},Fe=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click",devMode:t})=>{let n={pageLocation:""};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 o=await Z({apiUrl:r,headers:{authorization:""},func:a=>a.postPageTrackRaw({postSiteTrack:{key:e,data:n}})});return o.error?((0,p.warn)("tracking error:"+JSON.stringify(o.error,null,2)),{error:JSON.stringify(o.error,null,2)}):{}};0&&(module.exports={event,page});
|
package/dist/index.d.ts
CHANGED
@@ -66,8 +66,8 @@ declare module 'analytica.click/dist/helpers/errorTrack' {
|
|
66
66
|
declare module 'analytica.click/dist/helpers/index' {
|
67
67
|
export * from 'analytica.click/dist/helpers/errorTrack';
|
68
68
|
export * from 'analytica.click/dist/helpers/log';
|
69
|
-
export * from 'analytica.click/dist/helpers/
|
70
|
-
export * from 'analytica.click/dist/helpers/
|
69
|
+
export * from 'analytica.click/dist/helpers/server';
|
70
|
+
export * from 'analytica.click/dist/helpers/useAnalytica';
|
71
71
|
|
72
72
|
}
|
73
73
|
declare module 'analytica.click/dist/helpers/log' {
|
@@ -81,19 +81,21 @@ declare module 'analytica.click/dist/helpers/object' {
|
|
81
81
|
};
|
82
82
|
|
83
83
|
}
|
84
|
-
declare module 'analytica.click/dist/helpers/
|
85
|
-
import type {
|
86
|
-
|
87
|
-
export const
|
88
|
-
|
89
|
-
|
90
|
-
};
|
84
|
+
declare module 'analytica.click/dist/helpers/server' {
|
85
|
+
import type { TEvent, TPage } from 'analytica.click/dist/common-ui/src/types/index';
|
86
|
+
/** used for tracking arbitrary events */
|
87
|
+
export const event: TEvent;
|
88
|
+
/** used for tracking visits to a page */
|
89
|
+
export const page: TPage;
|
91
90
|
|
92
91
|
}
|
93
|
-
declare module 'analytica.click/dist/helpers/
|
94
|
-
import type {
|
95
|
-
|
96
|
-
export const
|
92
|
+
declare module 'analytica.click/dist/helpers/useAnalytica' {
|
93
|
+
import type { IEvent, IPage } from 'analytica.click/dist/common-ui/src/types/index';
|
94
|
+
import { event, page } from 'analytica.click/dist/helpers/server';
|
95
|
+
export const useAnalytica: () => {
|
96
|
+
event: (d: Omit<IEvent, 'analyticaToken' | 'overrideBaseUrl'>) => void;
|
97
|
+
page: (d: Omit<IPage, 'analyticaToken' | 'overrideBaseUrl'>) => void;
|
98
|
+
};
|
97
99
|
|
98
100
|
}
|
99
101
|
declare module 'analytica.click/dist/index' {
|
@@ -123,24 +125,34 @@ declare module 'analytica.click/dist/common-ui/src/types/index' {
|
|
123
125
|
|
124
126
|
}
|
125
127
|
declare module 'analytica.click/dist/common-ui/src/types/widgets' {
|
126
|
-
export type
|
128
|
+
export type TEvent = (p: IEvent) => Promise<{
|
127
129
|
error?: string;
|
128
130
|
}>;
|
129
|
-
export
|
131
|
+
export interface IEvent {
|
132
|
+
analyticaToken: string;
|
133
|
+
overrideBaseUrl?: string;
|
134
|
+
eventName: string;
|
135
|
+
/** internal testing only. also allows local sending of errors */
|
136
|
+
devMode?: boolean;
|
137
|
+
}
|
138
|
+
export type TPage = (p: IPage) => Promise<{
|
130
139
|
error?: string;
|
131
140
|
}>;
|
132
|
-
export interface
|
141
|
+
export interface IPage {
|
133
142
|
analyticaToken: string;
|
134
143
|
overrideBaseUrl?: string;
|
135
|
-
|
144
|
+
/** internal testing only. also allows local sending of errors */
|
145
|
+
devMode?: boolean;
|
136
146
|
}
|
137
147
|
export type TErrorMessage = (m: ErrorEvent) => Promise<void>;
|
138
148
|
export interface IAnalyticaConfig {
|
139
|
-
analyticaToken
|
149
|
+
analyticaToken: string;
|
140
150
|
overrideBaseUrl?: string;
|
141
151
|
/** internal testing only. also allows local sending of errors */
|
142
152
|
devMode?: boolean;
|
143
|
-
/** ignore any browser errors that include these words
|
153
|
+
/** ignore any browser errors that include these words.
|
154
|
+
* default 'will be removed', 'performing full reload
|
155
|
+
*/
|
144
156
|
ignoreBrowserErrors?: string[];
|
145
157
|
}
|
146
158
|
|
package/dist/index.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
'use client';"use strict";var Ge=Object.create;var S=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var Me=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty;var ze=(e,r)=>{for(var t in r)S(e,t,{get:r[t],enumerable:!0})},$=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Ve(r))!Qe.call(e,o)&&o!==t&&S(e,o,{get:()=>r[o],enumerable:!(n=He(r,o))||n.enumerable});return e};var U=(e,r,t)=>(t=e!=null?Ge(Me(e)):{},$(r||!e||!e.__esModule?S(t,"default",{value:e,enumerable:!0}):t,e)),$e=e=>$(S({},"__esModule",{value:!0}),e);var Ar={};ze(Ar,{AnalyticaClickProvider:()=>Sr,AnalyticaConfigContext:()=>y,errorTrack:()=>g,page:()=>Q,tokenMissing:()=>R,track:()=>k,useTrack:()=>xr});module.exports=$e(Ar);var Le=require("react");var P=require("ag-common/dist/common/helpers/log"),E=U(require("react"));var Ee=require("react");var T=require("ag-common/dist/common/helpers/log"),O=require("ag-common/dist/ui/helpers/callOpenApi");var Ue="https://api.analytica.click".replace(/\/+$/,""),We=e=>typeof Blob<"u"&&e instanceof Blob,w=class{constructor(r=new q){this.configuration=r;this.fetchApi=async(r,t)=>{let n={url:r,init:t};for(let i of this.middleware)i.pre&&(n=await i.pre({fetch:this.fetchApi,...n})||n);let o=await(this.configuration.fetchApi||fetch)(n.url,n.init);for(let i of this.middleware)i.post&&(o=await i.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),i=await this.fetchApi(n,o);if(i.status>=200&&i.status<300)return i;throw i}createFetchParams(r,t){let n=this.configuration.basePath+r.path;r.query!==void 0&&Object.keys(r.query).length!==0&&(n+="?"+(this.configuration.queryParamsStringify||I)(r.query));let o=typeof FormData<"u"&&r.body instanceof FormData||r.body instanceof URLSearchParams||We(r.body)?r.body:JSON.stringify(r.body),i=Object.assign({},this.configuration.headers,r.headers),s={method:r.method,headers:i,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 q=class{constructor(r={}){this.configuration=r}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Ue}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||I}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 a(e,r){let t=e[r];return t!=null}function I(e,r=""){return Object.keys(e).map(t=>{let n=r+(r.length?`[${t}]`:t),o=e[t];if(o instanceof Array){let i=o.map(s=>encodeURIComponent(String(s))).join(`&${encodeURIComponent(n)}=`);return`${encodeURIComponent(n)}=${i}`}return o instanceof Date?`${encodeURIComponent(n)}=${encodeURIComponent(o.toISOString())}`:o instanceof Object?I(o,n):`${encodeURIComponent(n)}=${encodeURIComponent(String(o))}`}).filter(t=>t.length>0).join("&")}var f=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 W(e){if(e!==void 0)return e===null?null:{PKsB64:e.PKsB64}}function _(e){if(e!==void 0)return e===null?null:{key:e.key,account:e.account}}function X(e){return Xe(e,!1)}function Xe(e,r){return e==null?e:{account:a(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,browser:e.browser,count:e.count,category:e.category}}function Y(e){if(e!==void 0)return e===null?null:{site:e.site}}function Z(e){return Ye(e,!1)}function Ye(e,r){return e==null?e:{account:a(e,"account")?e.account:void 0,site:e.site,eventName:e.eventName,datetime:e.datetime,count:e.count,category:e.category}}function x(e){return Ze(e,!1)}function Ze(e,r){return e==null?e:{site:e.site,account:e.account,apiKey:e.apiKey,adminApiKey:e.adminApiKey,favicon:a(e,"favicon")?e.favicon:void 0}}function v(e){return je(e,!1)}function je(e,r){return e==null?e:{accounts:e.accounts.map(x),googleEmail:a(e,"googleEmail")?e.googleEmail:void 0,googleKey:a(e,"googleKey")?e.googleKey:void 0,bingKey:a(e,"bingKey")?e.bingKey:void 0,bingAccount:a(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 er(e,!1)}function er(e,r){return e==null?e:{account:a(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,language:e.language,count:e.count,category:e.category}}function re(e){return rr(e,!1)}function rr(e,r){return e==null?e:{account:a(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,countryRegion:e.countryRegion,category:e.category,count:e.count}}function te(e){return tr(e,!1)}function tr(e,r){return e==null?e:{PK:e.PK,messageHash:a(e,"messageHash")?e.messageHash:void 0,site:e.site,account:e.account,message:a(e,"message")?e.message:void 0,name:a(e,"name")?e.name:void 0,stack:a(e,"stack")?e.stack:void 0,href:e.href,filename:a(e,"filename")?e.filename:void 0,datetime:e.datetime,archived:a(e,"archived")?e.archived:void 0,count:e.count,category:e.category}}function ne(e){if(e!==void 0)return e===null?null:{site:e.site}}function oe(e){if(e!==void 0)return e===null?null:{key:e.key,data:ie(e.data)}}function ie(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 ae(e){if(e!==void 0)return e===null?null:{key:e.key,data:se(e.data)}}function se(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 ue(e){return nr(e,!1)}function nr(e,r){return e==null?e:{account:a(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,pathName:e.pathName,search:a(e,"search")?e.search:void 0,hash:a(e,"hash")?e.hash:void 0,count:e.count,category:e.category}}function ce(e){return or(e,!1)}function or(e,r){return e==null?e:{account:a(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,referrer:e.referrer,count:e.count,category:e.category}}function pe(e){return ir(e,!1)}function ir(e,r){return e==null?e:{account:a(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,resolution:e.resolution,count:e.count,category:e.category}}function le(e){return ar(e,!1)}function ar(e,r){return e==null?e:{account:e.account,site:e.site,datetime:e.datetime,category:e.category,topReferrers:a(e,"topReferrers")?e.topReferrers.map(Re):void 0,topResolutions:a(e,"topResolutions")?e.topResolutions.map(he):void 0,topQueries:a(e,"topQueries")?e.topQueries.map(Te):void 0,topLocations:a(e,"topLocations")?e.topLocations.map(ye):void 0,topBrowsers:a(e,"topBrowsers")?e.topBrowsers.map(de):void 0,topEvents:a(e,"topEvents")?e.topEvents.map(me):void 0,topLanguages:a(e,"topLanguages")?e.topLanguages.map(ge):void 0,topErrors:a(e,"topErrors")?e.topErrors.map(fe):void 0}}function de(e){return sr(e,!1)}function sr(e,r){return e==null?e:{browser:e.browser,count:e.count}}function fe(e){return ur(e,!1)}function ur(e,r){return e==null?e:{href:e.href,count:e.count}}function me(e){return cr(e,!1)}function cr(e,r){return e==null?e:{eventName:e.eventName,count:e.count}}function ge(e){return pr(e,!1)}function pr(e,r){return e==null?e:{language:e.language,count:e.count}}function ye(e){return lr(e,!1)}function lr(e,r){return e==null?e:{countryRegion:e.countryRegion,count:e.count}}function Te(e){return dr(e,!1)}function dr(e,r){return e==null?e:{pathName:e.pathName,count:e.count}}function Re(e){return fr(e,!1)}function fr(e,r){return e==null?e:{referrer:e.referrer,count:e.count}}function he(e){return mr(e,!1)}function mr(e,r){return e==null?e:{resolution:e.resolution,count:e.count}}function B(e){return gr(e,!1)}function gr(e,r){return e==null?e:{account:e.account,email:e.email,site:e.site,datetime:e.datetime,category:e.category,totals:L(e.totals),queries:e.queries.map(L)}}function L(e){return yr(e,!1)}function yr(e,r){return e==null?e:{clicks:e.clicks,impressions:e.impressions,position:e.position,query:e.query}}function K(e){return Tr(e,!1)}function Tr(e,r){return e==null?e:{accountDetails:a(e,"accountDetails")?x(e.accountDetails):void 0,browsers:a(e,"browsers")?e.browsers.map(X):void 0,events:a(e,"events")?e.events.map(Z):void 0,locations:a(e,"locations")?e.locations.map(re):void 0,queries:a(e,"queries")?e.queries.map(ue):void 0,referrers:a(e,"referrers")?e.referrers.map(ce):void 0,resolutions:a(e,"resolutions")?e.resolutions.map(pe):void 0,languages:a(e,"languages")?e.languages.map(ee):void 0,rollups:a(e,"rollups")?e.rollups.map(le):void 0,errors:a(e,"errors")?e.errors.map(te):void 0,google:a(e,"google")?e.google.map(B):void 0,bing:a(e,"bing")?e.bing.map(B):void 0}}var m=class extends w{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 f(o,i=>v(i))}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 i=await this.request({path:"/errors/{id}".replace("{id}",encodeURIComponent(String(r.id))),method:"DELETE",headers:o,query:n},t);return new c(i)}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 i=await this.request({path:"/errors",method:"DELETE",headers:o,query:n,body:W(r.archiveErrors)},t);return new c(i)}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 i=await this.request({path:"/account/integrations/bing",method:"POST",headers:o,query:n,body:_(r.bingIntegration)},t);return new c(i)}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 i=await this.request({path:"/site/tracking",method:"GET",headers:o,query:n},t);return new f(i,s=>s.map(K))}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 i=await this.request({path:"/site/tracking/{id}".replace("{id}",encodeURIComponent(String(r.id))),method:"GET",headers:o,query:n},t);return new f(i,s=>K(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 i=await this.request({path:"/account/integrations/google",method:"POST",headers:o,query:n,body:j(r.googleIntegration)},t);return new c(i)}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 i=await this.request({path:"/errors",method:"POST",headers:o,query:n,body:r.postError.map(oe)},t);return new c(i)}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 i=await this.request({path:"/site",method:"POST",headers:o,query:n,body:ae(r.postSiteTrack)},t);return new c(i)}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 i=await this.request({path:"/account/site",method:"DELETE",headers:o,query:n,body:Y(r.deleteAccount)},t);return new c(i)}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 i=await this.request({path:"/account/site",method:"POST",headers:o,query:n,body:ne(r.postAccount)},t);return new c(i)}async sitePost(r,t){await this.sitePostRaw(r,t)}};var C=require("ag-common/dist/common/helpers/hashCode"),l=require("ag-common/dist/common/helpers/log"),Se=require("ag-common/dist/common/helpers/object");function we(e){return e?e.match(/^"?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}"?$/)?((0,l.info)("ignoring react devtools message"),!1):e===JSON.stringify([{}])?((0,l.info)("empty message payload?"),!1):!0:((0,l.info)("no message?"),!1)}var xe=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,i=[],s=e.message;(0,Se.isJson)(s)?i=JSON.parse(s):i=[s];let D=i.findIndex(p=>p.match(n)),F=i.findIndex(p=>p.match(o));D>=0&&F>=0&&F===D+1&&(i=i.filter((p,Ce)=>![D,F].includes(Ce))),i=i.map(p=>p.includes(".js:")||p.includes("node_modules")?p.replace(t,"$1 (stacktrace)"):p.replace(r,"[date]")),s=JSON.stringify(i);let z=(0,C.hashCode)(s)?.toString()??"";return(0,l.debug)("got errorKey=",s,z),z}catch(r){return(0,l.error)("error getting errorkey",r),(0,C.hashCode)(e.message)?.toString()??""}};var Ae=(e,r)=>{let t=[],n={},o=0;return Object.entries(e).forEach(([i,s])=>{o<r?t.push(s):n[i]=s,o+=1}),{part:t,rest:n}};function Oe(e){return(0,O.callOpenApi)({...e,func:r=>(0,O.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new m(r),logout:()=>window.location.reload(),refreshToken:async()=>{}})}var Ne=typeof window<"u"&&window?.location?.hostname==="localhost",d={},A,G,Pe=async()=>{try{if(Object.keys(d).length>100){let n=Object.keys(d)[0],o=d[n],i=await Oe({headers:{authorization:""},apiUrl:G,func:s=>s.postErrorsRaw({postError:[{key:o.key,data:{...o.data,message:`error overload!: ${o.data.message??"?"}`}}]})});if(d={},i.error)throw i.error;return{}}let{part:e,rest:r}=Ae(d,10);d=r;let t=await Oe({headers:{authorization:""},apiUrl:G,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{d.length?A=setTimeout(Pe,1e3):A=void 0}},g=async({data:e,overrideBaseUrl:r="https://api.analytica.click",ignoreBrowserErrors:t,devMode:n})=>{if(r||(r="https://api.analytica.click"),t&&t.length>0){let i=t.find(s=>e.data.message.includes(s));if(i){(0,T.debug)("ignoring error, contains=",i);return}}if(Ne&&n)(0,T.debug)("allowing local error tracking due to devmode=true");else if(Ne)return(0,T.debug)(`local error tracking ignored:${e.data.message} ${JSON.stringify(e)}, to ${r}`),{};if(!we(e?.data?.message))return{};(0,T.debug)("error track",e.data.message,JSON.stringify(e));let o=xe(e.data);return d[o]=e,G=r,A||(A=setTimeout(Pe,500)),{}};async function H({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 g({...r,data:{key:r.analyticaToken,data:t}})}function Je(e){(0,Ee.useEffect)(()=>{let r=t=>H({ev:t,values:e});if(e.analyticaToken)return window.addEventListener("error",r),()=>{window.removeEventListener("error",r)}},[])}var be=require("react");function ke(e){(0,be.useEffect)(()=>{if(window.consoleset)return;window.consoleset=!0;let r=window.console.error;window.console.error=(...n)=>{g({...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)=>{g({...e,data:{data:{href:window.location.href,message:JSON.stringify(n)},key:e.analyticaToken}}),t(...n)}},[])}var R=e=>`[Analytica.${e}] Please load analytica token in AnalyticaClickProvider to use this component`;var De=U(require("@emotion/styled")),Fe=require("ag-common/dist/ui/components/Modal"),qe=require("react"),h=require("react/jsx-runtime"),Rr=De.default.div`
|
1
|
+
'use client';"use strict";var Me=Object.create;var w=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var $e=Object.getPrototypeOf,Ue=Object.prototype.hasOwnProperty;var ve=(e,r)=>{for(var t in r)w(e,t,{get:r[t],enumerable:!0})},$=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of ze(r))!Ue.call(e,o)&&o!==t&&w(e,o,{get:()=>r[o],enumerable:!(n=Qe(r,o))||n.enumerable});return e};var U=(e,r,t)=>(t=e!=null?Me($e(e)):{},$(r||!e||!e.__esModule?w(t,"default",{value:e,enumerable:!0}):t,e)),We=e=>$(w({},"__esModule",{value:!0}),e);var Er={};ve(Er,{AnalyticaClickProvider:()=>Ar,AnalyticaConfigContext:()=>T,errorTrack:()=>y,event:()=>M,page:()=>Q,tokenMissing:()=>h,useAnalytica:()=>Pr});module.exports=We(Er);var Be=require("react");var N=require("ag-common/dist/common/helpers/log"),J=U(require("react"));var be=require("react");var R=require("ag-common/dist/common/helpers/log"),E=require("ag-common/dist/ui/helpers/callOpenApi");var _e="https://api.analytica.click".replace(/\/+$/,""),Xe=e=>typeof Blob<"u"&&e instanceof Blob,x=class{constructor(r=new F){this.configuration=r;this.fetchApi=async(r,t)=>{let n={url:r,init:t};for(let i of this.middleware)i.pre&&(n=await i.pre({fetch:this.fetchApi,...n})||n);let o=await(this.configuration.fetchApi||fetch)(n.url,n.init);for(let i of this.middleware)i.post&&(o=await i.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),i=await this.fetchApi(n,o);if(i.status>=200&&i.status<300)return i;throw i}createFetchParams(r,t){let n=this.configuration.basePath+r.path;r.query!==void 0&&Object.keys(r.query).length!==0&&(n+="?"+(this.configuration.queryParamsStringify||q)(r.query));let o=typeof FormData<"u"&&r.body instanceof FormData||r.body instanceof URLSearchParams||Xe(r.body)?r.body:JSON.stringify(r.body),i=Object.assign({},this.configuration.headers,r.headers),s={method:r.method,headers:i,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 F=class{constructor(r={}){this.configuration=r}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:_e}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||q}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 a(e,r){let t=e[r];return t!=null}function q(e,r=""){return Object.keys(e).map(t=>{let n=r+(r.length?`[${t}]`:t),o=e[t];if(o instanceof Array){let i=o.map(s=>encodeURIComponent(String(s))).join(`&${encodeURIComponent(n)}=`);return`${encodeURIComponent(n)}=${i}`}return o instanceof Date?`${encodeURIComponent(n)}=${encodeURIComponent(o.toISOString())}`:o instanceof Object?q(o,n):`${encodeURIComponent(n)}=${encodeURIComponent(String(o))}`}).filter(t=>t.length>0).join("&")}var d=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 v(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 Ze(e,!1)}function Ze(e,r){return e==null?e:{account:a(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 je(e,!1)}function je(e,r){return e==null?e:{account:a(e,"account")?e.account:void 0,site:e.site,eventName:e.eventName,datetime:e.datetime,count:e.count,category:e.category}}function A(e){return er(e,!1)}function er(e,r){return e==null?e:{site:e.site,account:e.account,apiKey:e.apiKey,adminApiKey:e.adminApiKey,favicon:a(e,"favicon")?e.favicon:void 0}}function Z(e){return tr(e,!1)}function tr(e,r){return e==null?e:{accounts:e.accounts.map(A),googleEmail:a(e,"googleEmail")?e.googleEmail:void 0,googleKey:a(e,"googleKey")?e.googleKey:void 0,bingKey:a(e,"bingKey")?e.bingKey:void 0,bingAccount:a(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 nr(e,!1)}function nr(e,r){return e==null?e:{account:a(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,language:e.language,count:e.count,category:e.category}}function re(e){return or(e,!1)}function or(e,r){return e==null?e:{account:a(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,countryRegion:e.countryRegion,category:e.category,count:e.count}}function te(e){return ir(e,!1)}function ir(e,r){return e==null?e:{PK:e.PK,messageHash:a(e,"messageHash")?e.messageHash:void 0,site:e.site,account:e.account,message:a(e,"message")?e.message:void 0,name:a(e,"name")?e.name:void 0,stack:a(e,"stack")?e.stack:void 0,href:e.href,filename:a(e,"filename")?e.filename:void 0,datetime:e.datetime,archived:a(e,"archived")?e.archived:void 0,count:e.count,category:e.category}}function ne(e){if(e!==void 0)return e===null?null:{site:e.site}}function oe(e){if(e!==void 0)return e===null?null:{key:e.key,data:ie(e.data)}}function ie(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 ae(e){if(e!==void 0)return e===null?null:{key:e.key,data:se(e.data)}}function se(e){if(e!==void 0)return e===null?null:{eventName:e.eventName,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage}}function ue(e){if(e!==void 0)return e===null?null:{key:e.key,data:ce(e.data)}}function ce(e){if(e!==void 0)return e===null?null:{pageLocation:e.pageLocation,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage}}function pe(e){return ar(e,!1)}function ar(e,r){return e==null?e:{account:a(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,pathName:e.pathName,search:a(e,"search")?e.search:void 0,hash:a(e,"hash")?e.hash:void 0,count:e.count,category:e.category}}function le(e){return sr(e,!1)}function sr(e,r){return e==null?e:{account:a(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,referrer:e.referrer,count:e.count,category:e.category}}function fe(e){return ur(e,!1)}function ur(e,r){return e==null?e:{account:a(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,resolution:e.resolution,count:e.count,category:e.category}}function de(e){return cr(e,!1)}function cr(e,r){return e==null?e:{account:e.account,site:e.site,datetime:e.datetime,category:e.category,topReferrers:a(e,"topReferrers")?e.topReferrers.map(Se):void 0,topResolutions:a(e,"topResolutions")?e.topResolutions.map(we):void 0,topQueries:a(e,"topQueries")?e.topQueries.map(he):void 0,topLocations:a(e,"topLocations")?e.topLocations.map(Re):void 0,topBrowsers:a(e,"topBrowsers")?e.topBrowsers.map(me):void 0,topEvents:a(e,"topEvents")?e.topEvents.map(ye):void 0,topLanguages:a(e,"topLanguages")?e.topLanguages.map(Te):void 0,topErrors:a(e,"topErrors")?e.topErrors.map(ge):void 0}}function me(e){return pr(e,!1)}function pr(e,r){return e==null?e:{browser:e.browser,count:e.count}}function ge(e){return lr(e,!1)}function lr(e,r){return e==null?e:{href:e.href,count:e.count}}function ye(e){return fr(e,!1)}function fr(e,r){return e==null?e:{eventName:e.eventName,count:e.count}}function Te(e){return dr(e,!1)}function dr(e,r){return e==null?e:{language:e.language,count:e.count}}function Re(e){return mr(e,!1)}function mr(e,r){return e==null?e:{countryRegion:e.countryRegion,count:e.count}}function he(e){return gr(e,!1)}function gr(e,r){return e==null?e:{pathName:e.pathName,count:e.count}}function Se(e){return yr(e,!1)}function yr(e,r){return e==null?e:{referrer:e.referrer,count:e.count}}function we(e){return Tr(e,!1)}function Tr(e,r){return e==null?e:{resolution:e.resolution,count:e.count}}function L(e){return Rr(e,!1)}function Rr(e,r){return e==null?e:{account:e.account,email:e.email,site:e.site,datetime:e.datetime,category:e.category,totals:I(e.totals),queries:e.queries.map(I)}}function I(e){return hr(e,!1)}function hr(e,r){return e==null?e:{clicks:e.clicks,impressions:e.impressions,position:e.position,query:e.query}}function K(e){return Sr(e,!1)}function Sr(e,r){return e==null?e:{accountDetails:a(e,"accountDetails")?A(e.accountDetails):void 0,browsers:a(e,"browsers")?e.browsers.map(_):void 0,events:a(e,"events")?e.events.map(Y):void 0,locations:a(e,"locations")?e.locations.map(re):void 0,queries:a(e,"queries")?e.queries.map(pe):void 0,referrers:a(e,"referrers")?e.referrers.map(le):void 0,resolutions:a(e,"resolutions")?e.resolutions.map(fe):void 0,languages:a(e,"languages")?e.languages.map(ee):void 0,rollups:a(e,"rollups")?e.rollups.map(de):void 0,errors:a(e,"errors")?e.errors.map(te):void 0,google:a(e,"google")?e.google.map(L):void 0,bing:a(e,"bing")?e.bing.map(L):void 0}}var m=class extends x{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 d(o,i=>Z(i))}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 i=await this.request({path:"/errors/{id}".replace("{id}",encodeURIComponent(String(r.id))),method:"DELETE",headers:o,query:n},t);return new c(i)}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 i=await this.request({path:"/errors",method:"DELETE",headers:o,query:n,body:v(r.archiveErrors)},t);return new c(i)}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 i=await this.request({path:"/account/integrations/bing",method:"POST",headers:o,query:n,body:W(r.bingIntegration)},t);return new c(i)}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 i=await this.request({path:"/site/tracking",method:"GET",headers:o,query:n},t);return new d(i,s=>s.map(K))}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 i=await this.request({path:"/site/tracking/{id}".replace("{id}",encodeURIComponent(String(r.id))),method:"GET",headers:o,query:n},t);return new d(i,s=>K(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 i=await this.request({path:"/account/integrations/google",method:"POST",headers:o,query:n,body:j(r.googleIntegration)},t);return new c(i)}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 i=await this.request({path:"/errors",method:"POST",headers:o,query:n,body:r.postError.map(oe)},t);return new c(i)}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 i=await this.request({path:"/site/event",method:"POST",headers:o,query:n,body:ae(r.postEvent)},t);return new c(i)}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 i=await this.request({path:"/site/tracking",method:"POST",headers:o,query:n,body:ue(r.postSiteTrack)},t);return new c(i)}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 i=await this.request({path:"/account/site",method:"DELETE",headers:o,query:n,body:X(r.deleteAccount)},t);return new c(i)}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 i=await this.request({path:"/account/site",method:"POST",headers:o,query:n,body:ne(r.postAccount)},t);return new c(i)}async sitePost(r,t){await this.sitePostRaw(r,t)}};var B=require("ag-common/dist/common/helpers/hashCode"),g=require("ag-common/dist/common/helpers/log"),xe=require("ag-common/dist/common/helpers/object");function Ae(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 Pe=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,i=[],s=e.message;(0,xe.isJson)(s)?i=JSON.parse(s):i=[s];let D=i.findIndex(p=>p.match(n)),k=i.findIndex(p=>p.match(o));D>=0&&k>=0&&k===D+1&&(i=i.filter((p,He)=>![D,k].includes(He))),i=i.map(p=>p.includes(".js:")||p.includes("node_modules")?p.replace(t,"$1 (stacktrace)"):p.replace(r,"[date]")),s=JSON.stringify(i);let z=(0,B.hashCode)(s)?.toString()??"";return(0,g.debug)("got errorKey=",s,z),z}catch{return(0,B.hashCode)(e.message)?.toString()??""}};var Ee=(e,r)=>{let t=[],n={},o=0;return Object.entries(e).forEach(([i,s])=>{o<r?t.push(s):n[i]=s,o+=1}),{part:t,rest:n}};function Oe(e){return(0,E.callOpenApi)({...e,func:r=>(0,E.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new m(r),logout:()=>window.location.reload(),refreshToken:async()=>{}})}var Ne=typeof window<"u"&&window?.location?.hostname==="localhost",l={},P,C,Je=async()=>{try{if(Object.keys(l).length>100){let n=Object.keys(l)[0],o=l[n],i=await Oe({headers:{authorization:""},apiUrl:C,func:s=>s.postErrorsRaw({postError:[{key:o.key,data:{...o.data,message:`error overload!: ${o.data.message??"?"}`}}]})});if(l={},i.error)throw i.error;return{}}let{part:e,rest:r}=Ee(l,10);l=r;let t=await Oe({headers:{authorization:""},apiUrl:C,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{l.length?P=setTimeout(Je,1e3):P=void 0}},y=async({data:e,overrideBaseUrl:r="https://api.analytica.click",ignoreBrowserErrors:t=["will be removed","performing full reload"],devMode:n})=>{if(r||(r="https://api.analytica.click"),t&&t.length>0){let i=t.find(s=>e.data.message.includes(s));if(i){(0,R.debug)("ignoring error, contains=",i);return}}if(Ne&&n)(0,R.debug)("allowing local error tracking due to devmode=true");else if(Ne)return(0,R.debug)(`local error tracking ignored:${e.data.message} ${JSON.stringify(e)}, to ${r}`),{};if(!Ae(e?.data?.message))return{};(0,R.debug)("error track",e.data.message,JSON.stringify(e));let o=Pe(e.data);return l[o]=e,C=r,P||(P=setTimeout(Je,500)),{}};async function G({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 y({...r,data:{key:r.analyticaToken,data:t}})}function De(e){(0,be.useEffect)(()=>{let r=t=>G({ev:t,values:e});if(e.analyticaToken)return window.addEventListener("error",r),()=>{window.removeEventListener("error",r)}},[])}var ke=require("react");function Fe(e){(0,ke.useEffect)(()=>{if(window.consoleset)return;window.consoleset=!0;let r=window.console.error;window.console.error=(...n)=>{y({...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)=>{y({...e,data:{data:{href:window.location.href,message:JSON.stringify(n)},key:e.analyticaToken}}),t(...n)}},[])}var h=e=>`[Analytica.${e}] Please load analytica token in AnalyticaClickProvider to use this component`;var qe=U(require("@emotion/styled")),Ie=require("ag-common/dist/ui/components/Modal"),Le=require("react"),S=require("react/jsx-runtime"),wr=qe.default.div`
|
2
2
|
font-size: 2rem;
|
3
|
-
`,
|
3
|
+
`,O=class extends Le.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,S.jsx)(Ie.Modal,{open:!0,setOpen:()=>{},children:(0,S.jsxs)(wr,{children:["A fatal error has occurred - the admin has been notified.",(0,S.jsx)("button",{type:"button",onClick:()=>window.location.reload(),children:"Press here to restart app"})]})})):t}};var V=require("react/jsx-runtime"),Ke=({children:e})=>{let r=(0,J.useContext)(T);return Fe(r),De(r),(0,N.debug)("installed analytica.click error handlers"),r.analyticaToken?(0,V.jsx)(O,{notify:t=>G({ev:t,values:r}),children:e}):((0,N.warn)(h("ErrorBoundary")),(0,V.jsx)(J.default.Fragment,{children:e}))};var H=require("react/jsx-runtime"),xr={analyticaToken:"",overrideBaseUrl:void 0},T=(0,Be.createContext)(xr),Ar=({children:e,values:r})=>(0,H.jsx)(T.Provider,{value:r,children:(0,H.jsx)(Ke,{children:e})});var f=require("ag-common/dist/common/helpers/log"),b=require("ag-common/dist/ui/helpers/callOpenApi");function Ce(e){return(0,b.callOpenApi)({...e,func:r=>(0,b.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new m(r),logout:()=>window.location.reload(),refreshToken:async()=>{}})}var M=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click",eventName:t,devMode:n})=>{let o={eventName:t};if(!n&&typeof window<"u"&&window?.location?.hostname==="localhost")return(0,f.debug)(`local page ignored: ${JSON.stringify(o)}, to ${r}`),{};let i=await Ce({apiUrl:r,headers:{authorization:""},func:s=>s.postEventRaw({postEvent:{key:e,data:o}})});return i.error?((0,f.warn)("tracking error:"+JSON.stringify(i.error,null,2)),{error:JSON.stringify(i.error,null,2)}):{}},Q=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click",devMode:t})=>{let n={pageLocation:""};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,f.debug)(`local page ignored: ${JSON.stringify(n)}, to ${r}`),{};if(!n.pageLocation)return(0,f.warn)("no pageLocation"),{};let o=await Ce({apiUrl:r,headers:{authorization:""},func:i=>i.postPageTrackRaw({postSiteTrack:{key:e,data:n}})});return o.error?((0,f.warn)("tracking error:"+JSON.stringify(o.error,null,2)),{error:JSON.stringify(o.error,null,2)}):{}};var Ge=require("ag-common/dist/common/helpers/log"),Ve=require("react");var Pr=()=>{let e=(0,Ve.useContext)(T);if(!e.analyticaToken){(0,Ge.warn)(h("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});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "analytica.click",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.452",
|
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.
|
14
|
+
"ag-common": "^0.0.624",
|
15
15
|
"axios": "^1",
|
16
16
|
"cross-env": "^7",
|
17
17
|
"esbuild": "^0.20.0",
|
@@ -1 +0,0 @@
|
|
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:{accountDetails:i(e,"accountDetails")?d(e.accountDetails):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});
|