Skip to content

Commit

Permalink
implement google analytics addon in the sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
aminekarimii committed Apr 24, 2023
1 parent 4e52487 commit 877c965
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.gms.google-services'
}

android {
Expand Down Expand Up @@ -49,6 +50,7 @@ dependencies {
implementation project(path: ':addon:analytiks-mixpanel')
implementation project(path: ':addon:analytiks-segment')
implementation project(path: ':addon:analytiks-timber')
implementation project(path: ':addon:analytiks-googleanalytics')

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/com/logitanalyticsapp/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package com.logitanalyticsapp
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.analytiks.Analytiks
import com.analytiks.addon.googleanalytics.GoogleAnalyticsClient
import com.analytiks.addon.mixpanel.MixpanelAnalyticsClient
import com.analytiks.addon.timber.TimberLocalClient
import com.analytiks.core.CoreAddon
import com.analytiks.core.model.Param
import com.analytiks.core.model.UserProperty
import com.analytiks.segment.SegmentAnalyticsClient
import com.logitanalyticsapp.databinding.ActivityMainBinding

Expand All @@ -31,14 +33,20 @@ class MainActivity : AppCompatActivity() {
token = "YOUR_TOKEN",
flushIntervalInSeconds = 5,
trackApplicationLifecycleEvents = true,
)
),
GoogleAnalyticsClient(isAnalyticsCollectionEnabled = true)
)

analytiks = Analytiks(clients)

with(analytiks) {
initialize(this@MainActivity.applicationContext)
reset()
setUserProperty(
property = UserProperty(
propertyName = "prop1",
propertyValue = "test1"
)
)
}


Expand Down
16 changes: 15 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.


buildscript {
repositories {
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}

dependencies {
// Add the dependency for the Google services Gradle plugin
classpath 'com.google.gms:google-services:4.3.15'
}
}

plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
}
}

0 comments on commit 877c965

Please sign in to comment.