Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log


## 28.2.0-rc.7

* Added: `Analytics` service and the `Tracking` auto-tracking helper, which were missing from `28.2.0-rc.5` and `rc.6`
* Changed: `Tracking` takes `new Analytics(client)` and a property id instead of an emitter callback; the adapter to `createEvent` now lives inside the SDK
* Changed: `enableAllAutoTracking()` is now `start()`
* Removed: `AnalyticsEventEmitter`; the option types are now `TrackingEventOptions` and `TrackingOptions`

## 28.2.0-rc.6

* Added: `Push.onNotificationOpened()` fires when a user taps a shown notification
Expand Down Expand Up @@ -242,3 +250,4 @@
* Fix pong response & chunked upload
* Add `ping` support to `Realtime` service


2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { Client, Account } from 'appwrite';
To install with a CDN (content delivery network) add the following scripts to the bottom of your <body> tag, but before you use any Appwrite services:

```html
<script src="https://cdn.jsdelivr.net/npm/appwrite@28.2.0-rc.6"></script>
<script src="https://cdn.jsdelivr.net/npm/appwrite@28.2.0-rc.7"></script>
```

## Getting Started
Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-o-auth-2-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ account.createOAuth2Session({
success: 'https://example.com', // optional
failure: 'https://example.com', // optional
scopes: [], // optional
state: '<STATE>', // optional
});
```
1 change: 1 addition & 0 deletions docs/examples/account/create-o-auth-2-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ account.createOAuth2Token({
success: 'https://example.com', // optional
failure: 'https://example.com', // optional
scopes: [], // optional
state: '<STATE>', // optional
});
```
27 changes: 27 additions & 0 deletions docs/examples/analytics/create-event.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
```javascript
import { Client, Analytics } from 'appwrite';

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const analytics = new Analytics(client);

const result = await analytics.createEvent({
propertyId: '<PROPERTY_ID>',
name: '<NAME>',
url: 'https://example.com',
domain: '<DOMAIN>', // optional
referrer: '<REFERRER>', // optional
screenWidth: null, // optional
sessionHash: '<SESSION_HASH>', // optional
scrollDepth: 0, // optional
engagementTime: 0, // optional
props: [], // optional
userId: '<USER_ID>', // optional
ip: '<IP>', // optional
userAgent: '<USER_AGENT>', // optional
});

console.log(result);
```
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "appwrite",
"homepage": "https://appwrite.io/support",
"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",
"version": "28.2.0-rc.6",
"version": "28.2.0-rc.7",
"license": "BSD-3-Clause",
"main": "dist/cjs/sdk.js",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ class Client {
'x-sdk-name': 'Web',
'x-sdk-platform': 'client',
'x-sdk-language': 'web',
'x-sdk-version': '28.2.0-rc.6',
'x-sdk-version': '28.2.0-rc.7',
'X-Appwrite-Response-Format': '2.3.0',
};

