analytica.click 0.0.494 → 0.0.496

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.
package/dist/index.d.ts CHANGED
@@ -23,11 +23,12 @@ declare module 'analytica.click/dist/components/ErrorBoundary/Comp' {
23
23
  static getDerivedStateFromError(errorV: any): {
24
24
  hasError: any;
25
25
  };
26
- render(): string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
26
+ render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
27
27
  }
28
28
 
29
29
  }
30
30
  declare module 'analytica.click/dist/components/ErrorBoundary/index' {
31
+ import type { JSX } from 'react';
31
32
  import React from 'react';
32
33
  export const ErrorBoundary: ({ children, }: {
33
34
  children?: React.ReactNode;
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- 'use client';"use strict";var Ue=Object.create;var x=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Xe=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty;var Ze=(e,r)=>{for(var t in r)x(e,t,{get:r[t],enumerable:!0})},$=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of _e(r))!Ye.call(e,o)&&o!==t&&x(e,o,{get:()=>r[o],enumerable:!(n=We(r,o))||n.enumerable});return e};var U=(e,r,t)=>(t=e!=null?Ue(Xe(e)):{},$(r||!e||!e.__esModule?x(t,"default",{value:e,enumerable:!0}):t,e)),ve=e=>$(x({},"__esModule",{value:!0}),e);var Fr={};Ze(Fr,{AnalyticaClickProvider:()=>Jr,AnalyticaConfigContext:()=>T,errorTrack:()=>f,event:()=>M,page:()=>Q,tokenMissing:()=>w,useAnalytica:()=>br});module.exports=ve(Fr);var He=require("react");var J=require("ag-common/dist/common/helpers/log"),b=U(require("react"));var De=require("react");var Gi=require("cross-fetch/polyfill"),h=require("ag-common/dist/common/helpers/log"),Fe=require("ag-common/dist/common/helpers/string/contains"),E=require("ag-common/dist/ui/helpers/callOpenApi");var je="https://api.analytica.click".replace(/\/+$/,""),er=e=>typeof Blob<"u"&&e instanceof Blob,A=class{constructor(r=new D){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||er(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 D=class{constructor(r={}){this.configuration=r}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:je}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||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 m=class{constructor(r,t=n=>n){this.raw=r;this.transformer=t}async value(){return this.transformer(await this.raw.json())}},c=class{constructor(r){this.raw=r}async value(){}};function 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 tr(e,!1)}function tr(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 nr(e,!1)}function nr(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 v(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,fingerprint:e.fingerprint,count:e.count,category:e.category}}function O(e){return ir(e,!1)}function ir(e,r){return e==null?e:{site:e.site,account:e.account,apiKey:e.apiKey,adminApiKey:e.adminApiKey,favicon:a(e,"favicon")?e.favicon:void 0}}function j(e){return sr(e,!1)}function sr(e,r){return e==null?e:{accounts:e.accounts.map(O),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 ee(e){if(e!==void 0)return e===null?null:{email:e.email,key:e.key,account:e.account}}function re(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,language:e.language,count:e.count,category:e.category}}function te(e){return cr(e,!1)}function cr(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 ne(e){return pr(e,!1)}function pr(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 oe(e){if(e!==void 0)return e===null?null:{site:e.site}}function ie(e){if(e!==void 0)return e===null?null:{key:e.key,data:ae(e.data)}}function ae(e){if(e!==void 0)return e===null?null:{message:e.message,name:e.name,stack:e.stack,href:e.href,filename:e.filename}}function se(e){if(e!==void 0)return e===null?null:{key:e.key,data:ue(e.data)}}function ue(e){if(e!==void 0)return e===null?null:{eventName:e.eventName,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage,browserFingerprint:e.browserFingerprint}}function ce(e){if(e!==void 0)return e===null?null:{key:e.key,data:pe(e.data)}}function pe(e){if(e!==void 0)return e===null?null:{pageLocation:e.pageLocation,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage,browserFingerprint:e.browserFingerprint}}function fe(e){return fr(e,!1)}function fr(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 lr(e,!1)}function lr(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 de(e){return dr(e,!1)}function dr(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 me(e){return mr(e,!1)}function mr(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(xe):void 0,topResolutions:a(e,"topResolutions")?e.topResolutions.map(Ae):void 0,topFingerprints:a(e,"topFingerprints")?e.topFingerprints.map(Re):void 0,topQueries:a(e,"topQueries")?e.topQueries.map(Se):void 0,topLocations:a(e,"topLocations")?e.topLocations.map(we):void 0,topBrowsers:a(e,"topBrowsers")?e.topBrowsers.map(ge):void 0,topEvents:a(e,"topEvents")?e.topEvents.map(Te):void 0,topLanguages:a(e,"topLanguages")?e.topLanguages.map(he):void 0,topErrors:a(e,"topErrors")?e.topErrors.map(ye):void 0}}function ge(e){return gr(e,!1)}function gr(e,r){return e==null?e:{browser:e.browser,count:e.count}}function ye(e){return yr(e,!1)}function yr(e,r){return e==null?e:{href:e.href,count:e.count}}function Te(e){return Tr(e,!1)}function Tr(e,r){return e==null?e:{eventName:e.eventName,count:e.count}}function Re(e){return Rr(e,!1)}function Rr(e,r){return e==null?e:{fingerprint:e.fingerprint,count:e.count}}function he(e){return hr(e,!1)}function hr(e,r){return e==null?e:{language:e.language,count:e.count}}function we(e){return wr(e,!1)}function wr(e,r){return e==null?e:{countryRegion:e.countryRegion,count:e.count}}function Se(e){return Sr(e,!1)}function Sr(e,r){return e==null?e:{pathName:e.pathName,count:e.count}}function xe(e){return xr(e,!1)}function xr(e,r){return e==null?e:{referrer:e.referrer,count:e.count}}function Ae(e){return Ar(e,!1)}function Ar(e,r){return e==null?e:{resolution:e.resolution,count:e.count}}function L(e){return Or(e,!1)}function Or(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 Pr(e,!1)}function Pr(e,r){return e==null?e:{clicks:e.clicks,impressions:e.impressions,position:e.position,query:e.query}}function K(e){return Er(e,!1)}function Er(e,r){return e==null?e:{accountDetails:a(e,"accountDetails")?O(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(te):void 0,queries:a(e,"queries")?e.queries.map(fe):void 0,referrers:a(e,"referrers")?e.referrers.map(le):void 0,resolutions:a(e,"resolutions")?e.resolutions.map(de):void 0,fingerprints:a(e,"fingerprints")?e.fingerprints.map(v):void 0,languages:a(e,"languages")?e.languages.map(re):void 0,rollups:a(e,"rollups")?e.rollups.map(me):void 0,errors:a(e,"errors")?e.errors.map(ne):void 0,google:a(e,"google")?e.google.map(L):void 0,bing:a(e,"bing")?e.bing.map(L):void 0}}var g=class extends A{async accountGetRaw(r){let t={},n={};this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let o=await this.request({path:"/account",method:"GET",headers:n,query:t},r);return new m(o,i=>j(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 m(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 m(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:ee(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(ie)},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:se(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:ce(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:oe(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"),y=require("ag-common/dist/common/helpers/log"),Oe=require("ag-common/dist/common/helpers/object");function Pe(e){return e?e.match(/^"?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}"?$/)?((0,y.info)("ignoring react devtools message"),!1):e===JSON.stringify([{}])?((0,y.info)("empty message payload?"),!1):!0:((0,y.info)("no message?"),!1)}var Ee=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,Oe.isJson)(s)?i=JSON.parse(s):i=[s];let R=i.findIndex(p=>p.match(n)),k=i.findIndex(p=>p.match(o));R>=0&&k>=0&&k===R+1&&(i=i.filter((p,$e)=>![R,k].includes($e))),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,y.debug)("got errorKey=",s,z),z}catch{return(0,B.hashCode)(e.message).toString()}};var Ne=(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 Je(e){return(0,E.callOpenApi)({...e,func:r=>(0,E.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new g(r),logout:()=>typeof window<"u"?window.location.reload():()=>{},refreshToken:async()=>{}})}var be=typeof window<"u"&&window.location.hostname==="localhost",l={},P,C,ke=async()=>{try{if(Object.keys(l).length>100){let n=Object.keys(l)[0],o=l[n],i=await Je({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}=Ne(l,10);l=r;let t=await Je({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{Object.keys(l).length>0?P=setTimeout(ke,1e3):P=void 0}},f=async({data:e,overrideBaseUrl:r="https://api.analytica.click",ignoreBrowserErrors:t=["will be removed","performing full reload","tracking error","fetch RSC payload","perform a full reload"],devMode:n})=>{if(r||(r="https://api.analytica.click"),r.startsWith("/")&&typeof window>"u"&&(r="https://api.analytica.click"),t.length>0){let i=(0,Fe.containsInsensitive)(e.data.message,...t);if(i){(0,h.debug)("ignoring error, contains=",i);return}}if(be&&n)(0,h.debug)("allowing local error tracking due to devmode=true");else if(be)return(0,h.debug)(`local error tracking ignored:${e.data.message} ${JSON.stringify(e)}, to ${r}`),{};if(!Pe(e.data.message))return{};(0,h.debug)("error track",e.data.message,JSON.stringify(e));let o=Ee(e.data);return l[o]=e,C=r,P||(P=setTimeout(ke,500)),{}};async function V({ev:e,values:r}){if(!r.analyticaToken)return;let t={message:e.message,href:window.location.href,filename:e.filename,name:"",stack:e.error.stack};await f({...r,data:{key:r.analyticaToken,data:t}})}function qe(e){(0,De.useEffect)(()=>{let r=t=>V({ev:t,values:e});if(e.analyticaToken)return window.addEventListener("error",r),()=>{try{window.removeEventListener("error",r)}catch{}}},[])}var Ie=require("react");function Le(e){(0,Ie.useEffect)(()=>{if(window.consoleset||!e.analyticaToken)return;window.consoleset=!0;let r=window.console.error;window.console.error=(...n)=>{f({...e,data:{data:{href:window.location.href,message:JSON.stringify(n)},key:e.analyticaToken}}),r(...n)};let t=window.console.warn;window.console.warn=(...n)=>{f({...e,data:{data:{href:window.location.href,message:JSON.stringify(n)},key:e.analyticaToken}}),t(...n)}},[])}var w=e=>`[Analytica.${e}] Please load analytica token in AnalyticaClickProvider to use this component`;function Ke(e){if(global.nodeset||typeof window<"u"||!e.analyticaToken)return;global.nodeset=!0;let r=global.console.error;global.console.error=(...n)=>{f({...e,data:{data:{href:"server",message:JSON.stringify(n)},key:e.analyticaToken}}),r(...n)};let t=global.console.warn;global.console.warn=(...n)=>{f({...e,data:{data:{href:"server",message:JSON.stringify(n)},key:e.analyticaToken}}),t(...n)}}var Be=U(require("@emotion/styled")),Ce=require("ag-common/dist/ui/components/Modal"),Ve=require("react"),S=require("react/jsx-runtime"),Nr=Be.default.div`
1
+ 'use client';"use strict";var Ue=Object.create;var x=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Xe=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty;var Ze=(e,r)=>{for(var t in r)x(e,t,{get:r[t],enumerable:!0})},$=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of _e(r))!Ye.call(e,o)&&o!==t&&x(e,o,{get:()=>r[o],enumerable:!(n=We(r,o))||n.enumerable});return e};var U=(e,r,t)=>(t=e!=null?Ue(Xe(e)):{},$(r||!e||!e.__esModule?x(t,"default",{value:e,enumerable:!0}):t,e)),ve=e=>$(x({},"__esModule",{value:!0}),e);var Fr={};Ze(Fr,{AnalyticaClickProvider:()=>Jr,AnalyticaConfigContext:()=>T,errorTrack:()=>f,event:()=>M,page:()=>Q,tokenMissing:()=>S,useAnalytica:()=>br});module.exports=ve(Fr);var He=require("react");var J=require("ag-common/dist/common/helpers/log"),b=U(require("react"));var De=require("react");var Gi=require("cross-fetch/polyfill"),h=require("ag-common/dist/common/helpers/log"),Fe=require("ag-common/dist/common/helpers/string/contains"),E=require("ag-common/dist/ui/helpers/callOpenApi");var je="https://api.analytica.click".replace(/\/+$/,""),er=e=>typeof Blob<"u"&&e instanceof Blob,A=class{constructor(r=new D){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||er(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 D=class{constructor(r={}){this.configuration=r}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:je}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||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 m=class{constructor(r,t=n=>n){this.raw=r;this.transformer=t}async value(){return this.transformer(await this.raw.json())}},c=class{constructor(r){this.raw=r}async value(){}};function 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 tr(e,!1)}function tr(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 nr(e,!1)}function nr(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 v(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,fingerprint:e.fingerprint,count:e.count,category:e.category}}function O(e){return ir(e,!1)}function ir(e,r){return e==null?e:{site:e.site,account:e.account,apiKey:e.apiKey,adminApiKey:e.adminApiKey,favicon:a(e,"favicon")?e.favicon:void 0}}function j(e){return sr(e,!1)}function sr(e,r){return e==null?e:{accounts:e.accounts.map(O),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 ee(e){if(e!==void 0)return e===null?null:{email:e.email,key:e.key,account:e.account}}function re(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,language:e.language,count:e.count,category:e.category}}function te(e){return cr(e,!1)}function cr(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 ne(e){return pr(e,!1)}function pr(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 oe(e){if(e!==void 0)return e===null?null:{site:e.site}}function ie(e){if(e!==void 0)return e===null?null:{key:e.key,data:ae(e.data)}}function ae(e){if(e!==void 0)return e===null?null:{message:e.message,name:e.name,stack:e.stack,href:e.href,filename:e.filename}}function se(e){if(e!==void 0)return e===null?null:{key:e.key,data:ue(e.data)}}function ue(e){if(e!==void 0)return e===null?null:{eventName:e.eventName,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage,browserFingerprint:e.browserFingerprint}}function ce(e){if(e!==void 0)return e===null?null:{key:e.key,data:pe(e.data)}}function pe(e){if(e!==void 0)return e===null?null:{pageLocation:e.pageLocation,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage,browserFingerprint:e.browserFingerprint}}function fe(e){return fr(e,!1)}function fr(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 lr(e,!1)}function lr(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 de(e){return dr(e,!1)}function dr(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 me(e){return mr(e,!1)}function mr(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(xe):void 0,topResolutions:a(e,"topResolutions")?e.topResolutions.map(Ae):void 0,topFingerprints:a(e,"topFingerprints")?e.topFingerprints.map(Re):void 0,topQueries:a(e,"topQueries")?e.topQueries.map(we):void 0,topLocations:a(e,"topLocations")?e.topLocations.map(Se):void 0,topBrowsers:a(e,"topBrowsers")?e.topBrowsers.map(ge):void 0,topEvents:a(e,"topEvents")?e.topEvents.map(Te):void 0,topLanguages:a(e,"topLanguages")?e.topLanguages.map(he):void 0,topErrors:a(e,"topErrors")?e.topErrors.map(ye):void 0}}function ge(e){return gr(e,!1)}function gr(e,r){return e==null?e:{browser:e.browser,count:e.count}}function ye(e){return yr(e,!1)}function yr(e,r){return e==null?e:{href:e.href,count:e.count}}function Te(e){return Tr(e,!1)}function Tr(e,r){return e==null?e:{eventName:e.eventName,count:e.count}}function Re(e){return Rr(e,!1)}function Rr(e,r){return e==null?e:{fingerprint:e.fingerprint,count:e.count}}function he(e){return hr(e,!1)}function hr(e,r){return e==null?e:{language:e.language,count:e.count}}function Se(e){return Sr(e,!1)}function Sr(e,r){return e==null?e:{countryRegion:e.countryRegion,count:e.count}}function we(e){return wr(e,!1)}function wr(e,r){return e==null?e:{pathName:e.pathName,count:e.count}}function xe(e){return xr(e,!1)}function xr(e,r){return e==null?e:{referrer:e.referrer,count:e.count}}function Ae(e){return Ar(e,!1)}function Ar(e,r){return e==null?e:{resolution:e.resolution,count:e.count}}function L(e){return Or(e,!1)}function Or(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 Pr(e,!1)}function Pr(e,r){return e==null?e:{clicks:e.clicks,impressions:e.impressions,position:e.position,query:e.query}}function K(e){return Er(e,!1)}function Er(e,r){return e==null?e:{accountDetails:a(e,"accountDetails")?O(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(te):void 0,queries:a(e,"queries")?e.queries.map(fe):void 0,referrers:a(e,"referrers")?e.referrers.map(le):void 0,resolutions:a(e,"resolutions")?e.resolutions.map(de):void 0,fingerprints:a(e,"fingerprints")?e.fingerprints.map(v):void 0,languages:a(e,"languages")?e.languages.map(re):void 0,rollups:a(e,"rollups")?e.rollups.map(me):void 0,errors:a(e,"errors")?e.errors.map(ne):void 0,google:a(e,"google")?e.google.map(L):void 0,bing:a(e,"bing")?e.bing.map(L):void 0}}var g=class extends A{async accountGetRaw(r){let t={},n={};this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let o=await this.request({path:"/account",method:"GET",headers:n,query:t},r);return new m(o,i=>j(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 m(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 m(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:ee(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(ie)},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:se(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:ce(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:oe(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"),y=require("ag-common/dist/common/helpers/log"),Oe=require("ag-common/dist/common/helpers/object");function Pe(e){return e?e.match(/^"?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}"?$/)?((0,y.info)("ignoring react devtools message"),!1):e===JSON.stringify([{}])?((0,y.info)("empty message payload?"),!1):!0:((0,y.info)("no message?"),!1)}var Ee=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,Oe.isJson)(s)?i=JSON.parse(s):i=[s];let R=i.findIndex(p=>p.match(n)),k=i.findIndex(p=>p.match(o));R>=0&&k>=0&&k===R+1&&(i=i.filter((p,$e)=>![R,k].includes($e))),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,y.debug)("got errorKey=",s,z),z}catch{return(0,B.hashCode)(e.message).toString()}};var Ne=(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 Je(e){return(0,E.callOpenApi)({...e,func:r=>(0,E.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new g(r),logout:()=>typeof window<"u"?window.location.reload():()=>{},refreshToken:async()=>{}})}var be=typeof window<"u"&&window.location.hostname==="localhost",l={},P,C,ke=async()=>{try{if(Object.keys(l).length>100){let n=Object.keys(l)[0],o=l[n],i=await Je({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}=Ne(l,10);l=r;let t=await Je({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{Object.keys(l).length>0?P=setTimeout(ke,1e3):P=void 0}},f=async({data:e,overrideBaseUrl:r="https://api.analytica.click",ignoreBrowserErrors:t=["will be removed","performing full reload","tracking error","fetch RSC payload","perform a full reload"],devMode:n})=>{if(r||(r="https://api.analytica.click"),r.startsWith("/")&&typeof window>"u"&&(r="https://api.analytica.click"),t.length>0){let i=(0,Fe.containsInsensitive)(e.data.message,...t);if(i){(0,h.debug)("ignoring error, contains=",i);return}}if(be&&n)(0,h.debug)("allowing local error tracking due to devmode=true");else if(be)return(0,h.debug)(`local error tracking ignored:${e.data.message} ${JSON.stringify(e)}, to ${r}`),{};if(!Pe(e.data.message))return{};(0,h.debug)("error track",e.data.message,JSON.stringify(e));let o=Ee(e.data);return l[o]=e,C=r,P||(P=setTimeout(ke,500)),{}};async function V({ev:e,values:r}){if(!r.analyticaToken)return;let t={message:e.message,href:window.location.href,filename:e.filename,name:"",stack:e.error.stack};await f({...r,data:{key:r.analyticaToken,data:t}})}function qe(e){(0,De.useEffect)(()=>{let r=t=>V({ev:t,values:e});if(e.analyticaToken)return window.addEventListener("error",r),()=>{try{window.removeEventListener("error",r)}catch{}}},[])}var Ie=require("react");function Le(e){(0,Ie.useEffect)(()=>{if(window.consoleset||!e.analyticaToken)return;window.consoleset=!0;let r=window.console.error;window.console.error=(...n)=>{f({...e,data:{data:{href:window.location.href,message:JSON.stringify(n)},key:e.analyticaToken}}),r(...n)};let t=window.console.warn;window.console.warn=(...n)=>{f({...e,data:{data:{href:window.location.href,message:JSON.stringify(n)},key:e.analyticaToken}}),t(...n)}},[])}var S=e=>`[Analytica.${e}] Please load analytica token in AnalyticaClickProvider to use this component`;function Ke(e){if(global.nodeset||typeof window<"u"||!e.analyticaToken)return;global.nodeset=!0;let r=global.console.error;global.console.error=(...n)=>{f({...e,data:{data:{href:"server",message:JSON.stringify(n)},key:e.analyticaToken}}),r(...n)};let t=global.console.warn;global.console.warn=(...n)=>{f({...e,data:{data:{href:"server",message:JSON.stringify(n)},key:e.analyticaToken}}),t(...n)}}var Be=U(require("@emotion/styled")),Ce=require("ag-common/dist/ui/components/Modal"),Ve=require("react"),w=require("react/jsx-runtime"),Nr=Be.default.div`
2
2
  font-size: 2rem;
3
- `,N=class extends Ve.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)(Ce.Modal,{open:!0,setOpen:()=>{},children:(0,S.jsxs)(Nr,{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 G=require("react/jsx-runtime"),Ge=({children:e})=>{let r=(0,b.useContext)(T);return Le(r),qe(r),Ke(r),(0,J.debug)("installed analytica.click error handlers"),r.analyticaToken?(0,G.jsx)(N,{notify:t=>V({ev:t,values:r}),children:e}):((0,J.warn)(w("ErrorBoundary")),(0,G.jsx)(b.default.Fragment,{children:e}))};var H=require("react/jsx-runtime"),T=(0,He.createContext)(void 0),Jr=({children:e,values:r})=>(0,H.jsx)(T.Provider,{value:r,children:(0,H.jsx)(Ge,{children:e})});var la=require("cross-fetch/polyfill"),d=require("ag-common/dist/common/helpers/log"),F=require("ag-common/dist/ui/helpers/callOpenApi");function Me(e){return(0,F.callOpenApi)({...e,func:r=>(0,F.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new g(r),logout:()=>typeof window<"u"?window.location.reload():()=>{},refreshToken:async()=>{}})}var M=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click",eventName:t,devMode:n,valueOverrides:o})=>{let i={eventName:t,browserFingerprint:o?.browserFingerprint};if(!n&&typeof window<"u"&&window.location.hostname==="localhost")return(0,d.debug)(`local page ignored: ${JSON.stringify(i)}, to ${r}`),{};let s=await Me({apiUrl:r,headers:{authorization:""},func:R=>R.postEventRaw({postEvent:{key:e,data:i}})});return s.error?((0,d.warn)("tracking error:"+JSON.stringify(s.error,null,2)),{error:JSON.stringify(s.error,null,2)}):{}},Q=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click",devMode:t,valueOverrides:n})=>{let o={pageLocation:"",browserFingerprint:n?.browserFingerprint};if(typeof window<"u"&&(o={...o,pageLocation:window.location.href,browserResolution:`${window.screen.width}:${window.screen.height}`}),typeof document<"u"&&(o={...o,pageReferrer:document.referrer,pageTitle:document.title}),typeof navigator<"u"&&(o={...o,browserLanguage:navigator.language}),!t&&typeof window<"u"&&window.location.hostname==="localhost")return(0,d.debug)(`local page ignored: ${JSON.stringify(o)}, to ${r}`),{};if(!o.pageLocation)return(0,d.warn)("no pageLocation"),{};let i=await Me({apiUrl:r,headers:{authorization:""},func:s=>s.postPageTrackRaw({postSiteTrack:{key:e,data:o}})});return i.error?((0,d.warn)("tracking error:"+JSON.stringify(i.error,null,2)),{error:JSON.stringify(i.error,null,2)}):{}};var Qe=require("ag-common/dist/common/helpers/log"),ze=require("react");var br=()=>{let e=(0,ze.useContext)(T);if(!e.analyticaToken){(0,Qe.warn)(w("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});
3
+ `,N=class extends Ve.Component{constructor(r){super(r),this.state={hasError:void 0},this.seenError=!1}static getDerivedStateFromError(r){let t=typeof window<"u"&&window.location.href;return{hasError:{...r,message:r?.message??r,...r?.stack&&{error:{stack:r?.stack}},...t&&{href:t}}}}render(){let{hasError:r}=this.state,{children:t,notify:n}=this.props;return r?(n&&n(r),(0,w.jsx)(Ce.Modal,{open:!0,setOpen:()=>{},children:(0,w.jsxs)(Nr,{children:["A fatal error has occurred - the admin has been notified.",(0,w.jsx)("button",{type:"button",onClick:()=>window.location.reload(),children:"Press here to restart app"})]})})):t}};var G=require("react/jsx-runtime"),Ge=({children:e})=>{let r=(0,b.useContext)(T);return Le(r),qe(r),Ke(r),(0,J.debug)("installed analytica.click error handlers"),r.analyticaToken?(0,G.jsx)(N,{notify:t=>V({ev:t,values:r}),children:e}):((0,J.warn)(S("ErrorBoundary")),(0,G.jsx)(b.default.Fragment,{children:e}))};var H=require("react/jsx-runtime"),T=(0,He.createContext)(void 0),Jr=({children:e,values:r})=>(0,H.jsx)(T.Provider,{value:r,children:(0,H.jsx)(Ge,{children:e})});var la=require("cross-fetch/polyfill"),d=require("ag-common/dist/common/helpers/log"),F=require("ag-common/dist/ui/helpers/callOpenApi");function Me(e){return(0,F.callOpenApi)({...e,func:r=>(0,F.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new g(r),logout:()=>typeof window<"u"?window.location.reload():()=>{},refreshToken:async()=>{}})}var M=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click",eventName:t,devMode:n,valueOverrides:o})=>{let i={eventName:t,browserFingerprint:o?.browserFingerprint};if(!n&&typeof window<"u"&&window.location.hostname==="localhost")return(0,d.debug)(`local page ignored: ${JSON.stringify(i)}, to ${r}`),{};let s=await Me({apiUrl:r,headers:{authorization:""},func:R=>R.postEventRaw({postEvent:{key:e,data:i}})});return s.error?((0,d.warn)("tracking error:"+JSON.stringify(s.error,null,2)),{error:JSON.stringify(s.error,null,2)}):{}},Q=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click",devMode:t,valueOverrides:n})=>{let o={pageLocation:"",browserFingerprint:n?.browserFingerprint};if(typeof window<"u"&&(o={...o,pageLocation:window.location.href,browserResolution:`${window.screen.width}:${window.screen.height}`}),typeof document<"u"&&(o={...o,pageReferrer:document.referrer,pageTitle:document.title}),typeof navigator<"u"&&(o={...o,browserLanguage:navigator.language}),!t&&typeof window<"u"&&window.location.hostname==="localhost")return(0,d.debug)(`local page ignored: ${JSON.stringify(o)}, to ${r}`),{};if(!o.pageLocation)return(0,d.warn)("no pageLocation"),{};let i=await Me({apiUrl:r,headers:{authorization:""},func:s=>s.postPageTrackRaw({postSiteTrack:{key:e,data:o}})});return i.error?((0,d.warn)("tracking error:"+JSON.stringify(i.error,null,2)),{error:JSON.stringify(i.error,null,2)}):{}};var Qe=require("ag-common/dist/common/helpers/log"),ze=require("react");var br=()=>{let e=(0,ze.useContext)(T);if(!e.analyticaToken){(0,Qe.warn)(S("useAnalytica"));let r=async()=>({error:"no token"});return{event:r,page:r}}return{event:r=>M({...r,...e}),page:r=>Q({...r,...e})}};0&&(module.exports={AnalyticaClickProvider,AnalyticaConfigContext,errorTrack,event,page,tokenMissing,useAnalytica});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "analytica.click",
3
- "version": "0.0.494",
3
+ "version": "0.0.496",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -9,17 +9,17 @@
9
9
  "dependencies": {
10
10
  "@emotion/react": "^11",
11
11
  "@emotion/styled": "^11",
12
- "@types/react": "^18",
13
- "ag-common": "^0.0.728",
12
+ "@types/react": "^19.0.0",
13
+ "ag-common": "^0.0.729",
14
14
  "cross-env": "^7",
15
15
  "cross-fetch": "^4.0.0",
16
16
  "nodemon": "^3",
17
- "react": "^18",
17
+ "react": "^19.0.0",
18
18
  "ts-node": "^10",
19
19
  "typescript": "^5"
20
20
  },
21
21
  "devDependencies": {
22
- "@types/node": "22.12.0",
22
+ "@types/node": "22.13.1",
23
23
  "esbuild": "0.24.2",
24
24
  "esbuild-node-externals": "1.16.0",
25
25
  "esbuild-plugin-d.ts": "1.1.0",
@@ -37,10 +37,10 @@
37
37
  "lint:tsc": "tsc --noEmit",
38
38
  "lint:eslint": "eslint src",
39
39
  "lint": "pnpm run /^lint:/",
40
- "build-direct": "rimraf .build && rimraf dist && cross-env NODE_ENV=prod ts-node esbuild",
40
+ "build-direct": "rimraf .build && rimraf dist && cross-env NODE_ENV=prod ts-node esbuild.ts",
41
41
  "build:debug": "cross-env NODE_ENV=development pnpm build-direct",
42
42
  "build": "pnpm run lint && pnpm build-direct",
43
- "build-test": "rimraf dist && cross-env NODE_ENV=development ts-node esbuild",
44
- "start": "cross-env NODE_ENV=development nodemon -e ts,tsx -w ./src --exec 'ts-node esbuild'"
43
+ "build-test": "rimraf dist && cross-env NODE_ENV=development ts-node esbuild.ts",
44
+ "start": "cross-env NODE_ENV=development nodemon -e ts,tsx -w ./src --exec 'ts-node esbuild.ts'"
45
45
  }
46
46
  }