analytica.click 0.0.538 → 0.0.540

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var p=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var y=(e,r)=>{for(var t in r)p(e,t,{get:r[t],enumerable:!0})},h=(e,r,t,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of w(r))!l.call(e,s)&&s!==t&&p(e,s,{get:()=>r[s],enumerable:!(d=f(r,s))||d.enumerable});return e};var u=e=>h(p({},"__esModule",{value:!0}),e);var T={};y(T,{event:()=>m,metric:()=>k,page:()=>v});module.exports=u(T);var P=require("cross-fetch/polyfill"),a=require("ag-common/dist/common/helpers/log"),m=async e=>{let{analyticaToken:r,overrideBaseUrl:t="https://analytica.click/api",eventName:d,devMode:s,valueOverrides:i}=e;if(!s&&typeof window<"u"&&window.location.hostname==="localhost")return(0,a.debug)(`local page ignored: ${JSON.stringify(e)}, to ${t}`),{};let o={eventName:d,browserFingerprint:i?.browserFingerprint,pageLocation:""};typeof window<"u"&&(o={...o,pageLocation:window.location.href,browserResolution:`${window.screen.width}:${window.screen.height}`}),typeof navigator<"u"&&(o={...o,browser:navigator.userAgent});try{let n=await fetch(`${t}/site/event`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:r,data:o})});if(!n.ok){let c=await n.text();return(0,a.warn)("tracking error:"+c),{error:c}}}catch(n){let c=n instanceof Error?n.message:"Unknown error";return(0,a.warn)("tracking error:"+c),{error:c}}return{}},v=async e=>{let{analyticaToken:r,overrideBaseUrl:t="https://analytica.click/api",devMode:d,valueOverrides:s}=e;if(!d&&typeof window<"u"&&window.location.hostname==="localhost")return(0,a.debug)(`local page ignored: ${JSON.stringify(e)}, to ${t}`),{};let i={pageLocation:"",browserFingerprint:s?.browserFingerprint};if(typeof window<"u"&&(i={...i,pageLocation:window.location.href,browserResolution:`${window.screen.width}:${window.screen.height}`}),typeof document<"u"&&(i={...i,pageReferrer:document.referrer,pageTitle:document.title}),typeof navigator<"u"&&(i={...i,browserLanguage:navigator.language,browser:navigator.userAgent}),!i.pageLocation)return(0,a.warn)("no pageLocation"),{};try{let o=await fetch(`${t}/site/tracking`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:r,data:i})});if(!o.ok){let n=await o.text();return(0,a.warn)("tracking error:"+n),{error:n}}}catch(o){let n=o instanceof Error?o.message:"Unknown error";return(0,a.warn)("tracking error:"+n),{error:n}}return{}},k=async e=>{let{analyticaToken:r,overrideBaseUrl:t="https://analytica.click/api",type:d,name:s,value:i,devMode:o}=e;if(!o&&typeof window<"u"&&window.location.hostname==="localhost")return(0,a.debug)(`local metric ignored: ${JSON.stringify(e)}, to ${t}`),{};if(d==="health")return(0,a.warn)('Type "health" is reserved for system metrics'),{error:'Type "health" is reserved for system metrics'};let n={type:d,name:s,value:i};try{let c=await fetch(`${t}/site/metric`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:r,data:n})});if(!c.ok){let g=await c.text();return(0,a.warn)("metric tracking error:"+g),{error:g}}}catch(c){let g=c instanceof Error?c.message:"Unknown error";return(0,a.warn)("metric tracking error:"+g),{error:g}}return{}};0&&(module.exports={event,metric,page});
1
+ "use strict";var g=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var l=(r,t)=>{for(var o in t)g(r,o,{get:t[o],enumerable:!0})},y=(r,t,o,d)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of f(t))!w.call(r,s)&&s!==o&&g(r,s,{get:()=>t[s],enumerable:!(d=p(t,s))||d.enumerable});return r};var h=r=>y(g({},"__esModule",{value:!0}),r);var k={};l(k,{event:()=>u,metric:()=>v,page:()=>m});module.exports=h(k);var b=require("cross-fetch/polyfill"),i=require("ag-common/dist/common/helpers/log"),u=async r=>{let{analyticaToken:t,overrideBaseUrl:o="https://analytica.click/api",eventName:d,devMode:s,valueOverrides:a}=r;if(!s&&typeof window<"u"&&window.location.hostname==="localhost")return(0,i.debug)(`local page ignored: ${JSON.stringify(r)}, to ${o}`),{};let n={eventName:d,browserFingerprint:a?.browserFingerprint,pageLocation:""};typeof window<"u"&&(n={...n,pageLocation:window.location.href,browserResolution:`${window.screen.width}:${window.screen.height}`}),typeof navigator<"u"&&(n={...n,browser:navigator.userAgent});try{let e=await fetch(`${o}/site/event`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:t,data:n})});if(!e.ok){let c=await e.text();return(0,i.warn)("tracking error:"+c),{error:c}}}catch(e){let c=e instanceof Error?e.message:"Unknown error";return(0,i.warn)("tracking error:"+c),{error:c}}return{}},m=async r=>{let{analyticaToken:t,overrideBaseUrl:o="https://analytica.click/api",devMode:d,valueOverrides:s}=r;if(!d&&typeof window<"u"&&window.location.hostname==="localhost")return(0,i.debug)(`local page ignored: ${JSON.stringify(r)}, to ${o}`),{};let a={pageLocation:"",browserFingerprint:s?.browserFingerprint};if(typeof window<"u"&&(a={...a,pageLocation:window.location.href,browserResolution:`${window.screen.width}:${window.screen.height}`}),typeof document<"u"&&(a={...a,pageReferrer:document.referrer,pageTitle:document.title}),typeof navigator<"u"&&(a={...a,browserLanguage:navigator.language,browser:navigator.userAgent}),!a.pageLocation)return(0,i.warn)("no pageLocation"),{};try{let n=await fetch(`${o}/site/tracking`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:t,data:a})});if(!n.ok){let e=await n.text();return(0,i.warn)("tracking error:"+e),{error:e}}}catch(n){let e=n instanceof Error?n.message:"Unknown error";return(0,i.warn)("tracking error:"+e),{error:e}}return{}},v=async r=>{let{analyticaToken:t,overrideBaseUrl:o="https://analytica.click/api",type:d,value:s,devMode:a}=r;if(!a&&typeof window<"u"&&window.location.hostname==="localhost")return(0,i.debug)(`local metric ignored: ${JSON.stringify(r)}, to ${o}`),{};if(d==="health")return(0,i.warn)('Type "health" is reserved for system metrics'),{error:'Type "health" is reserved for system metrics'};let n={type:d,value:s};try{let e=await fetch(`${o}/site/metric`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:t,data:n})});if(!e.ok){let c=await e.text();return(0,i.warn)("metric tracking error:"+c),{error:c}}}catch(e){let c=e instanceof Error?e.message:"Unknown error";return(0,i.warn)("metric tracking error:"+c),{error:c}}return{}};0&&(module.exports={event,metric,page});
package/dist/index.d.ts CHANGED
@@ -159,7 +159,6 @@ declare module 'analytica.click/dist/types' {
159
159
  analyticaToken: string;
160
160
  overrideBaseUrl?: string;
161
161
  type: string;
162
- name: string;
163
162
  value: number;
164
163
  /** internal testing only. also allows local sending of errors */
165
164
  devMode?: boolean;
@@ -182,38 +181,14 @@ declare module 'analytica.click/dist/types' {
182
181
  }
183
182
  declare module 'analytica.click/dist/ui/src/server/schema/index' {
184
183
  import { z } from 'zod';
184
+ import { RollupSchema } from 'analytica.click/dist/ui/src/server/schema/rollup';
185
+ export * from 'analytica.click/dist/ui/src/server/schema/rollup';
185
186
  export const category: z.ZodEnum<{
186
187
  SERVER: "SERVER";
187
188
  CLIENT: "CLIENT";
188
189
  }>;
189
190
  export type Category = z.infer<typeof category>;
190
- export const createSiteSchema: z.ZodObject<{
191
- site: z.ZodString;
192
- }, z.core.$strip>;
193
- export const deleteSiteSchema: z.ZodObject<{
194
- site: z.ZodString;
195
- }, z.core.$strip>;
196
- export const updateSiteDetailsSchema: z.ZodObject<{
197
- site: z.ZodString;
198
- healthCheckPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
199
- }, z.core.$strip>;
200
- export const createGoogleIntegrationSchema: z.ZodObject<{
201
- email: z.ZodString;
202
- key: z.ZodString;
203
- }, z.core.$strip>;
204
- export const createBingIntegrationSchema: z.ZodObject<{
205
- key: z.ZodString;
206
- }, z.core.$strip>;
207
- export const createCloudflareIntegrationSchema: z.ZodObject<{
208
- key: z.ZodString;
209
- }, z.core.$strip>;
210
- export const successResponseSchema: z.ZodObject<{
211
- success: z.ZodBoolean;
212
- }, z.core.$strip>;
213
- export const errorResponseSchema: z.ZodObject<{
214
- error: z.ZodString;
215
- }, z.core.$strip>;
216
- export const SeoResultValuesSchema: z.ZodObject<{
191
+ export const SeoResultValues: z.ZodObject<{
217
192
  clicks: z.ZodNumber;
218
193
  impressions: z.ZodNumber;
219
194
  position: z.ZodNumber;
@@ -241,7 +216,7 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
241
216
  query: z.ZodString;
242
217
  }, z.core.$strip>>;
243
218
  }, z.core.$strip>;
244
- export const GoogleIntegrationSchema: z.ZodObject<{
219
+ export const GoogleIntegration: z.ZodObject<{
245
220
  email: z.ZodString;
246
221
  key: z.ZodString;
247
222
  account: z.ZodString;
@@ -358,16 +333,14 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
358
333
  }, z.core.$strip>;
359
334
  export const UserMetricSchema: z.ZodObject<{
360
335
  type: z.ZodString;
361
- name: z.ZodString;
362
336
  value: z.ZodNumber;
363
337
  }, z.core.$strip>;
364
- export const MetricItemSchema: z.ZodUnion<readonly [z.ZodObject<{
338
+ export const MetricItemSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
365
339
  type: z.ZodLiteral<"health">;
366
340
  responseTimeMs: z.ZodNumber;
367
341
  success: z.ZodBoolean;
368
342
  }, z.core.$strip>, z.ZodObject<{
369
343
  type: z.ZodString;
370
- name: z.ZodString;
371
344
  value: z.ZodNumber;
372
345
  }, z.core.$strip>]>;
373
346
  export const MetricSchema: z.ZodObject<{
@@ -378,13 +351,12 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
378
351
  SERVER: "SERVER";
379
352
  CLIENT: "CLIENT";
380
353
  }>;
381
- metric: z.ZodUnion<readonly [z.ZodObject<{
354
+ metric: z.ZodDiscriminatedUnion<[z.ZodObject<{
382
355
  type: z.ZodLiteral<"health">;
383
356
  responseTimeMs: z.ZodNumber;
384
357
  success: z.ZodBoolean;
385
358
  }, z.core.$strip>, z.ZodObject<{
386
359
  type: z.ZodString;
387
- name: z.ZodString;
388
360
  value: z.ZodNumber;
389
361
  }, z.core.$strip>]>;
390
362
  }, z.core.$strip>;
@@ -412,97 +384,6 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
412
384
  CLIENT: "CLIENT";
413
385
  }>;
414
386
  }, z.core.$strip>;
415
- export const RollupTopReferrersSchema: z.ZodObject<{
416
- referrer: z.ZodString;
417
- count: z.ZodNumber;
418
- }, z.core.$strip>;
419
- export const RollupTopResolutionsSchema: z.ZodObject<{
420
- resolution: z.ZodString;
421
- count: z.ZodNumber;
422
- }, z.core.$strip>;
423
- export const RollupTopFingerprintsSchema: z.ZodObject<{
424
- fingerprint: z.ZodString;
425
- count: z.ZodNumber;
426
- }, z.core.$strip>;
427
- export const RollupTopQueriesSchema: z.ZodObject<{
428
- pathName: z.ZodString;
429
- count: z.ZodNumber;
430
- }, z.core.$strip>;
431
- export const RollupTopLocationsSchema: z.ZodObject<{
432
- countryRegion: z.ZodString;
433
- count: z.ZodNumber;
434
- }, z.core.$strip>;
435
- export const RollupTopBrowsersSchema: z.ZodObject<{
436
- browser: z.ZodString;
437
- count: z.ZodNumber;
438
- }, z.core.$strip>;
439
- export const RollupTopEventsSchema: z.ZodObject<{
440
- eventName: z.ZodString;
441
- count: z.ZodNumber;
442
- }, z.core.$strip>;
443
- export const RollupTopLanguagesSchema: z.ZodObject<{
444
- language: z.ZodString;
445
- count: z.ZodNumber;
446
- }, z.core.$strip>;
447
- export const RollupTopErrorsSchema: z.ZodObject<{
448
- href: z.ZodString;
449
- count: z.ZodNumber;
450
- }, z.core.$strip>;
451
- export const RollupMetricSummarySchema: z.ZodObject<{
452
- count: z.ZodNumber;
453
- sum: z.ZodNumber;
454
- average: z.ZodNumber;
455
- }, z.core.$strip>;
456
- export const RollupSchema: z.ZodObject<{
457
- account: z.ZodString;
458
- site: z.ZodString;
459
- datetime: z.ZodNumber;
460
- category: z.ZodEnum<{
461
- SERVER: "SERVER";
462
- CLIENT: "CLIENT";
463
- }>;
464
- topReferrers: z.ZodOptional<z.ZodArray<z.ZodObject<{
465
- referrer: z.ZodString;
466
- count: z.ZodNumber;
467
- }, z.core.$strip>>>;
468
- topResolutions: z.ZodOptional<z.ZodArray<z.ZodObject<{
469
- resolution: z.ZodString;
470
- count: z.ZodNumber;
471
- }, z.core.$strip>>>;
472
- topFingerprints: z.ZodOptional<z.ZodArray<z.ZodObject<{
473
- fingerprint: z.ZodString;
474
- count: z.ZodNumber;
475
- }, z.core.$strip>>>;
476
- topQueries: z.ZodOptional<z.ZodArray<z.ZodObject<{
477
- pathName: z.ZodString;
478
- count: z.ZodNumber;
479
- }, z.core.$strip>>>;
480
- topLocations: z.ZodOptional<z.ZodArray<z.ZodObject<{
481
- countryRegion: z.ZodString;
482
- count: z.ZodNumber;
483
- }, z.core.$strip>>>;
484
- topBrowsers: z.ZodOptional<z.ZodArray<z.ZodObject<{
485
- browser: z.ZodString;
486
- count: z.ZodNumber;
487
- }, z.core.$strip>>>;
488
- topEvents: z.ZodOptional<z.ZodArray<z.ZodObject<{
489
- eventName: z.ZodString;
490
- count: z.ZodNumber;
491
- }, z.core.$strip>>>;
492
- topLanguages: z.ZodOptional<z.ZodArray<z.ZodObject<{
493
- language: z.ZodString;
494
- count: z.ZodNumber;
495
- }, z.core.$strip>>>;
496
- topErrors: z.ZodOptional<z.ZodArray<z.ZodObject<{
497
- href: z.ZodString;
498
- count: z.ZodNumber;
499
- }, z.core.$strip>>>;
500
- metrics: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
501
- count: z.ZodNumber;
502
- sum: z.ZodNumber;
503
- average: z.ZodNumber;
504
- }, z.core.$strip>>>;
505
- }, z.core.$strip>;
506
387
  export const PostEventDataSchema: z.ZodObject<{
507
388
  eventName: z.ZodString;
508
389
  pageReferrer: z.ZodOptional<z.ZodString>;
@@ -566,14 +447,12 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
566
447
  }, z.core.$strip>;
567
448
  export const PostMetricDataSchema: z.ZodObject<{
568
449
  type: z.ZodString;
569
- name: z.ZodString;
570
450
  value: z.ZodNumber;
571
451
  }, z.core.$strip>;
572
452
  export const PostMetricSchema: z.ZodObject<{
573
453
  key: z.ZodString;
574
454
  data: z.ZodObject<{
575
455
  type: z.ZodString;
576
- name: z.ZodString;
577
456
  value: z.ZodNumber;
578
457
  }, z.core.$strip>;
579
458
  }, z.core.$strip>;
@@ -695,13 +574,12 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
695
574
  SERVER: "SERVER";
696
575
  CLIENT: "CLIENT";
697
576
  }>;