Expand Down
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
export { Client, Query, AppwriteException } from './client';
export { Account } from './services/account';
export { Analytics } from './services/analytics';
export { Apps } from './services/apps';
export { Avatars } from './services/avatars';
export { Databases } from './services/databases';
Expand All @@ -26,6 +27,7 @@ export { Teams } from './services/teams';
export { VectorsDB } from './services/vectors-db';
export { Realtime } from './services/realtime';
export { Push } from './services/push';
export { Tracking } from './services/analytics-tracking';
export type {
Models,
Payload,
Expand All @@ -40,6 +42,12 @@ export type {
SubscribeOptions,
MessageCallback,
} from './services/push';
export type {
DownloadTrackingOptions,
OutboundTrackingOptions,
TrackingEventOptions,
TrackingOptions,
} from './services/analytics-tracking';
export type { QueryTypes, QueryTypesList } from './query';
export { Permission } from './permission';
export { Role } from './role';
Expand Down
34 changes: 30 additions & 4 deletions src/services/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2809,6 +2809,7 @@ export class Account {
* @param {string} params.success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
* @param {string} params.failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
* @param {string[]} params.scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
* @param {string} params.state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars.
* @throws {AppwriteException}
* @returns {void | string}
*/
Expand All @@ -2817,6 +2818,7 @@ export class Account {
success?: string;
failure?: string;
scopes?: string[];
state?: string;
}): void | string;
/**
* Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed.
Expand All @@ -2830,6 +2832,7 @@ export class Account {
* @param {string} success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
* @param {string} failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
* @param {string[]} scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
* @param {string} state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars.
* @throws {AppwriteException}
* @returns {void | string}
* @deprecated Use the object parameter style method for a better developer experience.
Expand All @@ -2839,6 +2842,7 @@ export class Account {
success?: string,
failure?: string,
scopes?: string[],
state?: string,
): void | string;
createOAuth2Session(
paramsOrFirst:
Expand All @@ -2847,15 +2851,17 @@ export class Account {
success?: string;
failure?: string;
scopes?: string[];
state?: string;
}
| OAuthProvider,
...rest: [string?, string?, string[]?]
...rest: [string?, string?, string[]?, string?]
): void | string {
let params: {
provider: OAuthProvider;
success?: string;
failure?: string;
scopes?: string[];
state?: string;
};

if (
Expand All @@ -2865,27 +2871,31 @@ export class Account {
('provider' in paramsOrFirst ||
'success' in paramsOrFirst ||
'failure' in paramsOrFirst ||
'scopes' in paramsOrFirst)
'scopes' in paramsOrFirst ||
'state' in paramsOrFirst)
) {
params = (paramsOrFirst || {}) as {
provider: OAuthProvider;
success?: string;
failure?: string;
scopes?: string[];
state?: string;
};
} else {
params = {
provider: paramsOrFirst as OAuthProvider,
success: rest[0] as string,
failure: rest[1] as string,
scopes: rest[2] as string[],
state: rest[3] as string,
};
}

const provider = params.provider;
const success = params.success;
const failure = params.failure;
const scopes = params.scopes;
const state = params.state;

if (typeof provider === 'undefined') {
throw new AppwriteException(
Expand All @@ -2906,6 +2916,9 @@ export class Account {
if (typeof scopes !== 'undefined') {
apiPayload['scopes'] = scopes;
}
if (typeof state !== 'undefined') {
apiPayload['state'] = state;
}
const uri = new URL(this.client.config.endpoint + apiPath);

apiPayload['project'] = this.client.config.project;
Expand Down Expand Up @@ -3701,6 +3714,7 @@ export class Account {
* @param {string} params.success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
* @param {string} params.failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
* @param {string[]} params.scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
* @param {string} params.state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars.
* @throws {AppwriteException}
* @returns {void | string}
*/
Expand All @@ -3709,6 +3723,7 @@ export class Account {
success?: string;
failure?: string;
scopes?: string[];
state?: string;
}): void | string;
/**
* Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed.
Expand All @@ -3723,6 +3738,7 @@ export class Account {
* @param {string} success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
* @param {string} failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
* @param {string[]} scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
* @param {string} state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars.
* @throws {AppwriteException}
* @returns {void | string}
* @deprecated Use the object parameter style method for a better developer experience.
Expand All @@ -3732,6 +3748,7 @@ export class Account {
success?: string,
failure?: string,
scopes?: string[],
state?: string,
): void | string;
createOAuth2Token(
paramsOrFirst:
Expand All @@ -3740,15 +3757,17 @@ export class Account {
success?: string;
failure?: string;
scopes?: string[];
state?: string;
}
| OAuthProvider,
...rest: [string?, string?, string[]?]
...rest: [string?, string?, string[]?, string?]
): void | string {
let params: {
provider: OAuthProvider;
success?: string;
failure?: string;
scopes?: string[];
state?: string;
};

if (
Expand All @@ -3758,27 +3777,31 @@ export class Account {
('provider' in paramsOrFirst ||
'success' in paramsOrFirst ||
'failure' in paramsOrFirst ||
'scopes' in paramsOrFirst)
'scopes' in paramsOrFirst ||
'state' in paramsOrFirst)
) {
params = (paramsOrFirst || {}) as {
provider: OAuthProvider;
success?: string;
failure?: string;
scopes?: string[];
state?: string;
};
} else {
params = {
provider: paramsOrFirst as OAuthProvider,
success: rest[0] as string,
failure: rest[1] as string,
scopes: rest[2] as string[],
state: rest[3] as string,
};
}

const provider = params.provider;
const success = params.success;
const failure = params.failure;
const scopes = params.scopes;
const state = params.state;

if (typeof provider === 'undefined') {
throw new AppwriteException(
Expand All @@ -3799,6 +3822,9 @@ export class Account {
if (typeof scopes !== 'undefined') {
apiPayload['scopes'] = scopes;
}
if (typeof state !== 'undefined') {
apiPayload['state'] = state;
}
const uri = new URL(this.client.config.endpoint + apiPath);

apiPayload['project'] = this.client.config.project;
Expand Down
Loading
Loading