@@ -34,7 +34,7 @@ import kotlinx.coroutines.launch
34
34
internal fun interface SessionFirelogPublisher {
35
35
36
36
/* * Asynchronously logs the session represented by the given [SessionDetails] to Firelog. */
37
- fun logSession (sessionDetails : SessionDetails )
37
+ fun mayLogSession (sessionDetails : SessionDetails )
38
38
39
39
companion object {
40
40
val instance: SessionFirelogPublisher
@@ -64,7 +64,7 @@ constructor(
64
64
* This will pull all the necessary information about the device in order to create a full
65
65
* [SessionEvent], and then upload that through the Firelog interface.
66
66
*/
67
- override fun logSession (sessionDetails : SessionDetails ) {
67
+ override fun mayLogSession (sessionDetails : SessionDetails ) {
68
68
CoroutineScope (backgroundDispatcher).launch {
69
69
if (shouldLogSession()) {
70
70
val installationId = InstallationId .create(firebaseInstallations)
@@ -94,13 +94,16 @@ constructor(
94
94
95
95
/* * Determines if the SDK should log a session to Firelog. */
96
96
private suspend fun shouldLogSession (): Boolean {
97
- Log .d(TAG , " Data Collection is enabled for at least one Subscriber" )
98
-
97
+ val subscribers = FirebaseSessionsDependencies .getRegisteredSubscribers()
98
+ if (subscribers.values.none { it.isDataCollectionEnabled }) {
99
+ Log .d(TAG , " Sessions SDK disabled through data collection. Events will not be sent." )
100
+ return false
101
+ }
99
102
// This will cause remote settings to be fetched if the cache is expired.
100
103
sessionSettings.updateSettings()
101
104
102
105
if (! sessionSettings.sessionsEnabled) {
103
- Log .d(TAG , " Sessions SDK disabled. Events will not be sent." )
106
+ Log .d(TAG , " Sessions SDK disabled through settings API . Events will not be sent." )
104
107
return false
105
108
}
106
109
0 commit comments