698
- metric: z.ZodUnion<readonly [z.ZodObject<{
577
+ metric: z.ZodDiscriminatedUnion<[z.ZodObject<{
699
578
  type: z.ZodLiteral<"health">;
700
579
  responseTimeMs: z.ZodNumber;
701
580
  success: z.ZodBoolean;
702
581
  }, z.core.$strip>, z.ZodObject<{
703
582
  type: z.ZodString;
704
- name: z.ZodString;
705
583
  value: z.ZodNumber;
706
584
  }, z.core.$strip>]>;
707
585
  }, z.core.$strip>>>;
@@ -882,11 +760,11 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
882
760
  cloudflareKey: z.ZodOptional<z.ZodString>;
883
761
  cloudflareAccount: z.ZodOptional<z.ZodString>;
884
762
  }, z.core.$strip>;
885
- export type SeoResultValues = z.infer<typeof SeoResultValuesSchema>;
763
+ export type ISeoResultValues = z.infer<typeof SeoResultValues>;
886
764
  export type SeoResult = z.infer<typeof SeoResultSchema>;
887
765
  export type GetAccount = z.infer<typeof GetAccountSchema>;
888
766
  export type GetAccounts = z.infer<typeof GetAccountsSchema>;
889
- export type GoogleIntegration = z.infer<typeof GoogleIntegrationSchema>;
767
+ export type IGoogleIntegration = z.infer<typeof GoogleIntegration>;
890
768
  export type BingIntegration = z.infer<typeof BingIntegrationSchema>;
