Skip to content

Commit ac815f7

Browse files
committed
[Ft]:[DEVX-8764]:Clickstream Health refactor
1 parent 8582635 commit ac815f7

File tree

106 files changed

+2125
-2188
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+2125
-2188
lines changed

app/src/main/java/com/clickstream/app/App.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import clickstream.connection.CSConnectionEvent
99
import clickstream.connection.CSSocketConnectionListener
1010
import clickstream.eventvisualiser.CSEventVisualiserListener
1111
import clickstream.eventvisualiser.ui.CSEventVisualiserUI
12-
import clickstream.health.DefaultCSHealthGateway
1312
import clickstream.logger.CSLogLevel
1413
import com.clickstream.app.config.csConfig
1514
import com.clickstream.app.config.csInfo

app/src/main/java/com/clickstream/app/config/CSInfo.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import clickstream.api.CSSessionInfo
77
import clickstream.api.CSUserInfo
88

99
fun csInfo() = CSInfo(
10-
appInfo = CSAppInfo(appVersion = "1.1.0"),
10+
appInfo = CSAppInfo(appVersion = "2.1.0"),
1111
locationInfo = CSLocationInfo(
1212
latitude = -6.1753871,
1313
longitude = 106.8249641,

app/src/main/java/com/clickstream/app/config/DefaultCSConfig.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import clickstream.config.CSConfig
44
import clickstream.config.CSEventProcessorConfig
55
import clickstream.config.CSEventSchedulerConfig
66
import clickstream.config.CSNetworkConfig
7-
import clickstream.health.constant.CSTrackedVia
87
import clickstream.health.model.CSHealthEventConfig
98
import com.clickstream.app.helper.load
109

@@ -28,6 +27,5 @@ fun csConfig(
2827
"X-UniqueId" to deviceId
2928
)
3029
),
31-
healthEventConfig = CSHealthEventConfig.default(trackedVia = CSTrackedVia.Both)
3230
)
3331
}
Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,50 @@
11
package com.clickstream.app.config
22

3+
import DefaultCSHealthGateway
34
import android.content.Context
4-
import clickstream.health.DefaultCSHealthGateway
5-
import clickstream.health.constant.CSTrackedVia
6-
import clickstream.health.intermediate.CSEventHealthListener
5+
import android.util.Log
76
import clickstream.health.intermediate.CSHealthEventLoggerListener
8-
import clickstream.health.model.CSEventHealth
9-
import clickstream.health.model.CSHealthEvent
7+
import clickstream.health.intermediate.CSMemoryStatusProvider
108
import clickstream.health.model.CSHealthEventConfig
119
import clickstream.health.time.CSHealthTimeStampGenerator
12-
import clickstream.lifecycle.impl.DefaultCSAppLifeCycleObserver
1310
import clickstream.logger.CSLogLevel
1411
import clickstream.logger.CSLogger
1512

1613

17-
fun getHealthGateway(context: Context) =
18-
DefaultCSHealthGateway.factory(
19-
appVersion = "1.0.0",
20-
sessionId = "abc",
21-
context = context,
22-
healthEventConfig = CSHealthEventConfig(
23-
"1.0.0",
24-
listOf(), CSTrackedVia.Both
25-
),
26-
csInfo = csInfo(),
27-
logger = CSLogger(CSLogLevel.DEBUG),
28-
healthEventLogger = healthEventLogger(),
29-
eventHealthListener = healthEventListener(),
30-
timeStampGenerator = timeStampGenerator(),
31-
appLifeCycle = DefaultCSAppLifeCycleObserver(CSLogger(CSLogLevel.DEBUG))
32-
)
14+
fun getHealthGateway(context: Context) = DefaultCSHealthGateway(
15+
context = context,
16+
csInfo = csInfo(),
17+
logger = CSLogger(CSLogLevel.DEBUG),
18+
timeStampGenerator = timeStampGenerator(),
19+
csMemoryStatusProvider = memoryStatusProvider(),
20+
csHealthEventConfig = healthConfig(),
21+
csHealthEventLoggerListener = healthEventLogger()
22+
)
3323

3424

