umami-api-js 0.0.4 → 0.1.1
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 +3 -2
- package/dist/index.d.ts +191 -96
- package/dist/index.js +163 -69
- package/dist/namespaces/Admin.d.ts +8 -17
- package/dist/namespaces/Admin.js +4 -10
- package/dist/namespaces/Events.d.ts +15 -15
- package/dist/namespaces/Events.js +22 -22
- package/dist/namespaces/Links.d.ts +26 -0
- package/dist/namespaces/Links.js +25 -0
- package/dist/namespaces/Me.d.ts +38 -0
- package/dist/namespaces/Me.js +21 -0
- package/dist/namespaces/Pixels.d.ts +23 -0
- package/dist/namespaces/Pixels.js +25 -0
- package/dist/namespaces/Realtime.d.ts +3 -3
- package/dist/namespaces/Realtime.js +4 -4
- package/dist/namespaces/Reports.d.ts +28 -30
- package/dist/namespaces/Reports.js +40 -40
- package/dist/namespaces/Sessions.d.ts +17 -17
- package/dist/namespaces/Sessions.js +25 -25
- package/dist/namespaces/Teams.d.ts +29 -33
- package/dist/namespaces/Teams.js +37 -37
- package/dist/namespaces/Users.d.ts +33 -29
- package/dist/namespaces/Users.js +24 -24
- package/dist/namespaces/WebsiteStats.d.ts +18 -18
- package/dist/namespaces/WebsiteStats.js +19 -19
- package/dist/namespaces/Websites.d.ts +19 -22
- package/dist/namespaces/Websites.js +19 -19
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
A package to interact with [the API of self-hosted instances of Umami
|
|
1
|
+
A package to interact with [the API of self-hosted instances of Umami v3.0.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
|
-
|
|
3
|
+
If you are reading this from the [package's documentation](https://umami-api-js.taevas.xyz/), please be aware that the documentation is for **umami-api-js@0.1.1**, so make sure your package is up to date! Report any bug on [Codeberg](https://codeberg.org/Taevas/umami-api-js/issues).
|
|
4
4
|
|
|
5
|
+
Please note that this package is expected to work with self-hosted instances of **Umami v3.0.0**, and is *not* expected to work with [Umami Cloud](https://umami.is/docs/cloud), the instance of Umami hosted by its creators.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Admin } from "./namespaces/Admin.js";
|
|
2
2
|
import { Events } from "./namespaces/Events.js";
|
|
3
|
+
import { Links } from "./namespaces/Links.js";
|
|
4
|
+
import { Me } from "./namespaces/Me.js";
|
|
5
|
+
import { Pixels } from "./namespaces/Pixels.js";
|
|
3
6
|
import { Realtime } from "./namespaces/Realtime.js";
|
|
4
7
|
import { Reports } from "./namespaces/Reports.js";
|
|
5
8
|
import { Sessions } from "./namespaces/Sessions.js";
|
|
@@ -7,34 +10,28 @@ import { Teams } from "./namespaces/Teams.js";
|
|
|
7
10
|
import { Users } from "./namespaces/Users.js";
|
|
8
11
|
import { Websites } from "./namespaces/Websites.js";
|
|
9
12
|
import { WebsiteStats } from "./namespaces/WebsiteStats.js";
|
|
10
|
-
export { Admin,
|
|
11
|
-
export interface ValueAndPrev {
|
|
12
|
-
/** The actual value for the given time period */
|
|
13
|
-
value: number;
|
|
14
|
-
/** The value for the same *timespan* for the time period that ends where the time period for value starts */
|
|
15
|
-
prev: number;
|
|
16
|
-
}
|
|
17
|
-
export interface MinimalUser {
|
|
18
|
-
id: string;
|
|
19
|
-
username: string;
|
|
20
|
-
}
|
|
13
|
+
export { Admin, Events, Links, Me, Pixels, Websites, WebsiteStats, Realtime, Reports, Sessions, Teams, Users };
|
|
21
14
|
export interface GenericObject {
|
|
22
15
|
id: string;
|
|
23
16
|
createdAt: Date;
|
|
24
17
|
updatedAt: Date | null;
|
|
25
18
|
deletedAt: Date | null;
|
|
26
19
|
}
|
|
20
|
+
export interface DeletionResult {
|
|
21
|
+
ok: boolean;
|
|
22
|
+
}
|
|
27
23
|
export interface Website extends GenericObject {
|
|
28
24
|
name: string;
|
|
29
25
|
domain: string;
|
|
30
26
|
shareId: string | null;
|
|
31
27
|
resetAt: Date | null;
|
|
32
|
-
|
|
28
|
+
/** @remarks Is null if the website is under a team (has a `teamId`) */
|
|
29
|
+
userId: Users.User["id"] | null;
|
|
33
30
|
teamId: string | null;
|
|
34
|
-
createdBy:
|
|
31
|
+
createdBy: Users.User["id"];
|
|
35
32
|
}
|
|
36
33
|
export interface Report extends Omit<GenericObject, "deletedAt"> {
|
|
37
|
-
userId:
|
|
34
|
+
userId: Users.User["id"];
|
|
38
35
|
websiteId: string;
|
|
39
36
|
type: string;
|
|
40
37
|
name: string;
|
|
@@ -62,6 +59,7 @@ export interface Timestamps {
|
|
|
62
59
|
/** Timestamp of end date */
|
|
63
60
|
endAt: Date | number;
|
|
64
61
|
}
|
|
62
|
+
/** An object with the properties `x`, `t`, and `y`, where they're respectively a name, a date, and an amount */
|
|
65
63
|
export interface XTY {
|
|
66
64
|
/** Event name */
|
|
67
65
|
x: string;
|
|
@@ -104,7 +102,6 @@ export interface Filters {
|
|
|
104
102
|
/** UUID of cohort */
|
|
105
103
|
cohort?: string;
|
|
106
104
|
}
|
|
107
|
-
export type Role = "admin" | "user" | "view-only";
|
|
108
105
|
export type TeamRole = "team-manager" | "team-member" | "team-view-only";
|
|
109
106
|
/** If the {@link API} throws an error, it should always be an {@link APIError}! */
|
|
110
107
|
export declare class APIError extends Error {
|
|
@@ -166,20 +163,8 @@ export declare class API {
|
|
|
166
163
|
});
|
|
167
164
|
private _user;
|
|
168
165
|
/** Information about the account that has been used to log in */
|
|
169
|
-
get user():
|
|
170
|
-
|
|
171
|
-
username: string;
|
|
172
|
-
role: string;
|
|
173
|
-
createdAt: Date;
|
|
174
|
-
isAdmin: boolean;
|
|
175
|
-
};
|
|
176
|
-
set user(user: {
|
|
177
|
-
id: string;
|
|
178
|
-
username: string;
|
|
179
|
-
role: string;
|
|
180
|
-
createdAt: Date;
|
|
181
|
-
isAdmin: boolean;
|
|
182
|
-
});
|
|
166
|
+
get user(): Users.User;
|
|
167
|
+
set user(user: Users.User);
|
|
183
168
|
private number_of_requests;
|
|
184
169
|
/** Has {@link API.setNewToken} been called and not yet returned anything? */
|
|
185
170
|
private is_setting_token;
|
|
@@ -271,75 +256,185 @@ export declare class API {
|
|
|
271
256
|
request(method: "get" | "post" | "put" | "delete", endpoint: Array<string | number>, parameters?: {
|
|
272
257
|
[k: string]: any;
|
|
273
258
|
}): Promise<any>;
|
|
274
|
-
/**
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
259
|
+
/**
|
|
260
|
+
* To register an event
|
|
261
|
+
* (TODO UNTESTED)
|
|
262
|
+
* @group Sending stats
|
|
263
|
+
*/
|
|
264
|
+
sendStats(payload: {
|
|
265
|
+
/** Name of host */
|
|
266
|
+
hostname: string;
|
|
267
|
+
/** Screen resolution (ex. "1920x1080") */
|
|
268
|
+
screen: string;
|
|
269
|
+
/** Language of visitor (ex. "en-US") */
|
|
270
|
+
language: string;
|
|
271
|
+
/** Page URL */
|
|
272
|
+
url: string;
|
|
273
|
+
/** Referrer URL */
|
|
274
|
+
referrer: string;
|
|
275
|
+
/** Page title */
|
|
276
|
+
title: string;
|
|
277
|
+
/** Additional tag description */
|
|
278
|
+
tag: string;
|
|
279
|
+
/** Session identifier */
|
|
280
|
+
id: string;
|
|
281
|
+
/** Website ID */
|
|
282
|
+
website: string;
|
|
283
|
+
/** Name of the event */
|
|
284
|
+
name: string;
|
|
285
|
+
/** Additional data for the event */
|
|
286
|
+
data?: {
|
|
287
|
+
[k: string]: any;
|
|
288
|
+
};
|
|
289
|
+
}): Promise<{
|
|
290
|
+
cache: string;
|
|
291
|
+
sessionid: string;
|
|
292
|
+
visitId: string;
|
|
281
293
|
}>;
|
|
294
|
+
/** @group Admin endpoints */
|
|
282
295
|
readonly getUsersAsAdmin: typeof Admin.getUsers;
|
|
296
|
+
/** @group Admin endpoints */
|
|
283
297
|
readonly getWebsitesAsAdmin: typeof Admin.getWebsites;
|
|
298
|
+
/** @group Admin endpoints */
|
|
284
299
|
readonly getTeamsAsAdmin: typeof Admin.getTeams;
|
|
285
|
-
|
|
286
|
-
readonly
|
|
287
|
-
|
|
288
|
-
readonly
|
|
289
|
-
|
|
290
|
-
readonly
|
|
291
|
-
|
|
292
|
-
readonly
|
|
293
|
-
|
|
294
|
-
readonly
|
|
295
|
-
|
|
296
|
-
readonly
|
|
297
|
-
|
|
298
|
-
readonly
|
|
299
|
-
|
|
300
|
-
readonly
|
|
301
|
-
|
|
302
|
-
readonly
|
|
303
|
-
|
|
304
|
-
readonly
|
|
305
|
-
|
|
306
|
-
readonly
|
|
307
|
-
|
|
308
|
-
readonly
|
|
309
|
-
|
|
310
|
-
readonly
|
|
311
|
-
|
|
312
|
-
readonly
|
|
313
|
-
|
|
314
|
-
readonly
|
|
315
|
-
|
|
316
|
-
readonly
|
|
317
|
-
|
|
318
|
-
readonly
|
|
319
|
-
|
|
320
|
-
readonly
|
|
321
|
-
|
|
322
|
-
readonly
|
|
323
|
-
|
|
324
|
-
readonly
|
|
325
|
-
|
|
326
|
-
readonly
|
|
327
|
-
|
|
328
|
-
readonly
|
|
329
|
-
/** @
|
|
330
|
-
readonly
|
|
331
|
-
|
|
332
|
-
readonly
|
|
333
|
-
|
|
334
|
-
readonly
|
|
335
|
-
|
|
336
|
-
readonly
|
|
337
|
-
|
|
338
|
-
readonly
|
|
339
|
-
|
|
340
|
-
readonly
|
|
341
|
-
|
|
342
|
-
readonly
|
|
343
|
-
|
|
344
|
-
readonly
|
|
300
|
+
/** @group Events endpoints */
|
|
301
|
+
readonly getWebsiteEvents: typeof Events.get_WEBSITEID_Events;
|
|
302
|
+
/** @group Events endpoints */
|
|
303
|
+
readonly getWebsiteEventData: typeof Events.get_WEBSITEID_Eventdata_EVENTID;
|
|
304
|
+
/** @group Events endpoints */
|
|
305
|
+
readonly getWebsiteEventsData: typeof Events.get_WEBSITEID_EventdataEvents;
|
|
306
|
+
/** @group Events endpoints */
|
|
307
|
+
readonly getWebsiteEventsDataFields: typeof Events.get_WEBSITEID_EventdataFields;
|
|
308
|
+
/** @group Events endpoints */
|
|
309
|
+
readonly getWebsiteEventsDataProperties: typeof Events.get_WEBSITEID_EventdataProperties;
|
|
310
|
+
/** @group Events endpoints */
|
|
311
|
+
readonly getWebsiteEventsDataValues: typeof Events.get_WEBSITEID_EventdataValues;
|
|
312
|
+
/** @group Events endpoints */
|
|
313
|
+
readonly getWebsiteEventsDataStats: typeof Events.get_WEBSITEID_EventdataStats;
|
|
314
|
+
/** @group Links endpoints */
|
|
315
|
+
readonly getLinks: typeof Links.get;
|
|
316
|
+
/** @group Links endpoints */
|
|
317
|
+
readonly getLink: typeof Links.get_LINKID;
|
|
318
|
+
/** @group Links endpoints */
|
|
319
|
+
readonly updateLink: typeof Links.post_LINKID;
|
|
320
|
+
/** @group Links endpoints */
|
|
321
|
+
readonly deleteLink: typeof Links.delete_LINKID;
|
|
322
|
+
/** @group Me endpoints */
|
|
323
|
+
readonly getMyself: typeof Me.get;
|
|
324
|
+
/** @group Me endpoints */
|
|
325
|
+
readonly getMyTeams: typeof Me.getTeams;
|
|
326
|
+
/** @group Me endpoints */
|
|
327
|
+
readonly getMyWebsites: typeof Me.getWebsites;
|
|
328
|
+
/** @group Links endpoints */
|
|
329
|
+
readonly getPixels: typeof Pixels.get;
|
|
330
|
+
/** @group Links endpoints */
|
|
331
|
+
readonly getPixel: typeof Pixels.get_PIXELID;
|
|
332
|
+
/** @group Links endpoints */
|
|
333
|
+
readonly updatePixel: typeof Pixels.post_PIXELID;
|
|
334
|
+
/** @group Links endpoints */
|
|
335
|
+
readonly deletePixel: typeof Pixels.delete_PIXELID;
|
|
336
|
+
/** @group Websites endpoints */
|
|
337
|
+
readonly getWebsites: typeof Websites.get;
|
|
338
|
+
/** @group Websites endpoints */
|
|
339
|
+
readonly createWebsite: typeof Websites.post;
|
|
340
|
+
/** @group Websites endpoints */
|
|
341
|
+
readonly getWebsite: typeof Websites.get_WEBSITEID;
|
|
342
|
+
/** @group Websites endpoints */
|
|
343
|
+
readonly updateWebsite: typeof Websites.post_WEBSITEID;
|
|
344
|
+
/** @group Websites endpoints */
|
|
345
|
+
readonly deleteWebsite: typeof Websites.delete_WEBSITEID;
|
|
346
|
+
/** @group Websites endpoints */
|
|
347
|
+
readonly resetWebsite: typeof Websites.post_WEBSITEID_Reset;
|
|
348
|
+
/** @group Website stats endpoints */
|
|
349
|
+
readonly getWebsiteActiveVisitors: typeof WebsiteStats.get_WEBSITEID_Active;
|
|
350
|
+
/** @group Website stats endpoints */
|
|
351
|
+
readonly getWebsiteEventsStats: typeof WebsiteStats.get_WEBSITEID_EventsSeries;
|
|
352
|
+
/** @group Website stats endpoints */
|
|
353
|
+
readonly getWebsiteMetrics: typeof WebsiteStats.get_WEBSITEID_Metrics;
|
|
354
|
+
/** @group Website stats endpoints */
|
|
355
|
+
readonly getWebsiteMetricsExpanded: typeof WebsiteStats.get_WEBSITEID_MetricsExpanded;
|
|
356
|
+
/** @group Website stats endpoints */
|
|
357
|
+
readonly getWebsitePageviews: typeof WebsiteStats.get_WEBSITEID_Pageviews;
|
|
358
|
+
/** @group Website stats endpoints */
|
|
359
|
+
readonly getWebsiteStats: typeof WebsiteStats.get_WEBSITEID_Stats;
|
|
360
|
+
/** @group Realtime endpoints */
|
|
361
|
+
readonly getRealtime: typeof Realtime.get_WEBSITEID;
|
|
362
|
+
/** @group Reports endpoints */
|
|
363
|
+
readonly getReports: typeof Reports.get;
|
|
364
|
+
/** @group Reports endpoints */
|
|
365
|
+
readonly createReport: typeof Reports.post;
|
|
366
|
+
/** @group Reports endpoints */
|
|
367
|
+
readonly getReport: typeof Reports.get_REPORTID;
|
|
368
|
+
/** @group Reports endpoints */
|
|
369
|
+
readonly updateReport: typeof Reports.post_REPORTID;
|
|
370
|
+
/** @group Reports endpoints */
|
|
371
|
+
readonly deleteReport: typeof Reports.delete_REPORTID;
|
|
372
|
+
/** @group Reports endpoints */
|
|
373
|
+
readonly getReportsAttribution: typeof Reports.postAttribution;
|
|
374
|
+
/** @group Reports endpoints */
|
|
375
|
+
readonly getReportsBreakdown: typeof Reports.postBreakdown;
|
|
376
|
+
/** @group Reports endpoints */
|
|
377
|
+
readonly getReportsFunnel: typeof Reports.postFunnel;
|
|
378
|
+
/** @group Reports endpoints */
|
|
379
|
+
readonly getReportsGoals: typeof Reports.postGoals;
|
|
380
|
+
/** @group Reports endpoints */
|
|
381
|
+
readonly getReportsJourney: typeof Reports.postJourney;
|
|
382
|
+
/** @group Reports endpoints */
|
|
383
|
+
readonly getReportsRetention: typeof Reports.postRetention;
|
|
384
|
+
/** @group Reports endpoints */
|
|
385
|
+
readonly getReportsRevenue: typeof Reports.postRevenue;
|
|
386
|
+
/** @group Reports endpoints */
|
|
387
|
+
readonly getReportsUTM: typeof Reports.postUTM;
|
|
388
|
+
/** @group Sessions endpoints */
|
|
389
|
+
readonly getWebsiteSessions: typeof Sessions.get_WEBSITEID_Sessions;
|
|
390
|
+
/** @group Sessions endpoints */
|
|
391
|
+
readonly getWebsiteSessionsStats: typeof Sessions.get_WEBSITEID_SessionsStats;
|
|
392
|
+
/** @group Sessions endpoints */
|
|
393
|
+
readonly getWebsiteSessionsWeekly: typeof Sessions.get_WEBSITEID_SessionsWeekly;
|
|
394
|
+
/** @group Sessions endpoints */
|
|
395
|
+
readonly getWebsiteSession: typeof Sessions.get_WEBSITEID_Sessions_SESSIONID;
|
|
396
|
+
/** @group Sessions endpoints */
|
|
397
|
+
readonly getWebsiteSessionActivity: typeof Sessions.get_WEBSITEID_Sessions_SESSIONID_Activity;
|
|
398
|
+
/** @group Sessions endpoints */
|
|
399
|
+
readonly getWebsiteSessionProperties: typeof Sessions.get_WEBSITEID_Sessions_SESSIONID_Properties;
|
|
400
|
+
/** @group Sessions endpoints */
|
|
401
|
+
readonly getWebsiteSessionDataProperties: typeof Sessions.get_WEBSITEID_SessiondataProperties;
|
|
402
|
+
/** @group Sessions endpoints */
|
|
403
|
+
readonly getWebsiteSessionDataValues: typeof Sessions.get_WEBSITEID_SessiondataValues;
|
|
404
|
+
/** @group Teams endpoints */
|
|
405
|
+
readonly getTeams: typeof Teams.get;
|
|
406
|
+
/** @group Teams endpoints */
|
|
407
|
+
readonly createTeam: typeof Teams.post;
|
|
408
|
+
/** @group Teams endpoints */
|
|
409
|
+
readonly joinTeam: typeof Teams.postJoin;
|
|
410
|
+
/** @group Teams endpoints */
|
|
411
|
+
readonly getTeam: typeof Teams.get_TEAMID;
|
|
412
|
+
/** @group Teams endpoints */
|
|
413
|
+
readonly updateTeam: typeof Teams.post_TEAMID;
|
|
414
|
+
/** @group Teams endpoints */
|
|
415
|
+
readonly deleteTeam: typeof Teams.delete_TEAMID;
|
|
416
|
+
/** @group Teams endpoints */
|
|
417
|
+
readonly getTeamUsers: typeof Teams.get_TEAMID_Users;
|
|
418
|
+
/** @group Teams endpoints */
|
|
419
|
+
readonly addTeamUser: typeof Teams.post_TEAMID_Users;
|
|
420
|
+
/** @group Teams endpoints */
|
|
421
|
+
readonly getTeamUser: typeof Teams.get_TEAMID_Users_USERID;
|
|
422
|
+
/** @group Teams endpoints */
|
|
423
|
+
readonly updateTeamUser: typeof Teams.post_TEAMID_Users_USERID;
|
|
424
|
+
/** @group Teams endpoints */
|
|
425
|
+
readonly removeTeamUser: typeof Teams.delete_TEAMID_Users_USERID;
|
|
426
|
+
/** @group Teams endpoints */
|
|
427
|
+
readonly getTeamWebsites: typeof Teams.get_TEAMID_Websites;
|
|
428
|
+
/** @group Users endpoints */
|
|
429
|
+
readonly createUser: typeof Users.post;
|
|
430
|
+
/** @group Users endpoints */
|
|
431
|
+
readonly getUser: typeof Users.get_USERID;
|
|
432
|
+
/** @group Users endpoints */
|
|
433
|
+
readonly updateUser: typeof Users.post_USERID;
|
|
434
|
+
/** @group Users endpoints */
|
|
435
|
+
readonly deleteUser: typeof Users.delete_USERID;
|
|
436
|
+
/** @group Users endpoints */
|
|
437
|
+
readonly getUserTeams: typeof Users.get_USERID_Teams;
|
|
438
|
+
/** @group Users endpoints */
|
|
439
|
+
readonly getUserWebsites: typeof Users.get_USERID_Websites;
|
|
345
440
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Admin } from "./namespaces/Admin.js";
|
|
2
2
|
import { Events } from "./namespaces/Events.js";
|
|
3
|
+
import { Links } from "./namespaces/Links.js";
|
|
4
|
+
import { Me } from "./namespaces/Me.js";
|
|
5
|
+
import { Pixels } from "./namespaces/Pixels.js";
|
|
3
6
|
import { Realtime } from "./namespaces/Realtime.js";
|
|
4
7
|
import { Reports } from "./namespaces/Reports.js";
|
|
5
8
|
import { Sessions } from "./namespaces/Sessions.js";
|
|
@@ -8,7 +11,7 @@ import { Users } from "./namespaces/Users.js";
|
|
|
8
11
|
import { Websites } from "./namespaces/Websites.js";
|
|
9
12
|
import { WebsiteStats } from "./namespaces/WebsiteStats.js";
|
|
10
13
|
import { adaptParametersForGETRequests, correctType } from "./utilities.js";
|
|
11
|
-
export { Admin,
|
|
14
|
+
export { Admin, Events, Links, Me, Pixels, Websites, WebsiteStats, Realtime, Reports, Sessions, Teams, Users };
|
|
12
15
|
/** If the {@link API} throws an error, it should always be an {@link APIError}! */
|
|
13
16
|
export class APIError extends Error {
|
|
14
17
|
message;
|
|
@@ -99,7 +102,7 @@ export class API {
|
|
|
99
102
|
_user = {
|
|
100
103
|
id: "",
|
|
101
104
|
username: "",
|
|
102
|
-
role: "",
|
|
105
|
+
role: "view-only",
|
|
103
106
|
createdAt: new Date(),
|
|
104
107
|
isAdmin: false,
|
|
105
108
|
};
|
|
@@ -134,8 +137,8 @@ export class API {
|
|
|
134
137
|
this.log(true, "Unable to obtain a token! Here's what was received from the API:", json);
|
|
135
138
|
reject(new APIError(error_message, this.server, "post", ["auth", "login"], body, response.status));
|
|
136
139
|
}
|
|
137
|
-
this.token_type = json.token_type;
|
|
138
140
|
this.token = json.token;
|
|
141
|
+
this.user = json.user;
|
|
139
142
|
const expiration_date = new Date();
|
|
140
143
|
expiration_date.setDate(expiration_date.getDate() + 1); // Assume 24 hours
|
|
141
144
|
this.expires = expiration_date;
|
|
@@ -378,80 +381,171 @@ export class API {
|
|
|
378
381
|
throw new APIError(`${e?.name} (${e?.message ?? e?.errno ?? e?.type})`, this.server, method, endpoint, parameters, undefined, e);
|
|
379
382
|
}
|
|
380
383
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
+
// UNCATEGORIZED
|
|
385
|
+
/**
|
|
386
|
+
* To register an event
|
|
387
|
+
* (TODO UNTESTED)
|
|
388
|
+
* @group Sending stats
|
|
389
|
+
*/
|
|
390
|
+
async sendStats(payload) {
|
|
391
|
+
return await this.request("post", ["send"], { payload, type: "event" });
|
|
384
392
|
}
|
|
385
393
|
// ADMIN
|
|
394
|
+
/** @group Admin endpoints */
|
|
386
395
|
getUsersAsAdmin = Admin.getUsers;
|
|
396
|
+
/** @group Admin endpoints */
|
|
387
397
|
getWebsitesAsAdmin = Admin.getWebsites;
|
|
398
|
+
/** @group Admin endpoints */
|
|
388
399
|
getTeamsAsAdmin = Admin.getTeams;
|
|
389
|
-
// USERS
|
|
390
|
-
createUser = Users.createUser;
|
|
391
|
-
getUser = Users.getUser;
|
|
392
|
-
updateUser = Users.updateUser;
|
|
393
|
-
deleteUser = Users.deleteUser;
|
|
394
|
-
getUserTeams = Users.getUserTeams;
|
|
395
|
-
getUserWebsites = Users.getUserWebsites;
|
|
396
|
-
// TEAMS
|
|
397
|
-
getTeams = Teams.getTeams;
|
|
398
|
-
createTeam = Teams.createTeam;
|
|
399
|
-
joinTeam = Teams.joinTeam;
|
|
400
|
-
getTeam = Teams.getTeam;
|
|
401
|
-
updateTeam = Teams.updateTeam;
|
|
402
|
-
deleteTeam = Teams.deleteTeam;
|
|
403
|
-
getTeamUsers = Teams.getTeamUsers;
|
|
404
|
-
addTeamUser = Teams.addTeamUser;
|
|
405
|
-
getTeamUser = Teams.getTeamUser;
|
|
406
|
-
updateTeamUser = Teams.updateTeamUser;
|
|
407
|
-
removeTeamUser = Teams.removeTeamUser;
|
|
408
|
-
getTeamWebsites = Teams.getTeamWebsites;
|
|
409
400
|
// EVENTS
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
401
|
+
/** @group Events endpoints */
|
|
402
|
+
getWebsiteEvents = Events.get_WEBSITEID_Events;
|
|
403
|
+
/** @group Events endpoints */
|
|
404
|
+
getWebsiteEventData = Events.get_WEBSITEID_Eventdata_EVENTID;
|
|
405
|
+
/** @group Events endpoints */
|
|
406
|
+
getWebsiteEventsData = Events.get_WEBSITEID_EventdataEvents;
|
|
407
|
+
/** @group Events endpoints */
|
|
408
|
+
getWebsiteEventsDataFields = Events.get_WEBSITEID_EventdataFields;
|
|
409
|
+
/** @group Events endpoints */
|
|
410
|
+
getWebsiteEventsDataProperties = Events.get_WEBSITEID_EventdataProperties;
|
|
411
|
+
/** @group Events endpoints */
|
|
412
|
+
getWebsiteEventsDataValues = Events.get_WEBSITEID_EventdataValues;
|
|
413
|
+
/** @group Events endpoints */
|
|
414
|
+
getWebsiteEventsDataStats = Events.get_WEBSITEID_EventdataStats;
|
|
415
|
+
// LINKS
|
|
416
|
+
/** @group Links endpoints */
|
|
417
|
+
getLinks = Links.get;
|
|
418
|
+
/** @group Links endpoints */
|
|
419
|
+
getLink = Links.get_LINKID;
|
|
420
|
+
/** @group Links endpoints */
|
|
421
|
+
updateLink = Links.post_LINKID;
|
|
422
|
+
/** @group Links endpoints */
|
|
423
|
+
deleteLink = Links.delete_LINKID;
|
|
424
|
+
// ME
|
|
425
|
+
/** @group Me endpoints */
|
|
426
|
+
getMyself = Me.get;
|
|
427
|
+
/** @group Me endpoints */
|
|
428
|
+
getMyTeams = Me.getTeams;
|
|
429
|
+
/** @group Me endpoints */
|
|
430
|
+
getMyWebsites = Me.getWebsites;
|
|
431
|
+
// PIXELS
|
|
432
|
+
/** @group Links endpoints */
|
|
433
|
+
getPixels = Pixels.get;
|
|
434
|
+
/** @group Links endpoints */
|
|
435
|
+
getPixel = Pixels.get_PIXELID;
|
|
436
|
+
/** @group Links endpoints */
|
|
437
|
+
updatePixel = Pixels.post_PIXELID;
|
|
438
|
+
/** @group Links endpoints */
|
|
439
|
+
deletePixel = Pixels.delete_PIXELID;
|
|
426
440
|
// WEBSITES
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
441
|
+
/** @group Websites endpoints */
|
|
442
|
+
getWebsites = Websites.get;
|
|
443
|
+
/** @group Websites endpoints */
|
|
444
|
+
createWebsite = Websites.post;
|
|
445
|
+
/** @group Websites endpoints */
|
|
446
|
+
getWebsite = Websites.get_WEBSITEID;
|
|
447
|
+
/** @group Websites endpoints */
|
|
448
|
+
updateWebsite = Websites.post_WEBSITEID;
|
|
449
|
+
/** @group Websites endpoints */
|
|
450
|
+
deleteWebsite = Websites.delete_WEBSITEID;
|
|
451
|
+
/** @group Websites endpoints */
|
|
452
|
+
resetWebsite = Websites.post_WEBSITEID_Reset;
|
|
433
453
|
// WEBSITE STATS
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
454
|
+
/** @group Website stats endpoints */
|
|
455
|
+
getWebsiteActiveVisitors = WebsiteStats.get_WEBSITEID_Active;
|
|
456
|
+
/** @group Website stats endpoints */
|
|
457
|
+
getWebsiteEventsStats = WebsiteStats.get_WEBSITEID_EventsSeries;
|
|
458
|
+
/** @group Website stats endpoints */
|
|
459
|
+
getWebsiteMetrics = WebsiteStats.get_WEBSITEID_Metrics;
|
|
460
|
+
/** @group Website stats endpoints */
|
|
461
|
+
getWebsiteMetricsExpanded = WebsiteStats.get_WEBSITEID_MetricsExpanded;
|
|
462
|
+
/** @group Website stats endpoints */
|
|
463
|
+
getWebsitePageviews = WebsiteStats.get_WEBSITEID_Pageviews;
|
|
464
|
+
/** @group Website stats endpoints */
|
|
465
|
+
getWebsiteStats = WebsiteStats.get_WEBSITEID_Stats;
|
|
441
466
|
// REALTIME
|
|
442
|
-
|
|
467
|
+
/** @group Realtime endpoints */
|
|
468
|
+
getRealtime = Realtime.get_WEBSITEID;
|
|
443
469
|
// REPORTS
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
470
|
+
/** @group Reports endpoints */
|
|
471
|
+
getReports = Reports.get;
|
|
472
|
+
/** @group Reports endpoints */
|
|
473
|
+
createReport = Reports.post;
|
|
474
|
+
/** @group Reports endpoints */
|
|
475
|
+
getReport = Reports.get_REPORTID;
|
|
476
|
+
/** @group Reports endpoints */
|
|
477
|
+
updateReport = Reports.post_REPORTID;
|
|
478
|
+
/** @group Reports endpoints */
|
|
479
|
+
deleteReport = Reports.delete_REPORTID;
|
|
480
|
+
/** @group Reports endpoints */
|
|
481
|
+
getReportsAttribution = Reports.postAttribution;
|
|
482
|
+
/** @group Reports endpoints */
|
|
483
|
+
getReportsBreakdown = Reports.postBreakdown;
|
|
484
|
+
/** @group Reports endpoints */
|
|
485
|
+
getReportsFunnel = Reports.postFunnel;
|
|
486
|
+
/** @group Reports endpoints */
|
|
487
|
+
getReportsGoals = Reports.postGoals;
|
|
488
|
+
/** @group Reports endpoints */
|
|
489
|
+
getReportsJourney = Reports.postJourney;
|
|
490
|
+
/** @group Reports endpoints */
|
|
491
|
+
getReportsRetention = Reports.postRetention;
|
|
492
|
+
/** @group Reports endpoints */
|
|
493
|
+
getReportsRevenue = Reports.postRevenue;
|
|
494
|
+
/** @group Reports endpoints */
|
|
495
|
+
getReportsUTM = Reports.postUTM;
|
|
496
|
+
// SESSIONS
|
|
497
|
+
/** @group Sessions endpoints */
|
|
498
|
+
getWebsiteSessions = Sessions.get_WEBSITEID_Sessions;
|
|
499
|
+
/** @group Sessions endpoints */
|
|
500
|
+
getWebsiteSessionsStats = Sessions.get_WEBSITEID_SessionsStats;
|
|
501
|
+
/** @group Sessions endpoints */
|
|
502
|
+
getWebsiteSessionsWeekly = Sessions.get_WEBSITEID_SessionsWeekly;
|
|
503
|
+
/** @group Sessions endpoints */
|
|
504
|
+
getWebsiteSession = Sessions.get_WEBSITEID_Sessions_SESSIONID;
|
|
505
|
+
/** @group Sessions endpoints */
|
|
506
|
+
getWebsiteSessionActivity = Sessions.get_WEBSITEID_Sessions_SESSIONID_Activity;
|
|
507
|
+
/** @group Sessions endpoints */
|
|
508
|
+
getWebsiteSessionProperties = Sessions.get_WEBSITEID_Sessions_SESSIONID_Properties;
|
|
509
|
+
/** @group Sessions endpoints */
|
|
510
|
+
getWebsiteSessionDataProperties = Sessions.get_WEBSITEID_SessiondataProperties;
|
|
511
|
+
/** @group Sessions endpoints */
|
|
512
|
+
getWebsiteSessionDataValues = Sessions.get_WEBSITEID_SessiondataValues;
|
|
513
|
+
// TEAMS
|
|
514
|
+
/** @group Teams endpoints */
|
|
515
|
+
getTeams = Teams.get;
|
|
516
|
+
/** @group Teams endpoints */
|
|
517
|
+
createTeam = Teams.post;
|
|
518
|
+
/** @group Teams endpoints */
|
|
519
|
+
joinTeam = Teams.postJoin;
|
|
520
|
+
/** @group Teams endpoints */
|
|
521
|
+
getTeam = Teams.get_TEAMID;
|
|
522
|
+
/** @group Teams endpoints */
|
|
523
|
+
updateTeam = Teams.post_TEAMID;
|
|
524
|
+
/** @group Teams endpoints */
|
|
525
|
+
deleteTeam = Teams.delete_TEAMID;
|
|
526
|
+
/** @group Teams endpoints */
|
|
527
|
+
getTeamUsers = Teams.get_TEAMID_Users;
|
|
528
|
+
/** @group Teams endpoints */
|
|
529
|
+
addTeamUser = Teams.post_TEAMID_Users;
|
|
530
|
+
/** @group Teams endpoints */
|
|
531
|
+
getTeamUser = Teams.get_TEAMID_Users_USERID;
|
|
532
|
+
/** @group Teams endpoints */
|
|
533
|
+
updateTeamUser = Teams.post_TEAMID_Users_USERID;
|
|
534
|
+
/** @group Teams endpoints */
|
|
535
|
+
removeTeamUser = Teams.delete_TEAMID_Users_USERID;
|
|
536
|
+
/** @group Teams endpoints */
|
|
537
|
+
getTeamWebsites = Teams.get_TEAMID_Websites;
|
|
538
|
+
// USERS
|
|
539
|
+
/** @group Users endpoints */
|
|
540
|
+
createUser = Users.post;
|
|
541
|
+
/** @group Users endpoints */
|
|
542
|
+
getUser = Users.get_USERID;
|
|
543
|
+
/** @group Users endpoints */
|
|
544
|
+
updateUser = Users.post_USERID;
|
|
545
|
+
/** @group Users endpoints */
|
|
546
|
+
deleteUser = Users.delete_USERID;
|
|
547
|
+
/** @group Users endpoints */
|
|
548
|
+
getUserTeams = Users.get_USERID_Teams;
|
|
549
|
+
/** @group Users endpoints */
|
|
550
|
+
getUserWebsites = Users.get_USERID_Websites;
|
|
457
551
|
}
|