891
769
  export type CloudflareIntegration = z.infer<typeof CloudflareIntegrationSchema>;
892
770
  export type ApiKey = z.infer<typeof ApiKeySchema>;
@@ -901,7 +779,6 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
901
779
  export type MetricItem = z.infer<typeof MetricItemSchema>;
902
780
  export type Metric = z.infer<typeof MetricSchema>;
903
781
  export type ModelError = z.infer<typeof ModelErrorSchema>;
904
- export type RollupMetricSummary = z.infer<typeof RollupMetricSummarySchema>;
905
782
  export type Rollup = z.infer<typeof RollupSchema>;
906
783
  export type SiteData = z.infer<typeof SiteDataSchema>;
907
784
  export type SiteDetails = z.infer<typeof SiteDetailsSchema>;
@@ -917,6 +794,102 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
917
794
  export type DeleteAccount = z.infer<typeof DeleteAccountSchema>;
918
795
  export type ArchiveErrors = z.infer<typeof ArchiveErrorsSchema>;
919
796
 
797
+ }
798
+ declare module 'analytica.click/dist/ui/src/server/schema/rollup' {
799
+ import z from 'zod';
800
+ export const RollupTopReferrersSchema: z.ZodObject<{
801
+ referrer: z.ZodString;
802
+ count: z.ZodNumber;
803
+ }, z.core.$strip>;
804
+ export const RollupTopResolutionsSchema: z.ZodObject<{
805
+ resolution: z.ZodString;
806
+ count: z.ZodNumber;
807
+ }, z.core.$strip>;
808
+ export const RollupTopFingerprintsSchema: z.ZodObject<{
809
+ fingerprint: z.ZodString;
810
+ count: z.ZodNumber;
811
+ }, z.core.$strip>;
812
+ export const RollupTopQueriesSchema: z.ZodObject<{
813
+ pathName: z.ZodString;
814
+ count: z.ZodNumber;
815
+ }, z.core.$strip>;
816
+ export const RollupTopLocationsSchema: z.ZodObject<{
817
+ countryRegion: z.ZodString;
818
+ count: z.ZodNumber;
819
+ }, z.core.$strip>;
820
+ export const RollupTopBrowsersSchema: z.ZodObject<{
821
+ browser: z.ZodString;
822
+ count: z.ZodNumber;
823
+ }, z.core.$strip>;
824
+ export const RollupTopEventsSchema: z.ZodObject<{
825
+ eventName: z.ZodString;
826
+ count: z.ZodNumber;
827
+ }, z.core.$strip>;
828
+ export const RollupTopLanguagesSchema: z.ZodObject<{
829
+ language: z.ZodString;
830
+ count: z.ZodNumber;
831
+ }, z.core.$strip>;
832
+ export const RollupTopErrorsSchema: z.ZodObject<{
833
+ href: z.ZodString;
834
+ count: z.ZodNumber;
835
+ }, z.core.$strip>;
836
+ export const RollupMetricSummary: z.ZodObject<{
837
+ count: z.ZodNumber;
838
+ sum: z.ZodNumber;
839
+ average: z.ZodNumber;
840
+ }, z.core.$strip>;
841
+ export const RollupSchema: z.ZodObject<{
842
+ account: z.ZodString;
843
+ site: z.ZodString;
844
+ datetime: z.ZodNumber;
845
+ category: z.ZodEnum<{
846
+ SERVER: "SERVER";
847
+ CLIENT: "CLIENT";
848
+ }>;
849
+ topReferrers: z.ZodOptional<z.ZodArray<z.ZodObject<{
850
+ referrer: z.ZodString;
851
+ count: z.ZodNumber;
852
+ }, z.core.$strip>>>;
853
+ topResolutions: z.ZodOptional<z.ZodArray<z.ZodObject<{
854
+ resolution: z.ZodString;
855
+ count: z.ZodNumber;
856
+ }, z.core.$strip>>>;
857
+ topFingerprints: z.ZodOptional<z.ZodArray<z.ZodObject<{
858
+ fingerprint: z.ZodString;
859
+ count: z.ZodNumber;
860
+ }, z.core.$strip>>>;
861
+ topQueries: z.ZodOptional<z.ZodArray<z.ZodObject<{
862
+ pathName: z.ZodString;
863
+ count: z.ZodNumber;
864
+ }, z.core.$strip>>>;
865
+ topLocations: z.ZodOptional<z.ZodArray<z.ZodObject<{
866
+ countryRegion: z.ZodString;
867
+ count: z.ZodNumber;
868
+ }, z.core.$strip>>>;
869
+ topBrowsers: z.ZodOptional<z.ZodArray<z.ZodObject<{
870
+ browser: z.ZodString;
871
+ count: z.ZodNumber;
872
+ }, z.core.$strip>>>;
873
+ topEvents: z.ZodOptional<z.ZodArray<z.ZodObject<{
874
+ eventName: z.ZodString;
875
+ count: z.ZodNumber;
876
+ }, z.core.$strip>>>;
877
+ topLanguages: z.ZodOptional<z.ZodArray<z.ZodObject<{
878
+ language: z.ZodString;
879
+ count: z.ZodNumber;
880
+ }, z.core.$strip>>>;
881
+ topErrors: z.ZodOptional<z.ZodArray<z.ZodObject<{
882
+ href: z.ZodString;
883
+ count: z.ZodNumber;
884
+ }, z.core.$strip>>>;
885
+ metrics: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
886
+ count: z.ZodNumber;
887
+ sum: z.ZodNumber;
888
+ average: z.ZodNumber;
889
+ }, z.core.$strip>>>;
890
+ }, z.core.$strip>;
891
+ export type IRollupMetricSummary = z.infer<typeof RollupMetricSummary>;
892
+
920
893
  }
