@@ -22,7 +22,7 @@ import com.google.firebase.encoders.DataEncoder
22
22
import com.google.firebase.encoders.FieldDescriptor
23
23
import com.google.firebase.encoders.ObjectEncoderContext
24
24
import com.google.firebase.encoders.json.JsonDataEncoderBuilder
25
- import java.util.*
25
+ import com.google.firebase.sessions.settings.SessionsSettings
26
26
27
27
/* *
28
28
* Contains functions for [SessionEvent]s.
@@ -37,8 +37,7 @@ internal object SessionEvents {
37
37
.configureWith {
38
38
it.registerEncoder(SessionEvent ::class .java) {
39
39
sessionEvent: SessionEvent ,
40
- ctx: ObjectEncoderContext ,
41
- ->
40
+ ctx: ObjectEncoderContext ->
42
41
run {
43
42
ctx.add(FieldDescriptor .of(" event_type" ), sessionEvent.eventType)
44
43
ctx.add(FieldDescriptor .of(" session_data" ), sessionEvent.sessionData)
@@ -48,8 +47,7 @@ internal object SessionEvents {
48
47
49
48
it.registerEncoder(SessionInfo ::class .java) {
50
49
sessionInfo: SessionInfo ,
51
- ctx: ObjectEncoderContext ,
52
- ->
50
+ ctx: ObjectEncoderContext ->
53
51
run {
54
52
ctx.add(FieldDescriptor .of(" session_id" ), sessionInfo.sessionId)
55
53
ctx.add(FieldDescriptor .of(" first_session_id" ), sessionInfo.firstSessionId)
@@ -65,8 +63,7 @@ internal object SessionEvents {
65
63
66
64
it.registerEncoder(DataCollectionStatus ::class .java) {
67
65
dataCollectionStatus: DataCollectionStatus ,
68
- ctx: ObjectEncoderContext ,
69
- ->
66
+ ctx: ObjectEncoderContext ->
70
67
run {
71
68
ctx.add(FieldDescriptor .of(" performance" ), dataCollectionStatus.performance)
72
69
ctx.add(FieldDescriptor .of(" crashlytics" ), dataCollectionStatus.crashlytics)
@@ -79,8 +76,7 @@ internal object SessionEvents {
79
76
80
77
it.registerEncoder(ApplicationInfo ::class .java) {
81
78
applicationInfo: ApplicationInfo ,
82
- ctx: ObjectEncoderContext ,
83
- ->
79
+ ctx: ObjectEncoderContext ->
84
80
run {
85
81
ctx.add(FieldDescriptor .of(" app_id" ), applicationInfo.appId)
86
82
ctx.add(FieldDescriptor .of(" device_model" ), applicationInfo.deviceModel)
@@ -92,8 +88,7 @@ internal object SessionEvents {
92
88
93
89
it.registerEncoder(AndroidApplicationInfo ::class .java) {
94
90
androidAppInfo: AndroidApplicationInfo ,
95
- ctx: ObjectEncoderContext ,
96
- ->
91
+ ctx: ObjectEncoderContext ->
97
92
run {
98
93
ctx.add(FieldDescriptor .of(" package_name" ), androidAppInfo.packageName)
99
94
ctx.add(FieldDescriptor .of(" version_name" ), androidAppInfo.versionName)
@@ -110,7 +105,8 @@ internal object SessionEvents {
110
105
fun startSession (
111
106
firebaseApp : FirebaseApp ,
112
107
sessionDetails : SessionDetails ,
113
- currentTimeUs : Long = WallClock .currentTimeUs(),
108
+ sessionsSettings : SessionsSettings ,
109
+ currentTimeUs : Long = WallClock .currentTimeUs()
114
110
) =
115
111
SessionEvent (
116
112
eventType = EventType .SESSION_START ,
@@ -120,6 +116,7 @@ internal object SessionEvents {
120
116
sessionDetails.firstSessionId,
121
117
sessionDetails.sessionIndex,
122
118
currentTimeUs,
119
+ DataCollectionStatus (sessionSamplingRate = sessionsSettings.samplingRate),
123
120
),
124
121
applicationInfo = getApplicationInfo(firebaseApp)
125
122
)
0 commit comments