-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from appunite/feature/analytics
[LD-136] Firebase analytics
- Loading branch information
Showing
16 changed files
with
530 additions
and
12 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 |
---|---|---|
|
@@ -34,6 +34,18 @@ jobs: | |
with: | ||
lfs: true | ||
|
||
- name: create-json | ||
id: create-json | ||
uses: jsdaniell/[email protected] | ||
with: | ||
name: "app/google-services.json" | ||
json: ${{ secrets.GOOGLE_SERVICES_JSON }} | ||
|
||
- name: Add google-services.json | ||
env: | ||
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }} | ||
run: echo "$GOOGLE_SERVICES_JSON" | base64 --decode > app/google-services.json | ||
|
||
- name: Prepare Android Environment | ||
uses: ./.github/actions/prepare-android-env | ||
|
||
|
@@ -81,6 +93,11 @@ jobs: | |
with: | ||
lfs: true | ||
|
||
- name: Add google-services.json | ||
env: | ||
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }} | ||
run: echo "$GOOGLE_SERVICES_JSON" | base64 --decode > app/google-services.json | ||
|
||
- name: LFS-warning - Prevent large files that are not LFS tracked | ||
uses: ppremk/[email protected] | ||
|
||
|
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,22 @@ | ||
/* | ||
* Copyright 2023 AppUnite S.A. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.appunite.loudius.analytics | ||
|
||
interface Event { | ||
val name: String | ||
val parameters: List<EventParameter> | ||
} |
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/appunite/loudius/analytics/EventParameter.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,24 @@ | ||
/* | ||
* Copyright 2023 AppUnite S.A. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.appunite.loudius.analytics | ||
|
||
sealed class EventParameter { | ||
abstract val name: kotlin.String | ||
|
||
data class String(override val name: kotlin.String, val value: kotlin.String) : EventParameter() | ||
data class Boolean(override val name: kotlin.String, val value: kotlin.Boolean) : EventParameter() | ||
} |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/com/appunite/loudius/analytics/EventParametersConverter.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,33 @@ | ||
/* | ||
* Copyright 2023 AppUnite S.A. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.appunite.loudius.analytics | ||
|
||
import android.os.Bundle | ||
|
||
class EventParametersConverter { | ||
|
||
fun convert(parameters: List<EventParameter>): Bundle { | ||
val bundle = Bundle() | ||
for (parameter in parameters) { | ||
when (parameter) { | ||
is EventParameter.String -> bundle.putString(parameter.name, parameter.value) | ||
is EventParameter.Boolean -> bundle.putBoolean(parameter.name, parameter.value) | ||
} | ||
} | ||
return bundle | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/com/appunite/loudius/analytics/EventTracker.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,34 @@ | ||
/* | ||
* Copyright 2023 AppUnite S.A. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.appunite.loudius.analytics | ||
|
||
import com.google.firebase.analytics.FirebaseAnalytics | ||
|
||
interface EventTracker { | ||
|
||
fun trackEvent(event: Event) | ||
} | ||
|
||
class FirebaseAnalyticsEventTracker( | ||
private val firebaseAnalytics: FirebaseAnalytics, | ||
private val converter: EventParametersConverter | ||
) : EventTracker { | ||
|
||
override fun trackEvent(event: Event) { | ||
firebaseAnalytics.logEvent(event.name, converter.convert(event.parameters)) | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
app/src/main/java/com/appunite/loudius/analytics/events/ReviewersEvents.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,91 @@ | ||
/* | ||
* Copyright 2023 AppUnite S.A. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.appunite.loudius.analytics.events | ||
|
||
import com.appunite.loudius.analytics.Event | ||
import com.appunite.loudius.analytics.EventParameter | ||
|
||
interface ReviewersEvent : Event | ||
|
||
object ClickNotifyEvent : ReviewersEvent { | ||
override val name: String = "button_click" | ||
override val parameters: List<EventParameter> = listOf( | ||
EventParameter.String("item_name", "notify") | ||
) | ||
} | ||
|
||
object NotifySuccessEvent : ReviewersEvent { | ||
override val name: String = "action_finished" | ||
override val parameters: List<EventParameter> = listOf( | ||
EventParameter.String("item_name", "notify"), | ||
EventParameter.Boolean("success", true) | ||
) | ||
} | ||
|
||
object NotifyFailureEvent : ReviewersEvent { | ||
override val name: String = "action_finished" | ||
override val parameters: List<EventParameter> = listOf( | ||
EventParameter.String("item_name", "notify"), | ||
EventParameter.Boolean("success", false) | ||
) | ||
} | ||
|
||
object RefreshDataEvent : ReviewersEvent { | ||
override val name: String = "action_start" | ||
override val parameters: List<EventParameter> = listOf( | ||
EventParameter.String("item_name", "refresh_reviewers_data") | ||
) | ||
} | ||
|
||
object RefreshDataSuccessEvent : ReviewersEvent { | ||
override val name: String = "action_finished" | ||
override val parameters: List<EventParameter> = listOf( | ||
EventParameter.String("item_name", "refresh_reviewers_data"), | ||
EventParameter.Boolean("success", true) | ||
) | ||
} | ||
|
||
object RefreshDataFailureEvent : ReviewersEvent { | ||
override val name: String = "action_finished" | ||
override val parameters: List<EventParameter> = listOf( | ||
EventParameter.String("item_name", "refresh_reviewers_data"), | ||
EventParameter.Boolean("success", false) | ||
) | ||
} | ||
|
||
object FetchDataEvent : ReviewersEvent { | ||
override val name: String = "action_start" | ||
override val parameters: List<EventParameter> = listOf( | ||
EventParameter.String("item_name", "fetch_reviewers_data") | ||
) | ||
} | ||
|
||
object FetchDataSuccessEvent : ReviewersEvent { | ||
override val name: String = "action_finished" | ||
override val parameters: List<EventParameter> = listOf( | ||
EventParameter.String("item_name", "fetch_reviewers_data"), | ||
EventParameter.Boolean("success", true) | ||
) | ||
} | ||
|
||
object FetchDataFailureEvent : ReviewersEvent { | ||
override val name: String = "action_finished" | ||
override val parameters: List<EventParameter> = listOf( | ||
EventParameter.String("item_name", "fetch_reviewers_data"), | ||
EventParameter.Boolean("success", false) | ||
) | ||
} |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/com/appunite/loudius/di/AnalyticsModule.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,33 @@ | ||
/* | ||
* Copyright 2023 AppUnite S.A. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.appunite.loudius.di | ||
|
||
import com.appunite.loudius.analytics.EventParametersConverter | ||
import com.appunite.loudius.analytics.EventTracker | ||
import com.appunite.loudius.analytics.FirebaseAnalyticsEventTracker | ||
import com.google.firebase.analytics.FirebaseAnalytics | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.dsl.module | ||
|
||
val analyticsModule = module { | ||
single<FirebaseAnalytics> { | ||
FirebaseAnalytics.getInstance(androidContext()) | ||
} | ||
single<EventTracker> { | ||
FirebaseAnalyticsEventTracker(get(), EventParametersConverter()) | ||
} | ||
} |
Oops, something went wrong.