921
894
  declare module 'analytica.click' {
922
895
  import main = require('analytica.click/dist/index');
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- 'use client';"use strict";var Y=Object.create;var h=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var te=(e,r)=>{for(var t in r)h(e,t,{get:r[t],enumerable:!0})},N=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of V(r))!re.call(e,i)&&i!==t&&h(e,i,{get:()=>r[i],enumerable:!(o=Z(r,i))||o.enumerable});return e};var oe=(e,r,t)=>(t=e!=null?Y(ee(e)):{},N(r||!e||!e.__esModule?h(t,"default",{value:e,enumerable:!0}):t,e)),ne=e=>N(h({},"__esModule",{value:!0}),e);var de={};te(de,{AnalyticaClickProvider:()=>se,AnalyticaConfigContext:()=>y,Modal:()=>O,errorTrack:()=>p,event:()=>M,getErrorKey:()=>F,metric:()=>R,page:()=>$,tokenMissing:()=>u,useAnalytica:()=>ce});module.exports=ne(de);var X=require("react");var v=require("ag-common/dist/common/helpers/log"),T=oe(require("react"));var z=require("react");var pe=require("cross-fetch/polyfill"),E=require("ag-common/dist/common/helpers/hashCode"),f=require("ag-common/dist/common/helpers/log"),B=require("ag-common/dist/common/helpers/object"),D=require("ag-common/dist/common/helpers/string/contains");var A=(e,r)=>{let t=[],o={},i=0;return Object.entries(e).forEach(([n,a])=>{i<r?t.push(a):o[n]=a,i+=1}),{part:t,rest:o}};var J=typeof window<"u"&&window.location.hostname==="localhost",g={},x,b,L=async()=>{try{if(Object.keys(g).length>100){let o=Object.keys(g)[0],i=g[o],n=await fetch(`${b}/errors`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify([{key:i.key,data:{...i.data,message:`error overload!: ${i.data.message||"?"}`}}])});if(g={},!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return{}}let{part:e,rest:r}=A(g,10);g=r;let t=await fetch(`${b}/errors`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify(e)});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`)}catch(e){let r=e;return{error:r?.message??r.message}}finally{Object.keys(g).length>0?x=setTimeout(L,1e3):x=void 0}},p=async({data:e,overrideBaseUrl:r="https://analytica.click/api",ignoreBrowserErrors:t=["will be removed","performing full reload","tracking error","fetch RSC payload","perform a full reload","warnings#debug_enabled",'"digest"',"punycode"],devMode:o})=>{if(r||(r="https://analytica.click/api"),r.startsWith("/")&&typeof window>"u"&&(r="https://analytica.click/api"),t.length>0){let n=(0,D.containsInsensitive)(e.data.message,...t);if(n){(0,f.debug)("ignoring error, contains=",n);return}}if(J&&o)(0,f.debug)("allowing local error tracking due to devmode=true");else if(J)return(0,f.debug)(`local error tracking ignored:${e.data.message} ${JSON.stringify(e)}, to ${r}`),{};if(!ae(e.data.message))return{};(0,f.debug)("error track",e.data.message,JSON.stringify(e));let i=F({...e.data,name:e.data.name??"unknown"});return g[i]=e,b=r,x??=setTimeout(L,500),{}};function ae(e){return e?e.match(/^"?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}"?$/)?((0,f.info)("ignoring react devtools message"),!1):e===JSON.stringify([{}])?((0,f.info)("empty message payload?"),!1):!0:((0,f.info)("no message?"),!1)}var F=e=>{try{let r=/^\[?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}\]?$/gim,t=/(at \S+?) \(\S+\)\s/gim,o=/^((%[cs])+\s*)+$/gim,i=/^color:/gim,n=[],a=e.message;(0,B.isJson)(a)?n=JSON.parse(a):n=[a];let s=n.findIndex(l=>l.match(o)),c=n.findIndex(l=>l.match(i));s>=0&&c>=0&&c===s+1&&(n=n.filter((l,Q)=>![s,c].includes(Q))),n=n.map(l=>l.includes(".js:")||l.includes("node_modules")?l.replace(t,"$1 (stacktrace)"):l.replace(r,"[date]")),a=JSON.stringify(n);let m=(0,E.hashCode)(a).toString();return(0,f.debug)("got errorKey=",a,m),m}catch{return(0,E.hashCode)(e.message).toString()}};async function C({ev:e,values:r}){if(!r.analyticaToken)return;let t={message:e.message,href:window.location.href,filename:e.filename,name:"",stack:e.error.stack};await p({...r,data:{key:r.analyticaToken,data:t}})}function H(e){(0,z.useEffect)(()=>{let r=t=>C({ev:t,values:e});if(e.analyticaToken)return window.addEventListener("error",r),()=>{try{window.removeEventListener("error",r)}catch{}}},[])}var U=require("react");function j(e){(0,U.useEffect)(()=>{if(window.consoleset||!e.analyticaToken)return;window.consoleset=!0;let r=window.console.error;window.console.error=(...o)=>{p({...e,data:{data:{href:window.location.href,message:JSON.stringify(o)},key:e.analyticaToken}}),r(...o)};let t=window.console.warn;window.console.warn=(...o)=>{p({...e,data:{data:{href:window.location.href,message:JSON.stringify(o)},key:e.analyticaToken}}),t(...o)}},[])}var u=e=>`[Analytica.${e}] Please load analytica token in AnalyticaClickProvider to use this component`;function W(e){if(global.nodeset||typeof window<"u"||!e.analyticaToken)return;global.nodeset=!0;let r=global.console.error;global.console.error=(...o)=>{p({...e,data:{data:{href:"server",message:JSON.stringify(o)},key:e.analyticaToken}}),r(...o)};let t=global.console.warn;global.console.warn=(...o)=>{p({...e,data:{data:{href:"server",message:JSON.stringify(o)},key:e.analyticaToken}}),t(...o)}}var K=require("react");var w=require("react/jsx-runtime"),ie={fontSize:"2rem"},k=class extends K.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:o}=this.props;return r?(o&&o(r),(0,w.jsx)(O,{open:!0,setOpen:()=>{},children:(0,w.jsxs)("div",{style:ie,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 P=require("react/jsx-runtime"),_=({children:e})=>{let r=(0,T.useContext)(y);return j(r),H(r),W(r),(0,v.debug)("installed analytica.click error handlers"),r.analyticaToken?(0,P.jsx)(k,{notify:t=>C({ev:t,values:r}),children:e}):((0,v.warn)(u("ErrorBoundary")),(0,P.jsx)(T.default.Fragment,{children:e}))};var S=require("react/jsx-runtime"),y=(0,X.createContext)(void 0),se=({children:e,values:r})=>(0,S.jsx)(y.Provider,{value:r,children:(0,S.jsx)(_,{children:e})});var I=require("react/jsx-runtime"),O=({open:e,setOpen:r,children:t})=>e?(0,I.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>r(!1),children:(0,I.jsx)("div",{style:{backgroundColor:"white",padding:"2rem",borderRadius:"8px",maxWidth:"500px",maxHeight:"80vh",overflow:"auto",position:"relative",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.2)"},onClick:o=>o.stopPropagation(),children:t})}):null;var Fe=require("cross-fetch/polyfill"),d=require("ag-common/dist/common/helpers/log"),M=async e=>{let{analyticaToken:r,overrideBaseUrl:t="https://analytica.click/api",eventName:o,devMode:i,valueOverrides:n}=e;if(!i&&typeof window<"u"&&window.location.hostname==="localhost")return(0,d.debug)(`local page ignored: ${JSON.stringify(e)}, to ${t}`),{};let a={eventName:o,browserFingerprint:n?.browserFingerprint,pageLocation:""};typeof window<"u"&&(a={...a,pageLocation:window.location.href,browserResolution:`${window.screen.width}:${window.screen.height}`}),typeof navigator<"u"&&(a={...a,browser:navigator.userAgent});try{let s=await fetch(`${t}/site/event`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:r,data:a})});if(!s.ok){let c=await s.text();return(0,d.warn)("tracking error:"+c),{error:c}}}catch(s){let c=s instanceof Error?s.message:"Unknown error";return(0,d.warn)("tracking error:"+c),{error:c}}return{}},$=async e=>{let{analyticaToken:r,overrideBaseUrl:t="https://analytica.click/api",devMode:o,valueOverrides:i}=e;if(!o&&typeof window<"u"&&window.location.hostname==="localhost")return(0,d.debug)(`local page ignored: ${JSON.stringify(e)}, to ${t}`),{};let n={pageLocation:"",browserFingerprint:i?.browserFingerprint};if(typeof window<"u"&&(n={...n,pageLocation:window.location.href,browserResolution:`${window.screen.width}:${window.screen.height}`}),typeof document<"u"&&(n={...n,pageReferrer:document.referrer,pageTitle:document.title}),typeof navigator<"u"&&(n={...n,browserLanguage:navigator.language,browser:navigator.userAgent}),!n.pageLocation)return(0,d.warn)("no pageLocation"),{};try{let a=await fetch(`${t}/site/tracking`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:r,data:n})});if(!a.ok){let s=await a.text();return(0,d.warn)("tracking error:"+s),{error:s}}}catch(a){let s=a instanceof Error?a.message:"Unknown error";return(0,d.warn)("tracking error:"+s),{error:s}}return{}},R=async e=>{let{analyticaToken:r,overrideBaseUrl:t="https://analytica.click/api",type:o,name:i,value:n,devMode:a}=e;if(!a&&typeof window<"u"&&window.location.hostname==="localhost")return(0,d.debug)(`local metric ignored: ${JSON.stringify(e)}, to ${t}`),{};if(o==="health")return(0,d.warn)('Type "health" is reserved for system metrics'),{error:'Type "health" is reserved for system metrics'};let s={type:o,name:i,value:n};try{let c=await fetch(`${t}/site/metric`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:r,data:s})});if(!c.ok){let m=await c.text();return(0,d.warn)("metric tracking error:"+m),{error:m}}}catch(c){let m=c instanceof Error?c.message:"Unknown error";return(0,d.warn)("metric tracking error:"+m),{error:m}}return{}};var q=require("ag-common/dist/common/helpers/log"),G=require("react");var ce=()=>{let e=(0,G.useContext)(y);if(!e.analyticaToken){(0,q.warn)(u("useAnalytica"));let r=async()=>({error:"no token"});return{event:r,page:r,metric:r}}return{event:r=>M({...r,...e}),page:r=>$({...r,...e}),metric:r=>R({...r,...e})}};0&&(module.exports={AnalyticaClickProvider,AnalyticaConfigContext,Modal,errorTrack,event,getErrorKey,metric,page,tokenMissing,useAnalytica});
1
+ 'use client';"use strict";var Y=Object.create;var w=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var te=(e,r)=>{for(var t in r)w(e,t,{get:r[t],enumerable:!0})},N=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of V(r))!re.call(e,i)&&i!==t&&w(e,i,{get:()=>r[i],enumerable:!(o=Z(r,i))||o.enumerable});return e};var oe=(e,r,t)=>(t=e!=null?Y(ee(e)):{},N(r||!e||!e.__esModule?w(t,"default",{value:e,enumerable:!0}):t,e)),ne=e=>N(w({},"__esModule",{value:!0}),e);var de={};te(de,{AnalyticaClickProvider:()=>se,AnalyticaConfigContext:()=>g,Modal:()=>C,errorTrack:()=>p,event:()=>I,getErrorKey:()=>F,metric:()=>$,page:()=>M,tokenMissing:()=>y,useAnalytica:()=>ce});module.exports=ne(de);var X=require("react");var k=require("ag-common/dist/common/helpers/log"),v=oe(require("react"));var z=require("react");var pe=require("cross-fetch/polyfill"),T=require("ag-common/dist/common/helpers/hashCode"),f=require("ag-common/dist/common/helpers/log"),B=require("ag-common/dist/common/helpers/object"),D=require("ag-common/dist/common/helpers/string/contains");var A=(e,r)=>{let t=[],o={},i=0;return Object.entries(e).forEach(([n,a])=>{i<r?t.push(a):o[n]=a,i+=1}),{part:t,rest:o}};var J=typeof window<"u"&&window.location.hostname==="localhost",m={},E,x,L=async()=>{try{if(Object.keys(m).length>100){let o=Object.keys(m)[0],i=m[o],n=await fetch(`${x}/errors`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify([{key:i.key,data:{...i.data,message:`error overload!: ${i.data.message||"?"}`}}])});if(m={},!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return{}}let{part:e,rest:r}=A(m,10);m=r;let t=await fetch(`${x}/errors`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify(e)});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`)}catch(e){let r=e;return{error:r?.message??r.message}}finally{Object.keys(m).length>0?E=setTimeout(L,1e3):E=void 0}},p=async({data:e,overrideBaseUrl:r="https://analytica.click/api",ignoreBrowserErrors:t=["will be removed","performing full reload","tracking error","fetch RSC payload","perform a full reload","warnings#debug_enabled",'"digest"',"punycode"],devMode:o})=>{if(r||(r="https://analytica.click/api"),r.startsWith("/")&&typeof window>"u"&&(r="https://analytica.click/api"),t.length>0){let n=(0,D.containsInsensitive)(e.data.message,...t);if(n){(0,f.debug)("ignoring error, contains=",n);return}}if(J&&o)(0,f.debug)("allowing local error tracking due to devmode=true");else if(J)return(0,f.debug)(`local error tracking ignored:${e.data.message} ${JSON.stringify(e)}, to ${r}`),{};if(!ae(e.data.message))return{};(0,f.debug)("error track",e.data.message,JSON.stringify(e));let i=F({...e.data,name:e.data.name??"unknown"});return m[i]=e,x=r,E??=setTimeout(L,500),{}};function ae(e){return e?e.match(/^"?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}"?$/)?((0,f.info)("ignoring react devtools message"),!1):e===JSON.stringify([{}])?((0,f.info)("empty message payload?"),!1):!0:((0,f.info)("no message?"),!1)}var F=e=>{try{let r=/^\[?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}\]?$/gim,t=/(at \S+?) \(\S+\)\s/gim,o=/^((%[cs])+\s*)+$/gim,i=/^color:/gim,n=[],a=e.message;(0,B.isJson)(a)?n=JSON.parse(a):n=[a];let s=n.findIndex(l=>l.match(o)),c=n.findIndex(l=>l.match(i));s>=0&&c>=0&&c===s+1&&(n=n.filter((l,Q)=>![s,c].includes(Q))),n=n.map(l=>l.includes(".js:")||l.includes("node_modules")?l.replace(t,"$1 (stacktrace)"):l.replace(r,"[date]")),a=JSON.stringify(n);let R=(0,T.hashCode)(a).toString();return(0,f.debug)("got errorKey=",a,R),R}catch{return(0,T.hashCode)(e.message).toString()}};async function b({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 p({...r,data:{key:r.analyticaToken,data:t}})}function H(e){(0,z.useEffect)(()=>{let r=t=>b({ev:t,values:e});if(e.analyticaToken)return window.addEventListener("error",r),()=>{try{window.removeEventListener("error",r)}catch{}}},[])}var U=require("react");function j(e){(0,U.useEffect)(()=>{if(window.consoleset||!e.analyticaToken)return;window.consoleset=!0;let r=window.console.error;window.console.error=(...o)=>{p({...e,data:{data:{href:window.location.href,message:JSON.stringify(o)},key:e.analyticaToken}}),r(...o)};let t=window.console.warn;window.console.warn=(...o)=>{p({...e,data:{data:{href:window.location.href,message:JSON.stringify(o)},key:e.analyticaToken}}),t(...o)}},[])}var y=e=>`[Analytica.${e}] Please load analytica token in AnalyticaClickProvider to use this component`;function W(e){if(global.nodeset||typeof window<"u"||!e.analyticaToken)return;global.nodeset=!0;let r=global.console.error;global.console.error=(...o)=>{p({...e,data:{data:{href:"server",message:JSON.stringify(o)},key:e.analyticaToken}}),r(...o)};let t=global.console.warn;global.console.warn=(...o)=>{p({...e,data:{data:{href:"server",message:JSON.stringify(o)},key:e.analyticaToken}}),t(...o)}}var K=require("react");var u=require("react/jsx-runtime"),ie={fontSize:"2rem"},h=class extends K.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:o}=this.props;return r?(o&&o(r),(0,u.jsx)(C,{open:!0,setOpen:()=>{},children:(0,u.jsxs)("div",{style:ie,children:["A fatal error has occurred - the admin has been notified.",(0,u.jsx)("button",{type:"button",onClick:()=>window.location.reload(),children:"Press here to restart app"})]})})):t}};var O=require("react/jsx-runtime"),_=({children:e})=>{let r=(0,v.useContext)(g);return j(r),H(r),W(r),(0,k.debug)("installed analytica.click error handlers"),r.analyticaToken?(0,O.jsx)(h,{notify:t=>b({ev:t,values:r}),children:e}):((0,k.warn)(y("ErrorBoundary")),(0,O.jsx)(v.default.Fragment,{children:e}))};var P=require("react/jsx-runtime"),g=(0,X.createContext)(void 0),se=({children:e,values:r})=>(0,P.jsx)(g.Provider,{value:r,children:(0,P.jsx)(_,{children:e})});var S=require("react/jsx-runtime"),C=({open:e,setOpen:r,children:t})=>e?(0,S.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>r(!1),children:(0,S.jsx)("div",{style:{backgroundColor:"white",padding:"2rem",borderRadius:"8px",maxWidth:"500px",maxHeight:"80vh",overflow:"auto",position:"relative",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.2)"},onClick:o=>o.stopPropagation(),children:t})}):null;var Fe=require("cross-fetch/polyfill"),d=require("ag-common/dist/common/helpers/log"),I=async e=>{let{analyticaToken:r,overrideBaseUrl:t="https://analytica.click/api",eventName:o,devMode:i,valueOverrides:n}=e;if(!i&&typeof window<"u"&&window.location.hostname==="localhost")return(0,d.debug)(`local page ignored: ${JSON.stringify(e)}, to ${t}`),{};let a={eventName:o,browserFingerprint:n?.browserFingerprint,pageLocation:""};typeof window<"u"&&(a={...a,pageLocation:window.location.href,browserResolution:`${window.screen.width}:${window.screen.height}`}),typeof navigator<"u"&&(a={...a,browser:navigator.userAgent});try{let s=await fetch(`${t}/site/event`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:r,data:a})});if(!s.ok){let c=await s.text();return(0,d.warn)("tracking error:"+c),{error:c}}}catch(s){let c=s instanceof Error?s.message:"Unknown error";return(0,d.warn)("tracking error:"+c),{error:c}}return{}},M=async e=>{let{analyticaToken:r,overrideBaseUrl:t="https://analytica.click/api",devMode:o,valueOverrides:i}=e;if(!o&&typeof window<"u"&&window.location.hostname==="localhost")return(0,d.debug)(`local page ignored: ${JSON.stringify(e)}, to ${t}`),{};let n={pageLocation:"",browserFingerprint:i?.browserFingerprint};if(typeof window<"u"&&(n={...n,pageLocation:window.location.href,browserResolution:`${window.screen.width}:${window.screen.height}`}),typeof document<"u"&&(n={...n,pageReferrer:document.referrer,pageTitle:document.title}),typeof navigator<"u"&&(n={...n,browserLanguage:navigator.language,browser:navigator.userAgent}),!n.pageLocation)return(0,d.warn)("no pageLocation"),{};try{let a=await fetch(`${t}/site/tracking`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:r,data:n})});if(!a.ok){let s=await a.text();return(0,d.warn)("tracking error:"+s),{error:s}}}catch(a){let s=a instanceof Error?a.message:"Unknown error";return(0,d.warn)("tracking error:"+s),{error:s}}return{}},$=async e=>{let{analyticaToken:r,overrideBaseUrl:t="https://analytica.click/api",type:o,value:i,devMode:n}=e;if(!n&&typeof window<"u"&&window.location.hostname==="localhost")return(0,d.debug)(`local metric ignored: ${JSON.stringify(e)}, to ${t}`),{};if(o==="health")return(0,d.warn)('Type "health" is reserved for system metrics'),{error:'Type "health" is reserved for system metrics'};let a={type:o,value:i};try{let s=await fetch(`${t}/site/metric`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:r,data:a})});if(!s.ok){let c=await s.text();return(0,d.warn)("metric tracking error:"+c),{error:c}}}catch(s){let c=s instanceof Error?s.message:"Unknown error";return(0,d.warn)("metric tracking error:"+c),{error:c}}return{}};var q=require("ag-common/dist/common/helpers/log"),G=require("react");var ce=()=>{let e=(0,G.useContext)(g);if(!e.analyticaToken){(0,q.warn)(y("useAnalytica"));let r=async()=>({error:"no token"});return{event:r,page:r,metric:r}}return{event:r=>I({...r,...e}),page:r=>M({...r,...e}),metric:r=>$({...r,...e})}};0&&(module.exports={AnalyticaClickProvider,AnalyticaConfigContext,Modal,errorTrack,event,getErrorKey,metric,page,tokenMissing,useAnalytica});
@@ -1,36 +1,12 @@
1
1
  import { z } from 'zod';
2
+ import { RollupSchema } from './rollup';
3
+ export * from './rollup';
2
4
  export declare const category: z.ZodEnum<{
3
5
  SERVER: "SERVER";
4
6
  CLIENT: "CLIENT";
5
7
  }>;
6
8
  export type Category = z.infer<typeof category>;
7
- export declare const createSiteSchema: z.ZodObject<{
8
- site: z.ZodString;
9
- }, z.core.$strip>;
10
- export declare const deleteSiteSchema: z.ZodObject<{
11
- site: z.ZodString;
12
- }, z.core.$strip>;
13
- export declare const updateSiteDetailsSchema: z.ZodObject<{
14
- site: z.ZodString;
15
- healthCheckPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
16
- }, z.core.$strip>;
17
- export declare const createGoogleIntegrationSchema: z.ZodObject<{
18
- email: z.ZodString;
19
- key: z.ZodString;
20
- }, z.core.$strip>;
21
- export declare const createBingIntegrationSchema: z.ZodObject<{
22
- key: z.ZodString;
23
- }, z.core.$strip>;
24
- export declare const createCloudflareIntegrationSchema: z.ZodObject<{
25
- key: z.ZodString;
26
- }, z.core.$strip>;
27
- export declare const successResponseSchema: z.ZodObject<{
28
- success: z.ZodBoolean;
29
- }, z.core.$strip>;
30
- export declare const errorResponseSchema: z.ZodObject<{
31
- error: z.ZodString;
32
- }, z.core.$strip>;
33
- export declare const SeoResultValuesSchema: z.ZodObject<{
9
+ export declare const SeoResultValues: z.ZodObject<{
34
10
  clicks: z.ZodNumber;
35
11
  impressions: z.ZodNumber;
36
12
  position: z.ZodNumber;
@@ -58,7 +34,7 @@ export declare const SeoResultSchema: z.ZodObject<{
58
34
  query: z.ZodString;
59
35
  }, z.core.$strip>>;
60
36
  }, z.core.$strip>;
61
- export declare const GoogleIntegrationSchema: z.ZodObject<{
37
+ export declare const GoogleIntegration: z.ZodObject<{
62
38
  email: z.ZodString;
63
39
  key: z.ZodString;
64
40
  account: z.ZodString;
@@ -175,16 +151,14 @@ export declare const HealthMetricSchema: z.ZodObject<{
175
151
  }, z.core.$strip>;
176
152
  export declare const UserMetricSchema: z.ZodObject<{
177
153
  type: z.ZodString;
178
- name: z.ZodString;
179
154
  value: z.ZodNumber;
180
155
  }, z.core.$strip>;
181
- export declare const MetricItemSchema: z.ZodUnion<readonly [z.ZodObject<{
156
+ export declare const MetricItemSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
182
157
  type: z.ZodLiteral<"health">;
183
158
  responseTimeMs: z.ZodNumber;
184
159
  success: z.ZodBoolean;
185
160
  }, z.core.$strip>, z.ZodObject<{
186
161
  type: z.ZodString;
187
- name: z.ZodString;
188
162
  value: z.ZodNumber;
189
163
  }, z.core.$strip>]>;
190
164
  export declare const MetricSchema: z.ZodObject<{
@@ -195,13 +169,12 @@ export declare const MetricSchema: z.ZodObject<{
195
169
  SERVER: "SERVER";
196
170
  CLIENT: "CLIENT";
197
171
  }>;
198
- metric: z.ZodUnion<readonly [z.ZodObject<{
172
+ metric: z.ZodDiscriminatedUnion<[z.ZodObject<{
199
173
  type: z.ZodLiteral<"health">;
200
174
  responseTimeMs: z.ZodNumber;
201
175
  success: z.ZodBoolean;
202
176
  }, z.core.$strip>, z.ZodObject<{
203
177
  type: z.ZodString;
204
- name: z.ZodString;
205
178
  value: z.ZodNumber;
206
179
  }, z.core.$strip>]>;
207
180
  }, z.core.$strip>;
@@ -229,97 +202,6 @@ export declare const ModelErrorSchema: z.ZodObject<{
229
202
  CLIENT: "CLIENT";
230
203
  }>;
231
204
  }, z.core.$strip>;
232
- export declare const RollupTopReferrersSchema: z.ZodObject<{
233
- referrer: z.ZodString;
234
- count: z.ZodNumber;
235
- }, z.core.$strip>;
236
- export declare const RollupTopResolutionsSchema: z.ZodObject<{
237
- resolution: z.ZodString;
238
- count: z.ZodNumber;
239
- }, z.core.$strip>;
240
- export declare const RollupTopFingerprintsSchema: z.ZodObject<{
241
- fingerprint: z.ZodString;
242
- count: z.ZodNumber;
243
- }, z.core.$strip>;
244
- export declare const RollupTopQueriesSchema: z.ZodObject<{
245
- pathName: z.ZodString;
246
- count: z.ZodNumber;
247
- }, z.core.$strip>;
248
- export declare const RollupTopLocationsSchema: z.ZodObject<{
249
- countryRegion: z.ZodString;
250
- count: z.ZodNumber;
251
- }, z.core.$strip>;
252
- export declare const RollupTopBrowsersSchema: z.ZodObject<{
253
- browser: z.ZodString;
254
- count: z.ZodNumber;
255
- }, z.core.$strip>;
256
- export declare const RollupTopEventsSchema: z.ZodObject<{
257
- eventName: z.ZodString;
258
- count: z.ZodNumber;
259
- }, z.core.$strip>;
260
- export declare const RollupTopLanguagesSchema: z.ZodObject<{
261
- language: z.ZodString;
262
- count: z.ZodNumber;
263
- }, z.core.$strip>;
264
- export declare const RollupTopErrorsSchema: z.ZodObject<{
265
- href: z.ZodString;
266
- count: z.ZodNumber;
267
- }, z.core.$strip>;
268
- export declare const RollupMetricSummarySchema: z.ZodObject<{
269
- count: z.ZodNumber;
270
- sum: z.ZodNumber;
271
- average: z.ZodNumber;
272
- }, z.core.$strip>;
273
- export declare const RollupSchema: z.ZodObject<{
274
- account: z.ZodString;
275
- site: z.ZodString;
276
- datetime: z.ZodNumber;
277
- category: z.ZodEnum<{
278
- SERVER: "SERVER";
279
- CLIENT: "CLIENT";
280
- }>;
281
- topReferrers: z.ZodOptional<z.ZodArray<z.ZodObject<{
282
- referrer: z.ZodString;
283
- count: z.ZodNumber;
284
- }, z.core.$strip>>>;
285
- topResolutions: z.ZodOptional<z.ZodArray<z.ZodObject<{
286
- resolution: z.ZodString;
287
- count: z.ZodNumber;
288
- }, z.core.$strip>>>;
289
- topFingerprints: z.ZodOptional<z.ZodArray<z.ZodObject<{
290
- fingerprint: z.ZodString;
291
- count: z.ZodNumber;
292
- }, z.core.$strip>>>;
293
- topQueries: z.ZodOptional<z.ZodArray<z.ZodObject<{
294
- pathName: z.ZodString;
295
- count: z.ZodNumber;
296
- }, z.core.$strip>>>;
297
- topLocations: z.ZodOptional<z.ZodArray<z.ZodObject<{
298
- countryRegion: z.ZodString;
299
- count: z.ZodNumber;
300
- }, z.core.$strip>>>;
301
- topBrowsers: z.ZodOptional<z.ZodArray<z.ZodObject<{
302
- browser: z.ZodString;
303
- count: z.ZodNumber;
304
- }, z.core.$strip>>>;
305
- topEvents: z.ZodOptional<z.ZodArray<z.ZodObject<{
306
- eventName: z.ZodString;
307
- count: z.ZodNumber;
308
- }, z.core.$strip>>>;
309
- topLanguages: z.ZodOptional<z.ZodArray<z.ZodObject<{
310
- language: z.ZodString;
311
- count: z.ZodNumber;
312
- }, z.core.$strip>>>;
313
- topErrors: z.ZodOptional<z.ZodArray<z.ZodObject<{
314
- href: z.ZodString;
315
- count: z.ZodNumber;
316
- }, z.core.$strip>>>;
317
- metrics: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
318
- count: z.ZodNumber;
319
- sum: z.ZodNumber;
320
- average: z.ZodNumber;
321
- }, z.core.$strip>>>;
322
- }, z.core.$strip>;
323
205
  export declare const PostEventDataSchema: z.ZodObject<{
324
206
  eventName: z.ZodString;
325
207
  pageReferrer: z.ZodOptional<z.ZodString>;
@@ -383,14 +265,12 @@ export declare const PostErrorSchema: z.ZodObject<{
383
265
  }, z.core.$strip>;
384
266
  export declare const PostMetricDataSchema: z.ZodObject<{
385
267
  type: z.ZodString;
386
- name: z.ZodString;
387
268
  value: z.ZodNumber;
388
269
  }, z.core.$strip>;
389
270
  export declare const PostMetricSchema: z.ZodObject<{
390
271
  key: z.ZodString;
391
272
  data: z.ZodObject<{
392
273
  type: z.ZodString;
393
- name: z.ZodString;
394
274
  value: z.ZodNumber;
395
275
  }, z.core.$strip>;
396
276
  }, z.core.$strip>;
@@ -512,13 +392,12 @@ export declare const SiteDataSchema: z.ZodObject<{
512
392
  SERVER: "SERVER";
513
393
  CLIENT: "CLIENT";
514
394
  }>;
515
- metric: z.ZodUnion<readonly [z.ZodObject<{
395
+ metric: z.ZodDiscriminatedUnion<[z.ZodObject<{
516
396
  type: z.ZodLiteral<"health">;
517
397
  responseTimeMs: z.ZodNumber;
518
398
  success: z.ZodBoolean;
519
399
  }, z.core.$strip>, z.ZodObject<{
520
400
  type: z.ZodString;
521
- name: z.ZodString;
522
401
  value: z.ZodNumber;
523
402
  }, z.core.$strip>]>;
524
403
  }, z.core.$strip>>>;
@@ -699,11 +578,11 @@ export declare const GetAccountsSchema: z.ZodObject<{
699
578
  cloudflareKey: z.ZodOptional<z.ZodString>;
700
579
  cloudflareAccount: z.ZodOptional<z.ZodString>;
701
580
  }, z.core.$strip>;
702
- export type SeoResultValues = z.infer<typeof SeoResultValuesSchema>;
581
+ export type ISeoResultValues = z.infer<typeof SeoResultValues>;
703
582
  export type SeoResult = z.infer<typeof SeoResultSchema>;
704
583
  export type GetAccount = z.infer<typeof GetAccountSchema>;
705
584
  export type GetAccounts = z.infer<typeof GetAccountsSchema>;
706
- export type GoogleIntegration = z.infer<typeof GoogleIntegrationSchema>;
585
+ export type IGoogleIntegration = z.infer<typeof GoogleIntegration>;
707
586
  export type BingIntegration = z.infer<typeof BingIntegrationSchema>;
708
587
  export type CloudflareIntegration = z.infer<typeof CloudflareIntegrationSchema>;
709
588
  export type ApiKey = z.infer<typeof ApiKeySchema>;
@@ -718,7 +597,6 @@ export type Event = z.infer<typeof EventSchema>;
718
597
  export type MetricItem = z.infer<typeof MetricItemSchema>;
719
598
  export type Metric = z.infer<typeof MetricSchema>;
720
599
  export type ModelError = z.infer<typeof ModelErrorSchema>;
721
- export type RollupMetricSummary = z.infer<typeof RollupMetricSummarySchema>;
722
600
  export type Rollup = z.infer<typeof RollupSchema>;
723
601
  export type SiteData = z.infer<typeof SiteDataSchema>;
724
602
  export type SiteDetails = z.infer<typeof SiteDetailsSchema>;
@@ -0,0 +1,93 @@
1
+ import z from 'zod';
2
+ export declare const RollupTopReferrersSchema: z.ZodObject<{
3
+ referrer: z.ZodString;
4
+ count: z.ZodNumber;
5
+ }, z.core.$strip>;
6
+ export declare const RollupTopResolutionsSchema: z.ZodObject<{
7
+ resolution: z.ZodString;
8
+ count: z.ZodNumber;
9
+ }, z.core.$strip>;
10
+ export declare const RollupTopFingerprintsSchema: z.ZodObject<{
11
+ fingerprint: z.ZodString;
12
+ count: z.ZodNumber;
13
+ }, z.core.$strip>;
14
+ export declare const RollupTopQueriesSchema: z.ZodObject<{
15
+ pathName: z.ZodString;
16
+ count: z.ZodNumber;
17
+ }, z.core.$strip>;
18
+ export declare const RollupTopLocationsSchema: z.ZodObject<{
19
+ countryRegion: z.ZodString;
20
+ count: z.ZodNumber;
21
+ }, z.core.$strip>;
22
+ export declare const RollupTopBrowsersSchema: z.ZodObject<{
23
+ browser: z.ZodString;
24
+ count: z.ZodNumber;
25
+ }, z.core.$strip>;
26
+ export declare const RollupTopEventsSchema: z.ZodObject<{
27
+ eventName: z.ZodString;
28
+ count: z.ZodNumber;
29
+ }, z.core.$strip>;
30
+ export declare const RollupTopLanguagesSchema: z.ZodObject<{
31
+ language: z.ZodString;
32
+ count: z.ZodNumber;
33
+ }, z.core.$strip>;
34
+ export declare const RollupTopErrorsSchema: z.ZodObject<{
35
+ href: z.ZodString;
36
+ count: z.ZodNumber;
37
+ }, z.core.$strip>;
38
+ export declare const RollupMetricSummary: z.ZodObject<{
39
+ count: z.ZodNumber;
40
+ sum: z.ZodNumber;
41
+ average: z.ZodNumber;
42
+ }, z.core.$strip>;
43
+ export declare const RollupSchema: z.ZodObject<{
44
+ account: z.ZodString;
45
+ site: z.ZodString;
46
+ datetime: z.ZodNumber;
47
+ category: z.ZodEnum<{
48
+ SERVER: "SERVER";
49
+ CLIENT: "CLIENT";
50
+ }>;
51
+ topReferrers: z.ZodOptional<z.ZodArray<z.ZodObject<{
52
+ referrer: z.ZodString;
53
+ count: z.ZodNumber;
54
+ }, z.core.$strip>>>;
55
+ topResolutions: z.ZodOptional<z.ZodArray<z.ZodObject<{
56
+ resolution: z.ZodString;
57
+ count: z.ZodNumber;
58
+ }, z.core.$strip>>>;
59
+ topFingerprints: z.ZodOptional<z.ZodArray<z.ZodObject<{
60
+ fingerprint: z.ZodString;
61
+ count: z.ZodNumber;
62
+ }, z.core.$strip>>>;
63
+ topQueries: z.ZodOptional<z.ZodArray<z.ZodObject<{
64
+ pathName: z.ZodString;
65
+ count: z.ZodNumber;
66
+ }, z.core.$strip>>>;
67
+ topLocations: z.ZodOptional<z.ZodArray<z.ZodObject<{
68
+ countryRegion: z.ZodString;
69
+ count: z.ZodNumber;
70
+ }, z.core.$strip>>>;
71
+ topBrowsers: z.ZodOptional<z.ZodArray<z.ZodObject<{
72
+ browser: z.ZodString;
73
+ count: z.ZodNumber;
74
+ }, z.core.$strip>>>;
75
+ topEvents: z.ZodOptional<z.ZodArray<z.ZodObject<{
76
+ eventName: z.ZodString;
77
+ count: z.ZodNumber;
78
+ }, z.core.$strip>>>;
79
+ topLanguages: z.ZodOptional<z.ZodArray<z.ZodObject<{
80
+ language: z.ZodString;
81
+ count: z.ZodNumber;
82
+ }, z.core.$strip>>>;
83
+ topErrors: z.ZodOptional<z.ZodArray<z.ZodObject<{
84
+ href: z.ZodString;
85
+ count: z.ZodNumber;
86
+ }, z.core.$strip>>>;
87
+ metrics: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
88
+ count: z.ZodNumber;
89
+ sum: z.ZodNumber;
90
+ average: z.ZodNumber;
91
+ }, z.core.$strip>>>;
92
+ }, z.core.$strip>;
93
+ export type IRollupMetricSummary = z.infer<typeof RollupMetricSummary>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "analytica.click",
3
- "version": "0.0.538",
3
+ "version": "0.0.540",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",