Repository navigation
feat: SDK update for version 29.2.0 #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| ```java | ||
| import android.util.Log; | ||
|
|
||
| import io.appwrite.Client; | ||
| import io.appwrite.coroutines.CoroutineCallback; | ||
| import io.appwrite.services.Analytics; | ||
|
|
||
| Client client = new Client(context) | ||
| .setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint | ||
| .setProject("<YOUR_PROJECT_ID>"); // Your project ID | ||
|
|
||
| Analytics analytics = new Analytics(client); | ||
|
|
||
| analytics.createEvent( | ||
| "<PROPERTY_ID>", // propertyId | ||
| "<NAME>", // name | ||
| "https://example.com", // url | ||
| "<DOMAIN>", // domain (optional) | ||
| "<REFERRER>", // referrer (optional) | ||
| 0L, // screenWidth (optional) | ||
| "<SESSION_HASH>", // sessionHash (optional) | ||
| 0L, // scrollDepth (optional) | ||
| 0L, // engagementTime (optional) | ||
| List.of(), // props (optional) | ||
| "<USER_ID>", // userId (optional) | ||
| "<IP>", // ip (optional) | ||
| "<USER_AGENT>", // userAgent (optional) | ||
| new CoroutineCallback<>((result, error) -> { | ||
| if (error != null) { | ||
| error.printStackTrace(); | ||
| return; | ||
| } | ||
|
|
||
| Log.d("Appwrite", result.toString()); | ||
| }) | ||
| ); | ||
|
|
||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| ```kotlin | ||
| import io.appwrite.Client | ||
| import io.appwrite.coroutines.CoroutineCallback | ||
| import io.appwrite.services.Analytics | ||
|
|
||
| val client = Client(context) | ||
| .setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint | ||
| .setProject("<YOUR_PROJECT_ID>") // Your project ID | ||
|
|
||
| val analytics = Analytics(client) | ||
|
|
||
| val result = analytics.createEvent( | ||
| 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 = listOf(), // (optional) | ||
| userId = "<USER_ID>", // (optional) | ||
| ip = "<IP>", // (optional) | ||
| userAgent = "<USER_AGENT>", // (optional) | ||
| ) | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| package io.appwrite.services | ||
|
|
||
| import android.net.Uri | ||
| import io.appwrite.Client | ||
| import io.appwrite.Service | ||
| import io.appwrite.exceptions.AppwriteException | ||
| import io.appwrite.extensions.classOf | ||
| import io.appwrite.models.* | ||
| import okhttp3.Cookie | ||
| import java.io.File | ||
|
|
||
| /** | ||
| * | ||
| */ | ||
| class Analytics(client: Client) : Service(client) { | ||
| /** | ||
| * Send a tracking event from a browser, native app, or server-side SDK. | ||
| * | ||
| * @param propertyId Analytics property ID. | ||
| * @param name Event name. "pageview" is just a conventional event name; events are not modeled specially. | ||
| * @param url Full page URL or screen identifier. | ||
| * @param domain Hostname (e.g. example.com). | ||
| * @param referrer Referrer URL. | ||
| * @param screenWidth Viewport width in CSS pixels. | ||
| * @param sessionHash Optional session hash (provided by SDK). | ||
| * @param scrollDepth Scroll depth percentage 0-100. | ||
| * @param engagementTime Engagement time in seconds, 0-4294967295. | ||
| * @param props Custom string properties as a flat key=value list (max 32 entries, alternating key,value). | ||
| * @param userId Override user ID. Requires API-key auth with analytics.write scope. | ||
| * @param ip Override IP address. Requires API-key auth with analytics.write scope. | ||
| * @param userAgent Override user agent. Requires API-key auth with analytics.write scope. | ||
| * @return [Any] | ||
| */ | ||
| @JvmOverloads | ||
| suspend fun createEvent( | ||
| propertyId: String, | ||
| name: String, | ||
| url: String, | ||
| domain: String? = null, | ||
| referrer: String? = null, | ||
| screenWidth: Long? = null, | ||
| sessionHash: String? = null, | ||
| scrollDepth: Long? = null, | ||
| engagementTime: Long? = null, | ||
| props: List<String>? = null, | ||
| userId: String? = null, | ||
| ip: String? = null, | ||
| userAgent: String? = null, | ||
| ): Any { | ||
| if (propertyId.isEmpty()) { | ||
| throw AppwriteException("Missing required parameter: \"propertyId\"") | ||
| } | ||
| val apiPath = ("/analytics/properties/{propertyId}/events" | ||
| .replace("{propertyId}", propertyId) | ||
| ) | ||
| val apiParams = mutableMapOf<String, Any?>( | ||
| "name" to name, | ||
| "url" to url, | ||
| "domain" to domain, | ||
| "referrer" to referrer, | ||
| "screenWidth" to screenWidth, | ||
| "sessionHash" to sessionHash, | ||
| "scrollDepth" to scrollDepth, | ||
| "engagementTime" to engagementTime, | ||
| "props" to props, | ||
| "userId" to userId, | ||
| "ip" to ip, | ||
| "userAgent" to userAgent, | ||
| ) | ||
| val apiHeaders = mutableMapOf<String, String>( | ||
| "X-Appwrite-Project" to client.config["project"].orEmpty(), | ||
| "content-type" to "application/json", | ||
| "accept" to "application/json", | ||
| ) | ||
| return client.call( | ||
| "POST", | ||
| apiPath, | ||
| apiHeaders, | ||
| apiParams, | ||
| responseType = Any::class.java, | ||
| ) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.