analytica.click 0.0.431 → 0.0.432

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,7 +1,7 @@
1
1
  import type { IAnalyticaConfig } from 'common-ui/src/types/widgets';
2
2
  import React from 'react';
3
3
  export declare const AnalyticaConfigContext: React.Context<IAnalyticaConfig>;
4
- export declare const AnalyticaConfigProvider: ({ children, values, }: {
4
+ export declare const AnalyticaClickProvider: ({ children, values, }: {
5
5
  children: React.ReactNode;
6
6
  values: IAnalyticaConfig;
7
7
  }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import type { TErrorMessage } from 'common-ui/src/types/widgets';
2
+ import React, { Component } from 'react';
3
+ export interface IErrorBoundaryProps {
4
+ notify?: TErrorMessage;
5
+ children?: React.ReactNode;
6
+ }
7
+ export declare class ErrorBoundary extends Component<IErrorBoundaryProps, {
8
+ hasError: ErrorEvent | undefined;
9
+ }> {
10
+ seenError: boolean;
11
+ constructor(props: any);
12
+ static getDerivedStateFromError(errorV: any): {
13
+ hasError: any;
14
+ };
15
+ render(): string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
16
+ }
@@ -1,5 +1,4 @@
1
- /// <reference types="react" />
2
- export declare const ErrorBoundary: ({ children, filterBrowserError, }: {
3
- children?: JSX.Element | JSX.Element[] | undefined;
4
- filterBrowserError?: ((e: ErrorEvent | Error) => boolean) | undefined;
1
+ import React from 'react';
2
+ export declare const ErrorBoundary: ({ children, }: {
3
+ children?: React.ReactNode;
5
4
  }) => JSX.Element;
@@ -1,2 +1 @@
1
- export * from './AnalyticaConfig';
2
- export * from './ErrorBoundary';
1
+ export * from './AnalyticaClickProvider';
@@ -0,0 +1,6 @@
1
+ import type { IAnalyticaConfig } from 'common-ui/src/types';
2
+ export declare function onBrowserError({ ev: { error: { message, stack }, filename, }, values, }: {
3
+ ev: ErrorEvent;
4
+ values: IAnalyticaConfig;
5
+ }): Promise<void>;
6
+ export declare function OverloadBrowser(values: IAnalyticaConfig): void;
@@ -0,0 +1,2 @@
1
+ import type { IAnalyticaConfig } from 'common-ui/src/types';
2
+ export declare function OverloadConsole(values: IAnalyticaConfig): void;
@@ -1,5 +1,7 @@
1
1
  import type { PostError } from 'common-ui/src/types/api';
2
- export declare const errorTrack: ({ data, overrideBaseUrl, }: {
2
+ export declare const errorTrack: ({ data, overrideBaseUrl, ignoreBrowserErrors, }: {
3
3
  data: PostError;
4
4
  overrideBaseUrl?: string | undefined;
5
- }) => Promise<{}>;
5
+ /** will ignore any errors that contain these strings */
6
+ ignoreBrowserErrors?: string[] | undefined;
7
+ }) => Promise<{} | undefined>;
package/dist/index.d.ts CHANGED
@@ -1,32 +1,65 @@
1
- declare module 'analytica.click/analytica.click/src/components/AnalyticaConfig/index' {
1
+ declare module 'analytica.click/analytica.click/src/components/AnalyticaClickProvider/index' {
2
2
  import type { IAnalyticaConfig } from 'common-ui/src/types/widgets';
3
3
  import React from 'react';
4
4
  export const AnalyticaConfigContext: React.Context<IAnalyticaConfig>;
5
- export const AnalyticaConfigProvider: ({ children, values, }: {
5
+ export const AnalyticaClickProvider: ({ children, values, }: {
6
6
  children: React.ReactNode;
7
7
  values: IAnalyticaConfig;
8
8
  }) => import("react/jsx-runtime").JSX.Element;
9
9
 
10
+ }
11
+ declare module 'analytica.click/analytica.click/src/components/ErrorBoundary/Comp' {
12
+ import type { TErrorMessage } from 'common-ui/src/types/widgets';
13
+ import React, { Component } from 'react';
14
+ export interface IErrorBoundaryProps {
15
+ notify?: TErrorMessage;
16
+ children?: React.ReactNode;
17
+ }
18
+ export class ErrorBoundary extends Component<IErrorBoundaryProps, {
19
+ hasError: ErrorEvent | undefined;
20
+ }> {
21
+ seenError: boolean;
22
+ constructor(props: any);
23
+ static getDerivedStateFromError(errorV: any): {
24
+ hasError: any;
25
+ };
26
+ render(): string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
27
+ }
28
+
10
29
  }
11
30
  declare module 'analytica.click/analytica.click/src/components/ErrorBoundary/index' {
12
- /// <reference types="react" />
13
- export const ErrorBoundary: ({ children, filterBrowserError, }: {
14
- children?: JSX.Element | JSX.Element[] | undefined;
15
- filterBrowserError?: ((e: ErrorEvent | Error) => boolean) | undefined;
31
+ import React from 'react';
32
+ export const ErrorBoundary: ({ children, }: {
33
+ children?: React.ReactNode;
16
34
  }) => JSX.Element;
17
35
 
18
36
  }
19
37
  declare module 'analytica.click/analytica.click/src/components/index' {
20
- export * from 'analytica.click/analytica.click/src/components/AnalyticaConfig/index';
21
- export * from 'analytica.click/analytica.click/src/components/ErrorBoundary/index';
38
+ export * from 'analytica.click/analytica.click/src/components/AnalyticaClickProvider/index';
39
+
40
+ }
41
+ declare module 'analytica.click/analytica.click/src/helpers/browser' {
42
+ import type { IAnalyticaConfig } from 'common-ui/src/types';
43
+ export function onBrowserError({ ev: { error: { message, stack }, filename, }, values, }: {
44
+ ev: ErrorEvent;
45
+ values: IAnalyticaConfig;
46
+ }): Promise<void>;
47
+ export function OverloadBrowser(values: IAnalyticaConfig): void;
48
+
49
+ }
50
+ declare module 'analytica.click/analytica.click/src/helpers/console' {
51
+ import type { IAnalyticaConfig } from 'common-ui/src/types';
52
+ export function OverloadConsole(values: IAnalyticaConfig): void;
22
53
 
23
54
  }
24
55
  declare module 'analytica.click/analytica.click/src/helpers/errorTrack' {
25
56
  import type { PostError } from 'common-ui/src/types/api';
26
- export const errorTrack: ({ data, overrideBaseUrl, }: {
57
+ export const errorTrack: ({ data, overrideBaseUrl, ignoreBrowserErrors, }: {
27
58
  data: PostError;
28
59
  overrideBaseUrl?: string | undefined;
29
- }) => Promise<{}>;
60
+ /** will ignore any errors that contain these strings */
61
+ ignoreBrowserErrors?: string[] | undefined;
62
+ }) => Promise<{} | undefined>;
30
63
 
31
64
  }
32
65
  declare module 'analytica.click/analytica.click/src/helpers/index' {
@@ -98,11 +131,13 @@ declare module 'analytica.click/common-ui/src/types/widgets' {
98
131
  overrideBaseUrl?: string;
99
132
  eventName: string;
100
133
  }
101
- export type TErrorMessage = (m: Error | ErrorEvent) => Promise<void>;
134
+ export type TErrorMessage = (m: ErrorEvent) => Promise<void>;
102
135
  export interface IAnalyticaConfig {
103
136
  analyticaToken?: string;
104
137
  overrideBaseUrl?: string;
105
138
  devMode?: boolean;
139
+ /** ignore any browser errors that include these words */
140
+ ignoreBrowserErrors?: string[];
106
141
  }
107
142
 
108
143
  }
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- 'use client';"use strict";var Ee=Object.create;var h=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var be=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty;var De=(e,r)=>{for(var t in r)h(e,t,{get:r[t],enumerable:!0})},V=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Je(r))!ke.call(e,o)&&o!==t&&h(e,o,{get:()=>r[o],enumerable:!(n=Pe(r,o))||n.enumerable});return e};var b=(e,r,t)=>(t=e!=null?Ee(be(e)):{},V(r||!e||!e.__esModule?h(t,"default",{value:e,enumerable:!0}):t,e)),Fe=e=>V(h({},"__esModule",{value:!0}),e);var mr={};De(mr,{AnalyticaConfigContext:()=>m,AnalyticaConfigProvider:()=>ur,ErrorBoundary:()=>dr,errorTrack:()=>d,page:()=>C,tokenMissing:()=>R,track:()=>J,useTrack:()=>fr});module.exports=Fe(mr);var O=require("react");var B=require("ag-common/dist/common/helpers/log"),A=require("ag-common/dist/ui/helpers/callOpenApi");var qe="https://api.analytica.click".replace(/\/+$/,""),Ie=e=>typeof Blob<"u"&&e instanceof Blob,S=class{constructor(r=new k){this.configuration=r;this.fetchApi=async(r,t)=>{let n={url:r,init:t};for(let a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o=await(this.configuration.fetchApi||fetch)(n.url,n.init);for(let a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o};this.middleware=r.middleware||[]}withMiddleware(...r){let t=this.clone();return t.middleware=t.middleware.concat(...r),t}withPreMiddleware(...r){let t=r.map(n=>({pre:n}));return this.withMiddleware(...t)}withPostMiddleware(...r){let t=r.map(n=>({post:n}));return this.withMiddleware(...t)}async request(r,t){let{url:n,init:o}=this.createFetchParams(r,t),a=await this.fetchApi(n,o);if(a.status>=200&&a.status<300)return a;throw a}createFetchParams(r,t){let n=this.configuration.basePath+r.path;r.query!==void 0&&Object.keys(r.query).length!==0&&(n+="?"+(this.configuration.queryParamsStringify||D)(r.query));let o=typeof FormData<"u"&&r.body instanceof FormData||r.body instanceof URLSearchParams||Ie(r.body)?r.body:JSON.stringify(r.body),a=Object.assign({},this.configuration.headers,r.headers),u={method:r.method,headers:a,body:o,credentials:this.configuration.credentials,...t};return{url:n,init:u}}clone(){let r=this.constructor,t=new r(this.configuration);return t.middleware=this.middleware.slice(),t}},s=class extends Error{constructor(t,n){super(n);this.field=t;this.name="RequiredError"}};var k=class{constructor(r={}){this.configuration=r}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:qe}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||D}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){let r=this.configuration.apiKey;if(r)return typeof r=="function"?r:()=>r}get accessToken(){let r=this.configuration.accessToken;if(r)return typeof r=="function"?r:async()=>r}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}};function i(e,r){let t=e[r];return t!=null}function D(e,r=""){return Object.keys(e).map(t=>{let n=r+(r.length?`[${t}]`:t),o=e[t];if(o instanceof Array){let a=o.map(u=>encodeURIComponent(String(u))).join(`&${encodeURIComponent(n)}=`);return`${encodeURIComponent(n)}=${a}`}return o instanceof Date?`${encodeURIComponent(n)}=${encodeURIComponent(o.toISOString())}`:o instanceof Object?D(o,n):`${encodeURIComponent(n)}=${encodeURIComponent(String(o))}`}).filter(t=>t.length>0).join("&")}var l=class{constructor(r,t=n=>n){this.raw=r;this.transformer=t}async value(){return this.transformer(await this.raw.json())}},c=class{constructor(r){this.raw=r}async value(){}};function H(e){if(e!==void 0)return e===null?null:{PKsB64:e.PKsB64}}function Q(e){if(e!==void 0)return e===null?null:{key:e.key,account:e.account}}function M(e){return Be(e,!1)}function Be(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,browser:e.browser,count:e.count,category:e.category}}function U(e){if(e!==void 0)return e===null?null:{site:e.site}}function z(e){return Ke(e,!1)}function Ke(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,site:e.site,eventName:e.eventName,datetime:e.datetime,count:e.count,category:e.category}}function w(e){return Ge(e,!1)}function Ge(e,r){return e==null?e:{site:e.site,account:e.account,apiKey:e.apiKey,adminApiKey:e.adminApiKey,favicon:i(e,"favicon")?e.favicon:void 0}}function $(e){return Ve(e,!1)}function Ve(e,r){return e==null?e:{accounts:e.accounts.map(w),googleEmail:i(e,"googleEmail")?e.googleEmail:void 0,googleKey:i(e,"googleKey")?e.googleKey:void 0,bingKey:i(e,"bingKey")?e.bingKey:void 0,bingAccount:i(e,"bingAccount")?e.bingAccount:void 0}}function W(e){if(e!==void 0)return e===null?null:{email:e.email,key:e.key,account:e.account}}function X(e){return He(e,!1)}function He(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,language:e.language,count:e.count,category:e.category}}function _(e){return Qe(e,!1)}function Qe(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,countryRegion:e.countryRegion,category:e.category,count:e.count}}function Y(e){return Me(e,!1)}function Me(e,r){return e==null?e:{PK:e.PK,messageHash:i(e,"messageHash")?e.messageHash:void 0,site:e.site,account:e.account,message:i(e,"message")?e.message:void 0,name:i(e,"name")?e.name:void 0,stack:i(e,"stack")?e.stack:void 0,href:e.href,filename:i(e,"filename")?e.filename:void 0,datetime:e.datetime,archived:i(e,"archived")?e.archived:void 0,count:e.count,category:e.category}}function Z(e){if(e!==void 0)return e===null?null:{site:e.site}}function v(e){if(e!==void 0)return e===null?null:{key:e.key,data:j(e.data)}}function j(e){if(e!==void 0)return e===null?null:{message:e.message,name:e.name,stack:e.stack,href:e.href,filename:e.filename}}function ee(e){if(e!==void 0)return e===null?null:{key:e.key,data:re(e.data)}}function re(e){if(e!==void 0)return e===null?null:{eventName:e.eventName,pageLocation:e.pageLocation,pageReferrer:e.pageReferrer,pageTitle:e.pageTitle,browserResolution:e.browserResolution,browserLanguage:e.browserLanguage}}function te(e){return Ue(e,!1)}function Ue(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,pathName:e.pathName,search:i(e,"search")?e.search:void 0,hash:i(e,"hash")?e.hash:void 0,count:e.count,category:e.category}}function ne(e){return ze(e,!1)}function ze(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,referrer:e.referrer,count:e.count,category:e.category}}function oe(e){return $e(e,!1)}function $e(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,resolution:e.resolution,count:e.count,category:e.category}}function ie(e){return We(e,!1)}function We(e,r){return e==null?e:{account:e.account,site:e.site,datetime:e.datetime,category:e.category,topReferrers:i(e,"topReferrers")?e.topReferrers.map(le):void 0,topResolutions:i(e,"topResolutions")?e.topResolutions.map(fe):void 0,topQueries:i(e,"topQueries")?e.topQueries.map(de):void 0,topLocations:i(e,"topLocations")?e.topLocations.map(pe):void 0,topBrowsers:i(e,"topBrowsers")?e.topBrowsers.map(ae):void 0,topEvents:i(e,"topEvents")?e.topEvents.map(ue):void 0,topLanguages:i(e,"topLanguages")?e.topLanguages.map(ce):void 0,topErrors:i(e,"topErrors")?e.topErrors.map(se):void 0}}function ae(e){return Xe(e,!1)}function Xe(e,r){return e==null?e:{browser:e.browser,count:e.count}}function se(e){return _e(e,!1)}function _e(e,r){return e==null?e:{href:e.href,count:e.count}}function ue(e){return Ye(e,!1)}function Ye(e,r){return e==null?e:{eventName:e.eventName,count:e.count}}function ce(e){return Ze(e,!1)}function Ze(e,r){return e==null?e:{language:e.language,count:e.count}}function pe(e){return ve(e,!1)}function ve(e,r){return e==null?e:{countryRegion:e.countryRegion,count:e.count}}function de(e){return je(e,!1)}function je(e,r){return e==null?e:{pathName:e.pathName,count:e.count}}function le(e){return er(e,!1)}function er(e,r){return e==null?e:{referrer:e.referrer,count:e.count}}function fe(e){return rr(e,!1)}function rr(e,r){return e==null?e:{resolution:e.resolution,count:e.count}}function q(e){return tr(e,!1)}function tr(e,r){return e==null?e:{account:e.account,email:e.email,site:e.site,datetime:e.datetime,category:e.category,totals:F(e.totals),queries:e.queries.map(F)}}function F(e){return nr(e,!1)}function nr(e,r){return e==null?e:{clicks:e.clicks,impressions:e.impressions,position:e.position,query:e.query}}function I(e){return or(e,!1)}function or(e,r){return e==null?e:{details:i(e,"details")?w(e.details):void 0,browsers:i(e,"browsers")?e.browsers.map(M):void 0,events:i(e,"events")?e.events.map(z):void 0,locations:i(e,"locations")?e.locations.map(_):void 0,queries:i(e,"queries")?e.queries.map(te):void 0,referrers:i(e,"referrers")?e.referrers.map(ne):void 0,resolutions:i(e,"resolutions")?e.resolutions.map(oe):void 0,languages:i(e,"languages")?e.languages.map(X):void 0,rollups:i(e,"rollups")?e.rollups.map(ie):void 0,errors:i(e,"errors")?e.errors.map(Y):void 0,google:i(e,"google")?e.google.map(q):void 0,bing:i(e,"bing")?e.bing.map(q):void 0}}var f=class extends S{async accountGetRaw(r){let t={},n={};this.configuration&&this.configuration.apiKey&&(n.authorization=this.configuration.apiKey("authorization"));let o=await this.request({path:"/account",method:"GET",headers:n,query:t},r);return new l(o,a=>$(a))}async accountGet(r){return await(await this.accountGetRaw(r)).value()}async archiveErrorRaw(r,t){if(r.id===null||r.id===void 0)throw new s("id","Required parameter requestParameters.id was null or undefined when calling archiveError.");let n={},o={};this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/errors/{id}".replace("{id}",encodeURIComponent(String(r.id))),method:"DELETE",headers:o,query:n},t);return new c(a)}async archiveError(r,t){await this.archiveErrorRaw(r,t)}async archiveErrorsRaw(r,t){if(r.archiveErrors===null||r.archiveErrors===void 0)throw new s("archiveErrors","Required parameter requestParameters.archiveErrors was null or undefined when calling archiveErrors.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/errors",method:"DELETE",headers:o,query:n,body:H(r.archiveErrors)},t);return new c(a)}async archiveErrors(r,t){await this.archiveErrorsRaw(r,t)}async bingIntegrationPostRaw(r,t){if(r.bingIntegration===null||r.bingIntegration===void 0)throw new s("bingIntegration","Required parameter requestParameters.bingIntegration was null or undefined when calling bingIntegrationPost.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/integrations/bing",method:"POST",headers:o,query:n,body:Q(r.bingIntegration)},t);return new c(a)}async bingIntegrationPost(r,t){await this.bingIntegrationPostRaw(r,t)}async getTrackingAllSitesRaw(r,t){if(r.minDate===null||r.minDate===void 0)throw new s("minDate","Required parameter requestParameters.minDate was null or undefined when calling getTrackingAllSites.");if(r.maxDate===null||r.maxDate===void 0)throw new s("maxDate","Required parameter requestParameters.maxDate was null or undefined when calling getTrackingAllSites.");let n={};r.minDate!==void 0&&(n.minDate=r.minDate),r.maxDate!==void 0&&(n.maxDate=r.maxDate);let o={};this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/site/tracking",method:"GET",headers:o,query:n},t);return new l(a,u=>u.map(I))}async getTrackingAllSites(r,t){return await(await this.getTrackingAllSitesRaw(r,t)).value()}async getTrackingSiteRaw(r,t){if(r.id===null||r.id===void 0)throw new s("id","Required parameter requestParameters.id was null or undefined when calling getTrackingSite.");if(r.minDate===null||r.minDate===void 0)throw new s("minDate","Required parameter requestParameters.minDate was null or undefined when calling getTrackingSite.");if(r.maxDate===null||r.maxDate===void 0)throw new s("maxDate","Required parameter requestParameters.maxDate was null or undefined when calling getTrackingSite.");let n={};r.minDate!==void 0&&(n.minDate=r.minDate),r.maxDate!==void 0&&(n.maxDate=r.maxDate);let o={};this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/site/tracking/{id}".replace("{id}",encodeURIComponent(String(r.id))),method:"GET",headers:o,query:n},t);return new l(a,u=>I(u))}async getTrackingSite(r,t){return await(await this.getTrackingSiteRaw(r,t)).value()}async googleIntegrationPostRaw(r,t){if(r.googleIntegration===null||r.googleIntegration===void 0)throw new s("googleIntegration","Required parameter requestParameters.googleIntegration was null or undefined when calling googleIntegrationPost.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/integrations/google",method:"POST",headers:o,query:n,body:W(r.googleIntegration)},t);return new c(a)}async googleIntegrationPost(r,t){await this.googleIntegrationPostRaw(r,t)}async postErrorsRaw(r,t){if(r.postError===null||r.postError===void 0)throw new s("postError","Required parameter requestParameters.postError was null or undefined when calling postErrors.");let n={},o={};o["Content-Type"]="application/json";let a=await this.request({path:"/errors",method:"POST",headers:o,query:n,body:r.postError.map(v)},t);return new c(a)}async postErrors(r,t){await this.postErrorsRaw(r,t)}async postPageTrackRaw(r,t){if(r.postSiteTrack===null||r.postSiteTrack===void 0)throw new s("postSiteTrack","Required parameter requestParameters.postSiteTrack was null or undefined when calling postPageTrack.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/site",method:"POST",headers:o,query:n,body:ee(r.postSiteTrack)},t);return new c(a)}async postPageTrack(r,t){await this.postPageTrackRaw(r,t)}async siteDeleteRaw(r,t){if(r.deleteAccount===null||r.deleteAccount===void 0)throw new s("deleteAccount","Required parameter requestParameters.deleteAccount was null or undefined when calling siteDelete.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/site",method:"DELETE",headers:o,query:n,body:U(r.deleteAccount)},t);return new c(a)}async siteDelete(r,t){await this.siteDeleteRaw(r,t)}async sitePostRaw(r,t){if(r.postAccount===null||r.postAccount===void 0)throw new s("postAccount","Required parameter requestParameters.postAccount was null or undefined when calling sitePost.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/site",method:"POST",headers:o,query:n,body:Z(r.postAccount)},t);return new c(a)}async sitePost(r,t){await this.sitePostRaw(r,t)}};var L=require("ag-common/dist/common/helpers/hashCode"),T=require("ag-common/dist/common/helpers/log");function me(e){return e?e.match(/^"?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}"?$/)?((0,T.info)("ignoring react devtools message"),!1):e===JSON.stringify([{}])?((0,T.info)("empty message payload?"),!1):!0:((0,T.info)("no message?"),!1)}var ge=(e="")=>{let r="";try{let t=JSON.parse(e);Array.isArray(t)&&t[0]?.match(/^\[?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}\]?$/)?((0,T.info)("removing date from hash"),t[0]="(date)",r=(0,L.hashCode)(JSON.stringify(t))):r=t.message??t.name??t.description??void 0}catch{}return r||(r=(0,L.hashCode)(e)?.toString()??""),r};var ye=(e,r)=>{let t=[],n={},o=0;return Object.entries(e).forEach(([a,u])=>{o<r?t.push(u):n[a]=u,o+=1}),{part:t,rest:n}};function Te(e){return(0,A.callOpenApi)({...e,func:r=>(0,A.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new f(r),logout:()=>window.location.reload(),refreshToken:async()=>{}})}var ir=typeof window<"u"&&window?.location?.hostname==="localhost",p={},x,K,Re=async()=>{try{if(Object.keys(p).length>100){let n=Object.keys(p)[0],o=p[n],a=await Te({headers:{authorization:""},apiUrl:K,func:u=>u.postErrorsRaw({postError:[{key:o.key,data:{...o.data,message:`error overload!: ${o.data.message??"?"}`}}]})});if(p={},a.error)throw a.error;return{}}let{part:e,rest:r}=ye(p,10);p=r;let t=await Te({headers:{authorization:""},apiUrl:K,func:n=>n.postErrorsRaw({postError:e})});if(t.error)throw t.error}catch(e){let r=e,t=r;return{error:r?.error?.message??t.message}}finally{p.length?x=setTimeout(Re,1e3):x=void 0}},d=async({data:e,overrideBaseUrl:r="https://api.analytica.click"})=>{if(ir)return(0,B.debug)(`local error tracking ignored:${e.data.message} ${JSON.stringify(e)}, to ${r}`),{};if(!me(e?.data?.message))return{};(0,B.debug)("error track",e.data.message,JSON.stringify(e));let t=ge(e.data.message);return p[t]=e,K=r,x||(x=setTimeout(Re,500)),{}};var Se=require("react/jsx-runtime"),ar={analyticaToken:void 0,overrideBaseUrl:void 0},m=(0,O.createContext)(ar),he=!1;function sr(e){if(!e.analyticaToken||he)return;he=!0;let r=window.console.error;window.console.error=(...n)=>{d({data:{data:{href:window.location.href,message:JSON.stringify(n)},key:e.analyticaToken},overrideBaseUrl:e.overrideBaseUrl}),r(...n)};let t=window.console.warn;window.console.warn=(...n)=>{d({data:{data:{href:window.location.href,message:JSON.stringify(n)},key:e.analyticaToken},overrideBaseUrl:e.overrideBaseUrl}),t(...n)}}var ur=({children:e,values:r})=>((0,O.useEffect)(()=>{sr(r)},[]),(0,Se.jsx)(m.Provider,{value:r,children:e}));var Ae=require("ag-common/dist/common/helpers/log");var we=b(require("@emotion/styled")),xe=require("ag-common/dist/ui/components/Modal"),g=b(require("react")),cr=we.default.div`
1
+ 'use client';"use strict";var Fe=Object.create;var R=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Ie=Object.getOwnPropertyNames;var Le=Object.getPrototypeOf,Be=Object.prototype.hasOwnProperty;var Ke=(e,r)=>{for(var t in r)R(e,t,{get:r[t],enumerable:!0})},V=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Ie(r))!Be.call(e,o)&&o!==t&&R(e,o,{get:()=>r[o],enumerable:!(n=qe(r,o))||n.enumerable});return e};var H=(e,r,t)=>(t=e!=null?Fe(Le(e)):{},V(r||!e||!e.__esModule?R(t,"default",{value:e,enumerable:!0}):t,e)),Ce=e=>V(R({},"__esModule",{value:!0}),e);var Tr={};Ke(Tr,{AnalyticaClickProvider:()=>mr,AnalyticaConfigContext:()=>m,errorTrack:()=>f,page:()=>G,tokenMissing:()=>y,track:()=>J,useTrack:()=>yr});module.exports=Ce(Tr);var be=require("react");var Ee=require("ag-common/dist/common/helpers/log"),N=H(require("react"));var Se=require("react");var w=require("ag-common/dist/common/helpers/log"),A=require("ag-common/dist/ui/helpers/callOpenApi");var Ge="https://api.analytica.click".replace(/\/+$/,""),Ve=e=>typeof Blob<"u"&&e instanceof Blob,h=class{constructor(r=new b){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||k)(r.query));let o=typeof FormData<"u"&&r.body instanceof FormData||r.body instanceof URLSearchParams||Ve(r.body)?r.body:JSON.stringify(r.body),a=Object.assign({},this.configuration.headers,r.headers),u={method:r.method,headers:a,body:o,credentials:this.configuration.credentials,...t};return{url:n,init:u}}clone(){let r=this.constructor,t=new r(this.configuration);return t.middleware=this.middleware.slice(),t}},s=class extends Error{constructor(t,n){super(n);this.field=t;this.name="RequiredError"}};var b=class{constructor(r={}){this.configuration=r}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Ge}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||k}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 k(e,r=""){return Object.keys(e).map(t=>{let n=r+(r.length?`[${t}]`:t),o=e[t];if(o instanceof Array){let a=o.map(u=>encodeURIComponent(String(u))).join(`&${encodeURIComponent(n)}=`);return`${encodeURIComponent(n)}=${a}`}return o instanceof Date?`${encodeURIComponent(n)}=${encodeURIComponent(o.toISOString())}`:o instanceof Object?k(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 Q(e){if(e!==void 0)return e===null?null:{PKsB64:e.PKsB64}}function M(e){if(e!==void 0)return e===null?null:{key:e.key,account:e.account}}function U(e){return Qe(e,!1)}function Qe(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,browser:e.browser,count:e.count,category:e.category}}function z(e){if(e!==void 0)return e===null?null:{site:e.site}}function $(e){return Me(e,!1)}function Me(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 S(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 W(e){return $e(e,!1)}function $e(e,r){return e==null?e:{accounts:e.accounts.map(S),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){if(e!==void 0)return e===null?null:{email:e.email,key:e.key,account:e.account}}function X(e){return We(e,!1)}function We(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,language:e.language,count:e.count,category:e.category}}function Y(e){return _e(e,!1)}function _e(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,countryRegion:e.countryRegion,category:e.category,count:e.count}}function Z(e){return Xe(e,!1)}function Xe(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 v(e){if(e!==void 0)return e===null?null:{site:e.site}}function j(e){if(e!==void 0)return e===null?null:{key:e.key,data:ee(e.data)}}function ee(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 re(e){if(e!==void 0)return e===null?null:{key:e.key,data:te(e.data)}}function te(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 ne(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,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 oe(e){return Ze(e,!1)}function Ze(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,referrer:e.referrer,count:e.count,category:e.category}}function ie(e){return ve(e,!1)}function ve(e,r){return e==null?e:{account:i(e,"account")?e.account:void 0,datetime:e.datetime,site:e.site,resolution:e.resolution,count:e.count,category:e.category}}function ae(e){return je(e,!1)}function je(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(fe):void 0,topResolutions:i(e,"topResolutions")?e.topResolutions.map(me):void 0,topQueries:i(e,"topQueries")?e.topQueries.map(le):void 0,topLocations:i(e,"topLocations")?e.topLocations.map(de):void 0,topBrowsers:i(e,"topBrowsers")?e.topBrowsers.map(se):void 0,topEvents:i(e,"topEvents")?e.topEvents.map(ce):void 0,topLanguages:i(e,"topLanguages")?e.topLanguages.map(pe):void 0,topErrors:i(e,"topErrors")?e.topErrors.map(ue):void 0}}function se(e){return er(e,!1)}function er(e,r){return e==null?e:{browser:e.browser,count:e.count}}function ue(e){return rr(e,!1)}function rr(e,r){return e==null?e:{href:e.href,count:e.count}}function ce(e){return tr(e,!1)}function tr(e,r){return e==null?e:{eventName:e.eventName,count:e.count}}function pe(e){return nr(e,!1)}function nr(e,r){return e==null?e:{language:e.language,count:e.count}}function de(e){return or(e,!1)}function or(e,r){return e==null?e:{countryRegion:e.countryRegion,count:e.count}}function le(e){return ir(e,!1)}function ir(e,r){return e==null?e:{pathName:e.pathName,count:e.count}}function fe(e){return ar(e,!1)}function ar(e,r){return e==null?e:{referrer:e.referrer,count:e.count}}function me(e){return sr(e,!1)}function sr(e,r){return e==null?e:{resolution:e.resolution,count:e.count}}function F(e){return ur(e,!1)}function ur(e,r){return e==null?e:{account:e.account,email:e.email,site:e.site,datetime:e.datetime,category:e.category,totals:D(e.totals),queries:e.queries.map(D)}}function D(e){return cr(e,!1)}function cr(e,r){return e==null?e:{clicks:e.clicks,impressions:e.impressions,position:e.position,query:e.query}}function q(e){return pr(e,!1)}function pr(e,r){return e==null?e:{details:i(e,"details")?S(e.details):void 0,browsers:i(e,"browsers")?e.browsers.map(U):void 0,events:i(e,"events")?e.events.map($):void 0,locations:i(e,"locations")?e.locations.map(Y):void 0,queries:i(e,"queries")?e.queries.map(ne):void 0,referrers:i(e,"referrers")?e.referrers.map(oe):void 0,resolutions:i(e,"resolutions")?e.resolutions.map(ie):void 0,languages:i(e,"languages")?e.languages.map(X):void 0,rollups:i(e,"rollups")?e.rollups.map(ae):void 0,errors:i(e,"errors")?e.errors.map(Z):void 0,google:i(e,"google")?e.google.map(F):void 0,bing:i(e,"bing")?e.bing.map(F):void 0}}var l=class extends h{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,a=>W(a))}async accountGet(r){return await(await this.accountGetRaw(r)).value()}async archiveErrorRaw(r,t){if(r.id===null||r.id===void 0)throw new s("id","Required parameter requestParameters.id was null or undefined when calling archiveError.");let n={},o={};this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/errors/{id}".replace("{id}",encodeURIComponent(String(r.id))),method:"DELETE",headers:o,query:n},t);return new c(a)}async archiveError(r,t){await this.archiveErrorRaw(r,t)}async archiveErrorsRaw(r,t){if(r.archiveErrors===null||r.archiveErrors===void 0)throw new s("archiveErrors","Required parameter requestParameters.archiveErrors was null or undefined when calling archiveErrors.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/errors",method:"DELETE",headers:o,query:n,body:Q(r.archiveErrors)},t);return new c(a)}async archiveErrors(r,t){await this.archiveErrorsRaw(r,t)}async bingIntegrationPostRaw(r,t){if(r.bingIntegration===null||r.bingIntegration===void 0)throw new s("bingIntegration","Required parameter requestParameters.bingIntegration was null or undefined when calling bingIntegrationPost.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/integrations/bing",method:"POST",headers:o,query:n,body:M(r.bingIntegration)},t);return new c(a)}async bingIntegrationPost(r,t){await this.bingIntegrationPostRaw(r,t)}async getTrackingAllSitesRaw(r,t){if(r.minDate===null||r.minDate===void 0)throw new s("minDate","Required parameter requestParameters.minDate was null or undefined when calling getTrackingAllSites.");if(r.maxDate===null||r.maxDate===void 0)throw new s("maxDate","Required parameter requestParameters.maxDate was null or undefined when calling getTrackingAllSites.");let n={};r.minDate!==void 0&&(n.minDate=r.minDate),r.maxDate!==void 0&&(n.maxDate=r.maxDate);let o={};this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/site/tracking",method:"GET",headers:o,query:n},t);return new d(a,u=>u.map(q))}async getTrackingAllSites(r,t){return await(await this.getTrackingAllSitesRaw(r,t)).value()}async getTrackingSiteRaw(r,t){if(r.id===null||r.id===void 0)throw new s("id","Required parameter requestParameters.id was null or undefined when calling getTrackingSite.");if(r.minDate===null||r.minDate===void 0)throw new s("minDate","Required parameter requestParameters.minDate was null or undefined when calling getTrackingSite.");if(r.maxDate===null||r.maxDate===void 0)throw new s("maxDate","Required parameter requestParameters.maxDate was null or undefined when calling getTrackingSite.");let n={};r.minDate!==void 0&&(n.minDate=r.minDate),r.maxDate!==void 0&&(n.maxDate=r.maxDate);let o={};this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/site/tracking/{id}".replace("{id}",encodeURIComponent(String(r.id))),method:"GET",headers:o,query:n},t);return new d(a,u=>q(u))}async getTrackingSite(r,t){return await(await this.getTrackingSiteRaw(r,t)).value()}async googleIntegrationPostRaw(r,t){if(r.googleIntegration===null||r.googleIntegration===void 0)throw new s("googleIntegration","Required parameter requestParameters.googleIntegration was null or undefined when calling googleIntegrationPost.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/integrations/google",method:"POST",headers:o,query:n,body:_(r.googleIntegration)},t);return new c(a)}async googleIntegrationPost(r,t){await this.googleIntegrationPostRaw(r,t)}async postErrorsRaw(r,t){if(r.postError===null||r.postError===void 0)throw new s("postError","Required parameter requestParameters.postError was null or undefined when calling postErrors.");let n={},o={};o["Content-Type"]="application/json";let a=await this.request({path:"/errors",method:"POST",headers:o,query:n,body:r.postError.map(j)},t);return new c(a)}async postErrors(r,t){await this.postErrorsRaw(r,t)}async postPageTrackRaw(r,t){if(r.postSiteTrack===null||r.postSiteTrack===void 0)throw new s("postSiteTrack","Required parameter requestParameters.postSiteTrack was null or undefined when calling postPageTrack.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/site",method:"POST",headers:o,query:n,body:re(r.postSiteTrack)},t);return new c(a)}async postPageTrack(r,t){await this.postPageTrackRaw(r,t)}async siteDeleteRaw(r,t){if(r.deleteAccount===null||r.deleteAccount===void 0)throw new s("deleteAccount","Required parameter requestParameters.deleteAccount was null or undefined when calling siteDelete.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/site",method:"DELETE",headers:o,query:n,body:z(r.deleteAccount)},t);return new c(a)}async siteDelete(r,t){await this.siteDeleteRaw(r,t)}async sitePostRaw(r,t){if(r.postAccount===null||r.postAccount===void 0)throw new s("postAccount","Required parameter requestParameters.postAccount was null or undefined when calling sitePost.");let n={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o.authorization=this.configuration.apiKey("authorization"));let a=await this.request({path:"/account/site",method:"POST",headers:o,query:n,body:v(r.postAccount)},t);return new c(a)}async sitePost(r,t){await this.sitePostRaw(r,t)}};var I=require("ag-common/dist/common/helpers/hashCode"),g=require("ag-common/dist/common/helpers/log");function ge(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 ye=(e="")=>{let r="";try{let t=JSON.parse(e);Array.isArray(t)&&t[0]?.match(/^\[?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}\]?$/)?((0,g.info)("removing date from hash"),t[0]="(date)",r=(0,I.hashCode)(JSON.stringify(t))):r=t.message??t.name??t.description??void 0}catch{}return r||(r=(0,I.hashCode)(e)?.toString()??""),r};var Te=(e,r)=>{let t=[],n={},o=0;return Object.entries(e).forEach(([a,u])=>{o<r?t.push(u):n[a]=u,o+=1}),{part:t,rest:n}};function Re(e){return(0,A.callOpenApi)({...e,func:r=>(0,A.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new l(r),logout:()=>window.location.reload(),refreshToken:async()=>{}})}var dr=typeof window<"u"&&window?.location?.hostname==="localhost",p={},x,L,he=async()=>{try{if(Object.keys(p).length>100){let n=Object.keys(p)[0],o=p[n],a=await Re({headers:{authorization:""},apiUrl:L,func:u=>u.postErrorsRaw({postError:[{key:o.key,data:{...o.data,message:`error overload!: ${o.data.message??"?"}`}}]})});if(p={},a.error)throw a.error;return{}}let{part:e,rest:r}=Te(p,10);p=r;let t=await Re({headers:{authorization:""},apiUrl:L,func:n=>n.postErrorsRaw({postError:e})});if(t.error)throw t.error}catch(e){let r=e,t=r;return{error:r?.error?.message??t.message}}finally{p.length?x=setTimeout(he,1e3):x=void 0}},f=async({data:e,overrideBaseUrl:r="https://api.analytica.click",ignoreBrowserErrors:t})=>{if(t&&t.length>0){let o=t.find(a=>e.data.message.includes(a));if(o){(0,w.debug)("ignoring error, contains=",o);return}}if(dr)return(0,w.debug)(`local error tracking ignored:${e.data.message} ${JSON.stringify(e)}, to ${r}`),{};if(!ge(e?.data?.message))return{};(0,w.debug)("error track",e.data.message,JSON.stringify(e));let n=ye(e.data.message);return p[n]=e,L=r,x||(x=setTimeout(he,500)),{}};async function B({ev:{error:{message:e,stack:r},filename:t},values:n}){n.analyticaToken&&await f({data:{key:n.analyticaToken,data:{message:e,stack:r,filename:t,href:window.location.href}}})}function we(e){(0,Se.useEffect)(()=>{let r=t=>B({ev:t,values:e});if(e.analyticaToken)return window.addEventListener("error",r),()=>{window.removeEventListener("error",r)}},[])}var xe=require("react");function Ae(e){(0,xe.useEffect)(()=>{if(window.consoleset)return;window.consoleset=!0;let r=window.console.error;window.console.error=(...n)=>{f({ignoreBrowserErrors:e.ignoreBrowserErrors,data:{data:{href:window.location.href,message:JSON.stringify(n)},key:e.analyticaToken},overrideBaseUrl:e.overrideBaseUrl}),r(...n)};let t=window.console.warn;window.console.warn=(...n)=>{f({ignoreBrowserErrors:e.ignoreBrowserErrors,data:{data:{href:window.location.href,message:JSON.stringify(n)},key:e.analyticaToken},overrideBaseUrl:e.overrideBaseUrl}),t(...n)}},[])}var y=e=>`[Analytica.${e}] Please load analytica token in AnalyticaClickProvider to use this component`;var Oe=H(require("@emotion/styled")),Ne=require("ag-common/dist/ui/components/Modal"),Pe=require("react"),T=require("react/jsx-runtime"),lr=Oe.default.div`
2
2
  font-size: 2rem;
3
- `,N=class extends g.Component{constructor(r){super(r),this.state={hasError:void 0},this.seenError=!1}static getDerivedStateFromError(r){let t=typeof window<"u"&&window?.location?.href;return{hasError:{...r,message:r?.message??r,...r?.stack&&{stack:r?.stack},...t&&{href:t}}}}render(){let{hasError:r}=this.state,{children:t,notify:n}=this.props;return r?(n&&n(r),g.default.createElement(xe.Modal,{open:!0,setOpen:()=>{}},g.default.createElement(cr,null,"A fatal error has occurred - the admin has been notified.",g.default.createElement("button",{type:"button",onClick:()=>window.location.reload()},"Press here to restart app")))):t}};var y=b(require("react"));var R=e=>`[Analytica.${e}] Please load analytica token in AnalyticaConfigProvider to use this component`;var G=require("react/jsx-runtime");async function pr({ev:e,analyticaToken:r,filterBrowserError:t}){if(t&&t(e)===!1)return;let n=e?.message||e?.error,{href:o}=window.location,a=e?.stack,u=e?.filename;await d({data:{key:r,data:{message:n,stack:a,filename:u,href:o}}})}var dr=({children:e,filterBrowserError:r})=>{let{analyticaToken:t}=(0,y.useContext)(m);return(0,y.useEffect)(()=>{let n=o=>pr({ev:o,analyticaToken:t,filterBrowserError:r});return t&&window.addEventListener("error",n),()=>{window.removeEventListener("error",n)}},[t,r]),t?(0,G.jsx)(N,{notify:async n=>{let{href:o}=window.location;await d({data:{key:t,data:{...n,href:o}}})},children:e}):((0,Ae.warn)(R("ErrorBoundary")),(0,G.jsx)(y.default.Fragment,{children:e}))};var Oe=require("ag-common/dist/common/helpers/log"),Ne=require("react");var E=require("ag-common/dist/common/helpers/log"),P=require("ag-common/dist/ui/helpers/callOpenApi");function lr(e){return(0,P.callOpenApi)({...e,func:r=>(0,P.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new f(r),logout:()=>window.location.reload(),refreshToken:async()=>{}})}var J=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click",eventName:t})=>{let n={eventName:t};if(typeof window<"u"&&(n={...n,pageLocation:window.location.href,browserResolution:`${window?.screen?.width}:${window?.screen?.height}`}),typeof document<"u"&&(n={...n,pageReferrer:document.referrer,pageTitle:document.title}),typeof navigator<"u"&&(n={...n,browserLanguage:navigator.language}),typeof window<"u"&&window?.location?.hostname==="localhost")return(0,E.debug)(`local page ignored: ${JSON.stringify(n)}, to ${r}`),{};let o=await lr({apiUrl:r,headers:{authorization:""},func:a=>a.postPageTrackRaw({postSiteTrack:{key:e,data:n}})});return o.error?((0,E.warn)("tracking error:"+JSON.stringify(o.error,null,2)),{error:JSON.stringify(o.error,null,2)}):{}},C=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click"})=>J({analyticaToken:e,overrideBaseUrl:r,eventName:"PAGE"});var fr=()=>{let{analyticaToken:e,overrideBaseUrl:r}=(0,Ne.useContext)(m);if(!e){(0,Oe.warn)(R("useTrack"));let t=async()=>({error:"no token"});return{page:t,track:t}}return{page:t=>C({...t,analyticaToken:e,overrideBaseUrl:r}),track:t=>J({...t,analyticaToken:e,overrideBaseUrl:r})}};0&&(module.exports={AnalyticaConfigContext,AnalyticaConfigProvider,ErrorBoundary,errorTrack,page,tokenMissing,track,useTrack});
3
+ `,O=class extends Pe.Component{constructor(r){super(r),this.state={hasError:void 0},this.seenError=!1}static getDerivedStateFromError(r){let t=typeof window<"u"&&window?.location?.href;return{hasError:{...r,message:r?.message??r,...r?.stack&&{stack:r?.stack},...t&&{href:t}}}}render(){let{hasError:r}=this.state,{children:t,notify:n}=this.props;return r?(n&&n(r),(0,T.jsx)(Ne.Modal,{open:!0,setOpen:()=>{},children:(0,T.jsxs)(lr,{children:["A fatal error has occurred - the admin has been notified.",(0,T.jsx)("button",{type:"button",onClick:()=>window.location.reload(),children:"Press here to restart app"})]})})):t}};var K=require("react/jsx-runtime"),Je=({children:e})=>{let r=(0,N.useContext)(m);return Ae(r),we(r),r.analyticaToken?(0,K.jsx)(O,{notify:t=>B({ev:t,values:r}),children:e}):((0,Ee.warn)(y("ErrorBoundary")),(0,K.jsx)(N.default.Fragment,{children:e}))};var C=require("react/jsx-runtime"),fr={analyticaToken:void 0,overrideBaseUrl:void 0},m=(0,be.createContext)(fr),mr=({children:e,values:r})=>(0,C.jsx)(m.Provider,{value:r,children:(0,C.jsx)(Je,{children:e})});var ke=require("ag-common/dist/common/helpers/log"),De=require("react");var P=require("ag-common/dist/common/helpers/log"),E=require("ag-common/dist/ui/helpers/callOpenApi");function gr(e){return(0,E.callOpenApi)({...e,func:r=>(0,E.apiResponseToAxiosResponse)(()=>e.func(r)),newDefaultApi:r=>new l(r),logout:()=>window.location.reload(),refreshToken:async()=>{}})}var J=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click",eventName:t})=>{let n={eventName:t};if(typeof window<"u"&&(n={...n,pageLocation:window.location.href,browserResolution:`${window?.screen?.width}:${window?.screen?.height}`}),typeof document<"u"&&(n={...n,pageReferrer:document.referrer,pageTitle:document.title}),typeof navigator<"u"&&(n={...n,browserLanguage:navigator.language}),typeof window<"u"&&window?.location?.hostname==="localhost")return(0,P.debug)(`local page ignored: ${JSON.stringify(n)}, to ${r}`),{};let o=await gr({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)}):{}},G=async({analyticaToken:e,overrideBaseUrl:r="https://api.analytica.click"})=>J({analyticaToken:e,overrideBaseUrl:r,eventName:"PAGE"});var yr=()=>{let{analyticaToken:e,overrideBaseUrl:r}=(0,De.useContext)(m);if(!e){(0,ke.warn)(y("useTrack"));let t=async()=>({error:"no token"});return{page:t,track:t}}return{page:t=>G({...t,analyticaToken:e,overrideBaseUrl:r}),track:t=>J({...t,analyticaToken:e,overrideBaseUrl:r})}};0&&(module.exports={AnalyticaClickProvider,AnalyticaConfigContext,errorTrack,page,tokenMissing,track,useTrack});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "analytica.click",
3
- "version": "0.0.431",
3
+ "version": "0.0.432",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -1,16 +0,0 @@
1
- import { Component } from 'react';
2
- import type { TErrorMessage } from '../../types/widgets';
3
- export interface IErrorBoundaryProps {
4
- notify?: TErrorMessage;
5
- children?: JSX.Element | JSX.Element[];
6
- }
7
- export declare class ErrorBoundary extends Component<IErrorBoundaryProps, {
8
- hasError: Error | ErrorEvent | undefined;
9
- }> {
10
- seenError: boolean;
11
- constructor(props: any);
12
- static getDerivedStateFromError(errorV: any): {
13
- hasError: any;
14
- };
15
- render(): import("react/jsx-runtime").JSX.Element | JSX.Element[] | undefined;
16
- }
@@ -1,17 +0,0 @@
1
- export type TTrackNoEvent = (p: Omit<ITrack, 'eventName'>) => Promise<{
2
- error?: string;
3
- }>;
4
- export type TTrack = (p: ITrack) => Promise<{
5
- error?: string;
6
- }>;
7
- export interface ITrack {
8
- analyticaToken: string;
9
- overrideBaseUrl?: string;
10
- eventName: string;
11
- }
12
- export type TErrorMessage = (m: Error | ErrorEvent) => Promise<void>;
13
- export interface IAnalyticaConfig {
14
- analyticaToken?: string;
15
- overrideBaseUrl?: string;
16
- devMode?: boolean;
17
- }