-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
607 lines (513 loc) · 9.79 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
/**
* GeoLatitude
* @see https://developer.mozilla.org/en-US/docs/Web/API/GeolocationCoordinates/latitude
*/
type GeoLatitude = number;
/**
* GeoLongitude
* @see https://developer.mozilla.org/en-US/docs/Web/API/GeolocationCoordinates/longitude
*/
type GeoLongitude = number;
/**
* GeoAccuracy
* @see https://developer.mozilla.org/en-US/docs/Web/API/GeolocationCoordinates/accuracy
*/
type GeoAccuracy = number;
/**
* CollectorServerHost
*/
type CollectorServerHost = string;
/**
* PublicInstanceID
*
* Public instance id of analytics
* @example '0123456789aZ'
*/
type PublicInstanceID = string;
/**
* PrivateInstanceKey
*
* Private instance api key; require for API usage, on client side usage will be ignored
* @example '0123456789aZ0123456789aZ0123456789aZ12'
*/
type PrivateInstanceKey = string;
/**
* ClientIP
*
* Require for API usage, on client side usage will be ignored;
* @example '1.1.1.1'
*/
type ClientIP = string;
/**
* ClientUserAgent
*
* Require for API usage, on client side usage will be ignored;
* @example 'curl/8.0.0'
*/
type ClientUserAgent = string;
/**
* ClientTime
*
* Number in unix time, must be '<= now' and '>= (now - 8h)'
* Require for API usage, on client side usage will be ignored;
* If value not send `now` will on collector insert
* @example 1577836800
*/
type ClientTime = number;
/**
* PageURL
* @see {@link window.location.href}
* @example 'https://sub.example.tld/path/file.ext?n1=v1#hash'
*/
type PageURL = string;
/**
* ReferrerURL
* @see {@link document.referrer}
*/
type ReferrerURL = string;
/**
* IsIframe
*
* Is page loaded in iframe or main window
*/
type IsIframe = boolean;
/**
* IsTouchSupport
*
* Client support touch
*/
type IsTouchSupport = boolean;
/**
* Username or user identifier
*/
type UserIdOrName = string;
/**
* CanonicalURL `<link rel="canonical" href="http://example.tld/page.html">`
* @see https://en.wikipedia.org/wiki/Canonical_link_element
*/
type CanonicalURL = string;
/**
* PageTitle
* `<meta property="og:title" content="Page title">` or `<title>Page title</title>`
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title
* @example 'Page Title'
*/
type PageTitle = string;
/**
* PageLanguage
*`<html lang="en">`
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang
* @example 'en'
*/
type PageLanguage = string;
/**
* PageKeywords (up to 10 keywords)
* `<meta name="keywords" content="foo,bar">`
* @see https://en.wikipedia.org/wiki/Meta_element#The_keywords_attribute
* @example 'foo,bar'
*/
type PageKeywords = string;
/**
* Entity ID
*
* ID in RDBMS, or any Ident like data `/^[a-zA-Z0-9-_\/]{1,63}$/`
*
* @example '/' For home page
* @example '1000' MySQL
* @example '5e0bbe150000000000000000' MongoDB
* @example 'myusers/3456789' ArangoDB
* @example '6F9619FF-8B86-D011-B42D-00C04FC964FF' RethinkDB
*/
type MainEntityID = string;
/**
* Entity module
*
* Lower case and _ separated name of module /^[a-z0-9_]{1,31}$/
*
* @example 'home'
* @example 'video_gallery'
* @example 'product'
* @example 'newspaper'
* @example 'blog'
* @example 'landing'
* @example 'news'
*/
type MainEntityModule = string;
/**
* Entity Taxonomy ID must valid aasaam taxonomy id (uint16 1 to 65535)
*
* @see {@link https://github.com/aasaam/taxonomy}
* @example 21
* @example '91'
*/
type MainEntityTaxonomyID = string | number;
/**
* ScreenSize
* @see {@link window.screen.width}
* @see {@link window.screen.height}
* @example '1600x900'
*/
type ScreenSize = string;
/**
* ViewportSize
* @see {@link window.innerWidth}
* @see {@link window.innerHeight}
* @example '1400x600'
*/
type ViewportSize = string;
/**
* ColorDepth
* @see {@link window.screen.colorDepth}
* @example '24'
*/
type ColorDepth = string;
/**
* DevicePixelRatio
*
* @see {@link window.devicePixelRatio}
* @example '1.5'
*/
type DevicePixelRatio = string;
/**
* ScreenOrientationType
*
* @see {@link window.screen.orientation.type}
* @example 'l-p'
*/
type ScreenOrientationType = string;
// BreadcrumbList
type BreadcrumbListItemListElementItem = {
'@id': string;
name: string;
};
interface BreadcrumbListItemListElement {
position: number;
name?: string;
item: BreadcrumbListItemListElementItem | string;
}
interface BreadcrumbList {
itemListElement: BreadcrumbListItemListElement[];
}
interface PageBreadcrumbItem {
p: number;
n: string;
u: string;
}
interface PageBreadcrumbSend {}
type PageBreadcrumbObject = { [key: string]: string };
/**
* PageBreadcrumbList (up to 5)
*/
type PageBreadcrumbList = PageBreadcrumbItem[];
type AnalyticsRequestMode =
/**
* PageView
*/
// PageViewJavaScript
| 'pv_js'
// PageViewImageLegacy
| 'pv_il'
// PageViewImageNoScript
| 'pv_ins'
// PageViewAMP
| 'pv_amp'
// PageViewAMPImage
| 'pv_amp_i'
/**
* Event
*/
// EventJSInPageView
| 'e_js_pv'
// EventJSCross
| 'e_js_c'
// EventServiceWorker
| 'e_sw'
// EventAPI
| 'e_api'
// EventOther
| 'e_o';
interface PerformanceData {
/**
* Total resources
*/
r?: number;
/**
* PAGE_LOAD_TIME
*/
plt?: string;
/**
* DOMAIN_LOOKUP_TIME
*/
dlt?: string;
/**
* TCP_CONNECT_TIME
*/
tct?: string;
/**
* SERVER_RESPONSE_TIME
*/
srt?: string;
/**
* PAGE_DOWNLOAD_TIME
*/
pdt?: string;
/**
* REDIRECT_TIME
*/
rt?: string;
/**
* DOM_INTERACTIVE_TIME
*/
dit?: string;
/**
* CONTENT_LOAD_TIME
*/
clt?: string;
/**
* TOTAL_RESOURCES
*/
res?: string;
}
interface GeographyData {
lat: GeoLatitude;
lon: GeoLongitude;
}
interface EventData {
/**
* Category
*
* Valid regex: `[a-z0-9]{1,127}`
*/
c: string;
/**
* Action
*
* Valid regex: `[a-z0-9]{1,127}`
*/
a: string;
/**
* Label
*
* Any valid unicode string with length [1-127]
*/
l?: string;
/**
* Ident
*
* Identification for future usage
*/
id?: string;
/**
* Value
*
* None-negative integer number [0-18446744073709551615]
*/
v?: number;
}
interface EventDataBuffer extends EventData {
i: PublicInstanceID;
}
type EventDataGroup = { [key: string]: EventDataBuffer[] };
interface MainEntityProps {
i: MainEntityID;
m: MainEntityModule;
t?: MainEntityTaxonomyID;
}
interface ClientIdentifier {
i: Date;
s: Date;
r: string;
}
interface APIRequest {
i_p: PrivateInstanceKey;
c_ip: ClientIP;
c_ua: ClientUserAgent;
c_t?: ClientTime;
}
interface PageCommonData {
u?: PageURL;
r?: ReferrerURL;
t?: PageTitle;
l?: PageLanguage;
ei?: MainEntityID;
em?: MainEntityModule;
et?: MainEntityTaxonomyID;
cu?: CanonicalURL;
}
interface SegmentPayload {
s1n?: string;
s2n?: string;
s3n?: string;
s4n?: string;
s5n?: string;
s1v?: string;
s2v?: string;
s3v?: string;
s4v?: string;
s5v?: string;
}
interface PageData extends PageCommonData {
scr?: ScreenSize;
vps?: ViewportSize;
cd?: ColorDepth;
dpr?: DevicePixelRatio;
sot?: ScreenOrientationType;
seg?: SegmentPayload;
k?: PageKeywords;
bc?: PageBreadcrumbObject;
if?: IsIframe;
ts?: IsTouchSupport;
rs?: ReferrerURL;
usr?: UserIdOrName;
geo?: GeographyData;
prf?: PerformanceData;
}
interface AnalyticsRequestGET extends PageCommonData {
m: AnalyticsRequestMode;
i: PublicInstanceID;
}
interface AnalyticsRequestPOST {
/**
* Client identifier (Standard)
*/
cid_std?: string;
/**
* Client identifier (AMP)
*/
cid_amp?: string;
p?: PageData;
ev?: EventData[];
ar?: APIRequest;
}
interface StorageItem {
v: StorageValue;
e?: number;
}
type StorageData = { [key: string]: any };
type StorageValue =
| GeographyData
| ReferrerURL
| { [key: string]: string | number | string[] | number[] }
| string
| number
| string[]
| number[];
interface PageViewPayload extends PageCommonData {
usr?: UserIdOrName;
sg?: Segment[];
k?: PageKeywords;
geo?: GeographyData | boolean;
bc?: string | BreadcrumbList | boolean;
/**
* Performance wait time in millisecond
*
* @default 500
*/
pwt?: number;
}
interface InitializeDataGeo {
/**
* Geo location timeout in seconds [1-60]
*
* @default 10
*/
to?: number;
/**
* Geo location lifetime in seconds [3600-7776000]
*
* @default 604800
*/
lt?: number;
/**
* Geo location failed cache lifetime in seconds [60-86400]
*
* default is session duration time
*/
fc?: number;
/**
* Geo location enableHighAccuracy
*
* @default true
*/
ha?: boolean;
}
interface InitializeData {
i: PublicInstanceID;
s: CollectorServerHost;
/**
* Prefix for local storage and cookie
*
* @default 'aa_std'
*/
p?: string;
/**
* Initialize instance with page view
*
* @default true
*/
pv?: boolean | PageViewPayload;
/**
* Session duration in seconds [60-86400]
*
* @default 1800
*/
sd?: number;
/**
* Geolocation
*/
gl?: InitializeDataGeo;
}
declare function aasaamAnalytics(
initializeData: InitializeData
): aasaamAnalyticsInstance;
interface PublicCIDData {
/**
* Initialize date
*/
i: Date;
/**
* Session date
*/
s: Date;
/**
* Random part
*/
r: string;
/**
* Persist part
*/
p: string;
/**
* Is returned User
*/
ru: boolean;
}
type SegmentScope = 1 | 2 | 3 | 4 | 5;
interface Segment {
/**
* Scope
*/
s: SegmentScope;
/**
* Name
*/
n: string;
/**
* Value
*/
v: string;
}
interface aasaamAnalyticsInstance {
ie?: EventData[];
cid(): PublicCIDData;
pageView(injectPayload?: PageViewPayload): aasaamAnalyticsInstance;
event(
eventData: EventData,
crossProjectPublicInstanceID?: PublicInstanceID
): aasaamAnalyticsInstance;
}
interface Window {
aai_lid?: InitializeData;
aasaamAnalytics?: aasaamAnalytics;
aai: aasaamAnalyticsInstance;
}