Skip to content

Commit e1f286e

Browse files
committed
rename parameter, add comment
1 parent b3daa09 commit e1f286e

File tree

2 files changed

+39
-38
lines changed

2 files changed

+39
-38
lines changed

Sources/Analytics/Analytics.swift

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,21 @@ public struct Analytics<HTTPClient: HTTPClientProtocol> {
6262
EventPayload(
6363
parameters: parameters.merging([.platform: "app"]) { $1 }.compactMapValues { $0 },
6464
eventName: eventName,
65-
startDate: UInt(Date.now.timeIntervalSince1970 * 100),
66-
endDate: UInt(Date.now.timeIntervalSince1970 * 100)
65+
previousTimestampMillis: UInt(Date.now.timeIntervalSince1970 * 100),
66+
timestampMillis: UInt(Date.now.timeIntervalSince1970 * 100)
6767
),
6868
EventPayload(
6969
parameters: ["_et": .uint(891), .platform: "auto"],
7070
eventName: "_e",
71-
startDate: UInt(Date.now.timeIntervalSince1970 * 100),
72-
endDate: UInt(Date.now.timeIntervalSince1970 * 100)
71+
previousTimestampMillis: UInt(Date.now.timeIntervalSince1970 * 100),
72+
timestampMillis: UInt(Date.now.timeIntervalSince1970 * 100)
7373
),
7474
],
7575
sessionInformations: session.parameters,
76-
value4: UInt(Date.now.timeIntervalSince1970 * 100),
77-
value5: UInt(Date.now.timeIntervalSince1970 * 100),
78-
value6: UInt(Date.now.timeIntervalSince1970 * 100),
79-
value7: UInt(Date.now.timeIntervalSince1970 * 100),
76+
value4: UInt(Date.now.timeIntervalSince1970 * 100), // upload_timestamp_millis
77+
value5: UInt(Date.now.timeIntervalSince1970 * 100), // start_timestamp_millis
78+
value6: UInt(Date.now.timeIntervalSince1970 * 100), // end_timestamp_millis
79+
value7: UInt(Date.now.timeIntervalSince1970 * 100), // previous_bundle_end_timestamp_millis
8080
os: clientInformation.os,
8181
osVersion: clientInformation.osVersion,
8282
deviceModel: clientInformation.deviceModel,
@@ -85,20 +85,20 @@ public struct Analytics<HTTPClient: HTTPClientProtocol> {
8585
installMethod: clientInformation.installMethod,
8686
bundleId: clientInformation.bundleId,
8787
appVersion: clientInformation.appVersion,
88-
value17: 110700,
89-
value18: 110700,
90-
value21: "BC75E8783E8141ECB7A179248F24080C", // fix
91-
value23: 25, // count up
88+
value17: 110700, // gmp_version
89+
value18: 110700, // uploading_gmp_version
90+
value21: "BC75E8783E8141ECB7A179248F24080C", // fix // app_instance_id
91+
value23: 25, // count up // bundle_sequential_index
9292
googleAppId: clientInformation.googleAppId,
93-
value26: UInt(Date.now.timeIntervalSince1970 * 100), // free
94-
value27: "C86A6B98-E407-4954-BC16-F693A22F9FA9", // fix
95-
value30: "d4Xw8qsiRUIBoMYlsYHnot", // fix
96-
value31: 1,
97-
value35: 1_727_127_969_769_945, // fix
93+
value26: UInt(Date.now.timeIntervalSince1970 * 100), // free // previous_bundle_start_timestamp_millis
94+
value27: "C86A6B98-E407-4954-BC16-F693A22F9FA9", // fix // resettable_device_id
95+
value30: "d4Xw8qsiRUIBoMYlsYHnot", // fix // firebase_instance_id
96+
value31: 1, // app_version_major
97+
value35: 1_727_127_969_769_945, // fix // config_version
9898
value45: 42_820_019, // fix
99-
value52: "G1--", // fix
99+
value52: "G1--", // fix // consent_signals
100100
value64: "google_signals", // fix
101-
value71: "19911", // fix
101+
value71: "19911", // fix // consent_diagnostics
102102
value72: 0, // fix
103103
value77: 13 // count up
104104
)

Sources/Analytics/Payload/EventPayload.swift

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,55 @@ import ProtobufKit
22

33
public struct EventPayload: ProtobufMessage, Equatable {
44
public var parameters: [Parameter.Key: Parameter.Value]
5-
public var eventName: Event.Name
6-
public var startDate: UInt?
7-
public var endDate: UInt
5+
public var eventName: Event.Name
6+
public var previousTimestampMillis: UInt?
7+
public var timestampMillis: UInt
88

99
public init(
1010
parameters: [Parameter.Key: Parameter.Value],
1111
eventName: Event.Name,
12-
startDate: UInt,
13-
endDate: UInt
12+
previousTimestampMillis: UInt?,
13+
timestampMillis: UInt
1414
) {
1515
self.parameters = parameters
1616
self.eventName = eventName
17-
self.startDate = startDate
18-
self.endDate = endDate
19-
self.endDate = endDate
17+
self.previousTimestampMillis = previousTimestampMillis
18+
self.timestampMillis = timestampMillis
2019
}
2120

2221
public func encode(to encoder: inout ProtobufKit.ProtobufEncoder) throws {
2322
for parameter in parameters {
2423
try encoder.messageField(1, KeyValue(key: parameter.key, value: parameter.value))
2524
}
2625
try encoder.stringField(2, eventName.rawValue, defaultValue: nil)
27-
startDate.map { encoder.uintField(4, $0, defaultValue: nil) }
28-
encoder.uintField(3, endDate, defaultValue: nil)
26+
previousTimestampMillis.map { encoder.uintField(4, $0, defaultValue: nil) }
27+
encoder.uintField(3, timestampMillis, defaultValue: nil)
2928
}
3029

3130
public init(from decoder: inout ProtobufDecoder) throws {
3231
var eventName: Event.Name?
33-
var startDate: UInt?
34-
var endDate: UInt?
32+
var previousTimestampMillis: UInt?
33+
var timestampMillis: UInt?
3534
var parameters: [Parameter.Key: Parameter.Value] = [:]
3635
while let field = try decoder.nextField() {
3736
switch field.tag {
3837
case 1:
3938
let parameter: KeyValue = try decoder.messageField(field)
4039
parameters[parameter.key] = parameter.value
4140
case 2: eventName = .init(stringLiteral: try decoder.stringField(field))
42-
case 3: endDate = try decoder.uintField(field)
43-
case 4: startDate = try decoder.uintField(field)
41+
case 3: timestampMillis = try decoder.uintField(field)
42+
case 4: previousTimestampMillis = try decoder.uintField(field)
4443
default: throw ProtobufDecodingError.unknownError
4544
}
4645
}
4746

48-
if let eventName, let endDate {
49-
self.parameters = parameters
50-
self.eventName = eventName
51-
self.startDate = startDate
52-
self.endDate = endDate
47+
if let eventName, let timestampMillis {
48+
self.init(
49+
parameters: parameters,
50+
eventName: eventName,
51+
previousTimestampMillis: previousTimestampMillis,
52+
timestampMillis: timestampMillis
53+
)
5354
} else {
5455
throw ProtobufDecodingError.missingField
5556
}

0 commit comments

Comments
 (0)