umami-api-js 0.0.2 → 0.0.3
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/.forgejo/workflows/release.yaml +33 -0
- package/dist/index.d.ts +57 -2
- package/dist/index.js +23 -3
- package/dist/namespaces/Events.d.ts +7 -44
- package/dist/namespaces/Events.js +0 -4
- package/dist/namespaces/Sessions.d.ts +93 -0
- package/dist/namespaces/Sessions.js +45 -0
- package/dist/namespaces/Websites.d.ts +40 -0
- package/dist/namespaces/Websites.js +35 -0
- package/dist/utilities.js +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,33 @@
|
|
|
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
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
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 { Sessions } from "./namespaces/Sessions.js";
|
|
4
5
|
import { Teams } from "./namespaces/Teams.js";
|
|
5
6
|
import { Users } from "./namespaces/Users.js";
|
|
6
|
-
|
|
7
|
+
import { Websites } from "./namespaces/Websites.js";
|
|
8
|
+
export { Admin, Users, Teams, Events, Sessions, Websites, Realtime };
|
|
7
9
|
export interface ValueAndPrev {
|
|
8
10
|
/** The actual value for the given time period */
|
|
9
11
|
value: number;
|
|
@@ -24,6 +26,46 @@ export interface GenericRequestParameters {
|
|
|
24
26
|
/** Determines how many results to return **(default: 20)** */
|
|
25
27
|
pageSize?: number;
|
|
26
28
|
}
|
|
29
|
+
export interface Timestamps {
|
|
30
|
+
/** Timestamp of starting date */
|
|
31
|
+
startAt: Date | number;
|
|
32
|
+
/** Timestamp of end date */
|
|
33
|
+
endAt: Date | number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 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
|
|
38
|
+
*/
|
|
39
|
+
export interface Filters {
|
|
40
|
+
/** Name of URL */
|
|
41
|
+
path?: string;
|
|
42
|
+
/** Name of referrer */
|
|
43
|
+
referrer?: string;
|
|
44
|
+
/** Name of page title */
|
|
45
|
+
title?: string;
|
|
46
|
+
/** Name of query parameter */
|
|
47
|
+
query?: string;
|
|
48
|
+
/** Name of browser */
|
|
49
|
+
browser?: string;
|
|
50
|
+
/** Name of operating system */
|
|
51
|
+
os?: string;
|
|
52
|
+
/** Name of device (ex. Mobile) */
|
|
53
|
+
device?: string;
|
|
54
|
+
/** Name of country */
|
|
55
|
+
country?: string;
|
|
56
|
+
/** Name of region/state/province */
|
|
57
|
+
region?: string;
|
|
58
|
+
/** Name of city */
|
|
59
|
+
city?: string;
|
|
60
|
+
/** Name of hostname */
|
|
61
|
+
hostname?: string;
|
|
62
|
+
/** Name of tag */
|
|
63
|
+
tag?: string;
|
|
64
|
+
/** UUID of segment */
|
|
65
|
+
segment?: string;
|
|
66
|
+
/** UUID of cohort */
|
|
67
|
+
cohort?: string;
|
|
68
|
+
}
|
|
27
69
|
export type Role = "admin" | "user" | "view-only";
|
|
28
70
|
export type TeamRole = "team-manager" | "team-member" | "team-view-only";
|
|
29
71
|
/** If the {@link API} throws an error, it should always be an {@link APIError}! */
|
|
@@ -186,7 +228,6 @@ export declare class API {
|
|
|
186
228
|
* @param method The type of request, each endpoint uses a specific one (if it uses multiple, the intent and parameters become different)
|
|
187
229
|
* @param endpoint What comes in the URL after `api/`, **DO NOT USE TEMPLATE LITERALS (\`) OR THE ADDITION OPERATOR (+), put everything separately for type safety**
|
|
188
230
|
* @param parameters The things to specify in the request, such as the beatmap_id when looking for a beatmap
|
|
189
|
-
* @param settings Additional settings **to add** to the current settings of the `fetch()` request
|
|
190
231
|
* @returns A Promise with the API's response
|
|
191
232
|
*/
|
|
192
233
|
request(method: "get" | "post" | "put" | "delete", endpoint: Array<string | number>, parameters?: {
|
|
@@ -227,5 +268,19 @@ export declare class API {
|
|
|
227
268
|
readonly getWebsiteEventsDataProperties: typeof Events.getWebsiteEventsDataProperties;
|
|
228
269
|
readonly getWebsiteEventsDataValues: typeof Events.getWebsiteEventsDataValues;
|
|
229
270
|
readonly getWebsiteEventsDataStats: typeof Events.getWebsiteEventsDataStats;
|
|
271
|
+
readonly getWebsiteSessions: typeof Sessions.getWebsiteSessions;
|
|
272
|
+
readonly getWebsiteSessionsStats: typeof Sessions.getWebsiteSessionsStats;
|
|
273
|
+
readonly getWebsiteSessionsWeekly: typeof Sessions.getWebsiteSessionsWeekly;
|
|
274
|
+
readonly getWebsiteSession: typeof Sessions.getWebsiteSession;
|
|
275
|
+
readonly getWebsiteSessionActivity: typeof Sessions.getWebsiteSessionActivity;
|
|
276
|
+
readonly getWebsiteSessionProperties: typeof Sessions.getWebsiteSessionProperties;
|
|
277
|
+
readonly getWebsiteSessionDataProperties: typeof Sessions.getWebsiteSessionDataProperties;
|
|
278
|
+
readonly getWebsiteSessionDataValues: typeof Sessions.getWebsiteSessionDataValues;
|
|
279
|
+
readonly getWebsites: typeof Websites.getWebsites;
|
|
280
|
+
readonly createWebsite: typeof Websites.createWebsite;
|
|
281
|
+
readonly getWebsite: typeof Websites.getWebsite;
|
|
282
|
+
readonly updateWebsite: typeof Websites.updateWebsite;
|
|
283
|
+
readonly deleteWebsite: typeof Websites.deleteWebsite;
|
|
284
|
+
readonly resetWebsite: typeof Websites.resetWebsite;
|
|
230
285
|
readonly getRealtime: typeof Realtime.getRealtime;
|
|
231
286
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
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 { Sessions } from "./namespaces/Sessions.js";
|
|
4
5
|
import { Teams } from "./namespaces/Teams.js";
|
|
5
6
|
import { Users } from "./namespaces/Users.js";
|
|
7
|
+
import { Websites } from "./namespaces/Websites.js";
|
|
6
8
|
import { adaptParametersForGETRequests, correctType } from "./utilities.js";
|
|
7
|
-
export { Admin, Users, Teams, Events, Realtime };
|
|
9
|
+
export { Admin, Users, Teams, Events, Sessions, Websites, Realtime };
|
|
8
10
|
/** If the {@link API} throws an error, it should always be an {@link APIError}! */
|
|
9
11
|
export class APIError extends Error {
|
|
10
12
|
message;
|
|
@@ -265,6 +267,9 @@ export class API {
|
|
|
265
267
|
let error_message = "no error message available";
|
|
266
268
|
if (!is_token_related)
|
|
267
269
|
await this.token_promise.catch(() => this.token_promise = new Promise(r => r));
|
|
270
|
+
for (const [p, v] of Object.entries(parameters)) {
|
|
271
|
+
parameters[p] = v instanceof Date ? Number(v) : v; // Convert Dates to ms
|
|
272
|
+
}
|
|
268
273
|
let url = `${this.server}`;
|
|
269
274
|
if (url.slice(-1) !== "/")
|
|
270
275
|
url += "/";
|
|
@@ -346,7 +351,6 @@ export class API {
|
|
|
346
351
|
* @param method The type of request, each endpoint uses a specific one (if it uses multiple, the intent and parameters become different)
|
|
347
352
|
* @param endpoint What comes in the URL after `api/`, **DO NOT USE TEMPLATE LITERALS (\`) OR THE ADDITION OPERATOR (+), put everything separately for type safety**
|
|
348
353
|
* @param parameters The things to specify in the request, such as the beatmap_id when looking for a beatmap
|
|
349
|
-
* @param settings Additional settings **to add** to the current settings of the `fetch()` request
|
|
350
354
|
* @returns A Promise with the API's response
|
|
351
355
|
*/
|
|
352
356
|
async request(method, endpoint, parameters = {}) {
|
|
@@ -373,7 +377,7 @@ export class API {
|
|
|
373
377
|
}
|
|
374
378
|
}
|
|
375
379
|
async getWebsiteStats(website_id, startAt, endAt) {
|
|
376
|
-
return await this.request("get", ["websites", website_id, "stats"], { startAt
|
|
380
|
+
return await this.request("get", ["websites", website_id, "stats"], { startAt, endAt });
|
|
377
381
|
}
|
|
378
382
|
// ADMIN
|
|
379
383
|
getUsersAsAdmin = Admin.getUsers;
|
|
@@ -407,6 +411,22 @@ export class API {
|
|
|
407
411
|
getWebsiteEventsDataProperties = Events.getWebsiteEventsDataProperties;
|
|
408
412
|
getWebsiteEventsDataValues = Events.getWebsiteEventsDataValues;
|
|
409
413
|
getWebsiteEventsDataStats = Events.getWebsiteEventsDataStats;
|
|
414
|
+
// SESSIONS
|
|
415
|
+
getWebsiteSessions = Sessions.getWebsiteSessions;
|
|
416
|
+
getWebsiteSessionsStats = Sessions.getWebsiteSessionsStats;
|
|
417
|
+
getWebsiteSessionsWeekly = Sessions.getWebsiteSessionsWeekly;
|
|
418
|
+
getWebsiteSession = Sessions.getWebsiteSession;
|
|
419
|
+
getWebsiteSessionActivity = Sessions.getWebsiteSessionActivity;
|
|
420
|
+
getWebsiteSessionProperties = Sessions.getWebsiteSessionProperties;
|
|
421
|
+
getWebsiteSessionDataProperties = Sessions.getWebsiteSessionDataProperties;
|
|
422
|
+
getWebsiteSessionDataValues = Sessions.getWebsiteSessionDataValues;
|
|
423
|
+
// WEBSITES
|
|
424
|
+
getWebsites = Websites.getWebsites;
|
|
425
|
+
createWebsite = Websites.createWebsite;
|
|
426
|
+
getWebsite = Websites.getWebsite;
|
|
427
|
+
updateWebsite = Websites.updateWebsite;
|
|
428
|
+
deleteWebsite = Websites.deleteWebsite;
|
|
429
|
+
resetWebsite = Websites.resetWebsite;
|
|
410
430
|
// REALTIME
|
|
411
431
|
getRealtime = Realtime.getRealtime;
|
|
412
432
|
}
|
|
@@ -1,45 +1,8 @@
|
|
|
1
|
-
import { API, GenericRequestParameters } from "../index.js";
|
|
1
|
+
import { API, Filters, GenericRequestParameters, Timestamps } from "../index.js";
|
|
2
2
|
/** For endpoints listed on: https://umami.is/docs/api/events-api */
|
|
3
3
|
export declare namespace Events {
|
|
4
|
-
interface Timestamps {
|
|
5
|
-
/** Timestamp of starting date */
|
|
6
|
-
startAt: Date | number;
|
|
7
|
-
/** Timestamp of end date */
|
|
8
|
-
endAt: Date | number;
|
|
9
|
-
}
|
|
10
|
-
/** Many endpoints can make use of the filters in this interface: https://umami.is/docs/api/events-api#filters */
|
|
11
|
-
interface FiltersAndTimestamps extends Timestamps {
|
|
12
|
-
/** Name of URL */
|
|
13
|
-
path?: string;
|
|
14
|
-
/** Name of referrer */
|
|
15
|
-
referrer?: string;
|
|
16
|
-
/** Name of page title */
|
|
17
|
-
title?: string;
|
|
18
|
-
/** Name of query parameter */
|
|
19
|
-
query?: string;
|
|
20
|
-
/** Name of browser */
|
|
21
|
-
browser?: string;
|
|
22
|
-
/** Name of operating system */
|
|
23
|
-
os?: string;
|
|
24
|
-
/** Name of device (ex. Mobile) */
|
|
25
|
-
device?: string;
|
|
26
|
-
/** Name of country */
|
|
27
|
-
country?: string;
|
|
28
|
-
/** Name of region/state/province */
|
|
29
|
-
region?: string;
|
|
30
|
-
/** Name of city */
|
|
31
|
-
city?: string;
|
|
32
|
-
/** Name of hostname */
|
|
33
|
-
hostname?: string;
|
|
34
|
-
/** Name of tag */
|
|
35
|
-
tag?: string;
|
|
36
|
-
/** UUID of segment */
|
|
37
|
-
segment?: string;
|
|
38
|
-
/** UUID of cohort */
|
|
39
|
-
cohort?: string;
|
|
40
|
-
}
|
|
41
4
|
/** Gets website event details within a given time range: https://umami.is/docs/api/events-api#get-apiwebsiteswebsiteidevents (TODO UNTESTED) */
|
|
42
|
-
function getWebsiteEvents(this: API, websiteId: string, parameters:
|
|
5
|
+
function getWebsiteEvents(this: API, websiteId: string, parameters: Filters & Timestamps & GenericRequestParameters): Promise<{
|
|
43
6
|
id: string;
|
|
44
7
|
websiteId: string;
|
|
45
8
|
sessionId: string;
|
|
@@ -75,7 +38,7 @@ export declare namespace Events {
|
|
|
75
38
|
createdAt: Date;
|
|
76
39
|
}[]>;
|
|
77
40
|
/** Gets event data names, properties, and counts: https://umami.is/docs/api/events-api#get-apiwebsiteswebsiteidevent-dataevents (TODO UNTESTED) */
|
|
78
|
-
function getWebsiteEventsData(this: API, websiteId: string, parameters:
|
|
41
|
+
function getWebsiteEventsData(this: API, websiteId: string, parameters: Filters & Timestamps & {
|
|
79
42
|
/** Event name filter */
|
|
80
43
|
event?: string;
|
|
81
44
|
}): Promise<{
|
|
@@ -85,20 +48,20 @@ export declare namespace Events {
|
|
|
85
48
|
total: number;
|
|
86
49
|
}[]>;
|
|
87
50
|
/** Gets event data property and value counts within a given time range: https://umami.is/docs/api/events-api#get-apiwebsiteswebsiteidevent-datafields (TODO UNTESTED) */
|
|
88
|
-
function getWebsiteEventsDataFields(this: API, websiteId: string, parameters:
|
|
51
|
+
function getWebsiteEventsDataFields(this: API, websiteId: string, parameters: Filters & Timestamps): Promise<{
|
|
89
52
|
propertyName: string;
|
|
90
53
|
dataType: number;
|
|
91
54
|
value: string;
|
|
92
55
|
total: number;
|
|
93
56
|
}[]>;
|
|
94
57
|
/** Gets event name and property counts for a website: https://umami.is/docs/api/events-api#get-apiwebsiteswebsiteidevent-dataproperties (TODO UNTESTED) */
|
|
95
|
-
function getWebsiteEventsDataProperties(this: API, websiteId: string, parameters:
|
|
58
|
+
function getWebsiteEventsDataProperties(this: API, websiteId: string, parameters: Filters & Timestamps): Promise<{
|
|
96
59
|
eventName: string;
|
|
97
60
|
propertyName: string;
|
|
98
61
|
total: number;
|
|
99
62
|
}[]>;
|
|
100
63
|
/** Gets event data counts for a given event and property: https://umami.is/docs/api/events-api#get-apiwebsiteswebsiteidevent-datavalues (TODO UNTESTED) */
|
|
101
|
-
function getWebsiteEventsDataValues(this: API, websiteId: string, parameters:
|
|
64
|
+
function getWebsiteEventsDataValues(this: API, websiteId: string, parameters: Filters & Timestamps & {
|
|
102
65
|
/** Event name filter */
|
|
103
66
|
event: string;
|
|
104
67
|
/** Property name */
|
|
@@ -108,7 +71,7 @@ export declare namespace Events {
|
|
|
108
71
|
total: number;
|
|
109
72
|
}>;
|
|
110
73
|
/** Gets aggregated website events, properties, and records within a given time range https://umami.is/docs/api/events-api#get-apiwebsiteswebsiteidevent-datastats (TODO UNTESTED) */
|
|
111
|
-
function getWebsiteEventsDataStats(this: API, websiteId: string, parameters:
|
|
74
|
+
function getWebsiteEventsDataStats(this: API, websiteId: string, parameters: Filters & Timestamps): Promise<{
|
|
112
75
|
events: number;
|
|
113
76
|
properties: number;
|
|
114
77
|
records: number;
|
|
@@ -3,10 +3,6 @@ export var Events;
|
|
|
3
3
|
(function (Events) {
|
|
4
4
|
/** Gets website event details within a given time range: https://umami.is/docs/api/events-api#get-apiwebsiteswebsiteidevents (TODO UNTESTED) */
|
|
5
5
|
async function getWebsiteEvents(websiteId, parameters) {
|
|
6
|
-
if (parameters.startAt instanceof Date)
|
|
7
|
-
parameters.startAt = Number(parameters.startAt);
|
|
8
|
-
if (parameters.endAt instanceof Date)
|
|
9
|
-
parameters.endAt = Number(parameters.endAt);
|
|
10
6
|
const response = await this.request("get", ["websites", websiteId, "events"], parameters);
|
|
11
7
|
return response.data;
|
|
12
8
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { API, Filters, GenericRequestParameters, Timestamps } from "../index.js";
|
|
2
|
+
/** For endpoints listed on: https://umami.is/docs/api/sessions-api */
|
|
3
|
+
export declare namespace Sessions {
|
|
4
|
+
interface GenericSession {
|
|
5
|
+
id: string;
|
|
6
|
+
websiteId: string;
|
|
7
|
+
browser: string;
|
|
8
|
+
os: string;
|
|
9
|
+
device: string;
|
|
10
|
+
screen: string;
|
|
11
|
+
language: string;
|
|
12
|
+
country: string;
|
|
13
|
+
region: string;
|
|
14
|
+
city: string;
|
|
15
|
+
firstAt: Date;
|
|
16
|
+
lastAt: Date;
|
|
17
|
+
visits: number;
|
|
18
|
+
views: number;
|
|
19
|
+
}
|
|
20
|
+
/** Gets website session details within a given time range: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsessions (TODO UNTESTED) */
|
|
21
|
+
function getWebsiteSessions(this: API, websiteId: string, parameters: Filters & Timestamps & GenericRequestParameters): Promise<(GenericSession & {
|
|
22
|
+
hostname: string;
|
|
23
|
+
createdAt: Date;
|
|
24
|
+
})[]>;
|
|
25
|
+
/** Gets summarized website session statistics: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsessionsstats (TODO UNTESTED) */
|
|
26
|
+
function getWebsiteSessionsStats(this: API, websiteId: string, parameters: Filters & Timestamps): Promise<{
|
|
27
|
+
/** Pages hits */
|
|
28
|
+
pageviews: {
|
|
29
|
+
value: number;
|
|
30
|
+
};
|
|
31
|
+
/** Number of unique visitors */
|
|
32
|
+
visitors: {
|
|
33
|
+
value: number;
|
|
34
|
+
};
|
|
35
|
+
/** Number of unique visits */
|
|
36
|
+
visits: {
|
|
37
|
+
value: number;
|
|
38
|
+
};
|
|
39
|
+
/** Number of visitors who only visit a single page */
|
|
40
|
+
bounces: {
|
|
41
|
+
value: number;
|
|
42
|
+
};
|
|
43
|
+
/** Time spent on the website */
|
|
44
|
+
totaltime: {
|
|
45
|
+
value: number;
|
|
46
|
+
};
|
|
47
|
+
}>;
|
|
48
|
+
/** Get collected count of sessions by hour of weekday: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsessionsweekly (TODO UNTESTED) */
|
|
49
|
+
function getWebsiteSessionsWeekly(this: API, websiteId: string, parameters: Filters & Timestamps & {
|
|
50
|
+
timezone: string;
|
|
51
|
+
}): Promise<number[][]>;
|
|
52
|
+
/** Gets session details for a individual session: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsessionssessionid (TODO UNTESTED) */
|
|
53
|
+
function getWebsiteSession(this: API, websiteId: string, sessionId: string): Promise<GenericSession & {
|
|
54
|
+
distinctId: string;
|
|
55
|
+
events: number;
|
|
56
|
+
totaltime: number;
|
|
57
|
+
}>;
|
|
58
|
+
/** Gets session activity for a individual session: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsessionssessionidactivity (TODO UNTESTED) */
|
|
59
|
+
function getWebsiteSessionActivity(this: API, websiteId: string, sessionId: string, parameters: Timestamps): Promise<{
|
|
60
|
+
createdAt: Date;
|
|
61
|
+
urlPath: string;
|
|
62
|
+
urlQuery: string;
|
|
63
|
+
referrerDomain: string;
|
|
64
|
+
eventId: string;
|
|
65
|
+
eventType: number;
|
|
66
|
+
eventName: string;
|
|
67
|
+
visitId: string;
|
|
68
|
+
hasData: number;
|
|
69
|
+
}[]>;
|
|
70
|
+
/** Gets session properties for a individual session: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsessionssessionidproperties (TODO UNTESTED) */
|
|
71
|
+
function getWebsiteSessionProperties(this: API, websiteId: string, sessionId: string): Promise<{
|
|
72
|
+
websiteId: string;
|
|
73
|
+
sessionid: string;
|
|
74
|
+
dataKey: string;
|
|
75
|
+
dataType: number;
|
|
76
|
+
stringValue: string;
|
|
77
|
+
numberValue: number | null;
|
|
78
|
+
dateValue: Date | null;
|
|
79
|
+
createdAt: Date;
|
|
80
|
+
}[]>;
|
|
81
|
+
/** Gets session data counts by property name: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsession-dataproperties (TODO UNTESTED) */
|
|
82
|
+
function getWebsiteSessionDataProperties(this: API, websiteId: string, parameters: Filters & Timestamps): Promise<{
|
|
83
|
+
propertyName: string;
|
|
84
|
+
total: number;
|
|
85
|
+
}[]>;
|
|
86
|
+
/** Gets session data counts for a given property: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsession-datavalues (TODO UNTESTED) */
|
|
87
|
+
function getWebsiteSessionDataValues(this: API, websiteId: string, parameters: Filters & Timestamps & {
|
|
88
|
+
propertyName: string;
|
|
89
|
+
}): Promise<{
|
|
90
|
+
value: string;
|
|
91
|
+
total: number;
|
|
92
|
+
}[]>;
|
|
93
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** For endpoints listed on: https://umami.is/docs/api/sessions-api */
|
|
2
|
+
export var Sessions;
|
|
3
|
+
(function (Sessions) {
|
|
4
|
+
/** Gets website session details within a given time range: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsessions (TODO UNTESTED) */
|
|
5
|
+
async function getWebsiteSessions(websiteId, parameters) {
|
|
6
|
+
const response = await this.request("get", ["websites", websiteId, "sessions"], parameters);
|
|
7
|
+
return response.data;
|
|
8
|
+
}
|
|
9
|
+
Sessions.getWebsiteSessions = getWebsiteSessions;
|
|
10
|
+
/** Gets summarized website session statistics: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsessionsstats (TODO UNTESTED) */
|
|
11
|
+
async function getWebsiteSessionsStats(websiteId, parameters) {
|
|
12
|
+
return await this.request("get", ["websites", websiteId, "sessions"], parameters);
|
|
13
|
+
}
|
|
14
|
+
Sessions.getWebsiteSessionsStats = getWebsiteSessionsStats;
|
|
15
|
+
/** Get collected count of sessions by hour of weekday: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsessionsweekly (TODO UNTESTED) */
|
|
16
|
+
async function getWebsiteSessionsWeekly(websiteId, parameters) {
|
|
17
|
+
return await this.request("get", ["websites", websiteId, "sessions", "weekly"], parameters);
|
|
18
|
+
}
|
|
19
|
+
Sessions.getWebsiteSessionsWeekly = getWebsiteSessionsWeekly;
|
|
20
|
+
/** Gets session details for a individual session: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsessionssessionid (TODO UNTESTED) */
|
|
21
|
+
async function getWebsiteSession(websiteId, sessionId) {
|
|
22
|
+
return await this.request("get", ["websites", websiteId, "sessions", sessionId]);
|
|
23
|
+
}
|
|
24
|
+
Sessions.getWebsiteSession = getWebsiteSession;
|
|
25
|
+
/** Gets session activity for a individual session: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsessionssessionidactivity (TODO UNTESTED) */
|
|
26
|
+
async function getWebsiteSessionActivity(websiteId, sessionId, parameters) {
|
|
27
|
+
return await this.request("get", ["websites", websiteId, "sessions", sessionId, "activity"], parameters);
|
|
28
|
+
}
|
|
29
|
+
Sessions.getWebsiteSessionActivity = getWebsiteSessionActivity;
|
|
30
|
+
/** Gets session properties for a individual session: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsessionssessionidproperties (TODO UNTESTED) */
|
|
31
|
+
async function getWebsiteSessionProperties(websiteId, sessionId) {
|
|
32
|
+
return await this.request("get", ["websites", websiteId, "sessions", sessionId, "activity", "properties"]);
|
|
33
|
+
}
|
|
34
|
+
Sessions.getWebsiteSessionProperties = getWebsiteSessionProperties;
|
|
35
|
+
/** Gets session data counts by property name: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsession-dataproperties (TODO UNTESTED) */
|
|
36
|
+
async function getWebsiteSessionDataProperties(websiteId, parameters) {
|
|
37
|
+
return await this.request("get", ["websites", websiteId, "session-data", "properties"], parameters);
|
|
38
|
+
}
|
|
39
|
+
Sessions.getWebsiteSessionDataProperties = getWebsiteSessionDataProperties;
|
|
40
|
+
/** Gets session data counts for a given property: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsession-datavalues (TODO UNTESTED) */
|
|
41
|
+
async function getWebsiteSessionDataValues(websiteId, parameters) {
|
|
42
|
+
return await this.request("get", ["websites", websiteId, "session-data", "values"], parameters);
|
|
43
|
+
}
|
|
44
|
+
Sessions.getWebsiteSessionDataValues = getWebsiteSessionDataValues;
|
|
45
|
+
})(Sessions || (Sessions = {}));
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { API, GenericRequestParameters } from "../index.js";
|
|
2
|
+
/** For endpoints listed on: https://umami.is/docs/api/websites-api */
|
|
3
|
+
export declare namespace Websites {
|
|
4
|
+
/** Returns all user websites: https://umami.is/docs/api/websites-api#get-apiwebsites (TODO UNTESTED) */
|
|
5
|
+
function getWebsites(this: API, parameters: GenericRequestParameters & {
|
|
6
|
+
includeTeams: boolean;
|
|
7
|
+
}): Promise<any[]>;
|
|
8
|
+
/** Creates a website: https://umami.is/docs/api/websites-api#post-apiwebsites (TODO UNTESTED) */
|
|
9
|
+
function createWebsite(this: API, parameters: {
|
|
10
|
+
/** The name of the website in Umami */
|
|
11
|
+
name: string;
|
|
12
|
+
/** The full domain of the tracked website */
|
|
13
|
+
domain: string;
|
|
14
|
+
/** A unique string to enable a share url. Set `null` to unshare */
|
|
15
|
+
shareId?: string | null;
|
|
16
|
+
/** The ID of the team the website will be created under */
|
|
17
|
+
teamId?: string;
|
|
18
|
+
/** Force a UUID assignment to the website */
|
|
19
|
+
id?: string;
|
|
20
|
+
}): Promise<any>;
|
|
21
|
+
/** Gets a website by ID: https://umami.is/docs/api/websites-api#get-apiwebsiteswebsiteid (TODO UNTESTED) */
|
|
22
|
+
function getWebsite(this: API, websiteId: string): Promise<any>;
|
|
23
|
+
/** Updates a website: https://umami.is/docs/api/websites-api#post-apiwebsiteswebsiteid (TODO UNTESTED) */
|
|
24
|
+
function updateWebsite(this: API, websiteId: string, parameters: {
|
|
25
|
+
/** The name of the website in Umami */
|
|
26
|
+
name: string;
|
|
27
|
+
/** The full domain of the tracked website */
|
|
28
|
+
domain: string;
|
|
29
|
+
/** A unique string to enable a share url. Set `null` to unshare */
|
|
30
|
+
shareId?: string | null;
|
|
31
|
+
}): Promise<any>;
|
|
32
|
+
/** Deletes a website: https://umami.is/docs/api/websites-api#delete-apiwebsiteswebsiteid (TODO UNTESTED) */
|
|
33
|
+
function deleteWebsite(this: API, websiteId: string): Promise<{
|
|
34
|
+
ok: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
/** Resets a website by removing all data related to the website: https://umami.is/docs/api/websites-api#post-apiwebsiteswebsiteidreset (TODO UNTESTED) */
|
|
37
|
+
function resetWebsite(this: API, websiteId: string): Promise<{
|
|
38
|
+
ok: boolean;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** For endpoints listed on: https://umami.is/docs/api/websites-api */
|
|
2
|
+
export var Websites;
|
|
3
|
+
(function (Websites) {
|
|
4
|
+
/** Returns all user websites: https://umami.is/docs/api/websites-api#get-apiwebsites (TODO UNTESTED) */
|
|
5
|
+
async function getWebsites(parameters) {
|
|
6
|
+
const response = await this.request("get", ["websites"], parameters);
|
|
7
|
+
return response.data;
|
|
8
|
+
}
|
|
9
|
+
Websites.getWebsites = getWebsites;
|
|
10
|
+
/** Creates a website: https://umami.is/docs/api/websites-api#post-apiwebsites (TODO UNTESTED) */
|
|
11
|
+
async function createWebsite(parameters) {
|
|
12
|
+
return await this.request("post", ["websites"], parameters);
|
|
13
|
+
}
|
|
14
|
+
Websites.createWebsite = createWebsite;
|
|
15
|
+
/** Gets a website by ID: https://umami.is/docs/api/websites-api#get-apiwebsiteswebsiteid (TODO UNTESTED) */
|
|
16
|
+
async function getWebsite(websiteId) {
|
|
17
|
+
return await this.request("get", ["websites", websiteId]);
|
|
18
|
+
}
|
|
19
|
+
Websites.getWebsite = getWebsite;
|
|
20
|
+
/** Updates a website: https://umami.is/docs/api/websites-api#post-apiwebsiteswebsiteid (TODO UNTESTED) */
|
|
21
|
+
async function updateWebsite(websiteId, parameters) {
|
|
22
|
+
return await this.request("post", ["websites", websiteId], parameters);
|
|
23
|
+
}
|
|
24
|
+
Websites.updateWebsite = updateWebsite;
|
|
25
|
+
/** Deletes a website: https://umami.is/docs/api/websites-api#delete-apiwebsiteswebsiteid (TODO UNTESTED) */
|
|
26
|
+
async function deleteWebsite(websiteId) {
|
|
27
|
+
return await this.request("delete", ["websites", websiteId]);
|
|
28
|
+
}
|
|
29
|
+
Websites.deleteWebsite = deleteWebsite;
|
|
30
|
+
/** Resets a website by removing all data related to the website: https://umami.is/docs/api/websites-api#post-apiwebsiteswebsiteidreset (TODO UNTESTED) */
|
|
31
|
+
async function resetWebsite(websiteId) {
|
|
32
|
+
return await this.request("post", ["websites", websiteId, "reset"]);
|
|
33
|
+
}
|
|
34
|
+
Websites.resetWebsite = resetWebsite;
|
|
35
|
+
})(Websites || (Websites = {}));
|
package/dist/utilities.js
CHANGED
|
@@ -58,7 +58,7 @@ export function correctType(x, force_string) {
|
|
|
58
58
|
const unconvertables = ["value"];
|
|
59
59
|
const unconvertables_substrings = ["string", "name"]; // or if the key contains any of those substrings
|
|
60
60
|
for (let i = 0; i < keys.length; i++) {
|
|
61
|
-
x[keys[i]] = correctType(vals[i], unconvertables.some((u) => keys[i] === u)
|
|
61
|
+
x[keys[i]] = correctType(vals[i], unconvertables.some((u) => keys[i] === u) || unconvertables_substrings.some((s) => keys[i].toLowerCase().includes(s)));
|
|
62
62
|
}
|
|
63
63
|
return x;
|
|
64
64
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "umami-api-js",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Package to easily access the umami api!",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"prepublish": "npm run build",
|
|
10
10
|
"build": "tsc",
|
|
11
|
-
"test": "npm run build && node ./dist/test.js"
|
|
11
|
+
"test": "npm run build && node ./dist/test.js",
|
|
12
|
+
"docs": "npx typedoc lib/index.ts"
|
|
12
13
|
},
|
|
13
14
|
"engines": {
|
|
14
15
|
"node": ">=20.0.0"
|
|
@@ -27,9 +28,9 @@
|
|
|
27
28
|
],
|
|
28
29
|
"license": "Unlicense",
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@types/chai": "^5.2.2",
|
|
31
31
|
"@types/node": "^24.3.1",
|
|
32
32
|
"dotenv": "^17.2.2",
|
|
33
|
+
"typedoc": "^0.28.14",
|
|
33
34
|
"typescript": "^5.9.2"
|
|
34
35
|
}
|
|
35
36
|
}
|