From 472de99e9aa06246c811dc0549bd4728f243ce17 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Fri, 6 Nov 2026 14:26:08 +0530 Subject: [PATCH] chore: update React Native SDK to 3.2.0 --- CHANGELOG.md | 8 + README.md | 4 +- .../reactnative/services/PushBackground.kt | 18 +- docs/examples/analytics/create-event.md | 1 + package-lock.json | 295 +++++++++++------- package.json | 2 +- src/client.ts | 33 +- src/enums/o-auth-provider.ts | 1 + src/services/account.ts | 8 +- src/services/analytics.ts | 18 +- src/services/avatars.ts | 36 +++ src/services/realtime.ts | 14 +- src/services/storage.ts | 12 + 13 files changed, 320 insertions(+), 130 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74dc019e..4b1c4e51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change log +## 3.2.0 + +* Added: `Client.setEnvironment` to act in a project environment; realtime, avatar and storage URLs carry it +* Added: optional `interactive` param on `Analytics.createEvent` to mark an event as telemetry that does not end a bounce +* Added: `OAuthProvider.Vipps` +* Fixed: Android background push reconnects inside the system's network windows instead of minutes later +* Updated: requests send `X-Appwrite-Response-Format: 2.7.0`; the SDK targets Appwrite 2.7.x + ## 3.1.1 * Fixed: `Push` on Android verifies the push server's TLS hostname before sending credentials diff --git a/README.md b/README.md index 6db4ff0c..621b7e6a 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Appwrite React Native SDK ![License](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-2.6.2-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-2.7.0-blue.svg?style=flat-square) [![X Account](https://img.shields.io/badge/follow-%40appwrite-000000?logo=x&style=flat-square)](https://x.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK targets Appwrite server version 2.6.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-react-native/releases) when APIs differ. +**This SDK targets Appwrite server version 2.7.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-react-native/releases) when APIs differ. Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the React Native SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/android/src/main/java/io/appwrite/reactnative/services/PushBackground.kt b/android/src/main/java/io/appwrite/reactnative/services/PushBackground.kt index cc34f286..0477c575 100644 --- a/android/src/main/java/io/appwrite/reactnative/services/PushBackground.kt +++ b/android/src/main/java/io/appwrite/reactnative/services/PushBackground.kt @@ -644,7 +644,10 @@ internal object PushBackground { return } var client = mqtt - if (client != null && (current != connectedConfig || networkChanged(context))) { + // A client that lost its connection retries on its own backoff, which keeps firing while + // Android blocks a backgrounded app's network (the host lookup then fails at once), so it + // misses the short windows the scheduled runs are given. A run is such a window: reconnect now. + if (client != null && (current != connectedConfig || networkChanged(context) || !isConnected)) { disconnect() client = null } @@ -1298,6 +1301,19 @@ internal object PushBackground { } } } + + // The app may use the network again (it came on screen, or a run's window opened): + // reconnect now rather than when the client's backoff next fires. + override fun onBlockedStatusChanged(network: Network, blocked: Boolean) { + if (blocked) { + return + } + worker.execute { + if (mqtt != null && !isConnected) { + converge(context, heartbeat = false) + } + } + } } try { context.getSystemService(ConnectivityManager::class.java)?.registerDefaultNetworkCallback(callback) diff --git a/docs/examples/analytics/create-event.md b/docs/examples/analytics/create-event.md index b8b5e7eb..290b148a 100644 --- a/docs/examples/analytics/create-event.md +++ b/docs/examples/analytics/create-event.md @@ -21,6 +21,7 @@ const result = await analytics.createEvent({ userId: '', // optional ip: '', // optional userAgent: '', // optional + interactive: false, // optional }); console.log(result); diff --git a/package-lock.json b/package-lock.json index 4b211e8e..12e95b2a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "react-native-appwrite", - "version": "3.1.1", + "version": "3.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "react-native-appwrite", - "version": "3.1.1", + "version": "3.2.0", "license": "BSD-3-Clause", "dependencies": { "buffer": "6.0.3", @@ -51,6 +51,19 @@ "react-native-tcp-socket": { "optional": true } + }, + "overrides": { + "glob": { + ".": "^14.0.2", + "brace-expansion": "5.0.12" + }, + "brace-expansion": "5.0.12", + "minimatch": "^11.0.1", + "rimraf": "^6.0.0", + "@xmldom/xmldom": "^0.9.10", + "uuid": "^14.0.0", + "postcss": "^8.5.18", + "ws": "^8.20.1" } }, "node_modules/@babel/code-frame": { @@ -120,14 +133,14 @@ } }, "node_modules/@babel/generator": { - "version": "7.29.8", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.8.tgz", - "integrity": "sha512-gZbepsdh3WDtgZKWL+vTPh71LSBrm/Y4/QDZBVCcYfmeTEEuoOYwlSy+G1StfJg+/Zy550u/3TATbm7qDbbMtg==", + "version": "7.29.12", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.12.tgz", + "integrity": "sha512-2W76mhjrpQFO1lK5e8IvGYB2D0YZ7S2R1Z2BjO2ZUYuW+amcpK/z60U6ZZmzskwoa7sJ6XohP/Wg8H5KxXI/IA==", "license": "MIT", "peer": true, "dependencies": { - "@babel/parser": "^7.29.8", - "@babel/types": "^7.29.8", + "@babel/parser": "^7.29.12", + "@babel/types": "^7.29.11", "@jridgewell/gen-mapping": "^0.3.12", "@jridgewell/trace-mapping": "^0.3.28", "jsesc": "^3.0.2" @@ -177,9 +190,9 @@ } }, "node_modules/@babel/helper-create-class-features-plugin": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.29.7.tgz", - "integrity": "sha512-IY3ZD9Tmooqr3TUhc3DUWxiuo8xx1DWLhd5M7hQ+ZWJamqM2BbalrBJb2MisSLoYorOj75U03qULCxQTY9r3hg==", + "version": "7.29.12", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.29.12.tgz", + "integrity": "sha512-ACxGoWMV866q/QlZHeCOaQZAR5QclKsIvkAmlDemqjm6+6Bynijs1mH068BzH2N2e+wSuDmBWY87fqKfvhi1Lw==", "license": "MIT", "peer": true, "dependencies": { @@ -188,7 +201,7 @@ "@babel/helper-optimise-call-expression": "^7.29.7", "@babel/helper-replace-supers": "^7.29.7", "@babel/helper-skip-transparent-expression-wrappers": "^7.29.7", - "@babel/traverse": "^7.29.7", + "@babel/traverse": "^7.29.12", "semver": "^6.3.1" }, "engines": { @@ -442,9 +455,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.29.11", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.11.tgz", - "integrity": "sha512-OZ6+oaK7GMyg3IfCpj8JOmn8n+w2rJbDT0LLfVDTLb1ZFeKDh3AiNELgCMUw175IJHSkLl74hG0M0VLsvx+gag==", + "version": "7.29.12", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.12.tgz", + "integrity": "sha512-WJ7JBp/Q4+z/ImydtI7jS6NVco5++632ExBemSX+Ysb+G1lCwQ5BVo3SY+jGGOcZXI4ZccbZSUSJLNBW6eEpJg==", "license": "MIT", "peer": true, "dependencies": { @@ -647,9 +660,9 @@ } }, "node_modules/@babel/plugin-transform-block-scoping": { - "version": "7.29.11", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.29.11.tgz", - "integrity": "sha512-iARF4jjHSM0v8DImCACPXrwEltBP3DgqDpXTvjAMBAVpyEY0LiGss78wvI+KtmW+IJNEvZ5sOhPDCsOsXsIybA==", + "version": "7.29.12", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.29.12.tgz", + "integrity": "sha512-nEreZBofjfd6FG621xe9Rk3+tMGBXf1nAuFrR6NUGF67fkQbSQf3NrbRuhgWRn+zb0qcy9XVok1GVFI/t9wWVQ==", "license": "MIT", "peer": true, "dependencies": { @@ -1136,18 +1149,18 @@ } }, "node_modules/@babel/traverse": { - "version": "7.29.10", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.10.tgz", - "integrity": "sha512-B3lYAs2nkKskbgQ1nfy8Ma9ao9Q1rntTAQHrzzyDuj+TSO+X3le6PfWwqDvodsb+OumE10eMFfuMCTQSQ5iuIQ==", + "version": "7.29.12", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.12.tgz", + "integrity": "sha512-MscXe/NAZcOkYEsRajHZFt3ynsb22PUi6CTrp5U7+RYycR9By84mn9mFN54YgfITiqK4hFx3Ju3tZSyzfpS5ew==", "license": "MIT", "peer": true, "dependencies": { "@babel/code-frame": "^7.29.7", - "@babel/generator": "^7.29.8", + "@babel/generator": "^7.29.12", "@babel/helper-globals": "^7.29.7", - "@babel/parser": "^7.29.9", + "@babel/parser": "^7.29.12", "@babel/template": "^7.29.7", - "@babel/types": "^7.29.8", + "@babel/types": "^7.29.11", "debug": "^4.3.1" }, "engines": { @@ -1321,33 +1334,33 @@ } }, "node_modules/@expo/cli": { - "version": "58.1.17", - "resolved": "https://registry.npmjs.org/@expo/cli/-/cli-58.1.17.tgz", - "integrity": "sha512-2WKvwrq9Sr0jj4vFVt7dPtbHoxFzaSp4s5Bsk1FDmCQjZhQlWZjb7j6igBYCs0nBzZZ4UyBdSMY2hwmDhRmPQA==", + "version": "58.1.18", + "resolved": "https://registry.npmjs.org/@expo/cli/-/cli-58.1.18.tgz", + "integrity": "sha512-voZUcir9mEwvLKBNqQM6Jy2Yp67z8ONmcINXb6ZrLMayb7yxzwvEnN0eeH8ADzUABKL288pv1eJ1WRqtYxXQ/Q==", "license": "MIT", "peer": true, "dependencies": { "@expo/code-signing-certificates": "^0.0.7", - "@expo/config": "~58.0.9", + "@expo/config": "~58.0.10", "@expo/config-plugins": "~58.0.11", "@expo/devcert": "^1.2.2", "@expo/env": "~2.5.3", "@expo/image-utils": "^0.12.6", "@expo/inline-modules": "^0.2.8", "@expo/json-file": "^11.2.1", - "@expo/log-box": "^58.0.13", + "@expo/log-box": "^58.0.14", "@expo/log-box-utils": "^58.0.2", "@expo/metro": "~58.0.0", - "@expo/metro-config": "58.0.19", + "@expo/metro-config": "58.0.20", "@expo/metro-file-map": "^58.0.5", "@expo/osascript": "^2.8.1", "@expo/package-manager": "^1.14.2", "@expo/platforms": "^58.0.1", "@expo/plist": "^0.10.1", - "@expo/prebuild-config": "^58.0.17", + "@expo/prebuild-config": "^58.0.18", "@expo/require-utils": "^58.0.5", - "@expo/router-server": "^58.0.19", - "@expo/schema-utils": "^58.0.2", + "@expo/router-server": "^58.0.20", + "@expo/schema-utils": "^58.0.3", "@expo/spawn-async": "^1.8.0", "@expo/ws-tunnel": "^2.0.1", "@expo/xcpretty": "^4.4.6", @@ -1388,18 +1401,21 @@ "terminal-link": "^2.1.1", "toqr": "^0.1.1", "wrap-ansi": "^7.0.0", - "ws": "^8.12.1", - "zod": "^3.25.76" + "ws": "^8.12.1" }, "bin": { "expo-internal": "bin/cli.js" }, "peerDependencies": { "expo": "*", + "expo-mcp": "*", "expo-router": "*", "react-native": "*" }, "peerDependenciesMeta": { + "expo-mcp": { + "optional": true + }, "expo-router": { "optional": true }, @@ -1422,9 +1438,9 @@ } }, "node_modules/@expo/config": { - "version": "58.0.9", - "resolved": "https://registry.npmjs.org/@expo/config/-/config-58.0.9.tgz", - "integrity": "sha512-rN21dSqt6jfzpnVaBwCZVIvRFxoWEit+11AY+dSyaVkkwFWnVga0KOkFTQydtYgIZmP/vdm4QJhKeQkoUf4oMQ==", + "version": "58.0.10", + "resolved": "https://registry.npmjs.org/@expo/config/-/config-58.0.10.tgz", + "integrity": "sha512-EC2BKXf9nIVrsvpwMOIUw8fyJPLU4moeFFiWhQivpVX9Ta9EUfXjpeoJHhv8Nt7+lx9RfRfZy9sgMsSUVMuRBw==", "license": "MIT", "peer": true, "dependencies": { @@ -1433,7 +1449,6 @@ "@expo/json-file": "^11.2.1", "@expo/platforms": "^58.0.1", "@expo/require-utils": "^58.0.5", - "deepmerge": "^4.3.1", "getenv": "^2.0.0", "glob": "^13.0.0", "resolve-workspace-root": "^2.0.0", @@ -1545,9 +1560,9 @@ } }, "node_modules/@expo/fingerprint": { - "version": "0.21.7", - "resolved": "https://registry.npmjs.org/@expo/fingerprint/-/fingerprint-0.21.7.tgz", - "integrity": "sha512-rE9QN4TXGZxS3PC1yW77D1B6JNnuv3n7hXVUZxFEDDndPKFnQPC0XkqFyIz21oXbtrvThROCbV9CDVJiycCntg==", + "version": "0.21.8", + "resolved": "https://registry.npmjs.org/@expo/fingerprint/-/fingerprint-0.21.8.tgz", + "integrity": "sha512-ufFLmY4Lyf8POxZgaWsZGq3p16fWJUCrkkm9E0HM9mw74vGQkRu5sKUIPde+ROGXv2cWLsrudJkUZLU5l6Clvw==", "license": "MIT", "peer": true, "dependencies": { @@ -1605,20 +1620,20 @@ } }, "node_modules/@expo/local-build-cache-provider": { - "version": "58.0.9", - "resolved": "https://registry.npmjs.org/@expo/local-build-cache-provider/-/local-build-cache-provider-58.0.9.tgz", - "integrity": "sha512-C1QZ4GDljraOtARoZPvImxA9gKLd9kb/w1fRpc+x2sCZ1qXxWmqoVh+ISuwe6niB1BvzBEDA8KH0QQJj3r9nLQ==", + "version": "58.0.10", + "resolved": "https://registry.npmjs.org/@expo/local-build-cache-provider/-/local-build-cache-provider-58.0.10.tgz", + "integrity": "sha512-0O0EF9V2rEgIPYJI+4vYLEKQn3xUt2js4L2L6DLE9PrElozL7cvHJKPkfEpYSxo5NNJhyGfVxBdazd0vE4Xg3w==", "license": "MIT", "peer": true, "dependencies": { - "@expo/config": "~58.0.9", + "@expo/config": "~58.0.10", "chalk": "^4.1.2" } }, "node_modules/@expo/log-box": { - "version": "58.0.13", - "resolved": "https://registry.npmjs.org/@expo/log-box/-/log-box-58.0.13.tgz", - "integrity": "sha512-Cl9qc77nWjQVivUI5/OCPSEP8s20EtbK3Ivy5ayy+uHO0Cf+XatatWfTvKiHO38VOpT2ywlROzZb4XZyxZUZ1Q==", + "version": "58.0.14", + "resolved": "https://registry.npmjs.org/@expo/log-box/-/log-box-58.0.14.tgz", + "integrity": "sha512-0aXQIWgTBvtzlzzqS7+oDx+DeGyX961Xxr53HzWWiyxNM9PkK7QXVV2gVeuvAYL0RIKUL1hNC0ZCz7sSkYyfww==", "license": "MIT", "peer": true, "dependencies": { @@ -1670,16 +1685,16 @@ } }, "node_modules/@expo/metro-config": { - "version": "58.0.19", - "resolved": "https://registry.npmjs.org/@expo/metro-config/-/metro-config-58.0.19.tgz", - "integrity": "sha512-z8tOnyiY5jg2sbrCAD60N+G9AX6sZQyMrfrhL4DK4pkwyt5TODkxk61G0Y0k9RidXpvjguqftB7v/w8UK5wCGg==", + "version": "58.0.20", + "resolved": "https://registry.npmjs.org/@expo/metro-config/-/metro-config-58.0.20.tgz", + "integrity": "sha512-M8O9hcpHTYXZjuUO0UzHInbpqKiWVXW/If8ZD3tdg1l01vDjoS6ol5lzP0IJhGY4VeJNJI3U5MsdS7dxx0AlLw==", "license": "MIT", "peer": true, "dependencies": { "@babel/code-frame": "^7.20.0", "@babel/core": "^7.20.0", "@babel/generator": "^7.20.5", - "@expo/config": "~58.0.9", + "@expo/config": "~58.0.10", "@expo/env": "~2.5.3", "@expo/json-file": "~11.2.1", "@expo/metro": "~58.0.0", @@ -1736,6 +1751,9 @@ "cpu": [ "arm64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1750,6 +1768,9 @@ "cpu": [ "x64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1833,13 +1854,13 @@ } }, "node_modules/@expo/prebuild-config": { - "version": "58.0.17", - "resolved": "https://registry.npmjs.org/@expo/prebuild-config/-/prebuild-config-58.0.17.tgz", - "integrity": "sha512-QSMM9YiHQnRENUIgP7wgZt71WKPLUMLz5QFm4KWA2aa20a808F6b+HV/ZzfX47MWWt39RjyT9pUcLv/dgEp0UA==", + "version": "58.0.18", + "resolved": "https://registry.npmjs.org/@expo/prebuild-config/-/prebuild-config-58.0.18.tgz", + "integrity": "sha512-xTfSvhBrD2UYwRmpnQCPxY06j37ZMobXiZsdRPsW07vVMHe0ox4OpMbs47qv3h6RG/gfV+uu1RgMqi8d6cxurg==", "license": "MIT", "peer": true, "dependencies": { - "@expo/config": "~58.0.9", + "@expo/config": "~58.0.10", "@expo/config-plugins": "~58.0.11", "@expo/config-types": "^58.0.3", "@expo/image-utils": "^0.12.6", @@ -1872,16 +1893,16 @@ } }, "node_modules/@expo/router-server": { - "version": "58.0.19", - "resolved": "https://registry.npmjs.org/@expo/router-server/-/router-server-58.0.19.tgz", - "integrity": "sha512-yyqiU830tiKybH6Vr0BqXbcSCdCj5+lK/MR6l/DG5Jbv3s4jXKqa8vb4QuWRO2mMvk0xUeJO7RNyWEtGF9TYEA==", + "version": "58.0.20", + "resolved": "https://registry.npmjs.org/@expo/router-server/-/router-server-58.0.20.tgz", + "integrity": "sha512-EqrJBFWlouh6YywiKpCVr4vjRWYon3NeRTsvULuTEVpWD0EB/8eXDxcRTfUvAtxcc6Zlf5mCEXpzE8Hf8ulA1Q==", "license": "MIT", "peer": true, "dependencies": { "debug": "^4.3.4" }, "peerDependencies": { - "@expo/metro-runtime": "^58.0.15", + "@expo/metro-runtime": "^58.0.16", "expo": "*", "expo-constants": "^58.0.14", "expo-font": "^58.0.11", @@ -1907,9 +1928,9 @@ } }, "node_modules/@expo/schema-utils": { - "version": "58.0.2", - "resolved": "https://registry.npmjs.org/@expo/schema-utils/-/schema-utils-58.0.2.tgz", - "integrity": "sha512-w28y8SG+5ZTdDdmH2ZnCQk9wHVwGzI9NqX5V4urJUFEnxbm7I129fJRkb8RIAJmMA1WKU5h3ONmranV473uaXQ==", + "version": "58.0.3", + "resolved": "https://registry.npmjs.org/@expo/schema-utils/-/schema-utils-58.0.3.tgz", + "integrity": "sha512-DwoMEpT3H+r1lU+YUEP10UcUW7sDKmfvgE7oA+zQeuGyi0XxDSDgRZUUZ5nOGp+lymmTicoIUKkoN7rByuI04g==", "license": "MIT", "peer": true }, @@ -2171,6 +2192,9 @@ "x64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2221,6 +2245,9 @@ "cpu": [ "arm64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2238,6 +2265,9 @@ "cpu": [ "arm64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2255,6 +2285,9 @@ "cpu": [ "x64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2272,6 +2305,9 @@ "cpu": [ "x64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2653,6 +2689,9 @@ "arm" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2667,6 +2706,9 @@ "arm" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2681,6 +2723,9 @@ "arm64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2695,6 +2740,9 @@ "arm64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2709,6 +2757,9 @@ "loong64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2723,6 +2774,9 @@ "loong64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2737,6 +2791,9 @@ "ppc64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2751,6 +2808,9 @@ "ppc64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2765,6 +2825,9 @@ "riscv64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2779,6 +2842,9 @@ "riscv64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2793,6 +2859,9 @@ "s390x" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2807,6 +2876,9 @@ "x64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2821,6 +2893,9 @@ "x64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -3543,9 +3618,9 @@ } }, "node_modules/babel-preset-expo": { - "version": "58.0.22", - "resolved": "https://registry.npmjs.org/babel-preset-expo/-/babel-preset-expo-58.0.22.tgz", - "integrity": "sha512-2/pbzxDh4wd4MrBU4lFqFWEfCQooCVjnh6JJZnPLmWisOy5+r4qaOItcH+zaiO4hP2CyYwnyotg1QKhgsmAMEw==", + "version": "58.0.23", + "resolved": "https://registry.npmjs.org/babel-preset-expo/-/babel-preset-expo-58.0.23.tgz", + "integrity": "sha512-7wdPu1QSvG7BwZ1UCKFMedJp/I4hLFvVsOjchu78YooHyxoJ/6aU8QzW8uiwZR3ov5Z9OFkRWTTcYyDP9u113w==", "license": "MIT", "peer": true, "dependencies": { @@ -3595,7 +3670,7 @@ "peerDependencies": { "@babel/runtime": "^7.20.0", "expo": "*", - "expo-widgets": "^58.0.25", + "expo-widgets": "^58.0.26", "react-refresh": ">=0.14.0 <1.0.0" }, "peerDependenciesMeta": { @@ -4210,16 +4285,6 @@ "dev": true, "license": "MIT" }, - "node_modules/deepmerge": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", - "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", - "license": "MIT", - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/defaults": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", @@ -4289,9 +4354,9 @@ "peer": true }, "node_modules/electron-to-chromium": { - "version": "1.5.467", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.467.tgz", - "integrity": "sha512-Nw9X371rtZmYcBSnEijnCDONILjs93biCZO34juC7MBOmK8E+GFnyD4T/WvyrlJkppul7oxg6TwvtKst9SODTw==", + "version": "1.5.472", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.472.tgz", + "integrity": "sha512-s4+nfT29b0FKpVKoaIxl2pWsoNcn7A/nMPSrxayw4T3BsmPeV2lF9Y06BsAQeMGhCTQ4nYJ5XST7jkqe4ZEqFw==", "license": "ISC", "peer": true }, @@ -4552,26 +4617,26 @@ } }, "node_modules/expo": { - "version": "58.0.21", - "resolved": "https://registry.npmjs.org/expo/-/expo-58.0.21.tgz", - "integrity": "sha512-2Q8jp0fKLrDMou4aKWZ5V2cCVfcwOScuV8GBMkogiXIv7bCwwN4CIkUIq5QsX7DHXJxbruXLTXEgrp6J+iF4YA==", + "version": "58.0.22", + "resolved": "https://registry.npmjs.org/expo/-/expo-58.0.22.tgz", + "integrity": "sha512-9DmnUN+UxIRRmPLe+t7oOVwdnFzpq/9+1evMVXdFjiC4iwEF7iHCFU0AEm4o2A6HP6A7nTtCox7ADsobYvB/Lw==", "license": "MIT", "peer": true, "dependencies": { "@babel/runtime": "^7.20.0", - "@expo/cli": "^58.1.17", - "@expo/config": "~58.0.9", + "@expo/cli": "^58.1.18", + "@expo/config": "~58.0.10", "@expo/config-plugins": "~58.0.11", "@expo/devtools": "~58.0.2", "@expo/dom-webview": "~58.0.2", - "@expo/fingerprint": "^0.21.7", - "@expo/local-build-cache-provider": "^58.0.9", - "@expo/log-box": "^58.0.13", + "@expo/fingerprint": "^0.21.8", + "@expo/local-build-cache-provider": "^58.0.10", + "@expo/log-box": "^58.0.14", "@expo/log-box-utils": "^58.0.2", "@expo/metro": "~58.0.0", - "@expo/metro-config": "~58.0.19", + "@expo/metro-config": "~58.0.20", "@ungap/structured-clone": "^1.3.0", - "babel-preset-expo": "~58.0.22", + "babel-preset-expo": "~58.0.23", "expo-asset": "~58.0.19", "expo-constants": "~58.0.14", "expo-file-system": "~58.0.13", @@ -4579,7 +4644,7 @@ "expo-keep-awake": "~58.0.3", "expo-modules-autolinking": "~58.0.16", "expo-modules-cli": "~0.4.0", - "expo-modules-core": "~58.0.28", + "expo-modules-core": "~58.0.29", "pretty-format": "^29.7.0", "react-refresh": "^0.14.2", "whatwg-url-minimum": "^0.2.0" @@ -4720,9 +4785,9 @@ } }, "node_modules/expo-modules-core": { - "version": "58.0.28", - "resolved": "https://registry.npmjs.org/expo-modules-core/-/expo-modules-core-58.0.28.tgz", - "integrity": "sha512-2FCnT8mIubdQAHVtX9fVMN9qajF7hGDC3CjxxBG0HlyK7NEsxUDKkukiNVzqQpwiI+jJx7ysG0YvATwKKlu1sw==", + "version": "58.0.29", + "resolved": "https://registry.npmjs.org/expo-modules-core/-/expo-modules-core-58.0.29.tgz", + "integrity": "sha512-S3L38WVxcn1sQfUr9fiUgKri2n4YKdtuToF3r45V7dVIUmHN69Fc7nZPF5BiMtOl/CgPWACicqUZr7jawBxXFg==", "license": "MIT", "peer": true, "dependencies": { @@ -5774,6 +5839,9 @@ "cpu": [ "arm64" ], + "libc": [ + "glibc" + ], "license": "MPL-2.0", "optional": true, "os": [ @@ -5795,6 +5863,9 @@ "cpu": [ "arm64" ], + "libc": [ + "musl" + ], "license": "MPL-2.0", "optional": true, "os": [ @@ -5816,6 +5887,9 @@ "cpu": [ "x64" ], + "libc": [ + "glibc" + ], "license": "MPL-2.0", "optional": true, "os": [ @@ -5837,6 +5911,9 @@ "cpu": [ "x64" ], + "libc": [ + "musl" + ], "license": "MPL-2.0", "optional": true, "os": [ @@ -6517,16 +6594,16 @@ } }, "node_modules/minimatch": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.3.tgz", - "integrity": "sha512-iny/40PEGkNJQ5/Pv6z3nm6FbRAby32GeZRjCUJk2WnNDbgPSTcdI+DDvLqsgBdD4cD5sMtMheqPPnehCCa8Nw==", + "version": "11.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.4.tgz", + "integrity": "sha512-/UJ1dEoVQTjPNDh6SGlUo+ueLMmoHTas4q+8yaAR/5t6nLAIiBDJtoYUh20IYleix7ehiQkgczb84PE3uzHkxg==", "license": "BlueOak-1.0.0", "dependencies": { "@isaacs/nonrecursive-glob-match": "^1.0.3", "brace-expansion": "^5.0.12" }, "engines": { - "node": "18 || 20 || >=22" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -6666,9 +6743,9 @@ "peer": true }, "node_modules/node-releases": { - "version": "2.0.61", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.61.tgz", - "integrity": "sha512-5NUN6QCxNFrS9oEA9RPS+d0AP+ooGBzzovY2JhIpDRHacPvOhHjXjUsUMX9qp4nLHZ+5jVgXB2jj/P4arGOE/g==", + "version": "2.0.63", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.63.tgz", + "integrity": "sha512-6li2QanLsAXpIH2R6j77MzRyvOyrvdTqlKtO4CgBdHGNvN99ZZfyxszHc5o5+IZBWD5u6Hzwg83JoGXmqZNG9Q==", "license": "MIT", "peer": true, "engines": { @@ -8527,9 +8604,9 @@ } }, "node_modules/ws": { - "version": "8.22.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.22.0.tgz", - "integrity": "sha512-Ydggc987+RO0AnWtZ/7Wq9FtNvcrL1b/RO0ud9mWjUPgDrsAAwQSF51sm2hm1XofbU/4jkpGEsLFsZZxU+1DOg==", + "version": "8.22.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.22.1.tgz", + "integrity": "sha512-oyL6OPYme/CmiFvNuGzeoxCJ4nOrZE2O1FwM9MWM1AsGri6nLXB2pg+lNA8aLeXMSav0J6eIVS1j6vUPzUtK9g==", "license": "MIT", "engines": { "node": ">=10.0.0" @@ -8652,16 +8729,6 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } - }, - "node_modules/zod": { - "version": "3.25.76", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", - "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", - "license": "MIT", - "peer": true, - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } } } } diff --git a/package.json b/package.json index d450cd55..145d838c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-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": "3.1.1", + "version": "3.2.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index 81e5264c..fdaa5d63 100644 --- a/src/client.ts +++ b/src/client.ts @@ -289,6 +289,7 @@ class Client { jwt: '', bearer: '', locale: '', + environment: '', session: '', cookie: '', impersonateuserid: '', @@ -299,8 +300,8 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '3.1.1', - 'X-Appwrite-Response-Format': '2.6.2', + 'x-sdk-version': '3.2.0', + 'X-Appwrite-Response-Format': '2.7.0', }; /** @@ -479,6 +480,22 @@ class Client { return this; } + /** + * Set Environment + * + * The ID of the project environment to act in, alongside the project ID. Used + * with Appwrite Cloud projects that have environments. + * + * @param value string + * + * @return {this} + */ + setEnvironment(value: string): this { + this.headers['X-Appwrite-Environment'] = value; + this.config.environment = value; + return this; + } + /** * Set Session * @@ -614,6 +631,10 @@ class Client { channels.set('jwt', jwt); } + if (this.config.environment) { + channels.set('environment', this.config.environment); + } + const url = this.config.endpointRealtime + '/realtime?' + @@ -740,8 +761,12 @@ class Client { window.localStorage.getItem('cookieFallback') ?? '{}', ); - session = - cookie?.[`a_session_${this.config.project}`]; + // An environment's session is named by its project and environment IDs. + const { project, environment } = this.config; + const name = environment + ? `a_session_${project}_env_${environment}` + : `a_session_${project}`; + session = cookie?.[name]; } if (session && !messageData?.user) { this.realtime.socket?.send( diff --git a/src/enums/o-auth-provider.ts b/src/enums/o-auth-provider.ts index 3dab5fb3..9785d42a 100644 --- a/src/enums/o-auth-provider.ts +++ b/src/enums/o-auth-provider.ts @@ -41,6 +41,7 @@ export enum OAuthProvider { Tradeshift = 'tradeshift', TradeshiftBox = 'tradeshiftBox', Twitch = 'twitch', + Vipps = 'vipps', Webflow = 'webflow', Wordpress = 'wordpress', X = 'x', diff --git a/src/services/account.ts b/src/services/account.ts index 806e9e73..49abdd49 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -4799,7 +4799,7 @@ export class Account extends Service { * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * - * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, webflow, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, vipps, webflow, wordpress, x, yahoo, yammer, yandex, zoho, zoom. * @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. @@ -4822,7 +4822,7 @@ export class Account extends Service { * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * - * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, webflow, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, vipps, webflow, wordpress, x, yahoo, yammer, yandex, zoho, zoom. * @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. @@ -6108,7 +6108,7 @@ export class Account extends Service { * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * - * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, webflow, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, vipps, webflow, wordpress, x, yahoo, yammer, yandex, zoho, zoom. * @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. @@ -6132,7 +6132,7 @@ export class Account extends Service { * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * - * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, webflow, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, vipps, webflow, wordpress, x, yahoo, yammer, yandex, zoho, zoom. * @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. diff --git a/src/services/analytics.ts b/src/services/analytics.ts index 37e44a72..e885f45b 100644 --- a/src/services/analytics.ts +++ b/src/services/analytics.ts @@ -20,9 +20,10 @@ export class Analytics extends Service { * @param {number} params.scrollDepth - Scroll depth percentage 0-100. * @param {number} params.engagementTime - Engagement time in seconds, 0-4294967295. * @param {string[]} params.props - Custom string properties as a flat key=value list (max 32 entries, alternating key,value). - * @param {string} params.userId - Override user ID. Requires API-key auth with analytics.write scope. + * @param {string} params.userId - Override user ID. Pass an opaque ID, not personal data such as an email. Requires API-key auth with analytics.write scope. * @param {string} params.ip - Override IP address. Requires API-key auth with analytics.write scope. * @param {string} params.userAgent - Override user agent. Requires API-key auth with analytics.write scope. + * @param {boolean | null} params.interactive - Whether this event is a visitor interaction that ends a bounce. Set false for telemetry such as heartbeats or background syncs. Defaults to true for custom events and false for the automatic engagement, scroll and app lifecycle events. Ignored for views. * @throws {AppwriteException} * @returns {Promise} */ @@ -40,6 +41,7 @@ export class Analytics extends Service { userId?: string; ip?: string; userAgent?: string; + interactive?: boolean | null; }): Promise<{}>; /** * Send a tracking event from a browser, native app, or server-side SDK. @@ -54,9 +56,10 @@ export class Analytics extends Service { * @param {number} scrollDepth - Scroll depth percentage 0-100. * @param {number} engagementTime - Engagement time in seconds, 0-4294967295. * @param {string[]} props - Custom string properties as a flat key=value list (max 32 entries, alternating key,value). - * @param {string} userId - Override user ID. Requires API-key auth with analytics.write scope. + * @param {string} userId - Override user ID. Pass an opaque ID, not personal data such as an email. Requires API-key auth with analytics.write scope. * @param {string} ip - Override IP address. Requires API-key auth with analytics.write scope. * @param {string} userAgent - Override user agent. Requires API-key auth with analytics.write scope. + * @param {boolean | null} interactive - Whether this event is a visitor interaction that ends a bounce. Set false for telemetry such as heartbeats or background syncs. Defaults to true for custom events and false for the automatic engagement, scroll and app lifecycle events. Ignored for views. * @throws {AppwriteException} * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. @@ -75,6 +78,7 @@ export class Analytics extends Service { userId?: string, ip?: string, userAgent?: string, + interactive?: boolean | null, ): Promise<{}>; createEvent( paramsOrFirst: @@ -92,6 +96,7 @@ export class Analytics extends Service { userId?: string; ip?: string; userAgent?: string; + interactive?: boolean | null; } | string, ...rest: [ @@ -107,6 +112,7 @@ export class Analytics extends Service { string?, string?, string?, + (boolean | null)?, ] ): Promise<{}> { let params: { @@ -123,6 +129,7 @@ export class Analytics extends Service { userId?: string; ip?: string; userAgent?: string; + interactive?: boolean | null; }; if ( @@ -144,6 +151,7 @@ export class Analytics extends Service { userId?: string; ip?: string; userAgent?: string; + interactive?: boolean | null; }; } else { params = { @@ -160,6 +168,7 @@ export class Analytics extends Service { userId: rest[9] as string, ip: rest[10] as string, userAgent: rest[11] as string, + interactive: rest[12] as boolean | null, }; } @@ -176,6 +185,7 @@ export class Analytics extends Service { const userId = params.userId; const ip = params.ip; const userAgent = params.userAgent; + const interactive = params.interactive; if (typeof propertyId === 'undefined' || propertyId === '') { throw new AppwriteException( @@ -245,6 +255,10 @@ export class Analytics extends Service { apiPayload['userAgent'] = userAgent; } + if (typeof interactive !== 'undefined') { + apiPayload['interactive'] = interactive; + } + const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call( 'post', diff --git a/src/services/avatars.ts b/src/services/avatars.ts index 0748b5ab..d045632a 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -126,6 +126,8 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -256,6 +258,8 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -327,6 +331,8 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -452,6 +458,8 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -559,6 +567,8 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -687,6 +697,8 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -861,6 +873,8 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -1313,6 +1327,8 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -1670,6 +1686,8 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -1739,6 +1757,8 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -1799,6 +1819,8 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -1835,6 +1857,8 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -1896,6 +1920,8 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -1949,6 +1975,8 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -2013,6 +2041,8 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -2100,6 +2130,8 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -2155,6 +2187,8 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -2313,6 +2347,8 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( diff --git a/src/services/realtime.ts b/src/services/realtime.ts index 07b5c902..3a93f9ed 100644 --- a/src/services/realtime.ts +++ b/src/services/realtime.ts @@ -210,10 +210,15 @@ export class Realtime { } // URL carries only the project; channels/queries are sent via the subscribe message. - const queryParams = `project=${projectId}`; + let queryParams = `project=${projectId}`; const jwt = this.client.config.jwt; + const environment = this.client.config.environment; + if (environment) { + queryParams += `&environment=${encodeURIComponent(environment)}`; + } + const endpoint = this.client.config.endpointRealtime !== '' ? this.client.config.endpointRealtime @@ -765,7 +770,12 @@ export class Realtime { const cookie = JSONbig.parse( window.localStorage.getItem('cookieFallback') ?? '{}', ); - session = cookie?.[`a_session_${this.client.config.project}`]; + // An environment's session is named by its project and environment IDs. + const { project, environment } = this.client.config; + const name = environment + ? `a_session_${project}_env_${environment}` + : `a_session_${project}`; + session = cookie?.[name]; } catch (error) { console.error('Failed to parse cookie fallback:', error); } diff --git a/src/services/storage.ts b/src/services/storage.ts index 510d682a..3ca8b60e 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -954,6 +954,8 @@ export class Storage extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -1219,6 +1221,8 @@ export class Storage extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -1318,6 +1322,8 @@ export class Storage extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -1371,6 +1377,8 @@ export class Storage extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -1488,6 +1496,8 @@ export class Storage extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries( @@ -1533,6 +1543,8 @@ export class Storage extends Service { const uri = new URL(this.client.config.endpoint + apiPath); apiPayload['project'] = this.client.config.project; + apiPayload['environment'] = this.client.config.environment; + apiPayload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(