analytica.click 0.0.537 → 0.0.539
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/server.js +1 -1
- package/dist/index.d.ts +117 -37
- package/dist/index.js +1 -1
- package/dist/ui/src/server/schema/index.d.ts +117 -36
- package/package.json +1 -1
package/dist/helpers/server.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var
|
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,6 +181,11 @@ 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
|
+
export const category: z.ZodEnum<{
|
185
|
+
SERVER: "SERVER";
|
186
|
+
CLIENT: "CLIENT";
|
187
|
+
}>;
|
188
|
+
export type Category = z.infer<typeof category>;
|
185
189
|
export const createSiteSchema: z.ZodObject<{
|
186
190
|
site: z.ZodString;
|
187
191
|
}, z.core.$strip>;
|
@@ -219,7 +223,10 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
219
223
|
email: z.ZodString;
|
220
224
|
site: z.ZodString;
|
221
225
|
datetime: z.ZodNumber;
|
222
|
-
category: z.
|
226
|
+
category: z.ZodEnum<{
|
227
|
+
SERVER: "SERVER";
|
228
|
+
CLIENT: "CLIENT";
|
229
|
+
}>;
|
223
230
|
totals: z.ZodObject<{
|
224
231
|
clicks: z.ZodNumber;
|
225
232
|
impressions: z.ZodNumber;
|
@@ -261,7 +268,10 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
261
268
|
search: z.ZodOptional<z.ZodString>;
|
262
269
|
hash: z.ZodOptional<z.ZodString>;
|
263
270
|
count: z.ZodNumber;
|
264
|
-
category: z.
|
271
|
+
category: z.ZodEnum<{
|
272
|
+
SERVER: "SERVER";
|
273
|
+
CLIENT: "CLIENT";
|
274
|
+
}>;
|
265
275
|
}, z.core.$strip>;
|
266
276
|
export const BrowserSchema: z.ZodObject<{
|
267
277
|
account: z.ZodOptional<z.ZodString>;
|
@@ -269,7 +279,10 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
269
279
|
site: z.ZodString;
|
270
280
|
browser: z.ZodString;
|
271
281
|
count: z.ZodNumber;
|
272
|
-
category: z.
|
282
|
+
category: z.ZodEnum<{
|
283
|
+
SERVER: "SERVER";
|
284
|
+
CLIENT: "CLIENT";
|
285
|
+
}>;
|
273
286
|
}, z.core.$strip>;
|
274
287
|
export const ResolutionSchema: z.ZodObject<{
|
275
288
|
account: z.ZodOptional<z.ZodString>;
|
@@ -277,7 +290,10 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
277
290
|
site: z.ZodString;
|
278
291
|
resolution: z.ZodString;
|
279
292
|
count: z.ZodNumber;
|
280
|
-
category: z.
|
293
|
+
category: z.ZodEnum<{
|
294
|
+
SERVER: "SERVER";
|
295
|
+
CLIENT: "CLIENT";
|
296
|
+
}>;
|
281
297
|
}, z.core.$strip>;
|
282
298
|
export const ReferrerSchema: z.ZodObject<{
|
283
299
|
account: z.ZodOptional<z.ZodString>;
|
@@ -285,14 +301,20 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
285
301
|
site: z.ZodString;
|
286
302
|
referrer: z.ZodString;
|
287
303
|
count: z.ZodNumber;
|
288
|
-
category: z.
|
304
|
+
category: z.ZodEnum<{
|
305
|
+
SERVER: "SERVER";
|
306
|
+
CLIENT: "CLIENT";
|
307
|
+
}>;
|
289
308
|
}, z.core.$strip>;
|
290
309
|
export const LocationSchema: z.ZodObject<{
|
291
310
|
account: z.ZodOptional<z.ZodString>;
|
292
311
|
datetime: z.ZodNumber;
|
293
312
|
site: z.ZodString;
|
294
313
|
countryRegion: z.ZodString;
|
295
|
-
category: z.
|
314
|
+
category: z.ZodEnum<{
|
315
|
+
SERVER: "SERVER";
|
316
|
+
CLIENT: "CLIENT";
|
317
|
+
}>;
|
296
318
|
count: z.ZodNumber;
|
297
319
|
}, z.core.$strip>;
|
298
320
|
export const LanguageSchema: z.ZodObject<{
|
@@ -301,7 +323,10 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
301
323
|
site: z.ZodString;
|
302
324
|
language: z.ZodString;
|
303
325
|
count: z.ZodNumber;
|
304
|
-
category: z.
|
326
|
+
category: z.ZodEnum<{
|
327
|
+
SERVER: "SERVER";
|
328
|
+
CLIENT: "CLIENT";
|
329
|
+
}>;
|
305
330
|
}, z.core.$strip>;
|
306
331
|
export const FingerprintSchema: z.ZodObject<{
|
307
332
|
account: z.ZodOptional<z.ZodString>;
|
@@ -309,7 +334,10 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
309
334
|
site: z.ZodString;
|
310
335
|
fingerprint: z.ZodString;
|
311
336
|
count: z.ZodNumber;
|
312
|
-
category: z.
|
337
|
+
category: z.ZodEnum<{
|
338
|
+
SERVER: "SERVER";
|
339
|
+
CLIENT: "CLIENT";
|
340
|
+
}>;
|
313
341
|
}, z.core.$strip>;
|
314
342
|
export const EventSchema: z.ZodObject<{
|
315
343
|
account: z.ZodOptional<z.ZodString>;
|
@@ -317,7 +345,10 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
317
345
|
eventName: z.ZodString;
|
318
346
|
datetime: z.ZodNumber;
|
319
347
|
count: z.ZodNumber;
|
320
|
-
category: z.
|
348
|
+
category: z.ZodEnum<{
|
349
|
+
SERVER: "SERVER";
|
350
|
+
CLIENT: "CLIENT";
|
351
|
+
}>;
|
321
352
|
}, z.core.$strip>;
|
322
353
|
export const HealthMetricSchema: z.ZodObject<{
|
323
354
|
type: z.ZodLiteral<"health">;
|
@@ -326,36 +357,39 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
326
357
|
}, z.core.$strip>;
|
327
358
|
export const UserMetricSchema: z.ZodObject<{
|
328
359
|
type: z.ZodString;
|
329
|
-
name: z.ZodString;
|
330
360
|
value: z.ZodNumber;
|
331
361
|
}, z.core.$strip>;
|
332
|
-
export const MetricItemSchema: z.
|
362
|
+
export const MetricItemSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
333
363
|
type: z.ZodLiteral<"health">;
|
334
364
|
responseTimeMs: z.ZodNumber;
|
335
365
|
success: z.ZodBoolean;
|
336
366
|
}, z.core.$strip>, z.ZodObject<{
|
337
367
|
type: z.ZodString;
|
338
|
-
name: z.ZodString;
|
339
368
|
value: z.ZodNumber;
|
340
|
-
}, z.core.$strip>]>;
|
369
|
+
}, z.core.$strip>], "type">;
|
341
370
|
export const MetricSchema: z.ZodObject<{
|
342
371
|
account: z.ZodOptional<z.ZodString>;
|
343
372
|
site: z.ZodString;
|
344
373
|
datetime: z.ZodNumber;
|
345
|
-
|
374
|
+
category: z.ZodEnum<{
|
375
|
+
SERVER: "SERVER";
|
376
|
+
CLIENT: "CLIENT";
|
377
|
+
}>;
|
378
|
+
metric: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
346
379
|
type: z.ZodLiteral<"health">;
|
347
380
|
responseTimeMs: z.ZodNumber;
|
348
381
|
success: z.ZodBoolean;
|
349
382
|
}, z.core.$strip>, z.ZodObject<{
|
350
383
|
type: z.ZodString;
|
351
|
-
name: z.ZodString;
|
352
384
|
value: z.ZodNumber;
|
353
|
-
}, z.core.$strip>]>;
|
385
|
+
}, z.core.$strip>], "type">;
|
354
386
|
}, z.core.$strip>;
|
355
387
|
export interface IMetric extends z.infer<typeof MetricSchema> {
|
356
388
|
}
|
357
389
|
export interface IHealthMetric extends z.infer<typeof HealthMetricSchema> {
|
358
390
|
}
|
391
|
+
export interface IUserMetric extends z.infer<typeof UserMetricSchema> {
|
392
|
+
}
|
359
393
|
export const ModelErrorSchema: z.ZodObject<{
|
360
394
|
PK: z.ZodString;
|
361
395
|
messageHash: z.ZodOptional<z.ZodString>;
|
@@ -369,7 +403,10 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
369
403
|
datetime: z.ZodNumber;
|
370
404
|
archived: z.ZodOptional<z.ZodBoolean>;
|
371
405
|
count: z.ZodNumber;
|
372
|
-
category: z.
|
406
|
+
category: z.ZodEnum<{
|
407
|
+
SERVER: "SERVER";
|
408
|
+
CLIENT: "CLIENT";
|
409
|
+
}>;
|
373
410
|
}, z.core.$strip>;
|
374
411
|
export const RollupTopReferrersSchema: z.ZodObject<{
|
375
412
|
referrer: z.ZodString;
|
@@ -416,7 +453,10 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
416
453
|
account: z.ZodString;
|
417
454
|
site: z.ZodString;
|
418
455
|
datetime: z.ZodNumber;
|
419
|
-
category: z.
|
456
|
+
category: z.ZodEnum<{
|
457
|
+
SERVER: "SERVER";
|
458
|
+
CLIENT: "CLIENT";
|
459
|
+
}>;
|
420
460
|
topReferrers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
421
461
|
referrer: z.ZodString;
|
422
462
|
count: z.ZodNumber;
|
@@ -522,14 +562,12 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
522
562
|
}, z.core.$strip>;
|
523
563
|
export const PostMetricDataSchema: z.ZodObject<{
|
524
564
|
type: z.ZodString;
|
525
|
-
name: z.ZodString;
|
526
565
|
value: z.ZodNumber;
|
527
566
|
}, z.core.$strip>;
|
528
567
|
export const PostMetricSchema: z.ZodObject<{
|
529
568
|
key: z.ZodString;
|
530
569
|
data: z.ZodObject<{
|
531
570
|
type: z.ZodString;
|
532
|
-
name: z.ZodString;
|
533
571
|
value: z.ZodNumber;
|
534
572
|
}, z.core.$strip>;
|
535
573
|
}, z.core.$strip>;
|
@@ -570,7 +608,10 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
570
608
|
site: z.ZodString;
|
571
609
|
browser: z.ZodString;
|
572
610
|
count: z.ZodNumber;
|
573
|
-
category: z.
|
611
|
+
category: z.ZodEnum<{
|
612
|
+
SERVER: "SERVER";
|
613
|
+
CLIENT: "CLIENT";
|
614
|
+
}>;
|
574
615
|
}, z.core.$strip>>>;
|
575
616
|
events: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
576
617
|
account: z.ZodOptional<z.ZodString>;
|
@@ -578,14 +619,20 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
578
619
|
eventName: z.ZodString;
|
579
620
|
datetime: z.ZodNumber;
|
580
621
|
count: z.ZodNumber;
|
581
|
-
category: z.
|
622
|
+
category: z.ZodEnum<{
|
623
|
+
SERVER: "SERVER";
|
624
|
+
CLIENT: "CLIENT";
|
625
|
+
}>;
|
582
626
|
}, z.core.$strip>>>;
|
583
627
|
locations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
584
628
|
account: z.ZodOptional<z.ZodString>;
|
585
629
|
datetime: z.ZodNumber;
|
586
630
|
site: z.ZodString;
|
587
631
|
countryRegion: z.ZodString;
|
588
|
-
category: z.
|
632
|
+
category: z.ZodEnum<{
|
633
|
+
SERVER: "SERVER";
|
634
|
+
CLIENT: "CLIENT";
|
635
|
+
}>;
|
589
636
|
count: z.ZodNumber;
|
590
637
|
}, z.core.$strip>>>;
|
591
638
|
queries: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
@@ -596,7 +643,10 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
596
643
|
search: z.ZodOptional<z.ZodString>;
|
597
644
|
hash: z.ZodOptional<z.ZodString>;
|
598
645
|
count: z.ZodNumber;
|
599
|
-
category: z.
|
646
|
+
category: z.ZodEnum<{
|
647
|
+
SERVER: "SERVER";
|
648
|
+
CLIENT: "CLIENT";
|
649
|
+
}>;
|
600
650
|
}, z.core.$strip>>>;
|
601
651
|
referrers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
602
652
|
account: z.ZodOptional<z.ZodString>;
|
@@ -604,7 +654,10 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
604
654
|
site: z.ZodString;
|
605
655
|
referrer: z.ZodString;
|
606
656
|
count: z.ZodNumber;
|
607
|
-
category: z.
|
657
|
+
category: z.ZodEnum<{
|
658
|
+
SERVER: "SERVER";
|
659
|
+
CLIENT: "CLIENT";
|
660
|
+
}>;
|
608
661
|
}, z.core.$strip>>>;
|
609
662
|
resolutions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
610
663
|
account: z.ZodOptional<z.ZodString>;
|
@@ -612,7 +665,10 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
612
665
|
site: z.ZodString;
|
613
666
|
resolution: z.ZodString;
|
614
667
|
count: z.ZodNumber;
|
615
|
-
category: z.
|
668
|
+
category: z.ZodEnum<{
|
669
|
+
SERVER: "SERVER";
|
670
|
+
CLIENT: "CLIENT";
|
671
|
+
}>;
|
616
672
|
}, z.core.$strip>>>;
|
617
673
|
fingerprints: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
618
674
|
account: z.ZodOptional<z.ZodString>;
|
@@ -620,21 +676,27 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
620
676
|
site: z.ZodString;
|
621
677
|
fingerprint: z.ZodString;
|
622
678
|
count: z.ZodNumber;
|
623
|
-
category: z.
|
679
|
+
category: z.ZodEnum<{
|
680
|
+
SERVER: "SERVER";
|
681
|
+
CLIENT: "CLIENT";
|
682
|
+
}>;
|
624
683
|
}, z.core.$strip>>>;
|
625
684
|
metrics: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
626
685
|
account: z.ZodOptional<z.ZodString>;
|
627
686
|
site: z.ZodString;
|
628
687
|
datetime: z.ZodNumber;
|
629
|
-
|
688
|
+
category: z.ZodEnum<{
|
689
|
+
SERVER: "SERVER";
|
690
|
+
CLIENT: "CLIENT";
|
691
|
+
}>;
|
692
|
+
metric: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
630
693
|
type: z.ZodLiteral<"health">;
|
631
694
|
responseTimeMs: z.ZodNumber;
|
632
695
|
success: z.ZodBoolean;
|
633
696
|
}, z.core.$strip>, z.ZodObject<{
|
634
697
|
type: z.ZodString;
|
635
|
-
name: z.ZodString;
|
636
698
|
value: z.ZodNumber;
|
637
|
-
}, z.core.$strip>]>;
|
699
|
+
}, z.core.$strip>], "type">;
|
638
700
|
}, z.core.$strip>>>;
|
639
701
|
languages: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
640
702
|
account: z.ZodOptional<z.ZodString>;
|
@@ -642,13 +704,19 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
642
704
|
site: z.ZodString;
|
643
705
|
language: z.ZodString;
|
644
706
|
count: z.ZodNumber;
|
645
|
-
category: z.
|
707
|
+
category: z.ZodEnum<{
|
708
|
+
SERVER: "SERVER";
|
709
|
+
CLIENT: "CLIENT";
|
710
|
+
}>;
|
646
711
|
}, z.core.$strip>>>;
|
647
712
|
rollups: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
648
713
|
account: z.ZodString;
|
649
714
|
site: z.ZodString;
|
650
715
|
datetime: z.ZodNumber;
|
651
|
-
category: z.
|
716
|
+
category: z.ZodEnum<{
|
717
|
+
SERVER: "SERVER";
|
718
|
+
CLIENT: "CLIENT";
|
719
|
+
}>;
|
652
720
|
topReferrers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
653
721
|
referrer: z.ZodString;
|
654
722
|
count: z.ZodNumber;
|
@@ -704,14 +772,20 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
704
772
|
datetime: z.ZodNumber;
|
705
773
|
archived: z.ZodOptional<z.ZodBoolean>;
|
706
774
|
count: z.ZodNumber;
|
707
|
-
category: z.
|
775
|
+
category: z.ZodEnum<{
|
776
|
+
SERVER: "SERVER";
|
777
|
+
CLIENT: "CLIENT";
|
778
|
+
}>;
|
708
779
|
}, z.core.$strip>>>;
|
709
780
|
google: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
710
781
|
account: z.ZodString;
|
711
782
|
email: z.ZodString;
|
712
783
|
site: z.ZodString;
|
713
784
|
datetime: z.ZodNumber;
|
714
|
-
category: z.
|
785
|
+
category: z.ZodEnum<{
|
786
|
+
SERVER: "SERVER";
|
787
|
+
CLIENT: "CLIENT";
|
788
|
+
}>;
|
715
789
|
totals: z.ZodObject<{
|
716
790
|
clicks: z.ZodNumber;
|
717
791
|
impressions: z.ZodNumber;
|
@@ -730,7 +804,10 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
730
804
|
email: z.ZodString;
|
731
805
|
site: z.ZodString;
|
732
806
|
datetime: z.ZodNumber;
|
733
|
-
category: z.
|
807
|
+
category: z.ZodEnum<{
|
808
|
+
SERVER: "SERVER";
|
809
|
+
CLIENT: "CLIENT";
|
810
|
+
}>;
|
734
811
|
totals: z.ZodObject<{
|
735
812
|
clicks: z.ZodNumber;
|
736
813
|
impressions: z.ZodNumber;
|
@@ -749,7 +826,10 @@ declare module 'analytica.click/dist/ui/src/server/schema/index' {
|
|
749
826
|
email: z.ZodString;
|
750
827
|
site: z.ZodString;
|
751
828
|
datetime: z.ZodNumber;
|
752
|
-
category: z.
|
829
|
+
category: z.ZodEnum<{
|
830
|
+
SERVER: "SERVER";
|
831
|
+
CLIENT: "CLIENT";
|
832
|
+
}>;
|
753
833
|
totals: z.ZodObject<{
|
754
834
|
clicks: z.ZodNumber;
|
755
835
|
impressions: z.ZodNumber;
|
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,4 +1,9 @@
|
|
1
1
|
import { z } from 'zod';
|
2
|
+
export declare const category: z.ZodEnum<{
|
3
|
+
SERVER: "SERVER";
|
4
|
+
CLIENT: "CLIENT";
|
5
|
+
}>;
|
6
|
+
export type Category = z.infer<typeof category>;
|
2
7
|
export declare const createSiteSchema: z.ZodObject<{
|
3
8
|
site: z.ZodString;
|
4
9
|
}, z.core.$strip>;
|
@@ -36,7 +41,10 @@ export declare const SeoResultSchema: z.ZodObject<{
|
|
36
41
|
email: z.ZodString;
|
37
42
|
site: z.ZodString;
|
38
43
|
datetime: z.ZodNumber;
|
39
|
-
category: z.
|
44
|
+
category: z.ZodEnum<{
|
45
|
+
SERVER: "SERVER";
|
46
|
+
CLIENT: "CLIENT";
|
47
|
+
}>;
|
40
48
|
totals: z.ZodObject<{
|
41
49
|
clicks: z.ZodNumber;
|
42
50
|
impressions: z.ZodNumber;
|
@@ -78,7 +86,10 @@ export declare const QuerySchema: z.ZodObject<{
|
|
78
86
|
search: z.ZodOptional<z.ZodString>;
|
79
87
|
hash: z.ZodOptional<z.ZodString>;
|
80
88
|
count: z.ZodNumber;
|
81
|
-
category: z.
|
89
|
+
category: z.ZodEnum<{
|
90
|
+
SERVER: "SERVER";
|
91
|
+
CLIENT: "CLIENT";
|
92
|
+
}>;
|
82
93
|
}, z.core.$strip>;
|
83
94
|
export declare const BrowserSchema: z.ZodObject<{
|
84
95
|
account: z.ZodOptional<z.ZodString>;
|
@@ -86,7 +97,10 @@ export declare const BrowserSchema: z.ZodObject<{
|
|
86
97
|
site: z.ZodString;
|
87
98
|
browser: z.ZodString;
|
88
99
|
count: z.ZodNumber;
|
89
|
-
category: z.
|
100
|
+
category: z.ZodEnum<{
|
101
|
+
SERVER: "SERVER";
|
102
|
+
CLIENT: "CLIENT";
|
103
|
+
}>;
|
90
104
|
}, z.core.$strip>;
|
91
105
|
export declare const ResolutionSchema: z.ZodObject<{
|
92
106
|
account: z.ZodOptional<z.ZodString>;
|
@@ -94,7 +108,10 @@ export declare const ResolutionSchema: z.ZodObject<{
|
|
94
108
|
site: z.ZodString;
|
95
109
|
resolution: z.ZodString;
|
96
110
|
count: z.ZodNumber;
|
97
|
-
category: z.
|
111
|
+
category: z.ZodEnum<{
|
112
|
+
SERVER: "SERVER";
|
113
|
+
CLIENT: "CLIENT";
|
114
|
+
}>;
|
98
115
|
}, z.core.$strip>;
|
99
116
|
export declare const ReferrerSchema: z.ZodObject<{
|
100
117
|
account: z.ZodOptional<z.ZodString>;
|
@@ -102,14 +119,20 @@ export declare const ReferrerSchema: z.ZodObject<{
|
|
102
119
|
site: z.ZodString;
|
103
120
|
referrer: z.ZodString;
|
104
121
|
count: z.ZodNumber;
|
105
|
-
category: z.
|
122
|
+
category: z.ZodEnum<{
|
123
|
+
SERVER: "SERVER";
|
124
|
+
CLIENT: "CLIENT";
|
125
|
+
}>;
|
106
126
|
}, z.core.$strip>;
|
107
127
|
export declare const LocationSchema: z.ZodObject<{
|
108
128
|
account: z.ZodOptional<z.ZodString>;
|
109
129
|
datetime: z.ZodNumber;
|
110
130
|
site: z.ZodString;
|
111
131
|
countryRegion: z.ZodString;
|
112
|
-
category: z.
|
132
|
+
category: z.ZodEnum<{
|
133
|
+
SERVER: "SERVER";
|
134
|
+
CLIENT: "CLIENT";
|
135
|
+
}>;
|
113
136
|
count: z.ZodNumber;
|
114
137
|
}, z.core.$strip>;
|
115
138
|
export declare const LanguageSchema: z.ZodObject<{
|
@@ -118,7 +141,10 @@ export declare const LanguageSchema: z.ZodObject<{
|
|
118
141
|
site: z.ZodString;
|
119
142
|
language: z.ZodString;
|
120
143
|
count: z.ZodNumber;
|
121
|
-
category: z.
|
144
|
+
category: z.ZodEnum<{
|
145
|
+
SERVER: "SERVER";
|
146
|
+
CLIENT: "CLIENT";
|
147
|
+
}>;
|
122
148
|
}, z.core.$strip>;
|
123
149
|
export declare const FingerprintSchema: z.ZodObject<{
|
124
150
|
account: z.ZodOptional<z.ZodString>;
|
@@ -126,7 +152,10 @@ export declare const FingerprintSchema: z.ZodObject<{
|
|
126
152
|
site: z.ZodString;
|
127
153
|
fingerprint: z.ZodString;
|
128
154
|
count: z.ZodNumber;
|
129
|
-
category: z.
|
155
|
+
category: z.ZodEnum<{
|
156
|
+
SERVER: "SERVER";
|
157
|
+
CLIENT: "CLIENT";
|
158
|
+
}>;
|
130
159
|
}, z.core.$strip>;
|
131
160
|
export declare const EventSchema: z.ZodObject<{
|
132
161
|
account: z.ZodOptional<z.ZodString>;
|
@@ -134,7 +163,10 @@ export declare const EventSchema: z.ZodObject<{
|
|
134
163
|
eventName: z.ZodString;
|
135
164
|
datetime: z.ZodNumber;
|
136
165
|
count: z.ZodNumber;
|
137
|
-
category: z.
|
166
|
+
category: z.ZodEnum<{
|
167
|
+
SERVER: "SERVER";
|
168
|
+
CLIENT: "CLIENT";
|
169
|
+
}>;
|
138
170
|
}, z.core.$strip>;
|
139
171
|
export declare const HealthMetricSchema: z.ZodObject<{
|
140
172
|
type: z.ZodLiteral<"health">;
|
@@ -143,36 +175,39 @@ export declare const HealthMetricSchema: z.ZodObject<{
|
|
143
175
|
}, z.core.$strip>;
|
144
176
|
export declare const UserMetricSchema: z.ZodObject<{
|
145
177
|
type: z.ZodString;
|
146
|
-
name: z.ZodString;
|
147
178
|
value: z.ZodNumber;
|
148
179
|
}, z.core.$strip>;
|
149
|
-
export declare const MetricItemSchema: z.
|
180
|
+
export declare const MetricItemSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
150
181
|
type: z.ZodLiteral<"health">;
|
151
182
|
responseTimeMs: z.ZodNumber;
|
152
183
|
success: z.ZodBoolean;
|
153
184
|
}, z.core.$strip>, z.ZodObject<{
|
154
185
|
type: z.ZodString;
|
155
|
-
name: z.ZodString;
|
156
186
|
value: z.ZodNumber;
|
157
|
-
}, z.core.$strip>]>;
|
187
|
+
}, z.core.$strip>], "type">;
|
158
188
|
export declare const MetricSchema: z.ZodObject<{
|
159
189
|
account: z.ZodOptional<z.ZodString>;
|
160
190
|
site: z.ZodString;
|
161
191
|
datetime: z.ZodNumber;
|
162
|
-
|
192
|
+
category: z.ZodEnum<{
|
193
|
+
SERVER: "SERVER";
|
194
|
+
CLIENT: "CLIENT";
|
195
|
+
}>;
|
196
|
+
metric: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
163
197
|
type: z.ZodLiteral<"health">;
|
164
198
|
responseTimeMs: z.ZodNumber;
|
165
199
|
success: z.ZodBoolean;
|
166
200
|
}, z.core.$strip>, z.ZodObject<{
|
167
201
|
type: z.ZodString;
|
168
|
-
name: z.ZodString;
|
169
202
|
value: z.ZodNumber;
|
170
|
-
}, z.core.$strip>]>;
|
203
|
+
}, z.core.$strip>], "type">;
|
171
204
|
}, z.core.$strip>;
|
172
205
|
export interface IMetric extends z.infer<typeof MetricSchema> {
|
173
206
|
}
|
174
207
|
export interface IHealthMetric extends z.infer<typeof HealthMetricSchema> {
|
175
208
|
}
|
209
|
+
export interface IUserMetric extends z.infer<typeof UserMetricSchema> {
|
210
|
+
}
|
176
211
|
export declare const ModelErrorSchema: z.ZodObject<{
|
177
212
|
PK: z.ZodString;
|
178
213
|
messageHash: z.ZodOptional<z.ZodString>;
|
@@ -186,7 +221,10 @@ export declare const ModelErrorSchema: z.ZodObject<{
|
|
186
221
|
datetime: z.ZodNumber;
|
187
222
|
archived: z.ZodOptional<z.ZodBoolean>;
|
188
223
|
count: z.ZodNumber;
|
189
|
-
category: z.
|
224
|
+
category: z.ZodEnum<{
|
225
|
+
SERVER: "SERVER";
|
226
|
+
CLIENT: "CLIENT";
|
227
|
+
}>;
|
190
228
|
}, z.core.$strip>;
|
191
229
|
export declare const RollupTopReferrersSchema: z.ZodObject<{
|
192
230
|
referrer: z.ZodString;
|
@@ -233,7 +271,10 @@ export declare const RollupSchema: z.ZodObject<{
|
|
233
271
|
account: z.ZodString;
|
234
272
|
site: z.ZodString;
|
235
273
|
datetime: z.ZodNumber;
|
236
|
-
category: z.
|
274
|
+
category: z.ZodEnum<{
|
275
|
+
SERVER: "SERVER";
|
276
|
+
CLIENT: "CLIENT";
|
277
|
+
}>;
|
237
278
|
topReferrers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
238
279
|
referrer: z.ZodString;
|
239
280
|
count: z.ZodNumber;
|
@@ -339,14 +380,12 @@ export declare const PostErrorSchema: z.ZodObject<{
|
|
339
380
|
}, z.core.$strip>;
|
340
381
|
export declare const PostMetricDataSchema: z.ZodObject<{
|
341
382
|
type: z.ZodString;
|
342
|
-
name: z.ZodString;
|
343
383
|
value: z.ZodNumber;
|
344
384
|
}, z.core.$strip>;
|
345
385
|
export declare const PostMetricSchema: z.ZodObject<{
|
346
386
|
key: z.ZodString;
|
347
387
|
data: z.ZodObject<{
|
348
388
|
type: z.ZodString;
|
349
|
-
name: z.ZodString;
|
350
389
|
value: z.ZodNumber;
|
351
390
|
}, z.core.$strip>;
|
352
391
|
}, z.core.$strip>;
|
@@ -387,7 +426,10 @@ export declare const SiteDataSchema: z.ZodObject<{
|
|
387
426
|
site: z.ZodString;
|
388
427
|
browser: z.ZodString;
|
389
428
|
count: z.ZodNumber;
|
390
|
-
category: z.
|
429
|
+
category: z.ZodEnum<{
|
430
|
+
SERVER: "SERVER";
|
431
|
+
CLIENT: "CLIENT";
|
432
|
+
}>;
|
391
433
|
}, z.core.$strip>>>;
|
392
434
|
events: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
393
435
|
account: z.ZodOptional<z.ZodString>;
|
@@ -395,14 +437,20 @@ export declare const SiteDataSchema: z.ZodObject<{
|
|
395
437
|
eventName: z.ZodString;
|
396
438
|
datetime: z.ZodNumber;
|
397
439
|
count: z.ZodNumber;
|
398
|
-
category: z.
|
440
|
+
category: z.ZodEnum<{
|
441
|
+
SERVER: "SERVER";
|
442
|
+
CLIENT: "CLIENT";
|
443
|
+
}>;
|
399
444
|
}, z.core.$strip>>>;
|
400
445
|
locations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
401
446
|
account: z.ZodOptional<z.ZodString>;
|
402
447
|
datetime: z.ZodNumber;
|
403
448
|
site: z.ZodString;
|
404
449
|
countryRegion: z.ZodString;
|
405
|
-
category: z.
|
450
|
+
category: z.ZodEnum<{
|
451
|
+
SERVER: "SERVER";
|
452
|
+
CLIENT: "CLIENT";
|
453
|
+
}>;
|
406
454
|
count: z.ZodNumber;
|
407
455
|
}, z.core.$strip>>>;
|
408
456
|
queries: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
@@ -413,7 +461,10 @@ export declare const SiteDataSchema: z.ZodObject<{
|
|
413
461
|
search: z.ZodOptional<z.ZodString>;
|
414
462
|
hash: z.ZodOptional<z.ZodString>;
|
415
463
|
count: z.ZodNumber;
|
416
|
-
category: z.
|
464
|
+
category: z.ZodEnum<{
|
465
|
+
SERVER: "SERVER";
|
466
|
+
CLIENT: "CLIENT";
|
467
|
+
}>;
|
417
468
|
}, z.core.$strip>>>;
|
418
469
|
referrers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
419
470
|
account: z.ZodOptional<z.ZodString>;
|
@@ -421,7 +472,10 @@ export declare const SiteDataSchema: z.ZodObject<{
|
|
421
472
|
site: z.ZodString;
|
422
473
|
referrer: z.ZodString;
|
423
474
|
count: z.ZodNumber;
|
424
|
-
category: z.
|
475
|
+
category: z.ZodEnum<{
|
476
|
+
SERVER: "SERVER";
|
477
|
+
CLIENT: "CLIENT";
|
478
|
+
}>;
|
425
479
|
}, z.core.$strip>>>;
|
426
480
|
resolutions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
427
481
|
account: z.ZodOptional<z.ZodString>;
|
@@ -429,7 +483,10 @@ export declare const SiteDataSchema: z.ZodObject<{
|
|
429
483
|
site: z.ZodString;
|
430
484
|
resolution: z.ZodString;
|
431
485
|
count: z.ZodNumber;
|
432
|
-
category: z.
|
486
|
+
category: z.ZodEnum<{
|
487
|
+
SERVER: "SERVER";
|
488
|
+
CLIENT: "CLIENT";
|
489
|
+
}>;
|
433
490
|
}, z.core.$strip>>>;
|
434
491
|
fingerprints: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
435
492
|
account: z.ZodOptional<z.ZodString>;
|
@@ -437,21 +494,27 @@ export declare const SiteDataSchema: z.ZodObject<{
|
|
437
494
|
site: z.ZodString;
|
438
495
|
fingerprint: z.ZodString;
|
439
496
|
count: z.ZodNumber;
|
440
|
-
category: z.
|
497
|
+
category: z.ZodEnum<{
|
498
|
+
SERVER: "SERVER";
|
499
|
+
CLIENT: "CLIENT";
|
500
|
+
}>;
|
441
501
|
}, z.core.$strip>>>;
|
442
502
|
metrics: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
443
503
|
account: z.ZodOptional<z.ZodString>;
|
444
504
|
site: z.ZodString;
|
445
505
|
datetime: z.ZodNumber;
|
446
|
-
|
506
|
+
category: z.ZodEnum<{
|
507
|
+
SERVER: "SERVER";
|
508
|
+
CLIENT: "CLIENT";
|
509
|
+
}>;
|
510
|
+
metric: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
447
511
|
type: z.ZodLiteral<"health">;
|
448
512
|
responseTimeMs: z.ZodNumber;
|
449
513
|
success: z.ZodBoolean;
|
450
514
|
}, z.core.$strip>, z.ZodObject<{
|
451
515
|
type: z.ZodString;
|
452
|
-
name: z.ZodString;
|
453
516
|
value: z.ZodNumber;
|
454
|
-
}, z.core.$strip>]>;
|
517
|
+
}, z.core.$strip>], "type">;
|
455
518
|
}, z.core.$strip>>>;
|
456
519
|
languages: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
457
520
|
account: z.ZodOptional<z.ZodString>;
|
@@ -459,13 +522,19 @@ export declare const SiteDataSchema: z.ZodObject<{
|
|
459
522
|
site: z.ZodString;
|
460
523
|
language: z.ZodString;
|
461
524
|
count: z.ZodNumber;
|
462
|
-
category: z.
|
525
|
+
category: z.ZodEnum<{
|
526
|
+
SERVER: "SERVER";
|
527
|
+
CLIENT: "CLIENT";
|
528
|
+
}>;
|
463
529
|
}, z.core.$strip>>>;
|
464
530
|
rollups: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
465
531
|
account: z.ZodString;
|
466
532
|
site: z.ZodString;
|
467
533
|
datetime: z.ZodNumber;
|
468
|
-
category: z.
|
534
|
+
category: z.ZodEnum<{
|
535
|
+
SERVER: "SERVER";
|
536
|
+
CLIENT: "CLIENT";
|
537
|
+
}>;
|
469
538
|
topReferrers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
470
539
|
referrer: z.ZodString;
|
471
540
|
count: z.ZodNumber;
|
@@ -521,14 +590,20 @@ export declare const SiteDataSchema: z.ZodObject<{
|
|
521
590
|
datetime: z.ZodNumber;
|
522
591
|
archived: z.ZodOptional<z.ZodBoolean>;
|
523
592
|
count: z.ZodNumber;
|
524
|
-
category: z.
|
593
|
+
category: z.ZodEnum<{
|
594
|
+
SERVER: "SERVER";
|
595
|
+
CLIENT: "CLIENT";
|
596
|
+
}>;
|
525
597
|
}, z.core.$strip>>>;
|
526
598
|
google: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
527
599
|
account: z.ZodString;
|
528
600
|
email: z.ZodString;
|
529
601
|
site: z.ZodString;
|
530
602
|
datetime: z.ZodNumber;
|
531
|
-
category: z.
|
603
|
+
category: z.ZodEnum<{
|
604
|
+
SERVER: "SERVER";
|
605
|
+
CLIENT: "CLIENT";
|
606
|
+
}>;
|
532
607
|
totals: z.ZodObject<{
|
533
608
|
clicks: z.ZodNumber;
|
534
609
|
impressions: z.ZodNumber;
|
@@ -547,7 +622,10 @@ export declare const SiteDataSchema: z.ZodObject<{
|
|
547
622
|
email: z.ZodString;
|
548
623
|
site: z.ZodString;
|
549
624
|
datetime: z.ZodNumber;
|
550
|
-
category: z.
|
625
|
+
category: z.ZodEnum<{
|
626
|
+
SERVER: "SERVER";
|
627
|
+
CLIENT: "CLIENT";
|
628
|
+
}>;
|
551
629
|
totals: z.ZodObject<{
|
552
630
|
clicks: z.ZodNumber;
|
553
631
|
impressions: z.ZodNumber;
|
@@ -566,7 +644,10 @@ export declare const SiteDataSchema: z.ZodObject<{
|
|
566
644
|
email: z.ZodString;
|
567
645
|
site: z.ZodString;
|
568
646
|
datetime: z.ZodNumber;
|
569
|
-
category: z.
|
647
|
+
category: z.ZodEnum<{
|
648
|
+
SERVER: "SERVER";
|
649
|
+
CLIENT: "CLIENT";
|
650
|
+
}>;
|
570
651
|
totals: z.ZodObject<{
|
571
652
|
clicks: z.ZodNumber;
|
572
653
|
impressions: z.ZodNumber;
|