umami-api-js 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,11 +4,11 @@
4
4
  [![automated testing](https://codeberg.org/Taevas/umami-api-js/badges/workflows/test.yml/badge.svg)](https://codeberg.org/Taevas/umami-api-js/actions?workflow=test.yml)
5
5
  [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/V7V4J78L0)
6
6
 
7
- A package to interact with [the API of **self-hosted instances** of Umami](https://umami.is/docs/api).
7
+ A package to interact with [the API of **self-hosted instances** of Umami](https://docs.umami.is/docs/api).
8
8
 
9
9
  The documentation for the latest version of this package can be found at any time on [umami-api-js.taevas.xyz](https://umami-api-js.taevas.xyz)!
10
10
 
11
- Please note: It has not been made to work on [Umami Cloud](https://umami.is/docs/cloud) (the instance of Umami hosted by its creators) and is therefore not expected to work there.
11
+ Please note: It has NOT been made to work on [Umami Cloud](https://docs.umami.is/docs/cloud) (the instance of Umami hosted by its creators) and is therefore not expected to work there.
12
12
 
13
13
  ## How to install and get started
14
14
 
package/dist/index.d.ts CHANGED
@@ -307,6 +307,8 @@ export declare class API {
307
307
  readonly getWebsiteEventsDataValues: typeof Events.get_WEBSITEID_EventdataValues;
308
308
  /** @group Events endpoints */
309
309
  readonly getWebsiteEventsDataStats: typeof Events.get_WEBSITEID_EventdataStats;
310
+ /** @group Events endpoints */
311
+ readonly getWebsiteEventsDataPivoted: typeof Events.get_WEBSITEID_EventdataPivot;
310
312
  /** @group Links endpoints */
311
313
  readonly getLinks: typeof Links.get;
312
314
  /** @group Links endpoints */
@@ -345,9 +347,13 @@ export declare class API {
345
347
  readonly deleteWebsite: typeof Websites.delete_WEBSITEID;
346
348
  /** @group Websites endpoints */
347
349
  readonly resetWebsite: typeof Websites.post_WEBSITEID_Reset;
350
+ /** @group Websites endpoints */
351
+ readonly getWebsiteRecorder: typeof Websites.getRecorder;
348
352
  /** @group Website stats endpoints */
349
353
  readonly getWebsiteActiveVisitors: typeof WebsiteStats.get_WEBSITEID_Active;
350
354
  /** @group Website stats endpoints */
355
+ readonly getWebsiteDateRange: typeof WebsiteStats.get_WEBSITEID_DateRange;
356
+ /** @group Website stats endpoints */
351
357
  readonly getWebsiteEventsStats: typeof WebsiteStats.get_WEBSITEID_EventsSeries;
352
358
  /** @group Website stats endpoints */
353
359
  readonly getWebsiteMetrics: typeof WebsiteStats.get_WEBSITEID_Metrics;
@@ -384,6 +390,14 @@ export declare class API {
384
390
  /** @group Reports endpoints */
385
391
  readonly getReportsRevenue: typeof Reports.postRevenue;
386
392
  /** @group Reports endpoints */
393
+ readonly getReportsRevenueChart: typeof Reports.getRevenueChart;
394
+ /** @group Reports endpoints */
395
+ readonly getReportsRevenueStats: typeof Reports.getRevenueStats;
396
+ /** @group Reports endpoints */
397
+ readonly getReportsRevenueMetrics: typeof Reports.getRevenueMetrics;
398
+ /** @group Reports endpoints */
399
+ readonly getReportsRevenueSessions: typeof Reports.getRevenueSessions;
400
+ /** @group Reports endpoints */
387
401
  readonly getReportsUTM: typeof Reports.postUTM;
388
402
  /** @group Sessions endpoints */
389
403
  readonly getWebsiteSessions: typeof Sessions.get_WEBSITEID_Sessions;
@@ -401,6 +415,10 @@ export declare class API {
401
415
  readonly getWebsiteSessionDataProperties: typeof Sessions.get_WEBSITEID_SessiondataProperties;
402
416
  /** @group Sessions endpoints */
403
417
  readonly getWebsiteSessionDataValues: typeof Sessions.get_WEBSITEID_SessiondataValues;
418
+ /** @group Sessions endpoints */
419
+ readonly getWebsiteSessionDataPivoted: typeof Sessions.get_WEBSITEID_SessiondataPivot;
420
+ /** @group Sessions endpoints */
421
+ readonly getWebsiteSessionDataStats: typeof Sessions.get_WEBSITEID_SessiondataStats;
404
422
  /** @group Share endpoints */
405
423
  readonly createShare: typeof Share.post;
406
424
  /** @group Share endpoints */
@@ -446,7 +464,7 @@ export declare class API {
446
464
  /** @group Users endpoints */
447
465
  readonly deleteUser: typeof Users.delete_USERID;
448
466
  /** @group Users endpoints */
449
- readonly getUserTeams: typeof Users.get_USERID_Teams;
450
- /** @group Users endpoints */
451
467
  readonly getUserWebsites: typeof Users.get_USERID_Websites;
468
+ /** @group Users endpoints */
469
+ readonly getUserTeams: typeof Users.get_USERID_Teams;
452
470
  }
package/dist/index.js CHANGED
@@ -489,7 +489,7 @@ export class API {
489
489
  this.log(true, `Will request again in ${this.retry_delay} seconds...`, `(retry #${info.number_try}/${this.retry_maximum_amount})`, request_id);
490
490
  await new Promise((res) => setTimeout(res, this.retry_delay * 1000));
491
491
  if (response) {
492
- void response.text(); // Consume the response to avoid connection pool exhaustion
492
+ await response.text(); // Consume the response to avoid connection pool exhaustion, needs to be awaited
493
493
  }
494
494
  return await this.fetch(is_token_related, method, endpoint, parameters, {
495
495
  number_try: info.number_try + 1,
@@ -570,6 +570,8 @@ export class API {
570
570
  getWebsiteEventsDataValues = Events.get_WEBSITEID_EventdataValues;
571
571
  /** @group Events endpoints */
572
572
  getWebsiteEventsDataStats = Events.get_WEBSITEID_EventdataStats;
573
+ /** @group Events endpoints */
574
+ getWebsiteEventsDataPivoted = Events.get_WEBSITEID_EventdataPivot;
573
575
  // LINKS
574
576
  /** @group Links endpoints */
575
577
  getLinks = Links.get;
@@ -612,10 +614,14 @@ export class API {
612
614
  deleteWebsite = Websites.delete_WEBSITEID;
613
615
  /** @group Websites endpoints */
614
616
  resetWebsite = Websites.post_WEBSITEID_Reset;
617
+ /** @group Websites endpoints */
618
+ getWebsiteRecorder = Websites.getRecorder;
615
619
  // WEBSITE STATS
616
620
  /** @group Website stats endpoints */
617
621
  getWebsiteActiveVisitors = WebsiteStats.get_WEBSITEID_Active;
618
622
  /** @group Website stats endpoints */
623
+ getWebsiteDateRange = WebsiteStats.get_WEBSITEID_DateRange;
624
+ /** @group Website stats endpoints */
619
625
  getWebsiteEventsStats = WebsiteStats.get_WEBSITEID_EventsSeries;
620
626
  /** @group Website stats endpoints */
621
627
  getWebsiteMetrics = WebsiteStats.get_WEBSITEID_Metrics;
@@ -654,6 +660,14 @@ export class API {
654
660
  /** @group Reports endpoints */
655
661
  getReportsRevenue = Reports.postRevenue;
656
662
  /** @group Reports endpoints */
663
+ getReportsRevenueChart = Reports.getRevenueChart;
664
+ /** @group Reports endpoints */
665
+ getReportsRevenueStats = Reports.getRevenueStats;
666
+ /** @group Reports endpoints */
667
+ getReportsRevenueMetrics = Reports.getRevenueMetrics;
668
+ /** @group Reports endpoints */
669
+ getReportsRevenueSessions = Reports.getRevenueSessions;
670
+ /** @group Reports endpoints */
657
671
  getReportsUTM = Reports.postUTM;
658
672
  // SESSIONS
659
673
  /** @group Sessions endpoints */
@@ -672,6 +686,10 @@ export class API {
672
686
  getWebsiteSessionDataProperties = Sessions.get_WEBSITEID_SessiondataProperties;
673
687
  /** @group Sessions endpoints */
674
688
  getWebsiteSessionDataValues = Sessions.get_WEBSITEID_SessiondataValues;
689
+ /** @group Sessions endpoints */
690
+ getWebsiteSessionDataPivoted = Sessions.get_WEBSITEID_SessiondataPivot;
691
+ /** @group Sessions endpoints */
692
+ getWebsiteSessionDataStats = Sessions.get_WEBSITEID_SessiondataStats;
675
693
  // SHARE
676
694
  /** @group Share endpoints */
677
695
  createShare = Share.post;
@@ -720,7 +738,7 @@ export class API {
720
738
  /** @group Users endpoints */
721
739
  deleteUser = Users.delete_USERID;
722
740
  /** @group Users endpoints */
723
- getUserTeams = Users.get_USERID_Teams;
724
- /** @group Users endpoints */
725
741
  getUserWebsites = Users.get_USERID_Websites;
742
+ /** @group Users endpoints */
743
+ getUserTeams = Users.get_USERID_Teams;
726
744
  }
@@ -43,7 +43,6 @@ export declare namespace Events {
43
43
  /** Gets event-data for a individual event: https://umami.is/docs/api/events#get-apiwebsiteswebsiteidevent-dataeventid */
44
44
  function get_WEBSITEID_Eventdata_EVENTID(this: API, websiteId: Websites.Website["id"], eventId: Event["id"]): Promise<Data[]>;
45
45
  interface DataMultiple {
46
- eventName: Event["eventName"];
47
46
  propertyName: string;
48
47
  dataType: number;
49
48
  propertyValue: string | number;
@@ -63,7 +62,8 @@ export declare namespace Events {
63
62
  interface DataFields {
64
63
  propertyName: string;
65
64
  dataType: number;
66
- value: string;
65
+ /** @remarks Seems to have become optional or deleted since Umami v3.2.0 */
66
+ value?: string;
67
67
  total: number;
68
68
  }
69
69
  /** Gets event data property and value counts within a given time range: https://umami.is/docs/api/events#get-apiwebsiteswebsiteidevent-datafields */
@@ -104,4 +104,20 @@ export declare namespace Events {
104
104
  /** Can accept filter parameters */
105
105
  filters?: Filters;
106
106
  }): Promise<DataStats>;
107
+ interface DataPivot {
108
+ eventId: Event["id"];
109
+ sessionId: Sessions.Session["id"];
110
+ eventName: Event["eventName"];
111
+ urlPath: string;
112
+ createdAt: Date;
113
+ propertyKeys: string[];
114
+ propertyValues: (string | number)[];
115
+ }
116
+ /** Gets event data for a website in a pivoted format, with each row representing an event and its properties as parallel arrays: https://docs.umami.is/docs/api/events#get-apiwebsiteswebsiteidevent-data-pivot */
117
+ function get_WEBSITEID_EventdataPivot(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & Exclude<GenericRequestParameters, "search"> & {
118
+ /** Event name to pivot on */
119
+ eventName: Event["eventName"];
120
+ /** Can accept filter parameters */
121
+ filters?: Filters;
122
+ }): Promise<DataPivot[]>;
107
123
  }
@@ -46,4 +46,10 @@ export var Events;
46
46
  return await this.request("get", ["websites", websiteId, "event-data", "stats"], parameters);
47
47
  }
48
48
  Events.get_WEBSITEID_EventdataStats = get_WEBSITEID_EventdataStats;
49
+ /** Gets event data for a website in a pivoted format, with each row representing an event and its properties as parallel arrays: https://docs.umami.is/docs/api/events#get-apiwebsiteswebsiteidevent-data-pivot */
50
+ async function get_WEBSITEID_EventdataPivot(websiteId, parameters) {
51
+ const response = await this.request("get", ["websites", websiteId, "event-data-pivot"], parameters);
52
+ return response.data;
53
+ }
54
+ Events.get_WEBSITEID_EventdataPivot = get_WEBSITEID_EventdataPivot;
49
55
  })(Events || (Events = {}));
@@ -1,5 +1,5 @@
1
- import { API, DeletionResult, Filters, GenericRequestParameters, NameValue, Users, Websites, XTY } from "../index.js";
2
- /** Using reports throught [sic] the api: https://umami.is/docs/api/reports */
1
+ import { API, DeletionResult, Filters, GenericRequestParameters, NameValue, Sessions, Timestamps, Users, Websites, XTY } from "../index.js";
2
+ /** Using reports through the api: https://docs.umami.is/docs/api/reports */
3
3
  export declare namespace Reports {
4
4
  interface Report {
5
5
  id: string;
@@ -15,8 +15,8 @@ export declare namespace Reports {
15
15
  createdAt: Date;
16
16
  updatedAt: Date;
17
17
  }
18
- /** The Reports endpoints use `startDate` instead of `startAt`, and `endDate` instead of `endAt` */
19
- interface Timestamps {
18
+ /** Many of the Reports endpoints use `startDate` instead of `startAt`, and `endDate` instead of `endAt` */
19
+ interface DateTimestamps {
20
20
  /** Timestamp of starting date */
21
21
  startDate: Date | number;
22
22
  /** Timestamp of end date */
@@ -70,7 +70,7 @@ export declare namespace Reports {
70
70
  };
71
71
  }
72
72
  /** See how users engage with your marketing and what drives conversions: https://umami.is/docs/api/reports#post-apireportsattribution */
73
- function postAttribution(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & {
73
+ function postAttribution(this: API, websiteId: Websites.Website["id"], parameters: DateTimestamps & {
74
74
  /** Can accept filter parameters */
75
75
  filters?: Filters;
76
76
  /** Attribution model */
@@ -90,7 +90,7 @@ export declare namespace Reports {
90
90
  country: string;
91
91
  }
92
92
  /** Dive deeper into your data by using segments and filters: https://umami.is/docs/api/reports#post-apireportsbreakdown */
93
- function postBreakdown(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & {
93
+ function postBreakdown(this: API, websiteId: Websites.Website["id"], parameters: DateTimestamps & {
94
94
  /** Can accept filter parameters */
95
95
  filters?: Filters;
96
96
  /** List of column fields */
@@ -106,7 +106,7 @@ export declare namespace Reports {
106
106
  remaining: number | null;
107
107
  }
108
108
  /** Understand the conversion and drop-off rate of users: https://umami.is/docs/api/reports#post-apireportsfunnel */
109
- function postFunnel(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & {
109
+ function postFunnel(this: API, websiteId: Websites.Website["id"], parameters: DateTimestamps & {
110
110
  /** Can accept filter parameters */
111
111
  filters?: Filters;
112
112
  /** Type of event and conversion step */
@@ -125,7 +125,7 @@ export declare namespace Reports {
125
125
  * Track your goals for pageviews and events: https://umami.is/docs/api/reports#post-apireportsgoals
126
126
  * @remarks Here be dragons: I have no idea how to use this endpoint without it returning a client/server error, my apologies - The package developer
127
127
  */
128
- function postGoals(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & {
128
+ function postGoals(this: API, websiteId: Websites.Website["id"], parameters: DateTimestamps & {
129
129
  /** Can accept filter parameters */
130
130
  filters?: Filters;
131
131
  /** Conversion type */
@@ -143,8 +143,8 @@ export declare namespace Reports {
143
143
  items: (string | null)[];
144
144
  count: number;
145
145
  }
146
- /** Understand how users nagivate [sic] through your website: https://umami.is/docs/api/reports#post-apireportsjourney */
147
- function postJourney(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & {
146
+ /** Understand how users navigate through your website: https://docs.umami.is/docs/api/reports#post-apireportsjourney */
147
+ function postJourney(this: API, websiteId: Websites.Website["id"], parameters: DateTimestamps & {
148
148
  /** Can accept filter parameters */
149
149
  filters?: Filters;
150
150
  /** Number of steps from 3 to 7 */
@@ -162,24 +162,38 @@ export declare namespace Reports {
162
162
  percentage: number;
163
163
  }
164
164
  /** Measure your website stickiness by tracking how often users return: https://umami.is/docs/api/reports#post-apireportsretention */
165
- function postRetention(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & {
165
+ function postRetention(this: API, websiteId: Websites.Website["id"], parameters: DateTimestamps & {
166
166
  /** Can accept filter parameters */
167
167
  filters?: Filters;
168
168
  /** Timezone (ex. America/Los_Angeles) */
169
169
  timezone: string;
170
170
  }): Promise<Retention[]>;
171
+ interface RevenueChart extends XTY {
172
+ count: number;
173
+ }
174
+ interface RevenueStats {
175
+ sum: number | null;
176
+ count: number;
177
+ unique_count: number;
178
+ total_sessions: number;
179
+ average: number;
180
+ arpu: number;
181
+ }
182
+ interface RevenueStatsWithComparison extends RevenueStats {
183
+ comparison: RevenueStats;
184
+ }
171
185
  interface Revenue {
172
- chart: XTY[];
186
+ chart: RevenueChart[];
187
+ total: RevenueStatsWithComparison;
173
188
  country: NameValue[];
174
- total: {
175
- sum: number | null;
176
- count: number;
177
- unique_count: number;
178
- average: number;
179
- };
189
+ region: (NameValue & {
190
+ country: string;
191
+ })[];
192
+ referrer: NameValue[];
193
+ channel: NameValue[];
180
194
  }
181
195
  /** Get currency for given range. Needed for Revenue and optional in Attribution reports: https://umami.is/docs/api/reports#post-apireportsrevenue */
182
- function postRevenue(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & {
196
+ function postRevenue(this: API, websiteId: Websites.Website["id"], parameters: DateTimestamps & {
183
197
  /** Can accept filter parameters */
184
198
  filters?: Filters;
185
199
  /** Timezone (ex. America/Los_Angeles) */
@@ -187,6 +201,43 @@ export declare namespace Reports {
187
201
  /** Currency code (ISO 4217) */
188
202
  currency: string;
189
203
  }): Promise<Revenue>;
204
+ /** Returns revenue chart data for a given date range and currency: https://docs.umami.is/docs/api/reports#get-apiwebsiteswebsiteidrevenuechart */
205
+ function getRevenueChart(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & {
206
+ /** Timezone (ex. America/Los_Angeles) */
207
+ timezone: string;
208
+ /** Currency code (ISO 4217) */
209
+ currency: string;
210
+ /** Comparison period */
211
+ compare?: "prev" | "yoy";
212
+ }): Promise<RevenueChart[]>;
213
+ /** Returns revenue statistics for a given date range with optional comparison period: https://docs.umami.is/docs/api/reports#get-apiwebsiteswebsiteidrevenuestats */
214
+ function getRevenueStats(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & {
215
+ /** Timezone (ex. America/Los_Angeles) */
216
+ timezone: string;
217
+ /** Currency code (ISO 4217) */
218
+ currency: string;
219
+ /** Comparison period */
220
+ compare?: "prev" | "yoy";
221
+ }): Promise<RevenueStatsWithComparison>;
222
+ /** Returns revenue broken down by a specified dimension: https://docs.umami.is/docs/api/reports#get-apiwebsiteswebsiteidrevenuemetrics */
223
+ function getRevenueMetrics(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & {
224
+ /** Timezone (ex. America/Los_Angeles) */
225
+ timezone: string;
226
+ /** Breakdown type */
227
+ type: "country" | "region" | "referrer" | "channel";
228
+ /** Currency code (ISO 4217) */
229
+ currency: string;
230
+ }): Promise<any> /** TODO screw this lol */;
231
+ interface RevenueSession extends Sessions.SessionWithHostnameCreatedate {
232
+ events: number;
233
+ }
234
+ /** Returns a paginated list of sessions with revenue data: https://docs.umami.is/docs/api/reports#get-apiwebsiteswebsiteidrevenuesessions */
235
+ function getRevenueSessions(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & GenericRequestParameters & {
236
+ /** Timezone (ex. America/Los_Angeles) */
237
+ timezone: string;
238
+ /** Currency code (ISO 4217) */
239
+ currency: string;
240
+ }): Promise<RevenueSession[]>;
190
241
  interface UTMProperty {
191
242
  utm: string;
192
243
  views: number;
@@ -199,7 +250,7 @@ export declare namespace Reports {
199
250
  utm_content: UTMProperty[];
200
251
  }
201
252
  /** Track your campaigns through UTM parameters: https://umami.is/docs/api/reports#post-apireportsutm */
202
- function postUTM(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & {
253
+ function postUTM(this: API, websiteId: Websites.Website["id"], parameters: DateTimestamps & {
203
254
  /** Can accept filter parameters */
204
255
  filters?: Filters;
205
256
  }): Promise<UTM>;
@@ -1,4 +1,4 @@
1
- /** Using reports throught [sic] the api: https://umami.is/docs/api/reports */
1
+ /** Using reports through the api: https://docs.umami.is/docs/api/reports */
2
2
  export var Reports;
3
3
  (function (Reports) {
4
4
  /** Get all reports by website ID: https://umami.is/docs/api/reports#get-apireports */
@@ -87,7 +87,7 @@ export var Reports;
87
87
  }, parameters.name);
88
88
  }
89
89
  Reports.postGoals = postGoals;
90
- /** Understand how users nagivate [sic] through your website: https://umami.is/docs/api/reports#post-apireportsjourney */
90
+ /** Understand how users navigate through your website: https://docs.umami.is/docs/api/reports#post-apireportsjourney */
91
91
  async function postJourney(websiteId, parameters) {
92
92
  return await postNonReports(this, "journey", websiteId, parameters.filters, {
93
93
  startDate: parameters.startDate,
@@ -117,6 +117,28 @@ export var Reports;
117
117
  });
118
118
  }
119
119
  Reports.postRevenue = postRevenue;
120
+ /** Returns revenue chart data for a given date range and currency: https://docs.umami.is/docs/api/reports#get-apiwebsiteswebsiteidrevenuechart */
121
+ async function getRevenueChart(websiteId, parameters) {
122
+ const response = await this.request("get", ["websites", websiteId, "revenue", "chart"], parameters);
123
+ return response.chart;
124
+ }
125
+ Reports.getRevenueChart = getRevenueChart;
126
+ /** Returns revenue statistics for a given date range with optional comparison period: https://docs.umami.is/docs/api/reports#get-apiwebsiteswebsiteidrevenuestats */
127
+ async function getRevenueStats(websiteId, parameters) {
128
+ return await this.request("get", ["websites", websiteId, "revenue", "stats"], parameters);
129
+ }
130
+ Reports.getRevenueStats = getRevenueStats;
131
+ /** Returns revenue broken down by a specified dimension: https://docs.umami.is/docs/api/reports#get-apiwebsiteswebsiteidrevenuemetrics */
132
+ async function getRevenueMetrics(websiteId, parameters) {
133
+ return await this.request("get", ["websites", websiteId, "revenue", "metrics"], parameters);
134
+ }
135
+ Reports.getRevenueMetrics = getRevenueMetrics;
136
+ /** Returns a paginated list of sessions with revenue data: https://docs.umami.is/docs/api/reports#get-apiwebsiteswebsiteidrevenuesessions */
137
+ async function getRevenueSessions(websiteId, parameters) {
138
+ const response = await this.request("get", ["websites", websiteId, "revenue", "sessions"], parameters);
139
+ return response.data;
140
+ }
141
+ Reports.getRevenueSessions = getRevenueSessions;
120
142
  /** Track your campaigns through UTM parameters: https://umami.is/docs/api/reports#post-apireportsutm */
121
143
  async function postUTM(websiteId, parameters) {
122
144
  return await postNonReports(this, "utm", websiteId, parameters.filters, {
@@ -120,4 +120,33 @@ export declare namespace Sessions {
120
120
  /** Can accept filter parameters */
121
121
  filters?: Filters;
122
122
  }): Promise<DataValues[]>;
123
+ interface DataPivot {
124
+ sessionId: Session["id"];
125
+ distinctId: string | null;
126
+ createdAt: Date;
127
+ propertyKeys: string[];
128
+ propertyValues: (string | number)[];
129
+ }
130
+ /** Gets session data in a pivoted format, with each row representing a session and its properties as parallel arrays: https://docs.umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-data-pivot */
131
+ function get_WEBSITEID_SessiondataPivot(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & Exclude<GenericRequestParameters, "search"> & {
132
+ /** Session property name to pivot on */
133
+ propertyName: string;
134
+ /** Can accept filter parameters */
135
+ filters?: Filters;
136
+ }): Promise<DataPivot[]>;
137
+ interface DataStats {
138
+ label: string;
139
+ activity: number;
140
+ sessions: number;
141
+ visits: number;
142
+ views: number;
143
+ events: number;
144
+ }
145
+ /** Gets aggregated activity statistics for sessions grouped by a given property value: https://docs.umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-datastats */
146
+ function get_WEBSITEID_SessiondataStats(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & {
147
+ /** Property name to group by */
148
+ propertyName: string;
149
+ /** Can accept filter parameters */
150
+ filters?: Filters;
151
+ }): Promise<DataStats[]>;
123
152
  }
@@ -57,4 +57,15 @@ export var Sessions;
57
57
  return await this.request("get", ["websites", websiteId, "session-data", "values"], parameters);
58
58
  }
59
59
  Sessions.get_WEBSITEID_SessiondataValues = get_WEBSITEID_SessiondataValues;
60
+ /** Gets session data in a pivoted format, with each row representing a session and its properties as parallel arrays: https://docs.umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-data-pivot */
61
+ async function get_WEBSITEID_SessiondataPivot(websiteId, parameters) {
62
+ const response = await this.request("get", ["websites", websiteId, "session-data-pivot"], parameters);
63
+ return response.data;
64
+ }
65
+ Sessions.get_WEBSITEID_SessiondataPivot = get_WEBSITEID_SessiondataPivot;
66
+ /** Gets aggregated activity statistics for sessions grouped by a given property value: https://docs.umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-datastats */
67
+ async function get_WEBSITEID_SessiondataStats(websiteId, parameters) {
68
+ return await this.request("get", ["websites", websiteId, "session-data", "stats"], parameters);
69
+ }
70
+ Sessions.get_WEBSITEID_SessiondataStats = get_WEBSITEID_SessiondataStats;
60
71
  })(Sessions || (Sessions = {}));
@@ -36,6 +36,13 @@ export declare namespace WebsiteStats {
36
36
  }
37
37
  /** Gets the number of active users on a website: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteidactive */
38
38
  function get_WEBSITEID_Active(this: API, websiteId: Websites.Website["id"]): Promise<Active>;
39
+ /** @remarks Don't confuse with {@link Timestamps}, where the word "At" is used over "Date"! */
40
+ interface DateRange {
41
+ startDate: Date;
42
+ endDate: Date;
43
+ }
44
+ /** Gets the date range of available data for a website: https://docs.umami.is/docs/api/website-stats#get-apiwebsiteswebsiteiddaterange */
45
+ function get_WEBSITEID_DateRange(this: API, websiteId: Websites.Website["id"]): Promise<DateRange>;
39
46
  /** Gets events within a given time range: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteideventsseries */
40
47
  function get_WEBSITEID_EventsSeries(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & Units & {
41
48
  /** Can accept filter parameters */
@@ -86,8 +93,8 @@ export declare namespace WebsiteStats {
86
93
  function get_WEBSITEID_Pageviews(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & Units & {
87
94
  /** Timezone (ex. America/Los_Angeles) */
88
95
  timezone: string;
89
- /** Comparison value `prev` | `yoy` */
90
- compare?: string;
96
+ /** Comparison period */
97
+ compare?: "prev" | "yoy";
91
98
  /** Can accept filter parameters */
92
99
  filters?: Filters;
93
100
  }): Promise<Pageviews>;
@@ -6,6 +6,11 @@ export var WebsiteStats;
6
6
  return await this.request("get", ["websites", websiteId, "active"]);
7
7
  }
8
8
  WebsiteStats.get_WEBSITEID_Active = get_WEBSITEID_Active;
9
+ /** Gets the date range of available data for a website: https://docs.umami.is/docs/api/website-stats#get-apiwebsiteswebsiteiddaterange */
10
+ async function get_WEBSITEID_DateRange(websiteId) {
11
+ return await this.request("get", ["websites", websiteId, "daterange"]);
12
+ }
13
+ WebsiteStats.get_WEBSITEID_DateRange = get_WEBSITEID_DateRange;
9
14
  /** Gets events within a given time range: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteideventsseries */
10
15
  async function get_WEBSITEID_EventsSeries(websiteId, parameters) {
11
16
  return await this.request("get", ["websites", websiteId, "events", "series"], parameters);
@@ -59,4 +59,18 @@ export declare namespace Websites {
59
59
  function delete_WEBSITEID(this: API, websiteId: Website["id"]): Promise<DeletionResult>;
60
60
  /** Resets a website by removing all data related to the website: https://umami.is/docs/api/websites#post-apiwebsiteswebsiteidreset */
61
61
  function post_WEBSITEID_Reset(this: API, websiteId: Website["id"]): Promise<DeletionResult>;
62
+ type Recorder = {
63
+ enabled: false;
64
+ } | {
65
+ enabled: true;
66
+ replayEnabled: boolean;
67
+ heatmapEnabled: boolean;
68
+ sampleRate: number;
69
+ heatmapSampleRate: number;
70
+ maskLevel: "strict" | "moderate";
71
+ maxDuration: number;
72
+ blockSelector: string;
73
+ };
74
+ /** Returns the recorder configuration for a website: https://docs.umami.is/docs/api/websites#get-apiwebsiteswebsiteidrecorder */
75
+ function getRecorder(this: API, websiteId: Website["id"]): Promise<Recorder>;
62
76
  }
@@ -32,4 +32,9 @@ export var Websites;
32
32
  return await this.request("post", ["websites", websiteId, "reset"]);
33
33
  }
34
34
  Websites.post_WEBSITEID_Reset = post_WEBSITEID_Reset;
35
+ /** Returns the recorder configuration for a website: https://docs.umami.is/docs/api/websites#get-apiwebsiteswebsiteidrecorder */
36
+ async function getRecorder(websiteId) {
37
+ return await this.request("get", ["websites", websiteId, "recorder"]);
38
+ }
39
+ Websites.getRecorder = getRecorder;
35
40
  })(Websites || (Websites = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "umami-api-js",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Package to easily access the Umami api!",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -31,11 +31,11 @@
31
31
  "license": "Unlicense",
32
32
  "devDependencies": {
33
33
  "@types/chai": "^5.2.3",
34
- "@types/node": "^25.6.0",
34
+ "@types/node": "^26.0.1",
35
35
  "ajv": "^8.20.0",
36
36
  "chai": "^6.2.2",
37
37
  "dotenv": "^17.4.2",
38
- "prettier": "3.8.3",
38
+ "prettier": "3.9.1",
39
39
  "ts-json-schema-generator": "^2.9.0",
40
40
  "typedoc": "^0.28.19",
41
41
  "typescript": "^6.0.3"