-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1143ff0
commit 926945e
Showing
17 changed files
with
361 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
/build |
This file contains 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,35 @@ | ||
plugins { | ||
id 'com.android.library' | ||
id 'org.jetbrains.kotlin.android' | ||
} | ||
|
||
android { | ||
namespace 'com.analytiks.addon.amplitude' | ||
compileSdk 33 | ||
|
||
defaultConfig { | ||
minSdk 21 | ||
targetSdk 33 | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation project(':analytiks-core') | ||
implementation 'com.amplitude:analytics-android:1.8.2' | ||
} |
This file contains 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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
This file contains 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,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> | ||
|
||
</manifest> |
72 changes: 72 additions & 0 deletions
72
addon/analytiks-amplitude/src/main/java/com/analytiks/addon/amplitude/AmplitudeClient.kt
This file contains 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,72 @@ | ||
package com.analytiks.addon.amplitude | ||
|
||
import android.content.Context | ||
import com.amplitude.android.Amplitude | ||
import com.amplitude.android.Configuration | ||
import com.amplitude.android.events.Identify | ||
import com.amplitude.common.Logger | ||
import com.analytiks.core.AnalyticsDataTransmitterExtension | ||
import com.analytiks.core.CoreAddon | ||
import com.analytiks.core.EventsExtension | ||
import com.analytiks.core.UserProfileExtension | ||
import com.analytiks.core.formatters.MapFormatStrategy | ||
import com.analytiks.core.model.Param | ||
import com.analytiks.core.model.UserProperty | ||
|
||
class AmplitudeClient( | ||
private val token: String, | ||
private val serverGeoZone: ServerGeoZone = ServerGeoZone.EU, | ||
private val optOut: Boolean = false, | ||
private val minTimeBetweenSessionsMillis: Long = 10000 | ||
) : CoreAddon, EventsExtension, UserProfileExtension, AnalyticsDataTransmitterExtension { | ||
private lateinit var amplitude: Amplitude | ||
private val mapStrategy by lazy { | ||
MapFormatStrategy() | ||
} | ||
|
||
override fun initialize(context: Context) { | ||
amplitude = Amplitude( | ||
Configuration( | ||
apiKey = token, | ||
context = context, | ||
serverZone = serverGeoZone.serverZone, | ||
optOut = optOut, | ||
minTimeBetweenSessionsMillis = minTimeBetweenSessionsMillis | ||
) | ||
) | ||
|
||
amplitude.logger.logMode = Logger.LogMode.DEBUG | ||
} | ||
|
||
override fun reset() { | ||
amplitude.reset() | ||
} | ||
|
||
override fun logEvent(name: String) { | ||
amplitude.track(name) | ||
} | ||
|
||
override fun logEvent(name: String, vararg properties: Param) { | ||
amplitude.track(name, mapStrategy(*properties)) | ||
} | ||
|
||
override fun identify(userId: String) { | ||
amplitude.setUserId(userId) | ||
} | ||
|
||
override fun setUserProperty(property: UserProperty) { | ||
val identify = Identify() | ||
property.propertyValue?.let { | ||
identify.set( | ||
property.propertyName, | ||
it | ||
) | ||
} | ||
amplitude.identify(identify) | ||
} | ||
|
||
override fun setUserPropertyOnce(property: UserProperty) = Unit | ||
override fun pushAll() { | ||
amplitude.flush() | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
addon/analytiks-amplitude/src/main/java/com/analytiks/addon/amplitude/ServerGeoZone.kt
This file contains 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,8 @@ | ||
package com.analytiks.addon.amplitude | ||
|
||
import com.amplitude.core.ServerZone | ||
|
||
enum class ServerGeoZone(val serverZone: ServerZone) { | ||
US(ServerZone.US), | ||
EU(ServerZone.EU) | ||
} |
This file contains 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,31 @@ | ||
|
||
<h1 align="center">Google/Firebase Add-on implementation</h1></br> | ||
<p align="center"> | ||
<img src="https://github.com/aminekarimii/analytiks/assets/20410115/c16c3495-bb8e-4002-8cfe-bb68e3f82761" width="20%" /> | ||
</p> | ||
|
||
## Configuration | ||
| Field Name | Description | Default Value | | ||
|------------------------------|----------------------------------------------------|------------------| | ||
| isAnalyticsCollectionEnabled | Indicates whether analytics collection is enabled. | true | | ||
| sessionTimeoutDuration | Duration of the session timeout in milliseconds. | null | | ||
| defaultEventParameters | Default event parameters for tracking events. | null | | ||
|
||
Note: The default values mentioned above can be overridden by providing custom values during initialization. | ||
## Create Add-on | ||
1. Download Google analytics add-on: | ||
```gradle | ||
implementation 'com.github.aminekarimii.analytiks:analytiks-googleanalytics:0.1.0-beta' | ||
``` | ||
2. Create your own client | ||
``` kotlin | ||
val googleAnalytics = GoogleAnalyticsClient( | ||
isAnalyticsCollectionEnabled = true, | ||
sessionTimeoutDuration = 300L, | ||
defaultEventParameters = null | ||
) | ||
``` | ||
|
||
### Check the official documentation for more details: | ||
➡️ [Official firebase analytics](https://firebase.google.com/docs/analytics/get-started?platform=android) | ||
|
2 changes: 1 addition & 1 deletion
2
...s/addon/mixpanel/GoogleAnalyticsClient.kt → .../googleanalytics/GoogleAnalyticsClient.kt
This file contains 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 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,33 @@ | ||
|
||
<h1 align="center">Mixpanel Add-on implementation</h1></br> | ||
<p align="center"> | ||
<img src="https://github.com/aminekarimii/analytiks/assets/20410115/f5b648d4-529a-4309-8e9d-2409b47457da" width="20%" /> | ||
</p> | ||
|
||
## Configuration | ||
| Field Name | Description | Default Value | | ||
|-----------------------|---------------------------------------------------------------------|----------------------| | ||
| token | The token used for tracking events. | - | | ||
| optOutTrackingDefault | Determines whether tracking is enabled by default for new users. | false | | ||
| superProperties | Additional properties to be included with every tracked event. | null | | ||
| instanceName | A custom name for the analytics instance (optional). | null | | ||
| trackAutomaticEvents | Controls automatic event tracking (e.g., screen views, app opens). | true | | ||
|
||
Note: The default values mentioned above can be overridden by providing custom values during initialization. | ||
## Create Add-on | ||
1. Download Mixpanel add-on: | ||
```gradle | ||
implementation 'com.github.aminekarimii.analytiks:analytiks-mixpanel:0.1.0-beta' | ||
``` | ||
2. Create your own mixpanel client | ||
``` kotlin | ||
val mixpanel = MixpanelAnalyticsClient( | ||
token: "YOUR_TOKEN", | ||
optOutTrackingDefault: = false, | ||
trackAutomaticEvents = true | ||
) | ||
``` | ||
|
||
### Check the official documentation for more details: | ||
➡️ [Official documentation](https://developer.mixpanel.com/docs/android) | ||
|
This file contains 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,40 @@ | ||
<h1 align="center">Segment Add-on implementation</h1></br> | ||
<p align="center"> | ||
<img src="https://github.com/aminekarimii/analytiks/assets/20410115/6f8072f2-ca92-43a9-a974-dd0627c554c3" width="20%" /> | ||
</p> | ||
|
||
## Configuration | ||
| Field Name | Description | Default Value | | ||
|---------------------------------|---------------------------------------------------------------------------------|---------------| | ||
| token | The token used for tracking events. | - | | ||
| collectDeviceId | Determines whether to collect the device ID. | true | | ||
| trackApplicationLifecycleEvents | Controls automatic tracking of application lifecycle events. | false | | ||
| useLifecycleObserver | Determines whether to use the Lifecycle Observer for event tracking. | false | | ||
| flushIntervalInSeconds | The time interval (in seconds) for flushing queued events to the server. | null | | ||
| flushAt | The maximum number of events to be queued before flushing to the server. | null | | ||
| tag | A custom tag to identify the analytics instance (optional). | null | | ||
|
||
Note: The default values mentioned above can be overridden by providing custom values during initialization. | ||
|
||
## Create Add-on | ||
1. Download Segment add-on: | ||
```gradle | ||
implementation 'com.github.aminekarimii.analytiks:analytiks-segment:0.1.0-beta' | ||
``` | ||
2. Create your own Segment client: | ||
``` kotlin | ||
val segment = SegmentAnalyticsClient( | ||
token = "YOUR_TOKEN", | ||
collectDeviceId = true, | ||
trackApplicationLifecycleEvents = false, | ||
useLifecycleObserver = false, | ||
flushIntervalInSeconds = null, | ||
flushAt = null, | ||
tag = null | ||
) | ||
``` | ||
|
||
### Check the official documentation for more details: | ||
➡️ [Official documentation](https://segment.com/docs/sources/mobile/android/) | ||
|
||
Feel free to customize the content and formatting as per your preferences. |
This file contains 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,11 @@ | ||
# Core Analytiks | ||
## Create your custom Addon | ||
1. Create a new kotlin file, and create a new class | ||
2. Implement ```CoreAddon``` interface | ||
3. Extend your analytics addon with the available features: | ||
|
||
| Extention | Features | | ||
| --------- | ------------- | | ||
| **EventsExtension** | Provides support for custom event tracking via ```logEvent``` method. | | ||
| **UserProfileExtension** | Optional extension interface that can be implemented by analytics clients to provide support for user profile tracking. it provides three extensions: ```identify```, ```setUserProperty```, and ```setUserPropertyOnce```. | ||
| **AnalyticsDataTransmitterExtension** | Interface for handling the communication with the analytics server. There is one single method right now, ```pushAll``` | |
This file contains 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 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 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,40 @@ | ||
{ | ||
"project_info": { | ||
"project_number": "114883754482", | ||
"firebase_url": "URL-EXAMPLE", | ||
"project_id": "heyamine-fa897", | ||
"storage_bucket": "heyamine-fa897.appspot.com" | ||
}, | ||
"client": [ | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:114883754482:android:bbaf9192512ef89380936b", | ||
"android_client_info": { | ||
"package_name": "com.logitanalyticsapp" | ||
} | ||
}, | ||
"oauth_client": [ | ||
{ | ||
"client_id": "114883754482-hnt03ja1rmhjk6ipeh3k99ejl530anu6.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
], | ||
"api_key": [ | ||
{ | ||
"current_key": "API-KEY" | ||
} | ||
], | ||
"services": { | ||
"appinvite_service": { | ||
"other_platform_oauth_client": [ | ||
{ | ||
"client_id": "114883754482-71oilk5hlrltfk6c9kjg74acqmskk4s9.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"configuration_version": "1" | ||
} |
35 changes: 35 additions & 0 deletions
35
app/src/main/java/com/logitanalyticsapp/CustomAnalytiksAddon.kt
This file contains 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,35 @@ | ||
package com.logitanalyticsapp | ||
|
||
import android.content.Context | ||
import android.util.Log | ||
import com.analytiks.core.AnalyticsDataTransmitterExtension | ||
import com.analytiks.core.CoreAddon | ||
import com.analytiks.core.EventsExtension | ||
import com.analytiks.core.UserProfileExtension | ||
import com.analytiks.core.model.Param | ||
import com.analytiks.core.model.UserProperty | ||
|
||
class CustomAnalytiksAddon : CoreAddon, | ||
EventsExtension, | ||
UserProfileExtension, | ||
AnalyticsDataTransmitterExtension { | ||
override fun initialize(context: Context) { | ||
Log.d("GlobalTag", "CustomAnalytiksAddon has been initialized"); | ||
} | ||
|
||
override fun reset() { | ||
Log.d("GlobalTag", "CustomAnalytiksAddon has been reset"); | ||
} | ||
|
||
override fun logEvent(name: String) = Unit | ||
|
||
override fun logEvent(name: String, vararg properties: Param) = Unit | ||
|
||
override fun identify(userId: String) = Unit | ||
|
||
override fun setUserProperty(property: UserProperty) = Unit | ||
|
||
override fun setUserPropertyOnce(property: UserProperty) = Unit | ||
|
||
override fun pushAll() = Unit | ||
} |
Oops, something went wrong.