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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change Log


## 27.1.0-rc.8

* Added: `Analytics` service, the `Tracking` helper and `TrackingObserver`, which were missing from `27.1.0-rc.5` through `rc.7`
* Changed: `Tracking` takes the `Analytics` service and a property id instead of an emitter callback
* Changed: `enableAllAutoTracking()` is now `start()`
* Fixed: engagement time is no longer discarded when the app returns from `inactive` without backgrounding
* Fixed: a rejected tracking request no longer surfaces as an unhandled async error
* Fixed: removing a buried route no longer records a screen view for a screen that was never visible

## 27.1.0-rc.7

* Fixed: `host()` reports the live connection state instead of always resolving open
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Add this to your package's `pubspec.yaml` file:

```yml
dependencies:
appwrite: ^27.1.0-rc.7
appwrite: ^27.1.0-rc.8
```

You can install packages from the command line:
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// The native half of Push on Android: background delivery that survives the process being
// killed, a reboot and an app update, shared with the Appwrite Android SDK.
group = "io.appwrite.flutter"
version = "27.1.0-rc.7"
version = "27.1.0-rc.8"

buildscript {
ext.kotlin_version = "2.1.0"
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 @@ -13,5 +13,6 @@ await 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 @@ -13,5 +13,6 @@ await account.createOAuth2Token(
success: 'https://example.com', // optional
failure: 'https://example.com', // optional
scopes: [], // optional
state: '<STATE>', // optional
);
```
25 changes: 25 additions & 0 deletions docs/examples/analytics/create-event.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
```dart
import 'package:appwrite/appwrite.dart';

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

Analytics analytics = Analytics(client);

models. result = await analytics.createEvent(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the invalid result declaration in this example

models. result is not valid Dart syntax, so this new example cannot be copied and compiled as written. Use a valid declaration such as final result = await ....

Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/examples/analytics/create-event.md
Line: 10

Comment:
**Fix the invalid result declaration in this example**

`models. result` is not valid Dart syntax, so this new example cannot be copied and compiled as written. Use a valid declaration such as `final result = await ...`.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

🟡 Minor · documentation · Reply if this doesn't apply.

propertyId: '<PROPERTY_ID>',
name: '<NAME>',
url: 'https://example.com',
domain: '<DOMAIN>', // optional
referrer: '<REFERRER>', // optional
screenWidth: 0, // optional
sessionHash: '<SESSION_HASH>', // optional
scrollDepth: 0, // optional
engagementTime: 0, // optional
props: [], // optional
userId: '<USER_ID>', // optional
ip: '<IP>', // optional
userAgent: '<USER_AGENT>', // optional
);
```
3 changes: 3 additions & 0 deletions lib/appwrite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export 'src/upload_progress.dart';
export 'src/realtime_subscription.dart';
export 'src/realtime_message.dart';
export 'src/input_file.dart';
export 'src/tracking.dart';
export 'src/tracking_observer.dart';

part 'query.dart';
part 'permission.dart';
Expand All @@ -39,6 +41,7 @@ part 'topic.dart';
part 'channel.dart';
part 'operator.dart';
part 'services/account.dart';
part 'services/analytics.dart';
part 'services/apps.dart';
part 'services/avatars.dart';
part 'services/databases.dart';
Expand Down
4 changes: 4 additions & 0 deletions lib/services/account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,7 @@ class Account extends Service {
String? success,
String? failure,
List<String>? scopes,
String? state,
}) async {
final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll(
'{provider}',
Expand All @@ -1503,6 +1504,7 @@ class Account extends Service {
if (success != null) 'success': success,
if (failure != null) 'failure': failure,
if (scopes != null) 'scopes': scopes,
if (state != null) 'state': state,
'project': client.config['project'],
};

Expand Down Expand Up @@ -1945,6 +1947,7 @@ class Account extends Service {
String? success,
String? failure,
List<String>? scopes,
String? state,
}) async {
final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll(
'{provider}',
Expand All @@ -1955,6 +1958,7 @@ class Account extends Service {
if (success != null) 'success': success,
if (failure != null) 'failure': failure,
if (scopes != null) 'scopes': scopes,
if (state != null) 'state': state,
'project': client.config['project'],
};

Expand Down
65 changes: 65 additions & 0 deletions lib/services/analytics.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
part of '../appwrite.dart';

class Analytics extends Service {
/// Initializes a [Analytics] service
Analytics(super.client);

/// Send a tracking event from a browser, native app, or server-side SDK.
Future createEvent({
required String propertyId,
required String name,
required String url,
String? domain,
String? referrer,
int? screenWidth,
String? sessionHash,
int? scrollDepth,
int? engagementTime,
List<String>? props,
String? userId,
String? ip,
String? userAgent,
}) async {
if (propertyId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "propertyId"',
);
}

final String apiPath = '/analytics/properties/{propertyId}/events'
.replaceAll(
'{propertyId}',
propertyId,
);

final Map<String, dynamic> apiParams = {
'name': name,
'url': url,
if (domain != null) 'domain': domain,
if (referrer != null) 'referrer': referrer,
if (screenWidth != null) 'screenWidth': screenWidth,
if (sessionHash != null) 'sessionHash': sessionHash,
if (scrollDepth != null) 'scrollDepth': scrollDepth,
if (engagementTime != null) 'engagementTime': engagementTime,
if (props != null) 'props': props,
if (userId != null) 'userId': userId,
if (ip != null) 'ip': ip,
if (userAgent != null) 'userAgent': userAgent,
};

final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};

final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);

return res.data;
}
}
2 changes: 1 addition & 1 deletion lib/src/client_browser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
'x-sdk-name': 'Flutter',
'x-sdk-platform': 'client',
'x-sdk-language': 'flutter',
'x-sdk-version': '27.1.0-rc.7',
'x-sdk-version': '27.1.0-rc.8',
'X-Appwrite-Response-Format': '2.3.0',
};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/client_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ClientIO extends ClientBase with ClientMixin {
'x-sdk-name': 'Flutter',
'x-sdk-platform': 'client',
'x-sdk-language': 'flutter',
'x-sdk-version': '27.1.0-rc.7',
'x-sdk-version': '27.1.0-rc.8',
'X-Appwrite-Response-Format': '2.3.0',
};

Expand Down
Loading
Loading