Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
aminekarimii committed Jul 16, 2023
1 parent 1143ff0 commit 926945e
Show file tree
Hide file tree
Showing 17 changed files with 361 additions and 14 deletions.
1 change: 1 addition & 0 deletions addon/analytiks-amplitude/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
35 changes: 35 additions & 0 deletions addon/analytiks-amplitude/build.gradle
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'
}
21 changes: 21 additions & 0 deletions addon/analytiks-amplitude/proguard-rules.pro
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
7 changes: 7 additions & 0 deletions addon/analytiks-amplitude/src/main/AndroidManifest.xml
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>
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()
}
}
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)
}
31 changes: 31 additions & 0 deletions addon/analytiks-googleanalytics/README.md
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)

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.analytiks.addon.mixpanel
package com.analytiks.addon.googleanalytics

import android.content.Context
import android.os.Bundle
Expand Down
33 changes: 33 additions & 0 deletions addon/analytiks-mixpanel/README.md
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)

40 changes: 40 additions & 0 deletions addon/analytiks-segment/README.md
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.
11 changes: 11 additions & 0 deletions analytiks-core/README.md
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``` |
4 changes: 1 addition & 3 deletions analytiks-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ android {

dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
api 'androidx.core:core-ktx:1.7.0'

testImplementation 'junit:junit:4.13.2'
testImplementation 'org.json:json:20201115'
Expand Down
12 changes: 5 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,12 @@ dependencies {
implementation 'io.github.aminekarimii:analytiks:1.0.0'
implementation 'io.github.aminekarimii:analytiks-core:1.0.0'

implementation 'io.github.aminekarimii:analytiks-addon-googleanalytics:1.0.0'
implementation 'io.github.aminekarimii:analytiks-addon-mixpanel:1.0.0'
implementation 'io.github.aminekarimii:analytiks-addon-timber:1.0.0'
implementation 'io.github.aminekarimii:analytiks-addon-segment:1.0.0'

implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
// implementation project(':analytiks')
// implementation project(path: ':analytiks-core')
// implementation project(path: ':addon:analytiks-mixpanel')
// implementation project(path: ':addon:analytiks-segment')
// implementation project(path: ':addon:analytiks-timber')
implementation project(path: ':addon:analytiks-googleanalytics')
implementation project(path: ':addon:analytiks-amplitude')

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
Expand Down
40 changes: 40 additions & 0 deletions app/google-services.json
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 app/src/main/java/com/logitanalyticsapp/CustomAnalytiksAddon.kt
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
}
Loading

0 comments on commit 926945e

Please sign in to comment.