-
Notifications
You must be signed in to change notification settings - Fork 7
/
SessionMessage.kt
86 lines (69 loc) · 2.28 KB
/
SessionMessage.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package io.embrace.android.embracesdk.payload
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import io.embrace.android.embracesdk.comms.api.ApiClient
import io.embrace.android.embracesdk.internal.payload.EnvelopeMetadata
import io.embrace.android.embracesdk.internal.payload.EnvelopeResource
import io.embrace.android.embracesdk.internal.payload.SessionPayload
import io.embrace.android.embracesdk.internal.spans.EmbraceSpanData
/**
* The session message, containing the session itself, as well as performance information about the
* device which occurred during the session.
*/
@JsonClass(generateAdapter = true)
internal data class SessionMessage @JvmOverloads internal constructor(
/**
* The session information.
*/
@Json(name = "s")
val session: Session,
/**
* The user information.
*/
@Json(name = "u")
val userInfo: UserInfo? = null,
/**
* The app information.
*/
@Json(name = "a")
val appInfo: AppInfo? = null,
/**
* The device information.
*/
@Json(name = "d")
val deviceInfo: DeviceInfo? = null,
/**
* The device's performance info, such as power, cpu, network.
*/
@Json(name = "p")
val performanceInfo: PerformanceInfo? = null,
/**
* Breadcrumbs which occurred as part of this session.
*/
@Json(name = "br")
val breadcrumbs: Breadcrumbs? = null,
@Json(name = "spans")
val spans: List<EmbraceSpanData>? = null,
@Json(name = "v")
val version: Int = ApiClient.MESSAGE_VERSION,
/*
* Values below this point are copied temporarily from [Envelope]. Eventually we will migrate
* everything to use [Envelope] and [SessionPayload] and remove this class,
* but we'll keep it for now for backwards compat.
*/
@Json(name = "resource")
val resource: EnvelopeResource? = null,
@Json(name = "metadata")
val metadata: EnvelopeMetadata? = null,
@Json(name = "version")
val newVersion: String? = null,
@Json(name = "type")
val type: String? = null,
@Json(name = "data")
val data: SessionPayload? = null
)
/**
* Returns true if this message is a v2 payload. If so, it should be sent to a different
* endpoint & handled differently.
*/
internal fun SessionMessage.isV2Payload() = data != null