3525
fun healthEventLogger() = object : CSHealthEventLoggerListener {
36-
override fun logEvent(eventName: String, healthEvent: CSHealthEvent) {
37-
26+
override fun logEvent(eventName: String, healthData: HashMap<String, Any>) {
27+
Log.d("CS External Logger", "$eventName: $healthData")
3828
}
39-
}
4029

41-
fun healthEventListener() = object : CSEventHealthListener {
42-
override fun onEventCreated(healthEvent: CSEventHealth) {
30+
}
4331

32+
fun memoryStatusProvider() = object : CSMemoryStatusProvider {
33+
override fun isLowMemory(): Boolean {
34+
return false
4435
}
4536
}
4637

4738
fun timeStampGenerator() = object : CSHealthTimeStampGenerator {
4839
override fun getTimeStamp(): Long {
4940
return System.currentTimeMillis()
5041
}
42+
}
5143

52-
}
44+
fun healthConfig() =
45+
CSHealthEventConfig(
46+
minTrackedVersion = "1.1.0",
47+
randomUserIdRemainder = (0..9).toList(),
48+
destination = listOf("CS", "CT"),
49+
verbosityLevel = "minimum"
50+
)

clickstream-health-metrics-api/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ android {
3535
dependencies {
3636
// Clickstream
3737
compileOnly(files("$rootDir/libs/proto-sdk-1.18.6.jar"))
38+
implementation(deps.kotlin.coroutines.core)
39+
3840

3941
implementation(deps.android.core.annotation)
4042
}
Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
package clickstream.health
22

33
import androidx.annotation.RestrictTo
4-
import clickstream.health.intermediate.CSEventHealthListener
5-
import clickstream.health.intermediate.CSHealthEventFactory
64
import clickstream.health.intermediate.CSHealthEventProcessor
7-
import clickstream.health.intermediate.CSHealthEventRepository
85

6+
/**
7+
* Wrapper class that creates [CSHealthEventProcessor].
8+
*
9+
* */
910
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
1011
public interface CSHealthGateway {
11-
public val eventHealthListener: CSEventHealthListener
1212

13-
public val healthEventRepository: CSHealthEventRepository
13+
/**
14+
* Class to process health events.
15+
*
16+
* */
17+
public val healthEventProcessor: CSHealthEventProcessor?
1418

15-
public val healthEventProcessor: CSHealthEventProcessor
19+
/**
20+
* Clears health events on app version upgrade.
21+
*
22+
* */
23+
public suspend fun clearHealthEventsForVersionChange()
1624

17-
public val healthEventFactory: CSHealthEventFactory
1825
}

clickstream-health-metrics-api/src/main/kotlin/clickstream/health/constant/CSEventNamesConstant.kt

Lines changed: 14 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -3,141 +3,23 @@ package clickstream.health.constant
33
import androidx.annotation.RestrictTo
44

55
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
6-
public enum class CSEventNamesConstant(public val value: String) {;
6+
public enum class CSHealthEventName(public val value: String) {
77

8-
public enum class Instant(public val value: String) {
9-
/**
10-
* Tracks the instances where the connection gets dropped.
11-
*
12-
* Type: Instant
13-
* Priority: Critical
14-
*/
15-
ClickStreamConnectionDropped("Clickstream Connection Dropped"),
8+
// Batch sent events
9+
ClickStreamBatchSent("ClickStream Batch Sent"),
10+
ClickStreamEventBatchTriggerFailed("Clickstream Event Batch Trigger Failed"),
11+
ClickStreamBatchWriteFailed("ClickStream Write to Socket Failed"),
1612

17-
/**
18-
* Tracks the connection attempt instances.
19-
*
20-
* Type: Instant
21-
* Priority: Critical
22-
*/
23-
ClickStreamConnectionAttempt("Clickstream Connection Attempt"),
13+
// Socket connection events
14+
ClickStreamConnectionFailed("ClickStream Connection Failed"),
2415

25-
/**
26-
* Tracks the connection attempt success instances.
27-
*
28-
* Type: Instant
29-
* Priority: Critical
30-
*/
31-
ClickStreamConnectionSuccess("Clickstream Connection Success"),
16+
// Batch acknowledgement events
17+
ClickStreamEventBatchErrorResponse("Clickstream Event Batch Error response"),
18+
ClickStreamEventBatchAck("Clickstream Event Batch Success Ack"),
19+
ClickStreamEventBatchTimeout("Clickstream Event Batch Timeout"),
3220

33-
/**
34-
* Tracks the connection attempt failure instances.
35-
*
36-
* Type: Instant
37-
* Priority: Critical
38-
*/
39-
ClickStreamConnectionFailure("Clickstream Connection Failure"),
40-
41-
/**
42-
* Tracks the instances when the clickstream event batch gets timed out.
43-
*
44-
* Type: Instant
45-
* Priority: Critical
46-
*/
47-
ClickStreamEventBatchTimeout("Clickstream Event Batch Timeout"),
48-
49-
/**
50-
* Tracks the instances when the clickstream event batch fails to get written on the socket.
51-
*
52-
* Type: Instant
53-
* Priority: Critical
54-
*/
55-
ClickStreamWriteToSocketFailed("ClickStream Write to Socket Failed"),
56-
57-
/**
58-
* Tracks the instances when the batch fails to get triggered.
59-
*
60-
* Type: Instant
61-
* Priority: Low
62-
*/
63-
ClickStreamEventBatchTriggerFailed("Clickstream Event Batch Trigger Failed"),
64-
65-
/**
66-
* Tracks the instances when the clickstream request results in a error response.
67-
*
68-
* Type: Instant
69-
* Priority: Critical
70-
*/
71-
ClickStreamEventBatchErrorResponse("Clickstream Event Batch Error response"),
72-
}
73-
74-
public enum class Flushed(public val value: String) {
75-
/**
76-
* This event is track the drop rate comparison only and not the part of the funnel.
77-
* Would be triggered for the event which is used to track the drops Eg. `AdCardEvent`
78-
*
79-
* Type: Flushed
80-
* Priority: Critical
81-
*/
82-
ClickStreamEventReceivedForDropRate("Clickstream Event Received For Drop Rate"),
83-
84-
/**
85-
* Tracks the instances where the event is received by the Clickstream library
86-
*
87-
* Type: Flushed
88-
* Priority: Critical
89-
*/
90-
ClickStreamEventReceived("Clickstream Event Received"),
91-
}
92-
93-
public enum class AggregatedAndFlushed(public val value: String) {
94-
/**
95-
* Tracks the instances when the clickstream event object is cached.
96-
*
97-
* Type: Aggregated and Flushed
98-
* Priority: Low
99-
*/
100-
ClickStreamEventCached("Clickstream Event Cached"),
101-
102-
/**
103-
* Tracks the instances when the clickstream event batch is created.
104-
*
105-
* Type: Aggregated and Flushed
106-
* Priority: Low
107-
*/
108-
ClickStreamEventBatchCreated("Clickstream Event Batch Created"),
109-
110-
/**
111-
* Tracks the instances when the clickstream batch gets successfully sent to raccoon.
112-
*
113-
* Type: Aggregated and Flushed
114-
* Priority: Low
115-
*/
116-
ClickStreamBatchSent("ClickStream Batch Sent"),
117-
118-
/**
119-
* Tracks the instances when raccoon acks the event request.
120-
*
121-
* Type: Aggregated and Flushed
122-
* Priority: Low
123-
*/
124-
ClickStreamEventBatchSuccessAck("Clickstream Event Batch Success Ack"),
125-
126-
/**
127-
* Tracks the instances when the clickstream batches are flushed on background.
128-
*
129-
* Type: Aggregated and Flushed
130-
* Priority: Critical
131-
*/
132-
ClickStreamFlushOnBackground("ClickStream Flush On Background"),
133-
134-
/**
135-
* Tracks the instances when the clickstream batches are flushed on background.
136-
*
137-
* Type: Aggregated and Flushed
138-
* Priority: Critical
139-
*/
140-
ClickStreamFlushOnForeground("ClickStream Flush On Foreground"),
141-
}
21+
// Flush events
22+
ClickStreamFlushOnBackground("ClickStream Flush On Background"),
23+
ClickStreamFlushOnForeground("Clickstream Flush On Foreground"),
14224
}
14325

clickstream-health-metrics-api/src/main/kotlin/clickstream/health/constant/CSEventTypesConstant.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package clickstream.health.constant
22

33
import androidx.annotation.RestrictTo
44

5+
56
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
67
public object CSEventTypesConstant {
78
public const val INSTANT: String = "instant"

clickstream-health-metrics-api/src/main/kotlin/clickstream/health/constant/CSHealthEventConstant.kt

Lines changed: 0 additions & 22 deletions
This file was deleted.

clickstream-health-metrics-api/src/main/kotlin/clickstream/health/constant/CSTrackedVia.kt

Lines changed: 0 additions & 7 deletions
This file was deleted.

clickstream-health-metrics-api/src/main/kotlin/clickstream/health/intermediate/CSEventHealthListener.kt

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)