@appwrite.io/console 18.3.0 → 18.4.0-rc.2
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 +2 -2
- package/dist/cjs/sdk.js +3141 -384
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +3138 -385
- package/dist/esm/sdk.js.map +1 -1
- package/dist/iife/sdk.js +3141 -384
- package/package.json +1 -1
- package/types/enums/analytics-dimension.d.ts +24 -0
- package/types/enums/analytics-interval.d.ts +6 -0
- package/types/enums/platform-resource-type.d.ts +11 -0
- package/types/enums/project-auth-method-id.d.ts +2 -1
- package/types/enums/project-key-scopes.d.ts +5 -1
- package/types/enums/project-policy-id.d.ts +2 -1
- package/types/enums/project-resource-type.d.ts +13 -0
- package/types/enums/proxy-rule-deployment-resource-type.d.ts +2 -1
- package/types/enums/query-suggestion-resource.d.ts +8 -0
- package/types/enums/usage-event-metric.d.ts +3 -0
- package/types/enums/usage-gauge-metric.d.ts +1 -0
- package/types/enums/video-output.d.ts +5 -0
- package/types/enums/video-rendition-status.d.ts +9 -0
- package/types/index.d.ts +11 -0
- package/types/models.d.ts +595 -55
- package/types/services/account.d.ts +158 -0
- package/types/services/admin.d.ts +80 -0
- package/types/services/analytics-tracking.d.ts +211 -0
- package/types/services/analytics.d.ts +254 -0
- package/types/services/project.d.ts +40 -12
- package/types/services/push.d.ts +2 -2
- package/types/services/teams.d.ts +4 -1
- package/types/services/users.d.ts +69 -0
- package/types/services/videos.d.ts +860 -0
- package/types/service.d.ts +0 -11
|
@@ -846,6 +846,135 @@ export declare class Account {
|
|
|
846
846
|
* @deprecated Use the object parameter style method for a better developer experience.
|
|
847
847
|
*/
|
|
848
848
|
updateName<Preferences extends Models.Preferences = Models.DefaultPreferences>(name: string): Promise<Models.User<Preferences>>;
|
|
849
|
+
/**
|
|
850
|
+
* Get the list of verified passkeys registered by the currently logged in user.
|
|
851
|
+
*
|
|
852
|
+
* @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter and order on the following attributes: $id, $createdAt, $updatedAt
|
|
853
|
+
* @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated.
|
|
854
|
+
* @throws {AppwriteException}
|
|
855
|
+
* @returns {Promise<Models.PasskeyList>}
|
|
856
|
+
*/
|
|
857
|
+
listPasskeys(params?: {
|
|
858
|
+
queries?: string[];
|
|
859
|
+
total?: boolean;
|
|
860
|
+
}): Promise<Models.PasskeyList>;
|
|
861
|
+
/**
|
|
862
|
+
* Get the list of verified passkeys registered by the currently logged in user.
|
|
863
|
+
*
|
|
864
|
+
* @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter and order on the following attributes: $id, $createdAt, $updatedAt
|
|
865
|
+
* @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated.
|
|
866
|
+
* @throws {AppwriteException}
|
|
867
|
+
* @returns {Promise<Models.PasskeyList>}
|
|
868
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
869
|
+
*/
|
|
870
|
+
listPasskeys(queries?: string[], total?: boolean): Promise<Models.PasskeyList>;
|
|
871
|
+
/**
|
|
872
|
+
* Start registering a passkey for the currently logged in user. The session must have signed in or completed an MFA challenge within the last 10 minutes. Pass the returned `publicKey` options to `navigator.credentials.create()`, then complete the registration with [Update passkey verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). The passkey stays pending until verified, and the challenge expires after 5 minutes.
|
|
873
|
+
*
|
|
874
|
+
* @param {string} params.passkeyId - Passkey ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
875
|
+
* @param {string} params.name - Passkey name, shown when listing passkeys. Max length: 128 chars.
|
|
876
|
+
* @throws {AppwriteException}
|
|
877
|
+
* @returns {Promise<Models.PasskeyChallenge>}
|
|
878
|
+
*/
|
|
879
|
+
createPasskey(params?: {
|
|
880
|
+
passkeyId?: string;
|
|
881
|
+
name?: string;
|
|
882
|
+
}): Promise<Models.PasskeyChallenge>;
|
|
883
|
+
/**
|
|
884
|
+
* Start registering a passkey for the currently logged in user. The session must have signed in or completed an MFA challenge within the last 10 minutes. Pass the returned `publicKey` options to `navigator.credentials.create()`, then complete the registration with [Update passkey verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). The passkey stays pending until verified, and the challenge expires after 5 minutes.
|
|
885
|
+
*
|
|
886
|
+
* @param {string} passkeyId - Passkey ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
887
|
+
* @param {string} name - Passkey name, shown when listing passkeys. Max length: 128 chars.
|
|
888
|
+
* @throws {AppwriteException}
|
|
889
|
+
* @returns {Promise<Models.PasskeyChallenge>}
|
|
890
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
891
|
+
*/
|
|
892
|
+
createPasskey(passkeyId?: string, name?: string): Promise<Models.PasskeyChallenge>;
|
|
893
|
+
/**
|
|
894
|
+
* Get a verified passkey of the currently logged in user by its unique ID.
|
|
895
|
+
*
|
|
896
|
+
* @param {string} params.passkeyId - Passkey ID.
|
|
897
|
+
* @throws {AppwriteException}
|
|
898
|
+
* @returns {Promise<Models.Passkey>}
|
|
899
|
+
*/
|
|
900
|
+
getPasskey(params: {
|
|
901
|
+
passkeyId: string;
|
|
902
|
+
}): Promise<Models.Passkey>;
|
|
903
|
+
/**
|
|
904
|
+
* Get a verified passkey of the currently logged in user by its unique ID.
|
|
905
|
+
*
|
|
906
|
+
* @param {string} passkeyId - Passkey ID.
|
|
907
|
+
* @throws {AppwriteException}
|
|
908
|
+
* @returns {Promise<Models.Passkey>}
|
|
909
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
910
|
+
*/
|
|
911
|
+
getPasskey(passkeyId: string): Promise<Models.Passkey>;
|
|
912
|
+
/**
|
|
913
|
+
* Rename a passkey of the currently logged in user.
|
|
914
|
+
*
|
|
915
|
+
* @param {string} params.passkeyId - Passkey ID.
|
|
916
|
+
* @param {string} params.name - Passkey name. Max length: 128 chars.
|
|
917
|
+
* @throws {AppwriteException}
|
|
918
|
+
* @returns {Promise<Models.Passkey>}
|
|
919
|
+
*/
|
|
920
|
+
updatePasskey(params: {
|
|
921
|
+
passkeyId: string;
|
|
922
|
+
name: string;
|
|
923
|
+
}): Promise<Models.Passkey>;
|
|
924
|
+
/**
|
|
925
|
+
* Rename a passkey of the currently logged in user.
|
|
926
|
+
*
|
|
927
|
+
* @param {string} passkeyId - Passkey ID.
|
|
928
|
+
* @param {string} name - Passkey name. Max length: 128 chars.
|
|
929
|
+
* @throws {AppwriteException}
|
|
930
|
+
* @returns {Promise<Models.Passkey>}
|
|
931
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
932
|
+
*/
|
|
933
|
+
updatePasskey(passkeyId: string, name: string): Promise<Models.Passkey>;
|
|
934
|
+
/**
|
|
935
|
+
* Delete a passkey from the currently logged in user. The passkey can no longer be used to sign in, although it may remain stored on the user's device. The session must have signed in or completed an MFA challenge within the last 10 minutes.
|
|
936
|
+
*
|
|
937
|
+
* @param {string} params.passkeyId - Passkey ID.
|
|
938
|
+
* @throws {AppwriteException}
|
|
939
|
+
* @returns {Promise<{}>}
|
|
940
|
+
*/
|
|
941
|
+
deletePasskey(params: {
|
|
942
|
+
passkeyId: string;
|
|
943
|
+
}): Promise<{}>;
|
|
944
|
+
/**
|
|
945
|
+
* Delete a passkey from the currently logged in user. The passkey can no longer be used to sign in, although it may remain stored on the user's device. The session must have signed in or completed an MFA challenge within the last 10 minutes.
|
|
946
|
+
*
|
|
947
|
+
* @param {string} passkeyId - Passkey ID.
|
|
948
|
+
* @throws {AppwriteException}
|
|
949
|
+
* @returns {Promise<{}>}
|
|
950
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
951
|
+
*/
|
|
952
|
+
deletePasskey(passkeyId: string): Promise<{}>;
|
|
953
|
+
/**
|
|
954
|
+
* Complete a passkey registration started with [Create passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.create()`, for example `credential.toJSON()`. Each challenge can only be used once.
|
|
955
|
+
*
|
|
956
|
+
* @param {string} params.passkeyId - Passkey ID.
|
|
957
|
+
* @param {string} params.challengeId - Challenge ID returned when the passkey was created.
|
|
958
|
+
* @param {object} params.credential - Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`.
|
|
959
|
+
* @throws {AppwriteException}
|
|
960
|
+
* @returns {Promise<Models.Passkey>}
|
|
961
|
+
*/
|
|
962
|
+
updatePasskeyVerification(params: {
|
|
963
|
+
passkeyId: string;
|
|
964
|
+
challengeId: string;
|
|
965
|
+
credential: object;
|
|
966
|
+
}): Promise<Models.Passkey>;
|
|
967
|
+
/**
|
|
968
|
+
* Complete a passkey registration started with [Create passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.create()`, for example `credential.toJSON()`. Each challenge can only be used once.
|
|
969
|
+
*
|
|
970
|
+
* @param {string} passkeyId - Passkey ID.
|
|
971
|
+
* @param {string} challengeId - Challenge ID returned when the passkey was created.
|
|
972
|
+
* @param {object} credential - Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`.
|
|
973
|
+
* @throws {AppwriteException}
|
|
974
|
+
* @returns {Promise<Models.Passkey>}
|
|
975
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
976
|
+
*/
|
|
977
|
+
updatePasskeyVerification(passkeyId: string, challengeId: string, credential: object): Promise<Models.Passkey>;
|
|
849
978
|
/**
|
|
850
979
|
* Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional.
|
|
851
980
|
*
|
|
@@ -1632,6 +1761,35 @@ export declare class Account {
|
|
|
1632
1761
|
* @deprecated Use the object parameter style method for a better developer experience.
|
|
1633
1762
|
*/
|
|
1634
1763
|
createOAuth2Token(provider: OAuthProvider, success?: string, failure?: string, scopes?: string[]): void | string;
|
|
1764
|
+
/**
|
|
1765
|
+
* Start signing in with a passkey. No email or user ID is needed: pass the returned `publicKey` options to `navigator.credentials.get()` and the user picks one of their passkeys. Then call [Update passkey token](/docs/references/cloud/client-web/account#updatePasskeyToken) with the credential to receive a token, and exchange it with [Create session](/docs/references/cloud/client-web/account#createSession). The challenge expires after 5 minutes.
|
|
1766
|
+
*
|
|
1767
|
+
* @throws {AppwriteException}
|
|
1768
|
+
* @returns {Promise<Models.PasskeyChallenge>}
|
|
1769
|
+
*/
|
|
1770
|
+
createPasskeyToken(): Promise<Models.PasskeyChallenge>;
|
|
1771
|
+
/**
|
|
1772
|
+
* Complete a passkey sign-in started with [Create passkey token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.get()`, for example `credential.toJSON()`. The returned token includes its secret and expires after 1 minute: exchange it for a session with [Create session](/docs/references/cloud/client-web/account#createSession). Passkeys require user verification, so the session also satisfies MFA. Each challenge can only be used once.
|
|
1773
|
+
*
|
|
1774
|
+
* @param {string} params.challengeId - Challenge ID returned by createPasskeyToken.
|
|
1775
|
+
* @param {object} params.credential - Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`.
|
|
1776
|
+
* @throws {AppwriteException}
|
|
1777
|
+
* @returns {Promise<Models.Token>}
|
|
1778
|
+
*/
|
|
1779
|
+
updatePasskeyToken(params: {
|
|
1780
|
+
challengeId: string;
|
|
1781
|
+
credential: object;
|
|
1782
|
+
}): Promise<Models.Token>;
|
|
1783
|
+
/**
|
|
1784
|
+
* Complete a passkey sign-in started with [Create passkey token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.get()`, for example `credential.toJSON()`. The returned token includes its secret and expires after 1 minute: exchange it for a session with [Create session](/docs/references/cloud/client-web/account#createSession). Passkeys require user verification, so the session also satisfies MFA. Each challenge can only be used once.
|
|
1785
|
+
*
|
|
1786
|
+
* @param {string} challengeId - Challenge ID returned by createPasskeyToken.
|
|
1787
|
+
* @param {object} credential - Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`.
|
|
1788
|
+
* @throws {AppwriteException}
|
|
1789
|
+
* @returns {Promise<Models.Token>}
|
|
1790
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
1791
|
+
*/
|
|
1792
|
+
updatePasskeyToken(challengeId: string, credential: object): Promise<Models.Token>;
|
|
1635
1793
|
/**
|
|
1636
1794
|
* Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes.
|
|
1637
1795
|
*
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Client } from '../client';
|
|
2
|
+
import { PlatformResourceType } from '../enums/platform-resource-type';
|
|
3
|
+
import { ProjectResourceType } from '../enums/project-resource-type';
|
|
4
|
+
export declare class Admin {
|
|
5
|
+
client: Client;
|
|
6
|
+
constructor(client: Client);
|
|
7
|
+
/**
|
|
8
|
+
* Delete everything cached from the platform database in the region serving the request.
|
|
9
|
+
*
|
|
10
|
+
* @throws {AppwriteException}
|
|
11
|
+
* @returns {Promise<{}>}
|
|
12
|
+
*/
|
|
13
|
+
deletePlatformCache(): Promise<{}>;
|
|
14
|
+
/**
|
|
15
|
+
* Delete the cache of one platform resource, or of every resource of a type, in the region serving the request.
|
|
16
|
+
*
|
|
17
|
+
* @param {PlatformResourceType} params.resourceType - Resource type.
|
|
18
|
+
* @param {string} params.resourceId - Resource ID. Leave empty to delete the cache of every resource of this type.
|
|
19
|
+
* @throws {AppwriteException}
|
|
20
|
+
* @returns {Promise<{}>}
|
|
21
|
+
*/
|
|
22
|
+
deletePlatformResourceCache(params: {
|
|
23
|
+
resourceType: PlatformResourceType;
|
|
24
|
+
resourceId?: string;
|
|
25
|
+
}): Promise<{}>;
|
|
26
|
+
/**
|
|
27
|
+
* Delete the cache of one platform resource, or of every resource of a type, in the region serving the request.
|
|
28
|
+
*
|
|
29
|
+
* @param {PlatformResourceType} resourceType - Resource type.
|
|
30
|
+
* @param {string} resourceId - Resource ID. Leave empty to delete the cache of every resource of this type.
|
|
31
|
+
* @throws {AppwriteException}
|
|
32
|
+
* @returns {Promise<{}>}
|
|
33
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
34
|
+
*/
|
|
35
|
+
deletePlatformResourceCache(resourceType: PlatformResourceType, resourceId?: string): Promise<{}>;
|
|
36
|
+
/**
|
|
37
|
+
* Delete everything cached for a project. Send the request to the project's region.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} params.projectId - Project ID.
|
|
40
|
+
* @throws {AppwriteException}
|
|
41
|
+
* @returns {Promise<{}>}
|
|
42
|
+
*/
|
|
43
|
+
deleteProjectCache(params: {
|
|
44
|
+
projectId: string;
|
|
45
|
+
}): Promise<{}>;
|
|
46
|
+
/**
|
|
47
|
+
* Delete everything cached for a project. Send the request to the project's region.
|
|
48
|
+
*
|
|
49
|
+
* @param {string} projectId - Project ID.
|
|
50
|
+
* @throws {AppwriteException}
|
|
51
|
+
* @returns {Promise<{}>}
|
|
52
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
53
|
+
*/
|
|
54
|
+
deleteProjectCache(projectId: string): Promise<{}>;
|
|
55
|
+
/**
|
|
56
|
+
* Delete the cache of one project resource, or of every resource of a type. Send the request to the project's region.
|
|
57
|
+
*
|
|
58
|
+
* @param {string} params.projectId - Project ID.
|
|
59
|
+
* @param {ProjectResourceType} params.resourceType - Resource type.
|
|
60
|
+
* @param {string} params.resourceId - Resource ID. Leave empty to delete the cache of every resource of this type.
|
|
61
|
+
* @throws {AppwriteException}
|
|
62
|
+
* @returns {Promise<{}>}
|
|
63
|
+
*/
|
|
64
|
+
deleteProjectResourceCache(params: {
|
|
65
|
+
projectId: string;
|
|
66
|
+
resourceType: ProjectResourceType;
|
|
67
|
+
resourceId?: string;
|
|
68
|
+
}): Promise<{}>;
|
|
69
|
+
/**
|
|
70
|
+
* Delete the cache of one project resource, or of every resource of a type. Send the request to the project's region.
|
|
71
|
+
*
|
|
72
|
+
* @param {string} projectId - Project ID.
|
|
73
|
+
* @param {ProjectResourceType} resourceType - Resource type.
|
|
74
|
+
* @param {string} resourceId - Resource ID. Leave empty to delete the cache of every resource of this type.
|
|
75
|
+
* @throws {AppwriteException}
|
|
76
|
+
* @returns {Promise<{}>}
|
|
77
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
78
|
+
*/
|
|
79
|
+
deleteProjectResourceCache(projectId: string, resourceType: ProjectResourceType, resourceId?: string): Promise<{}>;
|
|
80
|
+
}
|
|
@@ -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
|
+
}
|