umami-api-js 0.0.3 → 0.0.4
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 +1 -2
- package/dist/index.d.ts +63 -4
- package/dist/index.js +28 -3
- package/dist/namespaces/Admin.d.ts +3 -13
- package/dist/namespaces/Reports.d.ts +146 -0
- package/dist/namespaces/Reports.js +70 -0
- package/dist/namespaces/Users.d.ts +4 -16
- package/dist/namespaces/WebsiteStats.d.ts +90 -0
- package/dist/namespaces/WebsiteStats.js +34 -0
- package/dist/namespaces/Websites.d.ts +7 -5
- package/package.json +1 -1
- package/.forgejo/workflows/release.yaml +0 -33
package/README.md
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
A package to interact with [the API of self-hosted instances of Umami v2.19.0](https://umami.is/docs/api). It is a lightweight alternative to [@umami/api-client](https://github.com/umami-software/api-client), forked from [osu-api-v2-js](https://github.com/TTTaevas/osu-api-v2-js).
|
|
2
2
|
|
|
3
|
-
Please note that this package is not expected to work with Umami Cloud, the instance of Umami hosted by its creators.
|
|
3
|
+
Please note that this package is expected to work with self-hosted instances of **Umami v2.19.0**, and is *not* expected to work with [Umami Cloud](https://umami.is/docs/cloud), the instance of Umami hosted by its creators.
|
|
4
4
|
|
|
5
|
-
Please also note that this is currently being built mainly to serve as a component to my [taevas.xyz](https://codeberg.org/Taevas/taevas.xyz) project, meaning it currently doesn't perfectly cover the API!
|
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,53 @@
|
|
|
1
1
|
import { Admin } from "./namespaces/Admin.js";
|
|
2
2
|
import { Events } from "./namespaces/Events.js";
|
|
3
3
|
import { Realtime } from "./namespaces/Realtime.js";
|
|
4
|
+
import { Reports } from "./namespaces/Reports.js";
|
|
4
5
|
import { Sessions } from "./namespaces/Sessions.js";
|
|
5
6
|
import { Teams } from "./namespaces/Teams.js";
|
|
6
7
|
import { Users } from "./namespaces/Users.js";
|
|
7
8
|
import { Websites } from "./namespaces/Websites.js";
|
|
8
|
-
|
|
9
|
+
import { WebsiteStats } from "./namespaces/WebsiteStats.js";
|
|
10
|
+
export { Admin, Users, Teams, Events, Sessions, Websites, WebsiteStats, Realtime, Reports };
|
|
9
11
|
export interface ValueAndPrev {
|
|
10
12
|
/** The actual value for the given time period */
|
|
11
13
|
value: number;
|
|
12
14
|
/** The value for the same *timespan* for the time period that ends where the time period for value starts */
|
|
13
15
|
prev: number;
|
|
14
16
|
}
|
|
17
|
+
export interface MinimalUser {
|
|
18
|
+
id: string;
|
|
19
|
+
username: string;
|
|
20
|
+
}
|
|
15
21
|
export interface GenericObject {
|
|
16
22
|
id: string;
|
|
17
23
|
createdAt: Date;
|
|
18
24
|
updatedAt: Date | null;
|
|
19
25
|
deletedAt: Date | null;
|
|
20
26
|
}
|
|
27
|
+
export interface Website extends GenericObject {
|
|
28
|
+
name: string;
|
|
29
|
+
domain: string;
|
|
30
|
+
shareId: string | null;
|
|
31
|
+
resetAt: Date | null;
|
|
32
|
+
userId: string;
|
|
33
|
+
teamId: string | null;
|
|
34
|
+
createdBy: string;
|
|
35
|
+
}
|
|
36
|
+
export interface Report extends Omit<GenericObject, "deletedAt"> {
|
|
37
|
+
userId: string;
|
|
38
|
+
websiteId: string;
|
|
39
|
+
type: string;
|
|
40
|
+
name: string;
|
|
41
|
+
description: string;
|
|
42
|
+
parameters: {
|
|
43
|
+
type: string;
|
|
44
|
+
value: string;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export interface NameValue {
|
|
48
|
+
name: string;
|
|
49
|
+
value: number;
|
|
50
|
+
}
|
|
21
51
|
export interface GenericRequestParameters {
|
|
22
52
|
/** Search text */
|
|
23
53
|
search?: string;
|
|
@@ -32,9 +62,17 @@ export interface Timestamps {
|
|
|
32
62
|
/** Timestamp of end date */
|
|
33
63
|
endAt: Date | number;
|
|
34
64
|
}
|
|
65
|
+
export interface XTY {
|
|
66
|
+
/** Event name */
|
|
67
|
+
x: string;
|
|
68
|
+
/** Timestamp */
|
|
69
|
+
t: Date;
|
|
70
|
+
/** Number of events */
|
|
71
|
+
y: number;
|
|
72
|
+
}
|
|
35
73
|
/**
|
|
36
74
|
* Many endpoints can make use of the filters in this interface
|
|
37
|
-
* @remarks As defined in the server documentation for the Endpoints in: Events, Sessions, Website stats
|
|
75
|
+
* @remarks As defined in the server documentation for the Endpoints in: Events, Sessions, Website stats, Reports
|
|
38
76
|
*/
|
|
39
77
|
export interface Filters {
|
|
40
78
|
/** Name of URL */
|
|
@@ -148,9 +186,9 @@ export declare class API {
|
|
|
148
186
|
/** If {@link API.setNewToken} has been called, you can wait for it to be done through this promise */
|
|
149
187
|
private token_promise;
|
|
150
188
|
/**
|
|
151
|
-
* This
|
|
189
|
+
* This contacts the server in order to get and set a new {@link API.token}!
|
|
152
190
|
* @remarks The API object requires a {@link API.username} and a {@link API.password} to successfully get any token
|
|
153
|
-
* @returns Whether or not the token has changed (
|
|
191
|
+
* @returns Whether or not the token has changed (**should be true** as otherwise the server would complain and an {@link APIError} would be thrown to give you some details)
|
|
154
192
|
*/
|
|
155
193
|
setNewToken(): Promise<boolean>;
|
|
156
194
|
private _set_token_on_401;
|
|
@@ -233,6 +271,7 @@ export declare class API {
|
|
|
233
271
|
request(method: "get" | "post" | "put" | "delete", endpoint: Array<string | number>, parameters?: {
|
|
234
272
|
[k: string]: any;
|
|
235
273
|
}): Promise<any>;
|
|
274
|
+
/** @remarks To be replaced by {@link API.getWebsiteStats2}, no deprecation warning as the new method is unreliable */
|
|
236
275
|
getWebsiteStats(website_id: string, startAt: Date, endAt: Date): Promise<{
|
|
237
276
|
pageviews: ValueAndPrev;
|
|
238
277
|
visitors: ValueAndPrev;
|
|
@@ -282,5 +321,25 @@ export declare class API {
|
|
|
282
321
|
readonly updateWebsite: typeof Websites.updateWebsite;
|
|
283
322
|
readonly deleteWebsite: typeof Websites.deleteWebsite;
|
|
284
323
|
readonly resetWebsite: typeof Websites.resetWebsite;
|
|
324
|
+
readonly getWebsiteActiveVisitors: typeof WebsiteStats.getWebsiteActiveVisitors;
|
|
325
|
+
readonly getWebsiteEventsStats: typeof WebsiteStats.getWebsiteEvents;
|
|
326
|
+
readonly getWebsiteMetrics: typeof WebsiteStats.getWebsiteMetrics;
|
|
327
|
+
readonly getWebsiteMetricsExpanded: typeof WebsiteStats.getWebsiteMetricsExpanded;
|
|
328
|
+
readonly getWebsitePageviews: typeof WebsiteStats.getWebsitePageviews;
|
|
329
|
+
/** @remarks Will replace {@link API.getWebsiteStats}, which you should use for a reliable experience */
|
|
330
|
+
readonly getWebsiteStats2: typeof WebsiteStats.getWebsiteStats;
|
|
285
331
|
readonly getRealtime: typeof Realtime.getRealtime;
|
|
332
|
+
readonly getReports: typeof Reports.getReports;
|
|
333
|
+
readonly createReport: typeof Reports.createReport;
|
|
334
|
+
readonly getReport: typeof Reports.getReport;
|
|
335
|
+
readonly updateReport: typeof Reports.updateReport;
|
|
336
|
+
readonly deleteReport: typeof Reports.deleteReport;
|
|
337
|
+
readonly getReportsAttribution: typeof Reports.getReportsAttribution;
|
|
338
|
+
readonly getReportsBreakdown: typeof Reports.getReportsBreakdown;
|
|
339
|
+
readonly getReportsFunnel: typeof Reports.getReportsFunnel;
|
|
340
|
+
readonly getReportsGoals: typeof Reports.getReportsGoals;
|
|
341
|
+
readonly getReportsJourney: typeof Reports.getReportsJourney;
|
|
342
|
+
readonly getReportsRetention: typeof Reports.getReportsRetention;
|
|
343
|
+
readonly getReportsRevenue: typeof Reports.getReportsRevenue;
|
|
344
|
+
readonly getReportsUTM: typeof Reports.getReportsUTM;
|
|
286
345
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Admin } from "./namespaces/Admin.js";
|
|
2
2
|
import { Events } from "./namespaces/Events.js";
|
|
3
3
|
import { Realtime } from "./namespaces/Realtime.js";
|
|
4
|
+
import { Reports } from "./namespaces/Reports.js";
|
|
4
5
|
import { Sessions } from "./namespaces/Sessions.js";
|
|
5
6
|
import { Teams } from "./namespaces/Teams.js";
|
|
6
7
|
import { Users } from "./namespaces/Users.js";
|
|
7
8
|
import { Websites } from "./namespaces/Websites.js";
|
|
9
|
+
import { WebsiteStats } from "./namespaces/WebsiteStats.js";
|
|
8
10
|
import { adaptParametersForGETRequests, correctType } from "./utilities.js";
|
|
9
|
-
export { Admin, Users, Teams, Events, Sessions, Websites, Realtime };
|
|
11
|
+
export { Admin, Users, Teams, Events, Sessions, Websites, WebsiteStats, Realtime, Reports };
|
|
10
12
|
/** If the {@link API} throws an error, it should always be an {@link APIError}! */
|
|
11
13
|
export class APIError extends Error {
|
|
12
14
|
message;
|
|
@@ -111,9 +113,9 @@ export class API {
|
|
|
111
113
|
/** If {@link API.setNewToken} has been called, you can wait for it to be done through this promise */
|
|
112
114
|
token_promise = new Promise(r => r);
|
|
113
115
|
/**
|
|
114
|
-
* This
|
|
116
|
+
* This contacts the server in order to get and set a new {@link API.token}!
|
|
115
117
|
* @remarks The API object requires a {@link API.username} and a {@link API.password} to successfully get any token
|
|
116
|
-
* @returns Whether or not the token has changed (
|
|
118
|
+
* @returns Whether or not the token has changed (**should be true** as otherwise the server would complain and an {@link APIError} would be thrown to give you some details)
|
|
117
119
|
*/
|
|
118
120
|
async setNewToken() {
|
|
119
121
|
const old_token = this.token;
|
|
@@ -376,6 +378,7 @@ export class API {
|
|
|
376
378
|
throw new APIError(`${e?.name} (${e?.message ?? e?.errno ?? e?.type})`, this.server, method, endpoint, parameters, undefined, e);
|
|
377
379
|
}
|
|
378
380
|
}
|
|
381
|
+
/** @remarks To be replaced by {@link API.getWebsiteStats2}, no deprecation warning as the new method is unreliable */
|
|
379
382
|
async getWebsiteStats(website_id, startAt, endAt) {
|
|
380
383
|
return await this.request("get", ["websites", website_id, "stats"], { startAt, endAt });
|
|
381
384
|
}
|
|
@@ -427,6 +430,28 @@ export class API {
|
|
|
427
430
|
updateWebsite = Websites.updateWebsite;
|
|
428
431
|
deleteWebsite = Websites.deleteWebsite;
|
|
429
432
|
resetWebsite = Websites.resetWebsite;
|
|
433
|
+
// WEBSITE STATS
|
|
434
|
+
getWebsiteActiveVisitors = WebsiteStats.getWebsiteActiveVisitors;
|
|
435
|
+
getWebsiteEventsStats = WebsiteStats.getWebsiteEvents;
|
|
436
|
+
getWebsiteMetrics = WebsiteStats.getWebsiteMetrics;
|
|
437
|
+
getWebsiteMetricsExpanded = WebsiteStats.getWebsiteMetricsExpanded;
|
|
438
|
+
getWebsitePageviews = WebsiteStats.getWebsitePageviews;
|
|
439
|
+
/** @remarks Will replace {@link API.getWebsiteStats}, which you should use for a reliable experience */
|
|
440
|
+
getWebsiteStats2 = WebsiteStats.getWebsiteStats;
|
|
430
441
|
// REALTIME
|
|
431
442
|
getRealtime = Realtime.getRealtime;
|
|
443
|
+
// REPORTS
|
|
444
|
+
getReports = Reports.getReports;
|
|
445
|
+
createReport = Reports.createReport;
|
|
446
|
+
getReport = Reports.getReport;
|
|
447
|
+
updateReport = Reports.updateReport;
|
|
448
|
+
deleteReport = Reports.deleteReport;
|
|
449
|
+
getReportsAttribution = Reports.getReportsAttribution;
|
|
450
|
+
getReportsBreakdown = Reports.getReportsBreakdown;
|
|
451
|
+
getReportsFunnel = Reports.getReportsFunnel;
|
|
452
|
+
getReportsGoals = Reports.getReportsGoals;
|
|
453
|
+
getReportsJourney = Reports.getReportsJourney;
|
|
454
|
+
getReportsRetention = Reports.getReportsRetention;
|
|
455
|
+
getReportsRevenue = Reports.getReportsRevenue;
|
|
456
|
+
getReportsUTM = Reports.getReportsUTM;
|
|
432
457
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { API, GenericObject, GenericRequestParameters, Role, Teams } from "../index.js";
|
|
1
|
+
import { API, GenericObject, GenericRequestParameters, MinimalUser, Role, Teams, Website } from "../index.js";
|
|
2
2
|
/** For endpoints listed on: https://umami.is/docs/api/admin-api */
|
|
3
3
|
export declare namespace Admin {
|
|
4
4
|
/** Returns all users: https://umami.is/docs/api/admin-api#get-apiadminusers */
|
|
@@ -18,18 +18,8 @@ export declare namespace Admin {
|
|
|
18
18
|
* Returns all websites: https://umami.is/docs/api/admin-api#get-apiadminwebsites
|
|
19
19
|
* @remarks TODO Possibly doesn't work? (throws 400 on my end)
|
|
20
20
|
*/
|
|
21
|
-
function getWebsites(this: API, parameters?: GenericRequestParameters): Promise<(
|
|
22
|
-
|
|
23
|
-
domain: string;
|
|
24
|
-
shareId: number | null;
|
|
25
|
-
resetAt: Date | null;
|
|
26
|
-
userId: string;
|
|
27
|
-
teamid: string | null;
|
|
28
|
-
createdBy: string;
|
|
29
|
-
user: {
|
|
30
|
-
username: string;
|
|
31
|
-
id: string;
|
|
32
|
-
};
|
|
21
|
+
function getWebsites(this: API, parameters?: GenericRequestParameters): Promise<(Website & {
|
|
22
|
+
user: MinimalUser;
|
|
33
23
|
/** @remarks TODO Documentation says it can be null but doesn't actually say what else it can be, ***presumed* to be string**, check */
|
|
34
24
|
team: string | null;
|
|
35
25
|
})[]>;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { API, Filters, GenericRequestParameters, NameValue, Report, Timestamps, XTY } from "../index.js";
|
|
2
|
+
/** For endpoints listed on: https://umami.is/docs/api/reports-api */
|
|
3
|
+
export declare namespace Reports {
|
|
4
|
+
type ReportType = {
|
|
5
|
+
type: "attribution" | "breakdown" | "funnel" | "goal" | "journey" | "retention" | "revenue" | "utm";
|
|
6
|
+
};
|
|
7
|
+
interface UTM {
|
|
8
|
+
utm: string;
|
|
9
|
+
views: number;
|
|
10
|
+
}
|
|
11
|
+
/** Get all reports by website ID: https://umami.is/docs/api/reports-api#get-apireports (TODO UNTESTED) */
|
|
12
|
+
function getReports(this: API, websiteId: string, parameters: ReportType & Omit<GenericRequestParameters, "search">): Promise<Report[]>;
|
|
13
|
+
/** Creates a report: https://umami.is/docs/api/reports-api#post-apireports (TODO UNTESTED) */
|
|
14
|
+
function createReport(this: API, websiteId: string, parameters: ReportType & {
|
|
15
|
+
/** Name of report */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Description of report */
|
|
18
|
+
description?: string;
|
|
19
|
+
/** Parameters for report */
|
|
20
|
+
parameters?: any;
|
|
21
|
+
}): Promise<Report>;
|
|
22
|
+
/** Gets a report by ID: https://umami.is/docs/api/reports-api#get-apireportsreportid (TODO UNTESTED) */
|
|
23
|
+
function getReport(this: API, reportId: string): Promise<Report>;
|
|
24
|
+
/** Updates a report: https://umami.is/docs/api/reports-api#post-apireportsreportid (TODO UNTESTED) */
|
|
25
|
+
function updateReport(this: API, reportId: string, websiteId: string, parameters: ReportType & {
|
|
26
|
+
/** Name of report */
|
|
27
|
+
name: string;
|
|
28
|
+
/** Description of report */
|
|
29
|
+
description?: string;
|
|
30
|
+
/** Parameters for report */
|
|
31
|
+
parameters?: any;
|
|
32
|
+
}): Promise<Report>;
|
|
33
|
+
/** Deletes a report: https://umami.is/docs/api/reports-api#delete-apireportsreportid (TODO UNTESTED) */
|
|
34
|
+
function deleteReport(this: API, reportId: string): Promise<{
|
|
35
|
+
ok: boolean;
|
|
36
|
+
}>;
|
|
37
|
+
/** See how users engage with your marketing and what drives conversions: https://umami.is/docs/api/reports-api#post-apireportsattribution (TODO UNTESTED) */
|
|
38
|
+
function getReportsAttribution(this: API, websiteId: string, parameters: ReportType & Filters & Timestamps & {
|
|
39
|
+
/** Attribution model */
|
|
40
|
+
model: "firstClick" | "lastClick";
|
|
41
|
+
/** Conversion type */
|
|
42
|
+
type: ("path" | "event")[];
|
|
43
|
+
/** Conversion step */
|
|
44
|
+
step: string;
|
|
45
|
+
}): Promise<{
|
|
46
|
+
referrer: NameValue[];
|
|
47
|
+
paidAds: NameValue[];
|
|
48
|
+
utm_source: NameValue[];
|
|
49
|
+
utm_medium: NameValue[];
|
|
50
|
+
utm_campaign: NameValue[];
|
|
51
|
+
utm_content: NameValue[];
|
|
52
|
+
utm_term: NameValue[];
|
|
53
|
+
total: {
|
|
54
|
+
pageviews: number;
|
|
55
|
+
visitors: number;
|
|
56
|
+
visits: number;
|
|
57
|
+
};
|
|
58
|
+
}>;
|
|
59
|
+
/** Dive deeper into your data by using segments and filters: https://umami.is/docs/api/reports-api#post-apireportsbreakdown (TODO UNTESTED) */
|
|
60
|
+
function getReportsBreakdown(this: API, websiteId: string, parameters: ReportType & Filters & Timestamps & {
|
|
61
|
+
fields: ("path" | "title" | "query" | "referrer" | "browser" | "os" | "device" | "country" | "region" | "city" | "hostname" | "tag" | "event")[];
|
|
62
|
+
}): Promise<{
|
|
63
|
+
views: number;
|
|
64
|
+
visitors: number;
|
|
65
|
+
visits: number;
|
|
66
|
+
bounces: number;
|
|
67
|
+
totaltime: number;
|
|
68
|
+
os: string;
|
|
69
|
+
country: string;
|
|
70
|
+
}[]>;
|
|
71
|
+
/** Understand the conversion and drop-off rate of users: https://umami.is/docs/api/reports-api#post-apireportsfunnel (TODO UNTESTED) */
|
|
72
|
+
function getReportsFunnel(this: API, websiteId: string, parameters: ReportType & Filters & Timestamps & {
|
|
73
|
+
/** Type of event and conversion step */
|
|
74
|
+
steps: {
|
|
75
|
+
type: "path" | "event";
|
|
76
|
+
value: string;
|
|
77
|
+
}[];
|
|
78
|
+
/** Window of days between funnel steps to be considered a conversion */
|
|
79
|
+
window: number;
|
|
80
|
+
}): Promise<{
|
|
81
|
+
type: string;
|
|
82
|
+
value: string;
|
|
83
|
+
visitors: number;
|
|
84
|
+
previous: number;
|
|
85
|
+
dropped: number;
|
|
86
|
+
dropoff: number | null;
|
|
87
|
+
remaining: number;
|
|
88
|
+
}[]>;
|
|
89
|
+
/** Track your goals for pageviews and events: https://umami.is/docs/api/reports-api#post-apireportsgoals (TODO UNTESTED) */
|
|
90
|
+
function getReportsGoals(this: API, websiteId: string, parameters: ReportType & Filters & Timestamps & {
|
|
91
|
+
/** Conversion type */
|
|
92
|
+
type: ("path" | "event")[];
|
|
93
|
+
/** Conversion step value */
|
|
94
|
+
value: string;
|
|
95
|
+
}): Promise<{
|
|
96
|
+
num: number;
|
|
97
|
+
total: number;
|
|
98
|
+
}>;
|
|
99
|
+
/** Understand how users nagivate through your website: https://umami.is/docs/api/reports-api#post-apireportsjourney (TODO UNTESTED) */
|
|
100
|
+
function getReportsJourney(this: API, websiteId: string, parameters: ReportType & Filters & Timestamps & {
|
|
101
|
+
/** Number of steps from 3 to 7 */
|
|
102
|
+
steps: number;
|
|
103
|
+
/** Starting step URL or event name */
|
|
104
|
+
startStep: string;
|
|
105
|
+
/** Ending step URL or event name */
|
|
106
|
+
endStep?: string;
|
|
107
|
+
}): Promise<{
|
|
108
|
+
items: (string | null)[];
|
|
109
|
+
count: number;
|
|
110
|
+
}[]>;
|
|
111
|
+
/** Measure your website stickiness by tracking how often users return: https://umami.is/docs/api/reports-api#post-apireportsretention (TODO UNTESTED) */
|
|
112
|
+
function getReportsRetention(this: API, websiteId: string, parameters: ReportType & Filters & Timestamps & {
|
|
113
|
+
/** Timezone (ex. America/Los_Angeles) */
|
|
114
|
+
timezone: string;
|
|
115
|
+
}): Promise<{
|
|
116
|
+
date: Date;
|
|
117
|
+
day: number;
|
|
118
|
+
visitors: number;
|
|
119
|
+
returnVisitors: number;
|
|
120
|
+
percentage: number;
|
|
121
|
+
}[]>;
|
|
122
|
+
/** Get currency for given range. Needed for Revenue and optional in Attribution reports: https://umami.is/docs/api/reports-api#post-apireportsrevenue (TODO UNTESTED) */
|
|
123
|
+
function getReportsRevenue(this: API, websiteId: string, parameters: ReportType & Filters & Timestamps & {
|
|
124
|
+
/** Timezone (ex. America/Los_Angeles) */
|
|
125
|
+
timezone: string;
|
|
126
|
+
/** Currency code (ISO 4217) */
|
|
127
|
+
currency: string;
|
|
128
|
+
}): Promise<{
|
|
129
|
+
chart: XTY[];
|
|
130
|
+
country: NameValue[];
|
|
131
|
+
total: {
|
|
132
|
+
sum: number;
|
|
133
|
+
count: number;
|
|
134
|
+
unique_count: number;
|
|
135
|
+
average: number;
|
|
136
|
+
};
|
|
137
|
+
}>;
|
|
138
|
+
/** Track your campaigns through UTM parameters: https://umami.is/docs/api/reports-api#post-apireportsutm (TODO UNTESTED) */
|
|
139
|
+
function getReportsUTM(this: API, websiteId: string, parameters: ReportType & Filters & Timestamps): Promise<{
|
|
140
|
+
utm_source: UTM[];
|
|
141
|
+
utm_medium: UTM[];
|
|
142
|
+
utm_campaign: UTM[];
|
|
143
|
+
utm_term: UTM[];
|
|
144
|
+
utm_content: UTM[];
|
|
145
|
+
}>;
|
|
146
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** For endpoints listed on: https://umami.is/docs/api/reports-api */
|
|
2
|
+
export var Reports;
|
|
3
|
+
(function (Reports) {
|
|
4
|
+
/** Get all reports by website ID: https://umami.is/docs/api/reports-api#get-apireports (TODO UNTESTED) */
|
|
5
|
+
async function getReports(websiteId, parameters) {
|
|
6
|
+
const response = await this.request("get", ["reports"], { websiteId, ...parameters });
|
|
7
|
+
return response.data;
|
|
8
|
+
}
|
|
9
|
+
Reports.getReports = getReports;
|
|
10
|
+
/** Creates a report: https://umami.is/docs/api/reports-api#post-apireports (TODO UNTESTED) */
|
|
11
|
+
async function createReport(websiteId, parameters) {
|
|
12
|
+
return await this.request("post", ["reports"], { websiteId, ...parameters });
|
|
13
|
+
}
|
|
14
|
+
Reports.createReport = createReport;
|
|
15
|
+
/** Gets a report by ID: https://umami.is/docs/api/reports-api#get-apireportsreportid (TODO UNTESTED) */
|
|
16
|
+
async function getReport(reportId) {
|
|
17
|
+
return await this.request("get", ["reports", reportId]);
|
|
18
|
+
}
|
|
19
|
+
Reports.getReport = getReport;
|
|
20
|
+
/** Updates a report: https://umami.is/docs/api/reports-api#post-apireportsreportid (TODO UNTESTED) */
|
|
21
|
+
async function updateReport(reportId, websiteId, parameters) {
|
|
22
|
+
return await this.request("get", ["reports", reportId], { websiteId, ...parameters });
|
|
23
|
+
}
|
|
24
|
+
Reports.updateReport = updateReport;
|
|
25
|
+
/** Deletes a report: https://umami.is/docs/api/reports-api#delete-apireportsreportid (TODO UNTESTED) */
|
|
26
|
+
async function deleteReport(reportId) {
|
|
27
|
+
return await this.request("delete", ["reports", reportId]);
|
|
28
|
+
}
|
|
29
|
+
Reports.deleteReport = deleteReport;
|
|
30
|
+
/** See how users engage with your marketing and what drives conversions: https://umami.is/docs/api/reports-api#post-apireportsattribution (TODO UNTESTED) */
|
|
31
|
+
async function getReportsAttribution(websiteId, parameters) {
|
|
32
|
+
return await this.request("post", ["reports", "attribution"], { websiteId, ...parameters });
|
|
33
|
+
}
|
|
34
|
+
Reports.getReportsAttribution = getReportsAttribution;
|
|
35
|
+
/** Dive deeper into your data by using segments and filters: https://umami.is/docs/api/reports-api#post-apireportsbreakdown (TODO UNTESTED) */
|
|
36
|
+
async function getReportsBreakdown(websiteId, parameters) {
|
|
37
|
+
return await this.request("post", ["reports", "breakdown"], { websiteId, ...parameters });
|
|
38
|
+
}
|
|
39
|
+
Reports.getReportsBreakdown = getReportsBreakdown;
|
|
40
|
+
/** Understand the conversion and drop-off rate of users: https://umami.is/docs/api/reports-api#post-apireportsfunnel (TODO UNTESTED) */
|
|
41
|
+
async function getReportsFunnel(websiteId, parameters) {
|
|
42
|
+
return await this.request("post", ["reports", "funnel"], { websiteId, ...parameters });
|
|
43
|
+
}
|
|
44
|
+
Reports.getReportsFunnel = getReportsFunnel;
|
|
45
|
+
/** Track your goals for pageviews and events: https://umami.is/docs/api/reports-api#post-apireportsgoals (TODO UNTESTED) */
|
|
46
|
+
async function getReportsGoals(websiteId, parameters) {
|
|
47
|
+
return await this.request("post", ["reports", "goals"], { websiteId, ...parameters });
|
|
48
|
+
}
|
|
49
|
+
Reports.getReportsGoals = getReportsGoals;
|
|
50
|
+
/** Understand how users nagivate through your website: https://umami.is/docs/api/reports-api#post-apireportsjourney (TODO UNTESTED) */
|
|
51
|
+
async function getReportsJourney(websiteId, parameters) {
|
|
52
|
+
return await this.request("post", ["reports", "journey"], { websiteId, ...parameters });
|
|
53
|
+
}
|
|
54
|
+
Reports.getReportsJourney = getReportsJourney;
|
|
55
|
+
/** Measure your website stickiness by tracking how often users return: https://umami.is/docs/api/reports-api#post-apireportsretention (TODO UNTESTED) */
|
|
56
|
+
async function getReportsRetention(websiteId, parameters) {
|
|
57
|
+
return await this.request("post", ["reports", "retention"], { websiteId, ...parameters });
|
|
58
|
+
}
|
|
59
|
+
Reports.getReportsRetention = getReportsRetention;
|
|
60
|
+
/** Get currency for given range. Needed for Revenue and optional in Attribution reports: https://umami.is/docs/api/reports-api#post-apireportsrevenue (TODO UNTESTED) */
|
|
61
|
+
async function getReportsRevenue(websiteId, parameters) {
|
|
62
|
+
return await this.request("post", ["reports", "revenue"], { websiteId, ...parameters });
|
|
63
|
+
}
|
|
64
|
+
Reports.getReportsRevenue = getReportsRevenue;
|
|
65
|
+
/** Track your campaigns through UTM parameters: https://umami.is/docs/api/reports-api#post-apireportsutm (TODO UNTESTED) */
|
|
66
|
+
async function getReportsUTM(websiteId, parameters) {
|
|
67
|
+
return await this.request("post", ["reports", "utm"], { websiteId, ...parameters });
|
|
68
|
+
}
|
|
69
|
+
Reports.getReportsUTM = getReportsUTM;
|
|
70
|
+
})(Reports || (Reports = {}));
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { API, GenericObject, GenericRequestParameters, Role, TeamRole } from "../index.js";
|
|
1
|
+
import { API, GenericObject, GenericRequestParameters, MinimalUser, Role, TeamRole, Website } from "../index.js";
|
|
2
2
|
/** For endpoints listed on: https://umami.is/docs/api/users-api */
|
|
3
3
|
export declare namespace Users {
|
|
4
|
-
interface GenericUser {
|
|
5
|
-
id: string;
|
|
6
|
-
username: string;
|
|
4
|
+
interface GenericUser extends MinimalUser {
|
|
7
5
|
role: Role;
|
|
8
6
|
}
|
|
9
7
|
/** Creates a user: https://umami.is/docs/api/users-api#post-apiusers */
|
|
@@ -39,18 +37,8 @@ export declare namespace Users {
|
|
|
39
37
|
/** Gets all websites that belong to a user: https://umami.is/docs/api/users-api#get-apiusersuseridwebsites */
|
|
40
38
|
function getUserWebsites(this: API, id: string, parameters: GenericRequestParameters & {
|
|
41
39
|
includeTeams: boolean;
|
|
42
|
-
}): Promise<(
|
|
43
|
-
|
|
44
|
-
domain: string;
|
|
45
|
-
shareId: string | null;
|
|
46
|
-
resetAt: Date | null;
|
|
47
|
-
userId: string;
|
|
48
|
-
teamId: string | null;
|
|
49
|
-
createdBy: string;
|
|
50
|
-
user: {
|
|
51
|
-
username: string;
|
|
52
|
-
id: string;
|
|
53
|
-
};
|
|
40
|
+
}): Promise<(Website & {
|
|
41
|
+
user: MinimalUser;
|
|
54
42
|
})[]>;
|
|
55
43
|
/** Gets all teams that belong to a user: https://umami.is/docs/api/users-api#get-apiusersuseridteams */
|
|
56
44
|
function getUserTeams(this: API, id: string, parameters?: Omit<GenericRequestParameters, "search">): Promise<(GenericObject & {
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { API, Filters, Timestamps, XTY } from "../index.js";
|
|
2
|
+
/** For endpoints listed on: https://umami.is/docs/api/website-stats-api */
|
|
3
|
+
export declare namespace WebsiteStats {
|
|
4
|
+
/**
|
|
5
|
+
* The unit parameter buckets the data returned
|
|
6
|
+
* @remarks The unit is automatically converted to the next largest applicable time unit if the maximum is exceeded
|
|
7
|
+
*/
|
|
8
|
+
interface Units {
|
|
9
|
+
/** Up to 60 minutes */
|
|
10
|
+
minute?: number;
|
|
11
|
+
/** Up to 48 hours */
|
|
12
|
+
hour?: number;
|
|
13
|
+
/** Up to 12 months */
|
|
14
|
+
day?: number;
|
|
15
|
+
/** No limit */
|
|
16
|
+
month?: number;
|
|
17
|
+
/** No limit */
|
|
18
|
+
year?: number;
|
|
19
|
+
}
|
|
20
|
+
interface Stats {
|
|
21
|
+
/** Pages hits */
|
|
22
|
+
pageviews: string;
|
|
23
|
+
/** Number of unique visitors */
|
|
24
|
+
visitors: string;
|
|
25
|
+
/** Number of unique visits */
|
|
26
|
+
visits: string;
|
|
27
|
+
/** Number of visitors who only visit a single page */
|
|
28
|
+
bounces: string;
|
|
29
|
+
/** Time spent on the website */
|
|
30
|
+
totaltime: string;
|
|
31
|
+
}
|
|
32
|
+
type MetricsTypes = "path" | "entry" | "exit" | "title" | "query" | "referrer" | "channel" | "domain" | "country" | "region" | "city" | "browser" | "os" | "device" | "language" | "screen" | "event" | "hostname" | "tag";
|
|
33
|
+
/** Gets the number of active users on a website: https://umami.is/docs/api/website-stats-api#get-apiwebsiteswebsiteidactive (TODO UNTESTED) */
|
|
34
|
+
function getWebsiteActiveVisitors(this: API, websiteId: string): Promise<{
|
|
35
|
+
visitors: number;
|
|
36
|
+
}>;
|
|
37
|
+
/** Gets events within a given time range: https://umami.is/docs/api/website-stats-api#get-apiwebsiteswebsiteideventsseries (TODO UNTESTED) */
|
|
38
|
+
function getWebsiteEvents(this: API, websiteId: string, parameters: Timestamps & Units & Filters & {
|
|
39
|
+
/** Timezone (ex. America/Los_Angeles) */
|
|
40
|
+
timezone: string;
|
|
41
|
+
}): Promise<XTY[]>;
|
|
42
|
+
/** Gets metrics for a given time range: https://umami.is/docs/api/website-stats-api#get-apiwebsiteswebsiteidmetrics (TODO UNTESTED) */
|
|
43
|
+
function getWebsiteMetrics(this: API, websiteId: string, parameters: Timestamps & Units & Filters & {
|
|
44
|
+
/** Timezone (ex. America/Los_Angeles) */
|
|
45
|
+
timezone: string;
|
|
46
|
+
/** Metrics type */
|
|
47
|
+
type: MetricsTypes;
|
|
48
|
+
/** (optional, default 500) Number of rows returned */
|
|
49
|
+
limit?: number;
|
|
50
|
+
/** (optional, default 0) Number of ows to skip */
|
|
51
|
+
offset?: number;
|
|
52
|
+
}): Promise<{
|
|
53
|
+
/** Unique value, depending on metric type */
|
|
54
|
+
x: string;
|
|
55
|
+
/** Number of visitors */
|
|
56
|
+
y: number;
|
|
57
|
+
}[]>;
|
|
58
|
+
/** Gets expanded metrics for a given time range: https://umami.is/docs/api/website-stats-api#get-apiwebsiteswebsiteidmetricsexpanded (TODO UNTESTED) */
|
|
59
|
+
function getWebsiteMetricsExpanded(this: API, ...args: Parameters<typeof getWebsiteMetrics>): Promise<(Stats & {
|
|
60
|
+
/** Unique value, depending on metric type */
|
|
61
|
+
name: string;
|
|
62
|
+
})[]>;
|
|
63
|
+
/** Gets pageviews within a given time range: https://umami.is/docs/api/website-stats-api#get-apiwebsiteswebsiteidpageviews (TODO UNTESTED) */
|
|
64
|
+
function getWebsitePageviews(this: API, websiteId: string, parameters: Timestamps & Units & Filters & {
|
|
65
|
+
/** Timezone (ex. America/Los_Angeles) */
|
|
66
|
+
timezone: string;
|
|
67
|
+
/** Comparison value `prev` | `yoy` */
|
|
68
|
+
compare?: string;
|
|
69
|
+
}): Promise<{
|
|
70
|
+
pageviews: {
|
|
71
|
+
/** Timestamp */
|
|
72
|
+
x: Date;
|
|
73
|
+
/** Number of pageviews or visitors */
|
|
74
|
+
y: number;
|
|
75
|
+
}[];
|
|
76
|
+
sessions: {
|
|
77
|
+
/** Timestamp */
|
|
78
|
+
x: Date;
|
|
79
|
+
/** Number of pageviews or visitors */
|
|
80
|
+
y: number;
|
|
81
|
+
}[];
|
|
82
|
+
}>;
|
|
83
|
+
/** Gets summarized website statistics: https://umami.is/docs/api/website-stats-api#get-apiwebsiteswebsiteidstats (TODO UNTESTED) */
|
|
84
|
+
function getWebsiteStats(this: API, websiteId: string, parameters: Timestamps & Filters & Units & {
|
|
85
|
+
/** Timezone (ex. America/Los_Angeles) */
|
|
86
|
+
timezone: string;
|
|
87
|
+
}): Promise<Stats & {
|
|
88
|
+
comparison: Stats;
|
|
89
|
+
}>;
|
|
90
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** For endpoints listed on: https://umami.is/docs/api/website-stats-api */
|
|
2
|
+
export var WebsiteStats;
|
|
3
|
+
(function (WebsiteStats) {
|
|
4
|
+
/** Gets the number of active users on a website: https://umami.is/docs/api/website-stats-api#get-apiwebsiteswebsiteidactive (TODO UNTESTED) */
|
|
5
|
+
async function getWebsiteActiveVisitors(websiteId) {
|
|
6
|
+
return await this.request("get", ["websites", websiteId, "active"]);
|
|
7
|
+
}
|
|
8
|
+
WebsiteStats.getWebsiteActiveVisitors = getWebsiteActiveVisitors;
|
|
9
|
+
/** Gets events within a given time range: https://umami.is/docs/api/website-stats-api#get-apiwebsiteswebsiteideventsseries (TODO UNTESTED) */
|
|
10
|
+
async function getWebsiteEvents(websiteId, parameters) {
|
|
11
|
+
return await this.request("get", ["websites", websiteId, "events", "series"], parameters);
|
|
12
|
+
}
|
|
13
|
+
WebsiteStats.getWebsiteEvents = getWebsiteEvents;
|
|
14
|
+
/** Gets metrics for a given time range: https://umami.is/docs/api/website-stats-api#get-apiwebsiteswebsiteidmetrics (TODO UNTESTED) */
|
|
15
|
+
async function getWebsiteMetrics(websiteId, parameters) {
|
|
16
|
+
return await this.request("get", ["websites", websiteId, "metrics"], parameters);
|
|
17
|
+
}
|
|
18
|
+
WebsiteStats.getWebsiteMetrics = getWebsiteMetrics;
|
|
19
|
+
/** Gets expanded metrics for a given time range: https://umami.is/docs/api/website-stats-api#get-apiwebsiteswebsiteidmetricsexpanded (TODO UNTESTED) */
|
|
20
|
+
async function getWebsiteMetricsExpanded(...args) {
|
|
21
|
+
return await this.request("get", ["websites", args[0], "metrics", "expanded"], args[1]);
|
|
22
|
+
}
|
|
23
|
+
WebsiteStats.getWebsiteMetricsExpanded = getWebsiteMetricsExpanded;
|
|
24
|
+
/** Gets pageviews within a given time range: https://umami.is/docs/api/website-stats-api#get-apiwebsiteswebsiteidpageviews (TODO UNTESTED) */
|
|
25
|
+
async function getWebsitePageviews(websiteId, parameters) {
|
|
26
|
+
return await this.request("get", ["websites", websiteId, "pageviews"], parameters);
|
|
27
|
+
}
|
|
28
|
+
WebsiteStats.getWebsitePageviews = getWebsitePageviews;
|
|
29
|
+
/** Gets summarized website statistics: https://umami.is/docs/api/website-stats-api#get-apiwebsiteswebsiteidstats (TODO UNTESTED) */
|
|
30
|
+
async function getWebsiteStats(websiteId, parameters) {
|
|
31
|
+
return await this.request("get", ["websites", websiteId, "stats"], parameters);
|
|
32
|
+
}
|
|
33
|
+
WebsiteStats.getWebsiteStats = getWebsiteStats;
|
|
34
|
+
})(WebsiteStats || (WebsiteStats = {}));
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { API, GenericRequestParameters } from "../index.js";
|
|
1
|
+
import { API, GenericRequestParameters, MinimalUser, Website } from "../index.js";
|
|
2
2
|
/** For endpoints listed on: https://umami.is/docs/api/websites-api */
|
|
3
3
|
export declare namespace Websites {
|
|
4
4
|
/** Returns all user websites: https://umami.is/docs/api/websites-api#get-apiwebsites (TODO UNTESTED) */
|
|
5
5
|
function getWebsites(this: API, parameters: GenericRequestParameters & {
|
|
6
6
|
includeTeams: boolean;
|
|
7
|
-
}): Promise<
|
|
7
|
+
}): Promise<(Website & {
|
|
8
|
+
user: MinimalUser;
|
|
9
|
+
})[]>;
|
|
8
10
|
/** Creates a website: https://umami.is/docs/api/websites-api#post-apiwebsites (TODO UNTESTED) */
|
|
9
11
|
function createWebsite(this: API, parameters: {
|
|
10
12
|
/** The name of the website in Umami */
|
|
@@ -17,9 +19,9 @@ export declare namespace Websites {
|
|
|
17
19
|
teamId?: string;
|
|
18
20
|
/** Force a UUID assignment to the website */
|
|
19
21
|
id?: string;
|
|
20
|
-
}): Promise<
|
|
22
|
+
}): Promise<Website>;
|
|
21
23
|
/** Gets a website by ID: https://umami.is/docs/api/websites-api#get-apiwebsiteswebsiteid (TODO UNTESTED) */
|
|
22
|
-
function getWebsite(this: API, websiteId: string): Promise<
|
|
24
|
+
function getWebsite(this: API, websiteId: string): Promise<Website>;
|
|
23
25
|
/** Updates a website: https://umami.is/docs/api/websites-api#post-apiwebsiteswebsiteid (TODO UNTESTED) */
|
|
24
26
|
function updateWebsite(this: API, websiteId: string, parameters: {
|
|
25
27
|
/** The name of the website in Umami */
|
|
@@ -28,7 +30,7 @@ export declare namespace Websites {
|
|
|
28
30
|
domain: string;
|
|
29
31
|
/** A unique string to enable a share url. Set `null` to unshare */
|
|
30
32
|
shareId?: string | null;
|
|
31
|
-
}): Promise<
|
|
33
|
+
}): Promise<Website>;
|
|
32
34
|
/** Deletes a website: https://umami.is/docs/api/websites-api#delete-apiwebsiteswebsiteid (TODO UNTESTED) */
|
|
33
35
|
function deleteWebsite(this: API, websiteId: string): Promise<{
|
|
34
36
|
ok: boolean;
|
package/package.json
CHANGED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
on:
|
|
2
|
-
release:
|
|
3
|
-
types: [published]
|
|
4
|
-
|
|
5
|
-
jobs:
|
|
6
|
-
docs:
|
|
7
|
-
runs-on: codeberg-tiny-lazy
|
|
8
|
-
steps:
|
|
9
|
-
- name: Checkout this very app
|
|
10
|
-
uses: actions/checkout@v4
|
|
11
|
-
- name: Install dependencies
|
|
12
|
-
run: npm install
|
|
13
|
-
- name: Generate documentation through the command defined in package.json
|
|
14
|
-
run: npm run docs
|
|
15
|
-
- name: Move the docs up and get rid of the rest (this preserves files that start with a dot)
|
|
16
|
-
run: |
|
|
17
|
-
mv docs/ ..
|
|
18
|
-
rm -rf *
|
|
19
|
-
mv ../docs/* .
|
|
20
|
-
- name: Add the .domains file
|
|
21
|
-
run: echo "umami-api-js.taevas.xyz" > .domains
|
|
22
|
-
- name: Configure our git client
|
|
23
|
-
run: |
|
|
24
|
-
git config user.name "forgejo-actions[bot]"
|
|
25
|
-
git config user.email "code@taevas.xyz"
|
|
26
|
-
- name: Create or switch to the "pages" branch
|
|
27
|
-
run: git switch -C pages
|
|
28
|
-
- name: Add and commit the changes
|
|
29
|
-
run: |
|
|
30
|
-
git add .
|
|
31
|
-
git commit -m "Automatically generated documentation"
|
|
32
|
-
- name: Send the changes to Codeberg, let Codeberg Pages do its magic~
|
|
33
|
-
run: git push
|