-
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.
- Loading branch information
1 parent
eebee47
commit 8787e54
Showing
71 changed files
with
593 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,19 @@ | ||
plugins { | ||
alias(libs.plugins.android.library) | ||
} | ||
|
||
android { | ||
namespace 'com.oscarliang.spotifyclone.core.analytics' | ||
compileSdk 34 | ||
defaultConfig { | ||
minSdk 21 | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation platform(libs.firebase.bom) | ||
implementation libs.firebase.analytics | ||
implementation libs.dagger.core | ||
|
||
annotationProcessor libs.dagger.compiler | ||
} |
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,2 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest /> |
8 changes: 8 additions & 0 deletions
8
core/analytics/src/main/java/com/oscarliang/spotifyclone/core/analytics/AnalyticsEvent.java
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.oscarliang.spotifyclone.core.analytics; | ||
|
||
public class AnalyticsEvent { | ||
|
||
public static final String SCREEN_VIEW = "screen_view"; | ||
public static final String MUSIC_PLAY = "music_play"; | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
core/analytics/src/main/java/com/oscarliang/spotifyclone/core/analytics/AnalyticsLogger.java
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,9 @@ | ||
package com.oscarliang.spotifyclone.core.analytics; | ||
|
||
import java.util.List; | ||
|
||
public interface AnalyticsLogger { | ||
|
||
void logEvent(String event, List<AnalyticsParam> params); | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
core/analytics/src/main/java/com/oscarliang/spotifyclone/core/analytics/AnalyticsParam.java
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,48 @@ | ||
package com.oscarliang.spotifyclone.core.analytics; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import java.util.Objects; | ||
|
||
public class AnalyticsParam { | ||
|
||
public static final String SCREEN_NAME = "screen_name"; | ||
public static final String MUSIC_ID = "music_id"; | ||
public static final String MUSIC_TITLE = "music_title"; | ||
|
||
public String key; | ||
public String value; | ||
|
||
public AnalyticsParam(String key, String value) { | ||
this.key = key; | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
AnalyticsParam param = (AnalyticsParam) o; | ||
return Objects.equals(key, param.key) | ||
&& Objects.equals(value, param.value); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(key, value); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String toString() { | ||
return "AnalyticsParam{" + | ||
"key='" + key + '\'' + | ||
", value='" + value + '\'' + | ||
'}'; | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...ics/src/main/java/com/oscarliang/spotifyclone/core/analytics/FirebaseAnalyticsLogger.java
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,29 @@ | ||
package com.oscarliang.spotifyclone.core.analytics; | ||
|
||
import android.os.Bundle; | ||
|
||
import com.google.firebase.analytics.FirebaseAnalytics; | ||
|
||
import java.util.List; | ||
|
||
import javax.inject.Inject; | ||
|
||
public class FirebaseAnalyticsLogger implements AnalyticsLogger { | ||
|
||
private final FirebaseAnalytics analytics; | ||
|
||
@Inject | ||
public FirebaseAnalyticsLogger(FirebaseAnalytics analytics) { | ||
this.analytics = analytics; | ||
} | ||
|
||
@Override | ||
public void logEvent(String event, List<AnalyticsParam> params) { | ||
Bundle bundle = new Bundle(); | ||
for (AnalyticsParam param : params) { | ||
bundle.putString(param.key, param.value); | ||
} | ||
analytics.logEvent(event, bundle); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...alytics/src/main/java/com/oscarliang/spotifyclone/core/analytics/NoOpAnalyticsLogger.java
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,17 @@ | ||
package com.oscarliang.spotifyclone.core.analytics; | ||
|
||
import java.util.List; | ||
|
||
import javax.inject.Inject; | ||
|
||
public class NoOpAnalyticsLogger implements AnalyticsLogger { | ||
|
||
@Inject | ||
public NoOpAnalyticsLogger() { | ||
} | ||
|
||
@Override | ||
public void logEvent(String event, List<AnalyticsParam> params) { | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...alytics/src/main/java/com/oscarliang/spotifyclone/core/analytics/StubAnalyticsLogger.java
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,23 @@ | ||
package com.oscarliang.spotifyclone.core.analytics; | ||
|
||
import android.util.Log; | ||
|
||
import java.util.List; | ||
|
||
import javax.inject.Inject; | ||
|
||
public class StubAnalyticsLogger implements AnalyticsLogger { | ||
|
||
@Inject | ||
public StubAnalyticsLogger() { | ||
} | ||
|
||
@Override | ||
public void logEvent(String event, List<AnalyticsParam> params) { | ||
Log.d( | ||
"StubAnalyticsLogger", | ||
"Analytics event: " + event + ", params: " + params.toString() | ||
); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...nalytics/src/main/java/com/oscarliang/spotifyclone/core/analytics/di/AnalyticsModule.java
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,20 @@ | ||
package com.oscarliang.spotifyclone.core.analytics.di; | ||
|
||
import com.oscarliang.spotifyclone.core.analytics.AnalyticsLogger; | ||
import com.oscarliang.spotifyclone.core.analytics.FirebaseAnalyticsLogger; | ||
|
||
import javax.inject.Singleton; | ||
|
||
import dagger.Binds; | ||
import dagger.Module; | ||
|
||
@Module(includes = FirebaseModule.class) | ||
public abstract class AnalyticsModule { | ||
|
||
@Singleton | ||
@Binds | ||
public abstract AnalyticsLogger bindAnalyticsLogger( | ||
FirebaseAnalyticsLogger analyticsLogger | ||
); | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...analytics/src/main/java/com/oscarliang/spotifyclone/core/analytics/di/FirebaseModule.java
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,25 @@ | ||
package com.oscarliang.spotifyclone.core.analytics.di; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.app.Application; | ||
|
||
import com.google.firebase.analytics.FirebaseAnalytics; | ||
|
||
import javax.inject.Singleton; | ||
|
||
import dagger.Module; | ||
import dagger.Provides; | ||
|
||
@Module | ||
public class FirebaseModule { | ||
|
||
@SuppressLint("MissingPermission") | ||
@Singleton | ||
@Provides | ||
public FirebaseAnalytics provideFirebaseAnalytics( | ||
Application application | ||
) { | ||
return FirebaseAnalytics.getInstance(application); | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.