{"id":22743407,"url":"https://github.com/stape-io/stape-sgtm-android","last_synced_at":"2025-04-23T23:42:16.945Z","repository":{"id":212803466,"uuid":"703002685","full_name":"stape-io/stape-sgtm-android","owner":"stape-io","description":"Stape sGTM Android SDK","archived":false,"fork":false,"pushed_at":"2024-01-30T19:42:50.000Z","size":133,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-15T09:13:31.485Z","etag":null,"topics":["android","gtm","gtm-server-side","sdk","sdk-android","stape"],"latest_commit_sha":null,"homepage":"https://stape.io","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stape-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-10-10T12:14:59.000Z","updated_at":"2024-09-19T15:05:55.000Z","dependencies_parsed_at":"2023-12-17T18:38:59.932Z","dependency_job_id":null,"html_url":"https://github.com/stape-io/stape-sgtm-android","commit_stats":null,"previous_names":["stape-io/stape-sgtm-android"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stape-io%2Fstape-sgtm-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stape-io%2Fstape-sgtm-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stape-io%2Fstape-sgtm-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stape-io%2Fstape-sgtm-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stape-io","download_url":"https://codeload.github.com/stape-io/stape-sgtm-android/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250535035,"owners_count":21446503,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","gtm","gtm-server-side","sdk","sdk-android","stape"],"created_at":"2024-12-11T01:22:35.845Z","updated_at":"2025-04-23T23:42:16.563Z","avatar_url":"https://github.com/stape-io.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stape sGTM Android SDK\n\n## Overview\n\nStape sGTM SDK implements two main functional parts.\n\nFirst is a simple event sending which allows to compose an event and send it to Stape Data Client.\n\nSDK API provides a response from the Data Client mapped to a simple model that contains serialized response fields.\n\nSecond is a mechanism that tracks events dispatched by the Firebase event SDK.\n\nIt hooks Firebase event dispatch and maps Firebase event to Stape Data Client.\n\nAfter that, it sends it as an ordinary event.\n\n## Usage\n\n### Download\n\n[![GitHub release](https://img.shields.io/github/release/stape-io/stape-sgtm-android.svg)](https://central.sonatype.com/artifact/io.stape/android-sgtm/overview)\n\nAdd the dependency to your build.gradle file:\n```kotlin\nimplementation(\"io.stape:android-sgtm:1.0\")\n```\nMake use you using the latest version of Stape SDK. \n\n### Initialization\n\nTo use the Stape SDK, you need to create an instance of the `Stape` class.\n\nThe instance can be created using the `Stape.withOption` method.\n\nThe method takes an `Options` object as a parameter.\n\n```kotlin\nimport io.stape.sgtm.Options\nimport io.stape.sgtm.Stape\n\nval stape = Stape.withOption(Options(\"yourdomain.com\"))\n```\n\nThe `Options` object contains data for correct SDK initialization and requires only one\nparameter - `domain`.\n\nThe `domain` parameter is a domain name of your sGTM container instance.\n\nDo not include `https://` or `http://` schemas.\n\nPlease do not override the default `Options` values if you are not sure what you are doing.\n\n### Sending events\n\nAfter the Stape instance is created, you can send events to the Stape Data Client.\n\nStape SDK allows sending data in a couple of ways:\n\n- Using a Map\u003cString, Any\u003e collection;\n- Using an EventData class.\n\nThese two ways are equivalent, and you can use any of them:\n\n```kotlin\nstape.sendEvent(\"event1\", mapOf(\"userId\" to \"cdd1eac3e254\", \"language\" to \"en\"))\nstape.sendEvent(\"event2\", EventData(userId = \"cdd1eac3e254\", language = \"en\"))\n```\n\nPlease extend the `EventData` class if you need to send any other data.\n\n### Tracking Firebase events\n\nStape SDK allows to decorate Firebase Analytics instance and deliver all sent events to the Stape Data Client as well.\n\nFor this purpose you need to use `FirebaseAnalyticsAdapter` class.\n\n```kotlin\nimport android.os.Bundle\nimport com.google.firebase.analytics.FirebaseAnalytics\nimport io.stape.sgtm.firebase.FirebaseAnalyticsAdapter\nimport io.stape.sgtm.Options\nimport io.stape.sgtm.Stape\n\nprivate val stape = Stape.withOption(Options(\"yourdomain.com\"))\nprivate val firebaseAnalytics = FirebaseAnalytics.getInstance(this)\nval analytics = FirebaseAnalyticsAdapter(stape, firebaseAnalytics)\n\n// Using Bundle as a parameter\nanalytics.logEvent(\"event3\", Bundle().apply {\n    putString(\"userId\", \"cdd1eac3e254\")\n    putString(\"language\", \"en\")\n})\n\n// Using ParamBuilder as a parameter\nanalytics.logEvent(\"event4\") {\n    param(\"userId\", \"cdd1eac3e254\")\n    param(\"language\", \"en\")\n}\n```\n\nThe `FirebaseAnalyticsAdapter` provides absolutely the same API as the Firebase Analytics instance.\n\nIt means that you can replace the provided types without a lot of changes.\n\n## Trying sample app\n\nIf you desire to try the sample app, please follow the next steps:\n\n1. Clone the repository;\n2. Open the project in Android Studio;\n3. Create a Firebase project with enabled Analytics;\n4. Generate your own `google-services.json` file and put it into the `app` folder;\n5. Create `stape.properties` file in the `app` folder and put your Stape domain name into it as a\n   value for `stape.url` property. Example: ```server.host=yourdomain.com```;\n6. Rebuild the app.\n\n## License\n\nSee [LICENSE](LICENSE) for more details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstape-io%2Fstape-sgtm-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstape-io%2Fstape-sgtm-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstape-io%2Fstape-sgtm-android/lists"}