@appwrite.io/console 18.2.0 → 18.3.0-rc.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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@appwrite.io/console",
3
3
  "homepage": "https://appwrite.io/support",
4
4
  "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API",
5
- "version": "18.2.0",
5
+ "version": "18.3.0-rc.1",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "dist/cjs/sdk.js",
8
8
  "exports": {
@@ -0,0 +1,24 @@
1
+ export declare enum AnalyticsDimension {
2
+ Country = "country",
3
+ Region = "region",
4
+ City = "city",
5
+ Browser = "browser",
6
+ OperatingSystem = "operatingSystem",
7
+ Device = "device",
8
+ ScreenSize = "screenSize",
9
+ ReferrerSource = "referrerSource",
10
+ Channel = "channel",
11
+ UtmSource = "utmSource",
12
+ UtmMedium = "utmMedium",
13
+ UtmCampaign = "utmCampaign",
14
+ UtmContent = "utmContent",
15
+ UtmTerm = "utmTerm",
16
+ Page = "page",
17
+ Hostname = "hostname",
18
+ EntryPage = "entryPage",
19
+ ExitPage = "exitPage",
20
+ TrafficType = "trafficType",
21
+ BotName = "botName",
22
+ BotCategory = "botCategory",
23
+ EventName = "eventName"
24
+ }
@@ -0,0 +1,6 @@
1
+ export declare enum AnalyticsInterval {
2
+ OneHour = "1h",
3
+ OneDay = "1d",
4
+ OneWeek = "1w",
5
+ OneMonth = "1m"
6
+ }
@@ -121,5 +121,7 @@ export declare enum ProjectKeyScopes {
121
121
  AppsWrite = "apps.write",
122
122
  Oauth2Read = "oauth2.read",
123
123
  Oauth2Write = "oauth2.write",
124
- Oauth2Introspect = "oauth2.introspect"
124
+ Oauth2Introspect = "oauth2.introspect",
125
+ AnalyticsRead = "analytics.read",
126
+ AnalyticsWrite = "analytics.write"
125
127
  }
@@ -1,4 +1,5 @@
1
1
  export declare enum ProxyRuleDeploymentResourceType {
2
2
  Function = "function",
3
- Site = "site"
3
+ Site = "site",
4
+ DedicatedDatabase = "dedicatedDatabase"
4
5
  }
@@ -88,6 +88,7 @@ export declare enum QuerySuggestionResource {
88
88
  ResourceTokens = "resourcetokens",
89
89
  Transactions = "transactions",
90
90
  TransactionLogs = "transactionlogs",
91
+ AnalyticsProperties = "analyticsproperties",
91
92
  DedicatedDatabases = "dedicateddatabases",
92
93
  DedicatedDatabaseConfigs = "dedicateddatabaseconfigs",
93
94
  DedicatedDatabaseRuntimes = "dedicateddatabaseruntimes",
@@ -1,4 +1,7 @@
1
1
  export declare enum UsageEventMetric {
2
+ AnalyticsEvents = "analytics.events",
3
+ AnalyticsPageviews = "analytics.pageviews",
4
+ AnalyticsBotsEvents = "analytics.bots.events",
2
5
  NetworkRequests = "network.requests",
3
6
  NetworkInbound = "network.inbound",
4
7
  NetworkOutbound = "network.outbound",
@@ -1,4 +1,5 @@
1
1
  export declare enum UsageGaugeMetric {
2
+ AnalyticsProperties = "analytics.properties",
2
3
  Teams = "teams",
3
4
  Users = "users",
4
5
  Messages = "messages",
package/types/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export { Client, Query, AppwriteException } from './client';
11
11
  export { Account } from './services/account';
12
12
  export { Activities } from './services/activities';
13
13
  export { Affiliates } from './services/affiliates';
14
+ export { Analytics } from './services/analytics';
14
15
  export { Apps } from './services/apps';
15
16
  export { Avatars } from './services/avatars';
16
17
  export { Backups } from './services/backups';
@@ -52,9 +53,11 @@ export { Waf } from './services/waf';
52
53
  export { Webhooks } from './services/webhooks';
53
54
  export { Realtime } from './services/realtime';
54
55
  export { Push } from './services/push';
56
+ export { AnalyticsTracking } from './services/analytics-tracking';
55
57
  export type { Models, Payload, RealtimeResponseEvent, UploadProgress, } from './client';
56
58
  export type { RealtimeSubscription } from './services/realtime';
57
59
  export type { PushMessage, PushSubscription, SubscribeOptions, MessageCallback, } from './services/push';
60
+ export type { AnalyticsEventEmitter, AnalyticsEventOptions, AnalyticsTrackingOptions, DownloadTrackingOptions, OutboundTrackingOptions, } from './services/analytics-tracking';
58
61
  export type { QueryTypes, QueryTypesList } from './query';
59
62
  export { Permission } from './permission';
60
63
  export { Role } from './role';
@@ -67,6 +70,8 @@ export { AuthenticatorType } from './enums/authenticator-type';
67
70
  export { AuthenticationFactor } from './enums/authentication-factor';
68
71
  export { IdTokenProvider } from './enums/id-token-provider';
69
72
  export { OAuthProvider } from './enums/o-auth-provider';
73
+ export { AnalyticsInterval } from './enums/analytics-interval';
74
+ export { AnalyticsDimension } from './enums/analytics-dimension';
70
75
  export { Browser } from './enums/browser';
71
76
  export { CreditCard } from './enums/credit-card';
72
77
  export { Flag } from './enums/flag';
package/types/models.d.ts CHANGED
@@ -7448,7 +7448,7 @@ export declare namespace Models {
7448
7448
  */
7449
7449
  deploymentId: string;
7450
7450
  /**
7451
- * Type of deployment. Possible values are "function", "site". Used if rule's type is "deployment".
7451
+ * Type of deployment resource: function, site, or dedicatedDatabase.
7452
7452
  */
7453
7453
  deploymentResourceType?: ProxyRuleDeploymentResourceType;
7454
7454
  /**
@@ -8904,6 +8904,117 @@ export declare namespace Models {
8904
8904
  */
8905
8905
  resources: UsageResources[];
8906
8906
  };
8907
+ /**
8908
+ * AnalyticsMetric
8909
+ */
8910
+ export type AnalyticsMetric = {
8911
+ /**
8912
+ * Dimension value this row covers. Null when no dimension was requested, empty when the dimension could not be derived for those events.
8913
+ */
8914
+ value?: string;
8915
+ /**
8916
+ * Start of the time bucket this row covers, in ISO 8601. Null when no interval was requested.
8917
+ */
8918
+ date?: string;
8919
+ /**
8920
+ * Unique visitors in the requested range.
8921
+ */
8922
+ visitors: number;
8923
+ /**
8924
+ * Unique sessions in the requested range.
8925
+ */
8926
+ sessions: number;
8927
+ /**
8928
+ * Total pageview events (events with name="pageview") in the requested range. Only the flat aggregate computes it; null on breakdown and time-series rows.
8929
+ */
8930
+ pageviews?: number;
8931
+ /**
8932
+ * Total events in the requested range.
8933
+ */
8934
+ events: number;
8935
+ /**
8936
+ * Total sessions with activity in the requested range. Only the flat aggregate computes it; null on breakdown and time-series rows.
8937
+ */
8938
+ visits?: number;
8939
+ /**
8940
+ * Share of single-event sessions, as a percentage. Only the flat aggregate computes it; null on breakdown and time-series rows.
8941
+ */
8942
+ bounceRate?: number;
8943
+ /**
8944
+ * Average session length in seconds, measured first event to last event. Single-event sessions count as 0. Only the flat aggregate computes it; null on breakdown and time-series rows.
8945
+ */
8946
+ visitDuration?: number;
8947
+ /**
8948
+ * Average pageviews per session (pageviews divided by visits). Only the flat aggregate computes it; null on breakdown and time-series rows.
8949
+ */
8950
+ viewsPerVisit?: number;
8951
+ /**
8952
+ * Average scroll depth across events, as a percentage. Only the flat aggregate computes it; null on breakdown and time-series rows.
8953
+ */
8954
+ scrollDepth?: number;
8955
+ /**
8956
+ * Average engaged time per session in seconds, counting only foreground time. Sessions that reported no engagement are excluded. Only the flat aggregate computes it; null on breakdown and time-series rows.
8957
+ */
8958
+ engagementTime?: number;
8959
+ };
8960
+ /**
8961
+ * AnalyticsMetricList
8962
+ */
8963
+ export type AnalyticsMetricList = {
8964
+ /**
8965
+ * Total number of metric rows returned.
8966
+ */
8967
+ total: number;
8968
+ /**
8969
+ * Metric rows: one per time bucket, one per dimension value, or a single row for the flat aggregate.
8970
+ */
8971
+ metrics: AnalyticsMetric[];
8972
+ };
8973
+ /**
8974
+ * AnalyticsProperty
8975
+ */
8976
+ export type AnalyticsProperty = {
8977
+ /**
8978
+ * Analytics property ID.
8979
+ */
8980
+ $id: string;
8981
+ /**
8982
+ * Property creation date in ISO 8601 format.
8983
+ */
8984
+ $createdAt: string;
8985
+ /**
8986
+ * Property update date in ISO 8601 format.
8987
+ */
8988
+ $updatedAt: string;
8989
+ /**
8990
+ * Human-readable name of the tracked website or application.
8991
+ */
8992
+ name: string;
8993
+ /**
8994
+ * Primary domain being tracked (e.g. example.com). May be empty for native apps.
8995
+ */
8996
+ domain: string;
8997
+ /**
8998
+ * IANA timezone used to define the daily boundary for stats.
8999
+ */
9000
+ timezone: string;
9001
+ /**
9002
+ * Whether tracking is currently active.
9003
+ */
9004
+ enabled: boolean;
9005
+ /**
9006
+ * Whether stats for this property are publicly viewable.
9007
+ */
9008
+ public: boolean;
9009
+ /**
9010
+ * List of origins allowed to send tracking events. Use ["*"] to allow all.
9011
+ */
9012
+ allowedOrigins: string[];
9013
+ /**
9014
+ * Unique identifier for the tracking script snippet.
9015
+ */
9016
+ snippetId: string;
9017
+ };
8907
9018
  /**
8908
9019
  * Team
8909
9020
  */
@@ -9054,17 +9165,17 @@ export declare namespace Models {
9054
9165
  */
9055
9166
  policyId: string;
9056
9167
  /**
9057
- * Archive size in bytes.
9168
+ * Archive size in bytes. Null until the size is known.
9058
9169
  */
9059
- size: number;
9170
+ size?: number;
9060
9171
  /**
9061
9172
  * The status of the archive creation. Possible values: pending, processing, uploading, completed, failed, skipped.
9062
9173
  */
9063
9174
  status: string;
9064
9175
  /**
9065
- * The backup start time.
9176
+ * The backup start time. Null until the backup starts.
9066
9177
  */
9067
- startedAt: string;
9178
+ startedAt?: string;
9068
9179
  /**
9069
9180
  * Migration ID.
9070
9181
  */
@@ -9436,9 +9547,9 @@ export declare namespace Models {
9436
9547
  */
9437
9548
  alertLimit: number;
9438
9549
  /**
9439
- * Additional resources
9550
+ * Additional resources. Null when the plan does not support usage billing.
9440
9551
  */
9441
- usage: UsageBillingPlan;
9552
+ usage?: UsageBillingPlan;
9442
9553
  /**
9443
9554
  * Addons
9444
9555
  */
@@ -10391,9 +10502,9 @@ export declare namespace Models {
10391
10502
  */
10392
10503
  uptime: number;
10393
10504
  /**
10394
- * Connection statistics.
10505
+ * Connection statistics. Null when the database has not been probed.
10395
10506
  */
10396
- connections: DatabaseStatusConnections;
10507
+ connections?: DatabaseStatusConnections;
10397
10508
  /**
10398
10509
  * Requested replication sync mode. Possible values: async, sync, quorum. Compare with effectiveSyncMode for what the primary is enforcing.
10399
10510
  */
@@ -11792,9 +11903,9 @@ export declare namespace Models {
11792
11903
  */
11793
11904
  status: string;
11794
11905
  /**
11795
- * The backup start time.
11906
+ * The restoration start time. Null until the restoration starts.
11796
11907
  */
11797
- startedAt: string;
11908
+ startedAt?: string;
11798
11909
  /**
11799
11910
  * Migration ID.
11800
11911
  */
@@ -11808,9 +11919,9 @@ export declare namespace Models {
11808
11919
  */
11809
11920
  resources: string[];
11810
11921
  /**
11811
- * Optional data in key-value object.
11922
+ * Restoration options as a key-value object.
11812
11923
  */
11813
- options: string;
11924
+ options: object;
11814
11925
  };
11815
11926
  /**
11816
11927
  * Dedicated database restorations list
@@ -12121,6 +12232,10 @@ export declare namespace Models {
12121
12232
  * Aggregated stats for total backups storage.
12122
12233
  */
12123
12234
  backupsStorageTotal: number;
12235
+ /**
12236
+ * Aggregated stats for total custom user photos storage.
12237
+ */
12238
+ avatarsStorageTotal: number;
12124
12239
  /**
12125
12240
  * Aggregated stats for total storage.
12126
12241
  */
@@ -13362,6 +13477,19 @@ export declare namespace Models {
13362
13477
  */
13363
13478
  addons: Addon[];
13364
13479
  };
13480
+ /**
13481
+ * Analytics properties list
13482
+ */
13483
+ export type AnalyticsPropertyList = {
13484
+ /**
13485
+ * Total number of properties that matched your query.
13486
+ */
13487
+ total: number;
13488
+ /**
13489
+ * List of properties.
13490
+ */
13491
+ properties: AnalyticsProperty[];
13492
+ };
13365
13493
  /**
13366
13494
  * Aggregation team list
13367
13495
  */
@@ -0,0 +1,211 @@
1
+ /**
2
+ * Analytics auto-tracking helpers.
3
+ *
4
+ * These are hand-written companions to the generated `Analytics` service.
5
+ * The generated service exposes `createEvent(params)` for arbitrary events;
6
+ * this module wires up common auto-tracking behaviours (pageviews, outbound
7
+ * links, downloads, scroll depth, active engagement) on top of it.
8
+ *
9
+ * The tracking helpers accept a plain event-emitter function so they do not
10
+ * hard-couple to the generated `Analytics` class. The emitter adapts this
11
+ * module's option shape to `createEvent`: `url` is required there, and `props`
12
+ * is a flat alternating key/value list rather than an object.
13
+ *
14
+ * ```ts
15
+ * const analytics = new Analytics(client);
16
+ * const tracking = new AnalyticsTracking(
17
+ * (name, options) => analytics.createEvent({
18
+ * propertyId: options?.propertyId ?? '<PROPERTY_ID>',
19
+ * name,
20
+ * url: options?.url ?? window.location.href,
21
+ * referrer: options?.referrer,
22
+ * scrollDepth: options?.scrollDepth,
23
+ * engagementTime: options?.engagementTime,
24
+ * props: Object.entries(options?.props ?? {}).flatMap(
25
+ * ([key, value]) => [key, String(value)],
26
+ * ),
27
+ * }),
28
+ * { propertyId: '<PROPERTY_ID>' }
29
+ * );
30
+ * tracking.enableAllAutoTracking();
31
+ * ```
32
+ *
33
+ * `propertyId` is optional: when set it is merged into the options of every
34
+ * emitted event, so an emitter that forwards `options.propertyId` (as above)
35
+ * picks it up instead of every caller hand-rolling it into the closure.
36
+ * Per-event `propertyId` always wins over the configured default.
37
+ *
38
+ * All helpers respect `navigator.doNotTrack === '1'` by default; opt out with
39
+ * `respectDoNotTrack: false` in the constructor options.
40
+ *
41
+ * Engagement time follows Plausible's model: rather than one total at unload,
42
+ * a delta is emitted at every natural checkpoint of the visit (tab hidden, SPA
43
+ * route change, unload). See `enableAutoEngagementTime` for details.
44
+ *
45
+ * Auto-emitted event names follow `snake_case` + lowercase (`pageview`,
46
+ * `outbound_link`, `file_download`, `screen_view`, etc.). Any prop keys use
47
+ * camelCase to match the endpoint's parameter naming. Callers can pass any
48
+ * custom event name; the auto-track methods only own the events they emit
49
+ * themselves.
50
+ */
51
+ export type AnalyticsEventOptions = {
52
+ props?: Record<string, unknown>;
53
+ url?: string;
54
+ referrer?: string;
55
+ propertyId?: string;
56
+ scrollDepth?: number;
57
+ engagementTime?: number;
58
+ };
59
+ export type AnalyticsEventEmitter = (name: string, options?: AnalyticsEventOptions) => unknown;
60
+ export type AnalyticsTrackingOptions = {
61
+ /**
62
+ * When true (default) the tracker becomes a no-op if `navigator.doNotTrack`
63
+ * is set to `'1'`. Set to false to always fire regardless of the DNT signal.
64
+ */
65
+ respectDoNotTrack?: boolean;
66
+ /**
67
+ * Analytics property (or snippet) ID to attach to every emitted event.
68
+ * Optional — omit it when the emitter closure already supplies one. A
69
+ * `propertyId` passed on an individual event takes precedence.
70
+ */
71
+ propertyId?: string;
72
+ };
73
+ export type OutboundTrackingOptions = {
74
+ /**
75
+ * When true, links pointing at the current host's subdomains are treated
76
+ * as outbound. Defaults to false (subdomains are same-origin for tracking).
77
+ */
78
+ includeSubdomains?: boolean;
79
+ };
80
+ export type DownloadTrackingOptions = {
81
+ /**
82
+ * File extensions (without the leading dot) that mark an anchor as a
83
+ * download. Defaults cover the common set.
84
+ */
85
+ extensions?: string[];
86
+ };
87
+ export declare class AnalyticsTracking {
88
+ private readonly emit;
89
+ private readonly respectDoNotTrack;
90
+ private readonly propertyId?;
91
+ private pageviewCleanups;
92
+ private outboundCleanup?;
93
+ private downloadCleanup?;
94
+ private scrollCleanups;
95
+ private engagementCleanups;
96
+ private currentPath?;
97
+ private maxScrollDepth;
98
+ private scrollTicking;
99
+ private lastScrollReport;
100
+ private engagementStart;
101
+ private engagementAccumulatedMs;
102
+ private engagementActive;
103
+ constructor(emit: AnalyticsEventEmitter, options?: AnalyticsTrackingOptions);
104
+ /**
105
+ * Enable the opinionated default auto-tracking set: pageviews, outbound
106
+ * links, scroll depth and active engagement time. Downloads must be opted
107
+ * into separately via `enableAutoDownloadTracking()` because the extension
108
+ * list is application-specific.
109
+ */
110
+ enableAllAutoTracking(): void;
111
+ /**
112
+ * Track an event manually. Respects the DNT setting and swallows emitter
113
+ * exceptions so tracking failures never surface to the host page.
114
+ */
115
+ track(name: string, options?: AnalyticsEventOptions): void;
116
+ /**
117
+ * Convenience wrapper for pageview-shaped events.
118
+ */
119
+ pageview(url?: string, referrer?: string): void;
120
+ /**
121
+ * Enable SPA-aware pageview tracking. Fires an initial pageview on
122
+ * enable, then again on every `pushState`, `replaceState`, `popstate`
123
+ * or hashchange. Idempotent — repeat calls no-op.
124
+ */
125
+ enableAutoPageviews(): void;
126
+ /**
127
+ * Disable auto-pageview tracking installed by `enableAutoPageviews`.
128
+ * Safe to call when auto-pageviews were never enabled.
129
+ */
130
+ disableAutoPageviews(): void;
131
+ /**
132
+ * Enable click-based outbound link tracking. Detects anchor clicks that
133
+ * navigate to a different origin and fires an `outbound_link` event
134
+ * (with `hostname` and `href` props) before the browser navigates.
135
+ */
136
+ enableAutoOutboundTracking(options?: OutboundTrackingOptions): void;
137
+ /**
138
+ * Disable outbound-link tracking installed by `enableAutoOutboundTracking`.
139
+ * Safe to call when auto-outbound was never enabled.
140
+ */
141
+ disableAutoOutboundTracking(): void;
142
+ /**
143
+ * Enable click-based download tracking. Detects anchor clicks that point
144
+ * at a file whose extension appears in the configured list and fires a
145
+ * `file_download` event with `filename`, `extension` and `href` props.
146
+ */
147
+ enableAutoDownloadTracking(options?: DownloadTrackingOptions): void;
148
+ /**
149
+ * Disable file-download tracking installed by `enableAutoDownloadTracking`.
150
+ * Safe to call when auto-download was never enabled.
151
+ */
152
+ disableAutoDownloadTracking(): void;
153
+ /**
154
+ * Enable passive scroll-depth tracking. Records the maximum percent of the
155
+ * document scrolled and reports it on `beforeunload` and on SPA route
156
+ * changes. Uses a throttled passive listener so it is safe on hot paths.
157
+ */
158
+ enableAutoScrollDepth(): void;
159
+ /**
160
+ * Disable scroll-depth tracking installed by `enableAutoScrollDepth`. Safe
161
+ * to call when auto-scroll-depth was never enabled. Any accumulated depth
162
+ * for the current page is dropped.
163
+ */
164
+ disableAutoScrollDepth(): void;
165
+ /**
166
+ * Enable active engagement-time tracking. Counts time the tab is visible
167
+ * and uses `visibilitychange` to exclude background time.
168
+ *
169
+ * Delivery follows Plausible's model rather than a single total at the
170
+ * end of the visit: an `engagement_time` event is emitted at every natural
171
+ * checkpoint — the tab going hidden, an SPA route change, and finally
172
+ * `beforeunload`/`pagehide`. Unload is kept only as a best-effort last
173
+ * flush; it is the least reliable moment to send anything (browsers
174
+ * routinely cancel in-flight requests there, and `sendBeacon` cannot set
175
+ * the `X-Appwrite-Project` header the endpoint requires), so it must never
176
+ * be the only delivery.
177
+ *
178
+ * Each event carries a **delta** — the seconds accrued since the previous
179
+ * flush, not a running total — so the values are additive per session and
180
+ * a lost event costs only its own slice.
181
+ *
182
+ * There is deliberately no periodic ping. The cadence is driven by
183
+ * navigation and tab switches, so request volume tracks what the visitor
184
+ * actually does instead of multiplying with time on page.
185
+ */
186
+ enableAutoEngagementTime(): void;
187
+ /**
188
+ * Disable engagement-time tracking installed by `enableAutoEngagementTime`.
189
+ * Safe to call when auto-engagement was never enabled. Any accumulated
190
+ * engagement time is dropped without being emitted.
191
+ */
192
+ disableAutoEngagementTime(): void;
193
+ /**
194
+ * Merge the configured `propertyId` into an event's options. Returns the
195
+ * caller's object untouched when no default is configured (or the event
196
+ * already carries one), so emitters written against the pre-`propertyId`
197
+ * shape keep receiving exactly what they received before.
198
+ */
199
+ private withPropertyId;
200
+ private canTrack;
201
+ private currentPageUrl;
202
+ private findAnchor;
203
+ private parseUrl;
204
+ private isExternal;
205
+ private rootDomain;
206
+ private computeScrollDepth;
207
+ private flushScrollDepth;
208
+ private startEngagement;
209
+ private pauseEngagement;
210
+ private flushEngagement;
211
+ }