umami-api-js 1.0.1 → 1.2.0
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/README.md +2 -2
- package/dist/index.d.ts +46 -11
- package/dist/index.js +54 -16
- package/dist/namespaces/Events.d.ts +18 -2
- package/dist/namespaces/Events.js +6 -0
- package/dist/namespaces/Links.d.ts +12 -1
- package/dist/namespaces/Links.js +5 -0
- package/dist/namespaces/Pixels.d.ts +10 -1
- package/dist/namespaces/Pixels.js +5 -0
- package/dist/namespaces/Reports.d.ts +71 -20
- package/dist/namespaces/Reports.js +24 -2
- package/dist/namespaces/Sessions.d.ts +29 -0
- package/dist/namespaces/Sessions.js +11 -0
- package/dist/namespaces/Share.d.ts +70 -0
- package/dist/namespaces/Share.js +46 -0
- package/dist/namespaces/Teams.d.ts +4 -2
- package/dist/namespaces/Users.d.ts +5 -4
- package/dist/namespaces/WebsiteStats.d.ts +9 -2
- package/dist/namespaces/WebsiteStats.js +5 -0
- package/dist/namespaces/Websites.d.ts +16 -2
- package/dist/namespaces/Websites.js +5 -0
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
[](https://codeberg.org/Taevas/umami-api-js/actions?workflow=test.yml)
|
|
5
5
|
[](https://ko-fi.com/V7V4J78L0)
|
|
6
6
|
|
|
7
|
-
A package to interact with [the API of **self-hosted instances** of Umami](https://umami.is/docs/api).
|
|
7
|
+
A package to interact with [the API of **self-hosted instances** of Umami](https://docs.umami.is/docs/api).
|
|
8
8
|
|
|
9
9
|
The documentation for the latest version of this package can be found at any time on [umami-api-js.taevas.xyz](https://umami-api-js.taevas.xyz)!
|
|
10
10
|
|
|
11
|
-
Please note: It has
|
|
11
|
+
Please note: It has NOT been made to work on [Umami Cloud](https://docs.umami.is/docs/cloud) (the instance of Umami hosted by its creators) and is therefore not expected to work there.
|
|
12
12
|
|
|
13
13
|
## How to install and get started
|
|
14
14
|
|
package/dist/index.d.ts
CHANGED
|
@@ -6,11 +6,12 @@ import { Pixels } from "./namespaces/Pixels.js";
|
|
|
6
6
|
import { Realtime } from "./namespaces/Realtime.js";
|
|
7
7
|
import { Reports } from "./namespaces/Reports.js";
|
|
8
8
|
import { Sessions } from "./namespaces/Sessions.js";
|
|
9
|
+
import { Share } from "./namespaces/Share.js";
|
|
9
10
|
import { Teams } from "./namespaces/Teams.js";
|
|
10
11
|
import { Users } from "./namespaces/Users.js";
|
|
11
12
|
import { Websites } from "./namespaces/Websites.js";
|
|
12
13
|
import { WebsiteStats } from "./namespaces/WebsiteStats.js";
|
|
13
|
-
export { Admin, Events, Links, Me, Pixels, Websites, WebsiteStats, Realtime, Reports, Sessions, Teams, Users, };
|
|
14
|
+
export { Admin, Events, Links, Me, Pixels, Websites, WebsiteStats, Realtime, Reports, Sessions, Share, Teams, Users, };
|
|
14
15
|
export interface DeletionResult {
|
|
15
16
|
ok: boolean;
|
|
16
17
|
}
|
|
@@ -157,8 +158,8 @@ export declare class API {
|
|
|
157
158
|
});
|
|
158
159
|
private _user;
|
|
159
160
|
/** Information about the account that has been used to log in */
|
|
160
|
-
get user(): Users.
|
|
161
|
-
set user(user: Users.
|
|
161
|
+
get user(): Users.UserWithTeams;
|
|
162
|
+
set user(user: Users.UserWithTeams);
|
|
162
163
|
private number_of_requests;
|
|
163
164
|
/** Has {@link API.setNewToken} been called and not yet returned anything? */
|
|
164
165
|
private is_setting_token;
|
|
@@ -192,8 +193,8 @@ export declare class API {
|
|
|
192
193
|
private updateTokenTimer;
|
|
193
194
|
private _verbose?;
|
|
194
195
|
/** Which events should be logged (defaults to **none**) */
|
|
195
|
-
get verbose(): "
|
|
196
|
-
set verbose(verbose: "
|
|
196
|
+
get verbose(): "all" | "none" | "errors" | undefined;
|
|
197
|
+
set verbose(verbose: "all" | "none" | "errors" | undefined);
|
|
197
198
|
private _timeout;
|
|
198
199
|
/**
|
|
199
200
|
* The maximum **amount of seconds** requests should take before returning an answer (defaults to **20**)
|
|
@@ -306,9 +307,13 @@ export declare class API {
|
|
|
306
307
|
readonly getWebsiteEventsDataValues: typeof Events.get_WEBSITEID_EventdataValues;
|
|
307
308
|
/** @group Events endpoints */
|
|
308
309
|
readonly getWebsiteEventsDataStats: typeof Events.get_WEBSITEID_EventdataStats;
|
|
310
|
+
/** @group Events endpoints */
|
|
311
|
+
readonly getWebsiteEventsDataPivoted: typeof Events.get_WEBSITEID_EventdataPivot;
|
|
309
312
|
/** @group Links endpoints */
|
|
310
313
|
readonly getLinks: typeof Links.get;
|
|
311
314
|
/** @group Links endpoints */
|
|
315
|
+
readonly createLink: typeof Links.post;
|
|
316
|
+
/** @group Links endpoints */
|
|
312
317
|
readonly getLink: typeof Links.get_LINKID;
|
|
313
318
|
/** @group Links endpoints */
|
|
314
319
|
readonly updateLink: typeof Links.post_LINKID;
|
|
@@ -320,13 +325,15 @@ export declare class API {
|
|
|
320
325
|
readonly getMyTeams: typeof Me.getTeams;
|
|
321
326
|
/** @group Me endpoints */
|
|
322
327
|
readonly getMyWebsites: typeof Me.getWebsites;
|
|
323
|
-
/** @group
|
|
328
|
+
/** @group Pixels endpoints */
|
|
324
329
|
readonly getPixels: typeof Pixels.get;
|
|
325
|
-
/** @group
|
|
330
|
+
/** @group Pixels endpoints */
|
|
331
|
+
readonly createPixel: typeof Pixels.post;
|
|
332
|
+
/** @group Pixels endpoints */
|
|
326
333
|
readonly getPixel: typeof Pixels.get_PIXELID;
|
|
327
|
-
/** @group
|
|
334
|
+
/** @group Pixels endpoints */
|
|
328
335
|
readonly updatePixel: typeof Pixels.post_PIXELID;
|
|
329
|
-
/** @group
|
|
336
|
+
/** @group Pixels endpoints */
|
|
330
337
|
readonly deletePixel: typeof Pixels.delete_PIXELID;
|
|
331
338
|
/** @group Websites endpoints */
|
|
332
339
|
readonly getWebsites: typeof Websites.get;
|
|
@@ -340,9 +347,13 @@ export declare class API {
|
|
|
340
347
|
readonly deleteWebsite: typeof Websites.delete_WEBSITEID;
|
|
341
348
|
/** @group Websites endpoints */
|
|
342
349
|
readonly resetWebsite: typeof Websites.post_WEBSITEID_Reset;
|
|
350
|
+
/** @group Websites endpoints */
|
|
351
|
+
readonly getWebsiteRecorder: typeof Websites.getRecorder;
|
|
343
352
|
/** @group Website stats endpoints */
|
|
344
353
|
readonly getWebsiteActiveVisitors: typeof WebsiteStats.get_WEBSITEID_Active;
|
|
345
354
|
/** @group Website stats endpoints */
|
|
355
|
+
readonly getWebsiteDateRange: typeof WebsiteStats.get_WEBSITEID_DateRange;
|
|
356
|
+
/** @group Website stats endpoints */
|
|
346
357
|
readonly getWebsiteEventsStats: typeof WebsiteStats.get_WEBSITEID_EventsSeries;
|
|
347
358
|
/** @group Website stats endpoints */
|
|
348
359
|
readonly getWebsiteMetrics: typeof WebsiteStats.get_WEBSITEID_Metrics;
|
|
@@ -379,6 +390,14 @@ export declare class API {
|
|
|
379
390
|
/** @group Reports endpoints */
|
|
380
391
|
readonly getReportsRevenue: typeof Reports.postRevenue;
|
|
381
392
|
/** @group Reports endpoints */
|
|
393
|
+
readonly getReportsRevenueChart: typeof Reports.getRevenueChart;
|
|
394
|
+
/** @group Reports endpoints */
|
|
395
|
+
readonly getReportsRevenueStats: typeof Reports.getRevenueStats;
|
|
396
|
+
/** @group Reports endpoints */
|
|
397
|
+
readonly getReportsRevenueMetrics: typeof Reports.getRevenueMetrics;
|
|
398
|
+
/** @group Reports endpoints */
|
|
399
|
+
readonly getReportsRevenueSessions: typeof Reports.getRevenueSessions;
|
|
400
|
+
/** @group Reports endpoints */
|
|
382
401
|
readonly getReportsUTM: typeof Reports.postUTM;
|
|
383
402
|
/** @group Sessions endpoints */
|
|
384
403
|
readonly getWebsiteSessions: typeof Sessions.get_WEBSITEID_Sessions;
|
|
@@ -396,6 +415,22 @@ export declare class API {
|
|
|
396
415
|
readonly getWebsiteSessionDataProperties: typeof Sessions.get_WEBSITEID_SessiondataProperties;
|
|
397
416
|
/** @group Sessions endpoints */
|
|
398
417
|
readonly getWebsiteSessionDataValues: typeof Sessions.get_WEBSITEID_SessiondataValues;
|
|
418
|
+
/** @group Sessions endpoints */
|
|
419
|
+
readonly getWebsiteSessionDataPivoted: typeof Sessions.get_WEBSITEID_SessiondataPivot;
|
|
420
|
+
/** @group Sessions endpoints */
|
|
421
|
+
readonly getWebsiteSessionDataStats: typeof Sessions.get_WEBSITEID_SessiondataStats;
|
|
422
|
+
/** @group Share endpoints */
|
|
423
|
+
readonly createShare: typeof Share.post;
|
|
424
|
+
/** @group Share endpoints */
|
|
425
|
+
readonly getShare: typeof Share.get_SHAREID;
|
|
426
|
+
/** @group Share endpoints */
|
|
427
|
+
readonly updateShare: typeof Share.post_SHAREID;
|
|
428
|
+
/** @group Share endpoints */
|
|
429
|
+
readonly deleteShare: typeof Share.delete_SHAREID;
|
|
430
|
+
/** @group Share endpoints */
|
|
431
|
+
readonly getWebsiteShares: typeof Share.get_WEBSITEID_Shares;
|
|
432
|
+
/** @group Share endpoints */
|
|
433
|
+
readonly createWebsiteShare: typeof Share.post_WEBSITEID_Shares;
|
|
399
434
|
/** @group Teams endpoints */
|
|
400
435
|
readonly getTeams: typeof Teams.get;
|
|
401
436
|
/** @group Teams endpoints */
|
|
@@ -429,7 +464,7 @@ export declare class API {
|
|
|
429
464
|
/** @group Users endpoints */
|
|
430
465
|
readonly deleteUser: typeof Users.delete_USERID;
|
|
431
466
|
/** @group Users endpoints */
|
|
432
|
-
readonly getUserTeams: typeof Users.get_USERID_Teams;
|
|
433
|
-
/** @group Users endpoints */
|
|
434
467
|
readonly getUserWebsites: typeof Users.get_USERID_Websites;
|
|
468
|
+
/** @group Users endpoints */
|
|
469
|
+
readonly getUserTeams: typeof Users.get_USERID_Teams;
|
|
435
470
|
}
|
package/dist/index.js
CHANGED
|
@@ -6,12 +6,13 @@ import { Pixels } from "./namespaces/Pixels.js";
|
|
|
6
6
|
import { Realtime } from "./namespaces/Realtime.js";
|
|
7
7
|
import { Reports } from "./namespaces/Reports.js";
|
|
8
8
|
import { Sessions } from "./namespaces/Sessions.js";
|
|
9
|
+
import { Share } from "./namespaces/Share.js";
|
|
9
10
|
import { Teams } from "./namespaces/Teams.js";
|
|
10
11
|
import { Users } from "./namespaces/Users.js";
|
|
11
12
|
import { Websites } from "./namespaces/Websites.js";
|
|
12
13
|
import { WebsiteStats } from "./namespaces/WebsiteStats.js";
|
|
13
14
|
import { adaptParametersForGETRequests, correctType } from "./utilities.js";
|
|
14
|
-
export { Admin, Events, Links, Me, Pixels, Websites, WebsiteStats, Realtime, Reports, Sessions, Teams, Users, };
|
|
15
|
+
export { Admin, Events, Links, Me, Pixels, Websites, WebsiteStats, Realtime, Reports, Sessions, Share, Teams, Users, };
|
|
15
16
|
/** If the {@link API} throws an error, it should always be an {@link APIError}! */
|
|
16
17
|
export class APIError extends Error {
|
|
17
18
|
message;
|
|
@@ -173,12 +174,14 @@ export class API {
|
|
|
173
174
|
role: "view-only",
|
|
174
175
|
createdAt: new Date(),
|
|
175
176
|
isAdmin: false,
|
|
177
|
+
teams: [],
|
|
176
178
|
};
|
|
177
179
|
/** Information about the account that has been used to log in */
|
|
178
180
|
get user() {
|
|
179
181
|
return this._user;
|
|
180
182
|
}
|
|
181
183
|
set user(user) {
|
|
184
|
+
user.createdAt = new Date(user.createdAt);
|
|
182
185
|
this._user = user;
|
|
183
186
|
}
|
|
184
187
|
number_of_requests = 0;
|
|
@@ -428,6 +431,10 @@ export class API {
|
|
|
428
431
|
})
|
|
429
432
|
.join("&");
|
|
430
433
|
}
|
|
434
|
+
const headers = new Headers(this.headers);
|
|
435
|
+
if (!is_token_related) {
|
|
436
|
+
headers.append("Authorization", `${this.token_type} ${this.token}`);
|
|
437
|
+
}
|
|
431
438
|
const signals = [];
|
|
432
439
|
if (this.timeout > 0)
|
|
433
440
|
signals.push(AbortSignal.timeout(this.timeout * 1000));
|
|
@@ -435,12 +442,7 @@ export class API {
|
|
|
435
442
|
signals.push(this.signal);
|
|
436
443
|
const response = await fetch(url, {
|
|
437
444
|
method,
|
|
438
|
-
headers
|
|
439
|
-
Authorization: is_token_related
|
|
440
|
-
? undefined
|
|
441
|
-
: `${this.token_type} ${this.token}`,
|
|
442
|
-
...this.headers,
|
|
443
|
-
},
|
|
445
|
+
headers,
|
|
444
446
|
body: method !== "get" ? JSON.stringify(parameters) : undefined, // parameters are here if method is NOT GET
|
|
445
447
|
signal: AbortSignal.any(signals),
|
|
446
448
|
})
|
|
@@ -486,6 +488,9 @@ export class API {
|
|
|
486
488
|
if (to_retry === true && info.number_try <= this.retry_maximum_amount) {
|
|
487
489
|
this.log(true, `Will request again in ${this.retry_delay} seconds...`, `(retry #${info.number_try}/${this.retry_maximum_amount})`, request_id);
|
|
488
490
|
await new Promise((res) => setTimeout(res, this.retry_delay * 1000));
|
|
491
|
+
if (response) {
|
|
492
|
+
await response.text(); // Consume the response to avoid connection pool exhaustion, needs to be awaited
|
|
493
|
+
}
|
|
489
494
|
return await this.fetch(is_token_related, method, endpoint, parameters, {
|
|
490
495
|
number_try: info.number_try + 1,
|
|
491
496
|
has_new_token: info.has_new_token,
|
|
@@ -512,9 +517,7 @@ export class API {
|
|
|
512
517
|
async request(method, endpoint, parameters = {}) {
|
|
513
518
|
try {
|
|
514
519
|
const response = await this.fetch(false, method, endpoint, parameters);
|
|
515
|
-
|
|
516
|
-
return undefined; // 204 means the request worked as intended and did not give us anything, so just return nothing
|
|
517
|
-
const arrBuff = await response.arrayBuffer();
|
|
520
|
+
const arrBuff = await response.arrayBuffer(); // note: immediately consume the response to prevent connection pool leaks
|
|
518
521
|
const buff = Buffer.from(arrBuff);
|
|
519
522
|
try {
|
|
520
523
|
// Assume the response is in JSON format as it often is, it'll fail into the catch block if it isn't anyway
|
|
@@ -567,10 +570,14 @@ export class API {
|
|
|
567
570
|
getWebsiteEventsDataValues = Events.get_WEBSITEID_EventdataValues;
|
|
568
571
|
/** @group Events endpoints */
|
|
569
572
|
getWebsiteEventsDataStats = Events.get_WEBSITEID_EventdataStats;
|
|
573
|
+
/** @group Events endpoints */
|
|
574
|
+
getWebsiteEventsDataPivoted = Events.get_WEBSITEID_EventdataPivot;
|
|
570
575
|
// LINKS
|
|
571
576
|
/** @group Links endpoints */
|
|
572
577
|
getLinks = Links.get;
|
|
573
578
|
/** @group Links endpoints */
|
|
579
|
+
createLink = Links.post;
|
|
580
|
+
/** @group Links endpoints */
|
|
574
581
|
getLink = Links.get_LINKID;
|
|
575
582
|
/** @group Links endpoints */
|
|
576
583
|
updateLink = Links.post_LINKID;
|
|
@@ -584,13 +591,15 @@ export class API {
|
|
|
584
591
|
/** @group Me endpoints */
|
|
585
592
|
getMyWebsites = Me.getWebsites;
|
|
586
593
|
// PIXELS
|
|
587
|
-
/** @group
|
|
594
|
+
/** @group Pixels endpoints */
|
|
588
595
|
getPixels = Pixels.get;
|
|
589
|
-
/** @group
|
|
596
|
+
/** @group Pixels endpoints */
|
|
597
|
+
createPixel = Pixels.post;
|
|
598
|
+
/** @group Pixels endpoints */
|
|
590
599
|
getPixel = Pixels.get_PIXELID;
|
|
591
|
-
/** @group
|
|
600
|
+
/** @group Pixels endpoints */
|
|
592
601
|
updatePixel = Pixels.post_PIXELID;
|
|
593
|
-
/** @group
|
|
602
|
+
/** @group Pixels endpoints */
|
|
594
603
|
deletePixel = Pixels.delete_PIXELID;
|
|
595
604
|
// WEBSITES
|
|
596
605
|
/** @group Websites endpoints */
|
|
@@ -605,10 +614,14 @@ export class API {
|
|
|
605
614
|
deleteWebsite = Websites.delete_WEBSITEID;
|
|
606
615
|
/** @group Websites endpoints */
|
|
607
616
|
resetWebsite = Websites.post_WEBSITEID_Reset;
|
|
617
|
+
/** @group Websites endpoints */
|
|
618
|
+
getWebsiteRecorder = Websites.getRecorder;
|
|
608
619
|
// WEBSITE STATS
|
|
609
620
|
/** @group Website stats endpoints */
|
|
610
621
|
getWebsiteActiveVisitors = WebsiteStats.get_WEBSITEID_Active;
|
|
611
622
|
/** @group Website stats endpoints */
|
|
623
|
+
getWebsiteDateRange = WebsiteStats.get_WEBSITEID_DateRange;
|
|
624
|
+
/** @group Website stats endpoints */
|
|
612
625
|
getWebsiteEventsStats = WebsiteStats.get_WEBSITEID_EventsSeries;
|
|
613
626
|
/** @group Website stats endpoints */
|
|
614
627
|
getWebsiteMetrics = WebsiteStats.get_WEBSITEID_Metrics;
|
|
@@ -647,6 +660,14 @@ export class API {
|
|
|
647
660
|
/** @group Reports endpoints */
|
|
648
661
|
getReportsRevenue = Reports.postRevenue;
|
|
649
662
|
/** @group Reports endpoints */
|
|
663
|
+
getReportsRevenueChart = Reports.getRevenueChart;
|
|
664
|
+
/** @group Reports endpoints */
|
|
665
|
+
getReportsRevenueStats = Reports.getRevenueStats;
|
|
666
|
+
/** @group Reports endpoints */
|
|
667
|
+
getReportsRevenueMetrics = Reports.getRevenueMetrics;
|
|
668
|
+
/** @group Reports endpoints */
|
|
669
|
+
getReportsRevenueSessions = Reports.getRevenueSessions;
|
|
670
|
+
/** @group Reports endpoints */
|
|
650
671
|
getReportsUTM = Reports.postUTM;
|
|
651
672
|
// SESSIONS
|
|
652
673
|
/** @group Sessions endpoints */
|
|
@@ -665,6 +686,23 @@ export class API {
|
|
|
665
686
|
getWebsiteSessionDataProperties = Sessions.get_WEBSITEID_SessiondataProperties;
|
|
666
687
|
/** @group Sessions endpoints */
|
|
667
688
|
getWebsiteSessionDataValues = Sessions.get_WEBSITEID_SessiondataValues;
|
|
689
|
+
/** @group Sessions endpoints */
|
|
690
|
+
getWebsiteSessionDataPivoted = Sessions.get_WEBSITEID_SessiondataPivot;
|
|
691
|
+
/** @group Sessions endpoints */
|
|
692
|
+
getWebsiteSessionDataStats = Sessions.get_WEBSITEID_SessiondataStats;
|
|
693
|
+
// SHARE
|
|
694
|
+
/** @group Share endpoints */
|
|
695
|
+
createShare = Share.post;
|
|
696
|
+
/** @group Share endpoints */
|
|
697
|
+
getShare = Share.get_SHAREID;
|
|
698
|
+
/** @group Share endpoints */
|
|
699
|
+
updateShare = Share.post_SHAREID;
|
|
700
|
+
/** @group Share endpoints */
|
|
701
|
+
deleteShare = Share.delete_SHAREID;
|
|
702
|
+
/** @group Share endpoints */
|
|
703
|
+
getWebsiteShares = Share.get_WEBSITEID_Shares;
|
|
704
|
+
/** @group Share endpoints */
|
|
705
|
+
createWebsiteShare = Share.post_WEBSITEID_Shares;
|
|
668
706
|
// TEAMS
|
|
669
707
|
/** @group Teams endpoints */
|
|
670
708
|
getTeams = Teams.get;
|
|
@@ -700,7 +738,7 @@ export class API {
|
|
|
700
738
|
/** @group Users endpoints */
|
|
701
739
|
deleteUser = Users.delete_USERID;
|
|
702
740
|
/** @group Users endpoints */
|
|
703
|
-
getUserTeams = Users.get_USERID_Teams;
|
|
704
|
-
/** @group Users endpoints */
|
|
705
741
|
getUserWebsites = Users.get_USERID_Websites;
|
|
742
|
+
/** @group Users endpoints */
|
|
743
|
+
getUserTeams = Users.get_USERID_Teams;
|
|
706
744
|
}
|
|
@@ -43,7 +43,6 @@ export declare namespace Events {
|
|
|
43
43
|
/** Gets event-data for a individual event: https://umami.is/docs/api/events#get-apiwebsiteswebsiteidevent-dataeventid */
|
|
44
44
|
function get_WEBSITEID_Eventdata_EVENTID(this: API, websiteId: Websites.Website["id"], eventId: Event["id"]): Promise<Data[]>;
|
|
45
45
|
interface DataMultiple {
|
|
46
|
-
eventName: Event["eventName"];
|
|
47
46
|
propertyName: string;
|
|
48
47
|
dataType: number;
|
|
49
48
|
propertyValue: string | number;
|
|
@@ -63,7 +62,8 @@ export declare namespace Events {
|
|
|
63
62
|
interface DataFields {
|
|
64
63
|
propertyName: string;
|
|
65
64
|
dataType: number;
|
|
66
|
-
|
|
65
|
+
/** @remarks Seems to have become optional or deleted since Umami v3.2.0 */
|
|
66
|
+
value?: string;
|
|
67
67
|
total: number;
|
|
68
68
|
}
|
|
69
69
|
/** Gets event data property and value counts within a given time range: https://umami.is/docs/api/events#get-apiwebsiteswebsiteidevent-datafields */
|
|
@@ -104,4 +104,20 @@ export declare namespace Events {
|
|
|
104
104
|
/** Can accept filter parameters */
|
|
105
105
|
filters?: Filters;
|
|
106
106
|
}): Promise<DataStats>;
|
|
107
|
+
interface DataPivot {
|
|
108
|
+
eventId: Event["id"];
|
|
109
|
+
sessionId: Sessions.Session["id"];
|
|
110
|
+
eventName: Event["eventName"];
|
|
111
|
+
urlPath: string;
|
|
112
|
+
createdAt: Date;
|
|
113
|
+
propertyKeys: string[];
|
|
114
|
+
propertyValues: (string | number)[];
|
|
115
|
+
}
|
|
116
|
+
/** Gets event data for a website in a pivoted format, with each row representing an event and its properties as parallel arrays: https://docs.umami.is/docs/api/events#get-apiwebsiteswebsiteidevent-data-pivot */
|
|
117
|
+
function get_WEBSITEID_EventdataPivot(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & Exclude<GenericRequestParameters, "search"> & {
|
|
118
|
+
/** Event name to pivot on */
|
|
119
|
+
eventName: Event["eventName"];
|
|
120
|
+
/** Can accept filter parameters */
|
|
121
|
+
filters?: Filters;
|
|
122
|
+
}): Promise<DataPivot[]>;
|
|
107
123
|
}
|
|
@@ -46,4 +46,10 @@ export var Events;
|
|
|
46
46
|
return await this.request("get", ["websites", websiteId, "event-data", "stats"], parameters);
|
|
47
47
|
}
|
|
48
48
|
Events.get_WEBSITEID_EventdataStats = get_WEBSITEID_EventdataStats;
|
|
49
|
+
/** Gets event data for a website in a pivoted format, with each row representing an event and its properties as parallel arrays: https://docs.umami.is/docs/api/events#get-apiwebsiteswebsiteidevent-data-pivot */
|
|
50
|
+
async function get_WEBSITEID_EventdataPivot(websiteId, parameters) {
|
|
51
|
+
const response = await this.request("get", ["websites", websiteId, "event-data-pivot"], parameters);
|
|
52
|
+
return response.data;
|
|
53
|
+
}
|
|
54
|
+
Events.get_WEBSITEID_EventdataPivot = get_WEBSITEID_EventdataPivot;
|
|
49
55
|
})(Events || (Events = {}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { API, DeletionResult, GenericRequestParameters, Users } from "../index.js";
|
|
1
|
+
import { API, DeletionResult, GenericRequestParameters, Teams, Users } from "../index.js";
|
|
2
2
|
/** Operations around Links management: https://umami.is/docs/api/links */
|
|
3
3
|
export declare namespace Links {
|
|
4
4
|
interface Link {
|
|
@@ -14,6 +14,17 @@ export declare namespace Links {
|
|
|
14
14
|
}
|
|
15
15
|
/** Returns all user links: https://umami.is/docs/api/links#get-apilinks */
|
|
16
16
|
function get(this: API, parameters?: GenericRequestParameters): Promise<Link[]>;
|
|
17
|
+
/** Creates a link: https://docs.umami.is/docs/api/links#post-apilinks */
|
|
18
|
+
function post(this: API, parameters: {
|
|
19
|
+
/** The link's name */
|
|
20
|
+
name: Link["name"];
|
|
21
|
+
/** The link's destination URL */
|
|
22
|
+
url: Link["url"];
|
|
23
|
+
/** The link's URL slug, **with a minimum of 8 characters** */
|
|
24
|
+
slug: Link["slug"];
|
|
25
|
+
/** The ID of the team the link will be created under */
|
|
26
|
+
teamId?: Teams.Team["id"];
|
|
27
|
+
}): Promise<Link>;
|
|
17
28
|
/** Gets a link by ID: https://umami.is/docs/api/links#get-apilinkslinkid */
|
|
18
29
|
function get_LINKID(this: API, linkId: Link["id"]): Promise<Link>;
|
|
19
30
|
/** Updates a link: https://umami.is/docs/api/links#post-apilinkslinkid */
|
package/dist/namespaces/Links.js
CHANGED
|
@@ -7,6 +7,11 @@ export var Links;
|
|
|
7
7
|
return response.data;
|
|
8
8
|
}
|
|
9
9
|
Links.get = get;
|
|
10
|
+
/** Creates a link: https://docs.umami.is/docs/api/links#post-apilinks */
|
|
11
|
+
async function post(parameters) {
|
|
12
|
+
return await this.request("post", ["links"], parameters);
|
|
13
|
+
}
|
|
14
|
+
Links.post = post;
|
|
10
15
|
/** Gets a link by ID: https://umami.is/docs/api/links#get-apilinkslinkid */
|
|
11
16
|
async function get_LINKID(linkId) {
|
|
12
17
|
return await this.request("get", ["links", linkId]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { API, DeletionResult, GenericRequestParameters, Users } from "../index.js";
|
|
1
|
+
import { API, DeletionResult, GenericRequestParameters, Teams, Users } from "../index.js";
|
|
2
2
|
/** Operations around Pixels management: https://umami.is/docs/api/pixels */
|
|
3
3
|
export declare namespace Pixels {
|
|
4
4
|
interface Pixel {
|
|
@@ -13,6 +13,15 @@ export declare namespace Pixels {
|
|
|
13
13
|
}
|
|
14
14
|
/** Returns all user pixels: https://umami.is/docs/api/pixels#get-apipixels */
|
|
15
15
|
function get(this: API, parameters?: GenericRequestParameters): Promise<Pixel[]>;
|
|
16
|
+
/** Creates a pixel: https://docs.umami.is/docs/api/pixels#post-apipixels */
|
|
17
|
+
function post(this: API, parameters: {
|
|
18
|
+
/** The pixel's name */
|
|
19
|
+
name: Pixel["name"];
|
|
20
|
+
/** The pixel's URL slug, **with a minimum of 8 characters** */
|
|
21
|
+
slug: Pixel["slug"];
|
|
22
|
+
/** The ID of the team the pixel will be created under */
|
|
23
|
+
teamId?: Teams.Team["id"];
|
|
24
|
+
}): Promise<Pixel>;
|
|
16
25
|
/** Gets a pixel by ID: https://umami.is/docs/api/pixels#get-apipixelspixelid */
|
|
17
26
|
function get_PIXELID(this: API, pixelId: Pixel["id"]): Promise<Pixel>;
|
|
18
27
|
/** Updates a pixel: https://umami.is/docs/api/pixels#post-apipixelspixelid */
|
|
@@ -7,6 +7,11 @@ export var Pixels;
|
|
|
7
7
|
return response.data;
|
|
8
8
|
}
|
|
9
9
|
Pixels.get = get;
|
|
10
|
+
/** Creates a pixel: https://docs.umami.is/docs/api/pixels#post-apipixels */
|
|
11
|
+
async function post(parameters) {
|
|
12
|
+
return await this.request("post", ["pixels"], parameters);
|
|
13
|
+
}
|
|
14
|
+
Pixels.post = post;
|
|
10
15
|
/** Gets a pixel by ID: https://umami.is/docs/api/pixels#get-apipixelspixelid */
|
|
11
16
|
async function get_PIXELID(pixelId) {
|
|
12
17
|
return await this.request("get", ["pixels", pixelId]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { API, DeletionResult, Filters, GenericRequestParameters, NameValue, Users, Websites, XTY } from "../index.js";
|
|
2
|
-
/** Using reports
|
|
1
|
+
import { API, DeletionResult, Filters, GenericRequestParameters, NameValue, Sessions, Timestamps, Users, Websites, XTY } from "../index.js";
|
|
2
|
+
/** Using reports through the api: https://docs.umami.is/docs/api/reports */
|
|
3
3
|
export declare namespace Reports {
|
|
4
4
|
interface Report {
|
|
5
5
|
id: string;
|
|
@@ -15,8 +15,8 @@ export declare namespace Reports {
|
|
|
15
15
|
createdAt: Date;
|
|
16
16
|
updatedAt: Date;
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
19
|
-
interface
|
|
18
|
+
/** Many of the Reports endpoints use `startDate` instead of `startAt`, and `endDate` instead of `endAt` */
|
|
19
|
+
interface DateTimestamps {
|
|
20
20
|
/** Timestamp of starting date */
|
|
21
21
|
startDate: Date | number;
|
|
22
22
|
/** Timestamp of end date */
|
|
@@ -70,7 +70,7 @@ export declare namespace Reports {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
/** See how users engage with your marketing and what drives conversions: https://umami.is/docs/api/reports#post-apireportsattribution */
|
|
73
|
-
function postAttribution(this: API, websiteId: Websites.Website["id"], parameters:
|
|
73
|
+
function postAttribution(this: API, websiteId: Websites.Website["id"], parameters: DateTimestamps & {
|
|
74
74
|
/** Can accept filter parameters */
|
|
75
75
|
filters?: Filters;
|
|
76
76
|
/** Attribution model */
|
|
@@ -90,7 +90,7 @@ export declare namespace Reports {
|
|
|
90
90
|
country: string;
|
|
91
91
|
}
|
|
92
92
|
/** Dive deeper into your data by using segments and filters: https://umami.is/docs/api/reports#post-apireportsbreakdown */
|
|
93
|
-
function postBreakdown(this: API, websiteId: Websites.Website["id"], parameters:
|
|
93
|
+
function postBreakdown(this: API, websiteId: Websites.Website["id"], parameters: DateTimestamps & {
|
|
94
94
|
/** Can accept filter parameters */
|
|
95
95
|
filters?: Filters;
|
|
96
96
|
/** List of column fields */
|
|
@@ -106,7 +106,7 @@ export declare namespace Reports {
|
|
|
106
106
|
remaining: number | null;
|
|
107
107
|
}
|
|
108
108
|
/** Understand the conversion and drop-off rate of users: https://umami.is/docs/api/reports#post-apireportsfunnel */
|
|
109
|
-
function postFunnel(this: API, websiteId: Websites.Website["id"], parameters:
|
|
109
|
+
function postFunnel(this: API, websiteId: Websites.Website["id"], parameters: DateTimestamps & {
|
|
110
110
|
/** Can accept filter parameters */
|
|
111
111
|
filters?: Filters;
|
|
112
112
|
/** Type of event and conversion step */
|
|
@@ -125,7 +125,7 @@ export declare namespace Reports {
|
|
|
125
125
|
* Track your goals for pageviews and events: https://umami.is/docs/api/reports#post-apireportsgoals
|
|
126
126
|
* @remarks Here be dragons: I have no idea how to use this endpoint without it returning a client/server error, my apologies - The package developer
|
|
127
127
|
*/
|
|
128
|
-
function postGoals(this: API, websiteId: Websites.Website["id"], parameters:
|
|
128
|
+
function postGoals(this: API, websiteId: Websites.Website["id"], parameters: DateTimestamps & {
|
|
129
129
|
/** Can accept filter parameters */
|
|
130
130
|
filters?: Filters;
|
|
131
131
|
/** Conversion type */
|
|
@@ -143,8 +143,8 @@ export declare namespace Reports {
|
|
|
143
143
|
items: (string | null)[];
|
|
144
144
|
count: number;
|
|
145
145
|
}
|
|
146
|
-
/** Understand how users
|
|
147
|
-
function postJourney(this: API, websiteId: Websites.Website["id"], parameters:
|
|
146
|
+
/** Understand how users navigate through your website: https://docs.umami.is/docs/api/reports#post-apireportsjourney */
|
|
147
|
+
function postJourney(this: API, websiteId: Websites.Website["id"], parameters: DateTimestamps & {
|
|
148
148
|
/** Can accept filter parameters */
|
|
149
149
|
filters?: Filters;
|
|
150
150
|
/** Number of steps from 3 to 7 */
|
|
@@ -162,24 +162,38 @@ export declare namespace Reports {
|
|
|
162
162
|
percentage: number;
|
|
163
163
|
}
|
|
164
164
|
/** Measure your website stickiness by tracking how often users return: https://umami.is/docs/api/reports#post-apireportsretention */
|
|
165
|
-
function postRetention(this: API, websiteId: Websites.Website["id"], parameters:
|
|
165
|
+
function postRetention(this: API, websiteId: Websites.Website["id"], parameters: DateTimestamps & {
|
|
166
166
|
/** Can accept filter parameters */
|
|
167
167
|
filters?: Filters;
|
|
168
168
|
/** Timezone (ex. America/Los_Angeles) */
|
|
169
169
|
timezone: string;
|
|
170
170
|
}): Promise<Retention[]>;
|
|
171
|
+
interface RevenueChart extends XTY {
|
|
172
|
+
count: number;
|
|
173
|
+
}
|
|
174
|
+
interface RevenueStats {
|
|
175
|
+
sum: number | null;
|
|
176
|
+
count: number;
|
|
177
|
+
unique_count: number;
|
|
178
|
+
total_sessions: number;
|
|
179
|
+
average: number;
|
|
180
|
+
arpu: number;
|
|
181
|
+
}
|
|
182
|
+
interface RevenueStatsWithComparison extends RevenueStats {
|
|
183
|
+
comparison: RevenueStats;
|
|
184
|
+
}
|
|
171
185
|
interface Revenue {
|
|
172
|
-
chart:
|
|
186
|
+
chart: RevenueChart[];
|
|
187
|
+
total: RevenueStatsWithComparison;
|
|
173
188
|
country: NameValue[];
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
};
|
|
189
|
+
region: (NameValue & {
|
|
190
|
+
country: string;
|
|
191
|
+
})[];
|
|
192
|
+
referrer: NameValue[];
|
|
193
|
+
channel: NameValue[];
|
|
180
194
|
}
|
|
181
195
|
/** Get currency for given range. Needed for Revenue and optional in Attribution reports: https://umami.is/docs/api/reports#post-apireportsrevenue */
|
|
182
|
-
function postRevenue(this: API, websiteId: Websites.Website["id"], parameters:
|
|
196
|
+
function postRevenue(this: API, websiteId: Websites.Website["id"], parameters: DateTimestamps & {
|
|
183
197
|
/** Can accept filter parameters */
|
|
184
198
|
filters?: Filters;
|
|
185
199
|
/** Timezone (ex. America/Los_Angeles) */
|
|
@@ -187,6 +201,43 @@ export declare namespace Reports {
|
|
|
187
201
|
/** Currency code (ISO 4217) */
|
|
188
202
|
currency: string;
|
|
189
203
|
}): Promise<Revenue>;
|
|
204
|
+
/** Returns revenue chart data for a given date range and currency: https://docs.umami.is/docs/api/reports#get-apiwebsiteswebsiteidrevenuechart */
|
|
205
|
+
function getRevenueChart(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & {
|
|
206
|
+
/** Timezone (ex. America/Los_Angeles) */
|
|
207
|
+
timezone: string;
|
|
208
|
+
/** Currency code (ISO 4217) */
|
|
209
|
+
currency: string;
|
|
210
|
+
/** Comparison period */
|
|
211
|
+
compare?: "prev" | "yoy";
|
|
212
|
+
}): Promise<RevenueChart[]>;
|
|
213
|
+
/** Returns revenue statistics for a given date range with optional comparison period: https://docs.umami.is/docs/api/reports#get-apiwebsiteswebsiteidrevenuestats */
|
|
214
|
+
function getRevenueStats(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & {
|
|
215
|
+
/** Timezone (ex. America/Los_Angeles) */
|
|
216
|
+
timezone: string;
|
|
217
|
+
/** Currency code (ISO 4217) */
|
|
218
|
+
currency: string;
|
|
219
|
+
/** Comparison period */
|
|
220
|
+
compare?: "prev" | "yoy";
|
|
221
|
+
}): Promise<RevenueStatsWithComparison>;
|
|
222
|
+
/** Returns revenue broken down by a specified dimension: https://docs.umami.is/docs/api/reports#get-apiwebsiteswebsiteidrevenuemetrics */
|
|
223
|
+
function getRevenueMetrics(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & {
|
|
224
|
+
/** Timezone (ex. America/Los_Angeles) */
|
|
225
|
+
timezone: string;
|
|
226
|
+
/** Breakdown type */
|
|
227
|
+
type: "country" | "region" | "referrer" | "channel";
|
|
228
|
+
/** Currency code (ISO 4217) */
|
|
229
|
+
currency: string;
|
|
230
|
+
}): Promise<any> /** TODO screw this lol */;
|
|
231
|
+
interface RevenueSession extends Sessions.SessionWithHostnameCreatedate {
|
|
232
|
+
events: number;
|
|
233
|
+
}
|
|
234
|
+
/** Returns a paginated list of sessions with revenue data: https://docs.umami.is/docs/api/reports#get-apiwebsiteswebsiteidrevenuesessions */
|
|
235
|
+
function getRevenueSessions(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & GenericRequestParameters & {
|
|
236
|
+
/** Timezone (ex. America/Los_Angeles) */
|
|
237
|
+
timezone: string;
|
|
238
|
+
/** Currency code (ISO 4217) */
|
|
239
|
+
currency: string;
|
|
240
|
+
}): Promise<RevenueSession[]>;
|
|
190
241
|
interface UTMProperty {
|
|
191
242
|
utm: string;
|
|
192
243
|
views: number;
|
|
@@ -199,7 +250,7 @@ export declare namespace Reports {
|
|
|
199
250
|
utm_content: UTMProperty[];
|
|
200
251
|
}
|
|
201
252
|
/** Track your campaigns through UTM parameters: https://umami.is/docs/api/reports#post-apireportsutm */
|
|
202
|
-
function postUTM(this: API, websiteId: Websites.Website["id"], parameters:
|
|
253
|
+
function postUTM(this: API, websiteId: Websites.Website["id"], parameters: DateTimestamps & {
|
|
203
254
|
/** Can accept filter parameters */
|
|
204
255
|
filters?: Filters;
|
|
205
256
|
}): Promise<UTM>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Using reports
|
|
1
|
+
/** Using reports through the api: https://docs.umami.is/docs/api/reports */
|
|
2
2
|
export var Reports;
|
|
3
3
|
(function (Reports) {
|
|
4
4
|
/** Get all reports by website ID: https://umami.is/docs/api/reports#get-apireports */
|
|
@@ -87,7 +87,7 @@ export var Reports;
|
|
|
87
87
|
}, parameters.name);
|
|
88
88
|
}
|
|
89
89
|
Reports.postGoals = postGoals;
|
|
90
|
-
/** Understand how users
|
|
90
|
+
/** Understand how users navigate through your website: https://docs.umami.is/docs/api/reports#post-apireportsjourney */
|
|
91
91
|
async function postJourney(websiteId, parameters) {
|
|
92
92
|
return await postNonReports(this, "journey", websiteId, parameters.filters, {
|
|
93
93
|
startDate: parameters.startDate,
|
|
@@ -117,6 +117,28 @@ export var Reports;
|
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
Reports.postRevenue = postRevenue;
|
|
120
|
+
/** Returns revenue chart data for a given date range and currency: https://docs.umami.is/docs/api/reports#get-apiwebsiteswebsiteidrevenuechart */
|
|
121
|
+
async function getRevenueChart(websiteId, parameters) {
|
|
122
|
+
const response = await this.request("get", ["websites", websiteId, "revenue", "chart"], parameters);
|
|
123
|
+
return response.chart;
|
|
124
|
+
}
|
|
125
|
+
Reports.getRevenueChart = getRevenueChart;
|
|
126
|
+
/** Returns revenue statistics for a given date range with optional comparison period: https://docs.umami.is/docs/api/reports#get-apiwebsiteswebsiteidrevenuestats */
|
|
127
|
+
async function getRevenueStats(websiteId, parameters) {
|
|
128
|
+
return await this.request("get", ["websites", websiteId, "revenue", "stats"], parameters);
|
|
129
|
+
}
|
|
130
|
+
Reports.getRevenueStats = getRevenueStats;
|
|
131
|
+
/** Returns revenue broken down by a specified dimension: https://docs.umami.is/docs/api/reports#get-apiwebsiteswebsiteidrevenuemetrics */
|
|
132
|
+
async function getRevenueMetrics(websiteId, parameters) {
|
|
133
|
+
return await this.request("get", ["websites", websiteId, "revenue", "metrics"], parameters);
|
|
134
|
+
}
|
|
135
|
+
Reports.getRevenueMetrics = getRevenueMetrics;
|
|
136
|
+
/** Returns a paginated list of sessions with revenue data: https://docs.umami.is/docs/api/reports#get-apiwebsiteswebsiteidrevenuesessions */
|
|
137
|
+
async function getRevenueSessions(websiteId, parameters) {
|
|
138
|
+
const response = await this.request("get", ["websites", websiteId, "revenue", "sessions"], parameters);
|
|
139
|
+
return response.data;
|
|
140
|
+
}
|
|
141
|
+
Reports.getRevenueSessions = getRevenueSessions;
|
|
120
142
|
/** Track your campaigns through UTM parameters: https://umami.is/docs/api/reports#post-apireportsutm */
|
|
121
143
|
async function postUTM(websiteId, parameters) {
|
|
122
144
|
return await postNonReports(this, "utm", websiteId, parameters.filters, {
|
|
@@ -120,4 +120,33 @@ export declare namespace Sessions {
|
|
|
120
120
|
/** Can accept filter parameters */
|
|
121
121
|
filters?: Filters;
|
|
122
122
|
}): Promise<DataValues[]>;
|
|
123
|
+
interface DataPivot {
|
|
124
|
+
sessionId: Session["id"];
|
|
125
|
+
distinctId: string | null;
|
|
126
|
+
createdAt: Date;
|
|
127
|
+
propertyKeys: string[];
|
|
128
|
+
propertyValues: (string | number)[];
|
|
129
|
+
}
|
|
130
|
+
/** Gets session data in a pivoted format, with each row representing a session and its properties as parallel arrays: https://docs.umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-data-pivot */
|
|
131
|
+
function get_WEBSITEID_SessiondataPivot(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & Exclude<GenericRequestParameters, "search"> & {
|
|
132
|
+
/** Session property name to pivot on */
|
|
133
|
+
propertyName: string;
|
|
134
|
+
/** Can accept filter parameters */
|
|
135
|
+
filters?: Filters;
|
|
136
|
+
}): Promise<DataPivot[]>;
|
|
137
|
+
interface DataStats {
|
|
138
|
+
label: string;
|
|
139
|
+
activity: number;
|
|
140
|
+
sessions: number;
|
|
141
|
+
visits: number;
|
|
142
|
+
views: number;
|
|
143
|
+
events: number;
|
|
144
|
+
}
|
|
145
|
+
/** Gets aggregated activity statistics for sessions grouped by a given property value: https://docs.umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-datastats */
|
|
146
|
+
function get_WEBSITEID_SessiondataStats(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & {
|
|
147
|
+
/** Property name to group by */
|
|
148
|
+
propertyName: string;
|
|
149
|
+
/** Can accept filter parameters */
|
|
150
|
+
filters?: Filters;
|
|
151
|
+
}): Promise<DataStats[]>;
|
|
123
152
|
}
|
|
@@ -57,4 +57,15 @@ export var Sessions;
|
|
|
57
57
|
return await this.request("get", ["websites", websiteId, "session-data", "values"], parameters);
|
|
58
58
|
}
|
|
59
59
|
Sessions.get_WEBSITEID_SessiondataValues = get_WEBSITEID_SessiondataValues;
|
|
60
|
+
/** Gets session data in a pivoted format, with each row representing a session and its properties as parallel arrays: https://docs.umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-data-pivot */
|
|
61
|
+
async function get_WEBSITEID_SessiondataPivot(websiteId, parameters) {
|
|
62
|
+
const response = await this.request("get", ["websites", websiteId, "session-data-pivot"], parameters);
|
|
63
|
+
return response.data;
|
|
64
|
+
}
|
|
65
|
+
Sessions.get_WEBSITEID_SessiondataPivot = get_WEBSITEID_SessiondataPivot;
|
|
66
|
+
/** Gets aggregated activity statistics for sessions grouped by a given property value: https://docs.umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-datastats */
|
|
67
|
+
async function get_WEBSITEID_SessiondataStats(websiteId, parameters) {
|
|
68
|
+
return await this.request("get", ["websites", websiteId, "session-data", "stats"], parameters);
|
|
69
|
+
}
|
|
70
|
+
Sessions.get_WEBSITEID_SessiondataStats = get_WEBSITEID_SessiondataStats;
|
|
60
71
|
})(Sessions || (Sessions = {}));
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { API, DeletionResult, Websites } from "../index.js";
|
|
2
|
+
/** Operations around Share page management: https://docs.umami.is/docs/api/share */
|
|
3
|
+
export declare namespace Share {
|
|
4
|
+
enum ShareType {
|
|
5
|
+
website = 1,
|
|
6
|
+
link = 2,
|
|
7
|
+
pixel = 3,
|
|
8
|
+
board = 4
|
|
9
|
+
}
|
|
10
|
+
interface Share {
|
|
11
|
+
id: string;
|
|
12
|
+
entityId: string;
|
|
13
|
+
name: string;
|
|
14
|
+
shareType: ShareType;
|
|
15
|
+
slug: string;
|
|
16
|
+
parameters: Parameters;
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
updatedAt: Date;
|
|
19
|
+
}
|
|
20
|
+
interface Parameters {
|
|
21
|
+
overview?: boolean;
|
|
22
|
+
events?: boolean;
|
|
23
|
+
sessions?: boolean;
|
|
24
|
+
realtime?: boolean;
|
|
25
|
+
performance?: boolean;
|
|
26
|
+
compare?: boolean;
|
|
27
|
+
breakdown?: boolean;
|
|
28
|
+
goals?: boolean;
|
|
29
|
+
funnels?: boolean;
|
|
30
|
+
journeys?: boolean;
|
|
31
|
+
retention?: boolean;
|
|
32
|
+
utm?: boolean;
|
|
33
|
+
revenue?: boolean;
|
|
34
|
+
attribution?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** Creates a share page: https://docs.umami.is/docs/api/share#post-apishare */
|
|
37
|
+
function post(this: API, parameters: {
|
|
38
|
+
/** ID of entity to be added (websiteId, pixelId, linkId, etc.) */
|
|
39
|
+
entityId: Share["entityId"];
|
|
40
|
+
shareType: ShareType;
|
|
41
|
+
/** Name of the share page */
|
|
42
|
+
name: Share["name"];
|
|
43
|
+
/** Slug of the share page */
|
|
44
|
+
slug: Share["slug"];
|
|
45
|
+
/** Parameters for share page */
|
|
46
|
+
parameters: Parameters;
|
|
47
|
+
}): Promise<Share>;
|
|
48
|
+
/** Gets a share page by ID: https://docs.umami.is/docs/api/share#get-apishareidshareid */
|
|
49
|
+
function get_SHAREID(this: API, share_id: Share["id"]): Promise<Share>;
|
|
50
|
+
/** Updates a share page: https://docs.umami.is/docs/api/share#post-apishareidshareid */
|
|
51
|
+
function post_SHAREID(this: API, share_id: Share["id"], parameters: {
|
|
52
|
+
/** Name of the share page */
|
|
53
|
+
name: Share["name"];
|
|
54
|
+
/** Slug of the share page */
|
|
55
|
+
slug: Share["slug"];
|
|
56
|
+
/** Parameters for share page */
|
|
57
|
+
parameters: Parameters;
|
|
58
|
+
}): Promise<Share>;
|
|
59
|
+
/** Deletes a share page: https://docs.umami.is/docs/api/share#delete-apishareidshareid */
|
|
60
|
+
function delete_SHAREID(this: API, share_id: Share["id"]): Promise<DeletionResult>;
|
|
61
|
+
/** Gets all share pages that belong to a website: https://docs.umami.is/docs/api/share#get-apiwebsiteswebsiteidshares */
|
|
62
|
+
function get_WEBSITEID_Shares(this: API, website_id: Websites.Website["id"]): Promise<Share[]>;
|
|
63
|
+
/** Creates a share page belonging to a website: https://docs.umami.is/docs/api/share#post-apiwebsiteswebsiteidshares */
|
|
64
|
+
function post_WEBSITEID_Shares(this: API, website_id: Websites.Website["id"], parameters: {
|
|
65
|
+
/** Name of the share page */
|
|
66
|
+
name: Share["name"];
|
|
67
|
+
/** Parameters for share page */
|
|
68
|
+
parameters: Parameters;
|
|
69
|
+
}): Promise<Share>;
|
|
70
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Operations around Share page management: https://docs.umami.is/docs/api/share */
|
|
2
|
+
export var Share;
|
|
3
|
+
(function (Share) {
|
|
4
|
+
let ShareType;
|
|
5
|
+
(function (ShareType) {
|
|
6
|
+
ShareType[ShareType["website"] = 1] = "website";
|
|
7
|
+
ShareType[ShareType["link"] = 2] = "link";
|
|
8
|
+
ShareType[ShareType["pixel"] = 3] = "pixel";
|
|
9
|
+
ShareType[ShareType["board"] = 4] = "board";
|
|
10
|
+
})(ShareType = Share.ShareType || (Share.ShareType = {}));
|
|
11
|
+
/** Creates a share page: https://docs.umami.is/docs/api/share#post-apishare */
|
|
12
|
+
async function post(parameters) {
|
|
13
|
+
return await this.request("post", ["share"], parameters);
|
|
14
|
+
}
|
|
15
|
+
Share.post = post;
|
|
16
|
+
/** Gets a share page by ID: https://docs.umami.is/docs/api/share#get-apishareidshareid */
|
|
17
|
+
async function get_SHAREID(share_id) {
|
|
18
|
+
return await this.request("get", ["share", "id", share_id]);
|
|
19
|
+
}
|
|
20
|
+
Share.get_SHAREID = get_SHAREID;
|
|
21
|
+
/** Updates a share page: https://docs.umami.is/docs/api/share#post-apishareidshareid */
|
|
22
|
+
async function post_SHAREID(share_id, parameters) {
|
|
23
|
+
return await this.request("post", ["share", "id", share_id], parameters);
|
|
24
|
+
}
|
|
25
|
+
Share.post_SHAREID = post_SHAREID;
|
|
26
|
+
/** Deletes a share page: https://docs.umami.is/docs/api/share#delete-apishareidshareid */
|
|
27
|
+
async function delete_SHAREID(share_id) {
|
|
28
|
+
return await this.request("delete", ["share", "id", share_id]);
|
|
29
|
+
}
|
|
30
|
+
Share.delete_SHAREID = delete_SHAREID;
|
|
31
|
+
/** Gets all share pages that belong to a website: https://docs.umami.is/docs/api/share#get-apiwebsiteswebsiteidshares */
|
|
32
|
+
async function get_WEBSITEID_Shares(website_id) {
|
|
33
|
+
const response = await this.request("get", [
|
|
34
|
+
"websites",
|
|
35
|
+
website_id,
|
|
36
|
+
"shares",
|
|
37
|
+
]);
|
|
38
|
+
return response.data;
|
|
39
|
+
}
|
|
40
|
+
Share.get_WEBSITEID_Shares = get_WEBSITEID_Shares;
|
|
41
|
+
/** Creates a share page belonging to a website: https://docs.umami.is/docs/api/share#post-apiwebsiteswebsiteidshares */
|
|
42
|
+
async function post_WEBSITEID_Shares(website_id, parameters) {
|
|
43
|
+
return await this.request("post", ["websites", website_id, "shares"], parameters);
|
|
44
|
+
}
|
|
45
|
+
Share.post_WEBSITEID_Shares = post_WEBSITEID_Shares;
|
|
46
|
+
})(Share || (Share = {}));
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { API, DeletionResult, GenericRequestParameters, Users, Websites } from "../index.js";
|
|
2
2
|
/** Operations around Team management: https://umami.is/docs/api/teams */
|
|
3
3
|
export declare namespace Teams {
|
|
4
|
-
interface
|
|
4
|
+
interface MinimalTeam {
|
|
5
5
|
id: string;
|
|
6
6
|
name: string;
|
|
7
|
-
accessCode: string;
|
|
8
7
|
logoUrl: string | null;
|
|
8
|
+
}
|
|
9
|
+
interface Team extends MinimalTeam {
|
|
10
|
+
accessCode: string;
|
|
9
11
|
createdAt: Date;
|
|
10
12
|
updatedAt: Date;
|
|
11
13
|
deletedAt: Date | null;
|
|
@@ -9,15 +9,16 @@ export declare namespace Users {
|
|
|
9
9
|
interface MinimalUserWithRole extends MinimalUser {
|
|
10
10
|
role: Role;
|
|
11
11
|
}
|
|
12
|
-
interface
|
|
12
|
+
interface MinimalUserWithRoleCreatedAt extends MinimalUserWithRole {
|
|
13
13
|
createdAt: Date;
|
|
14
14
|
}
|
|
15
|
-
interface MinimalUserWithRoleCreatedAt extends MinimalUserWithRole, MinimalUserWithCreatedAt {
|
|
16
|
-
}
|
|
17
15
|
interface User extends MinimalUserWithRoleCreatedAt {
|
|
18
16
|
isAdmin: boolean;
|
|
19
17
|
}
|
|
20
|
-
interface
|
|
18
|
+
interface UserWithTeams extends User {
|
|
19
|
+
teams: Teams.MinimalTeam[];
|
|
20
|
+
}
|
|
21
|
+
interface DetailedUser extends MinimalUserWithRoleCreatedAt {
|
|
21
22
|
logoUrl: string | null;
|
|
22
23
|
displayName: string | null;
|
|
23
24
|
updatedAt: Date;
|
|
@@ -36,6 +36,13 @@ export declare namespace WebsiteStats {
|
|
|
36
36
|
}
|
|
37
37
|
/** Gets the number of active users on a website: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteidactive */
|
|
38
38
|
function get_WEBSITEID_Active(this: API, websiteId: Websites.Website["id"]): Promise<Active>;
|
|
39
|
+
/** @remarks Don't confuse with {@link Timestamps}, where the word "At" is used over "Date"! */
|
|
40
|
+
interface DateRange {
|
|
41
|
+
startDate: Date;
|
|
42
|
+
endDate: Date;
|
|
43
|
+
}
|
|
44
|
+
/** Gets the date range of available data for a website: https://docs.umami.is/docs/api/website-stats#get-apiwebsiteswebsiteiddaterange */
|
|
45
|
+
function get_WEBSITEID_DateRange(this: API, websiteId: Websites.Website["id"]): Promise<DateRange>;
|
|
39
46
|
/** Gets events within a given time range: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteideventsseries */
|
|
40
47
|
function get_WEBSITEID_EventsSeries(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & Units & {
|
|
41
48
|
/** Can accept filter parameters */
|
|
@@ -86,8 +93,8 @@ export declare namespace WebsiteStats {
|
|
|
86
93
|
function get_WEBSITEID_Pageviews(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & Units & {
|
|
87
94
|
/** Timezone (ex. America/Los_Angeles) */
|
|
88
95
|
timezone: string;
|
|
89
|
-
/** Comparison
|
|
90
|
-
compare?:
|
|
96
|
+
/** Comparison period */
|
|
97
|
+
compare?: "prev" | "yoy";
|
|
91
98
|
/** Can accept filter parameters */
|
|
92
99
|
filters?: Filters;
|
|
93
100
|
}): Promise<Pageviews>;
|
|
@@ -6,6 +6,11 @@ export var WebsiteStats;
|
|
|
6
6
|
return await this.request("get", ["websites", websiteId, "active"]);
|
|
7
7
|
}
|
|
8
8
|
WebsiteStats.get_WEBSITEID_Active = get_WEBSITEID_Active;
|
|
9
|
+
/** Gets the date range of available data for a website: https://docs.umami.is/docs/api/website-stats#get-apiwebsiteswebsiteiddaterange */
|
|
10
|
+
async function get_WEBSITEID_DateRange(websiteId) {
|
|
11
|
+
return await this.request("get", ["websites", websiteId, "daterange"]);
|
|
12
|
+
}
|
|
13
|
+
WebsiteStats.get_WEBSITEID_DateRange = get_WEBSITEID_DateRange;
|
|
9
14
|
/** Gets events within a given time range: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteideventsseries */
|
|
10
15
|
async function get_WEBSITEID_EventsSeries(websiteId, parameters) {
|
|
11
16
|
return await this.request("get", ["websites", websiteId, "events", "series"], parameters);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { API, DeletionResult, GenericRequestParameters, Teams, Users } from "../index.js";
|
|
1
|
+
import { API, DeletionResult, GenericRequestParameters, Share, Teams, Users } from "../index.js";
|
|
2
2
|
/** Operations around Website management and statistics: https://umami.is/docs/api/websites */
|
|
3
3
|
export declare namespace Websites {
|
|
4
4
|
interface Website {
|
|
5
5
|
id: string;
|
|
6
6
|
name: string;
|
|
7
7
|
domain: string;
|
|
8
|
-
shareId:
|
|
8
|
+
shareId: Share.Share["id"] | null;
|
|
9
9
|
resetAt: Date | null;
|
|
10
10
|
/** @remarks Is null if the website is under a team (has a `teamId`) */
|
|
11
11
|
userId: Users.User["id"] | null;
|
|
@@ -59,4 +59,18 @@ export declare namespace Websites {
|
|
|
59
59
|
function delete_WEBSITEID(this: API, websiteId: Website["id"]): Promise<DeletionResult>;
|
|
60
60
|
/** Resets a website by removing all data related to the website: https://umami.is/docs/api/websites#post-apiwebsiteswebsiteidreset */
|
|
61
61
|
function post_WEBSITEID_Reset(this: API, websiteId: Website["id"]): Promise<DeletionResult>;
|
|
62
|
+
type Recorder = {
|
|
63
|
+
enabled: false;
|
|
64
|
+
} | {
|
|
65
|
+
enabled: true;
|
|
66
|
+
replayEnabled: boolean;
|
|
67
|
+
heatmapEnabled: boolean;
|
|
68
|
+
sampleRate: number;
|
|
69
|
+
heatmapSampleRate: number;
|
|
70
|
+
maskLevel: "strict" | "moderate";
|
|
71
|
+
maxDuration: number;
|
|
72
|
+
blockSelector: string;
|
|
73
|
+
};
|
|
74
|
+
/** Returns the recorder configuration for a website: https://docs.umami.is/docs/api/websites#get-apiwebsiteswebsiteidrecorder */
|
|
75
|
+
function getRecorder(this: API, websiteId: Website["id"]): Promise<Recorder>;
|
|
62
76
|
}
|
|
@@ -32,4 +32,9 @@ export var Websites;
|
|
|
32
32
|
return await this.request("post", ["websites", websiteId, "reset"]);
|
|
33
33
|
}
|
|
34
34
|
Websites.post_WEBSITEID_Reset = post_WEBSITEID_Reset;
|
|
35
|
+
/** Returns the recorder configuration for a website: https://docs.umami.is/docs/api/websites#get-apiwebsiteswebsiteidrecorder */
|
|
36
|
+
async function getRecorder(websiteId) {
|
|
37
|
+
return await this.request("get", ["websites", websiteId, "recorder"]);
|
|
38
|
+
}
|
|
39
|
+
Websites.getRecorder = getRecorder;
|
|
35
40
|
})(Websites || (Websites = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "umami-api-js",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Package to easily access the Umami api!",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"license": "Unlicense",
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/chai": "^5.2.3",
|
|
34
|
-
"@types/node": "^
|
|
35
|
-
"ajv": "^8.
|
|
34
|
+
"@types/node": "^26.0.1",
|
|
35
|
+
"ajv": "^8.20.0",
|
|
36
36
|
"chai": "^6.2.2",
|
|
37
|
-
"dotenv": "^17.2
|
|
38
|
-
"prettier": "3.
|
|
39
|
-
"ts-json-schema-generator": "^2.
|
|
40
|
-
"typedoc": "^0.28.
|
|
41
|
-
"typescript": "^
|
|
37
|
+
"dotenv": "^17.4.2",
|
|
38
|
+
"prettier": "3.9.1",
|
|
39
|
+
"ts-json-schema-generator": "^2.9.0",
|
|
40
|
+
"typedoc": "^0.28.19",
|
|
41
|
+
"typescript": "^6.0.3"
|
|
42
42
|
}
|
|
43
43
|
}
|