File tree 3 files changed +23
-20
lines changed
3 files changed +23
-20
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"pins" : [
3
- {
4
- "identity" : " analytics-swift-mixpanel" ,
5
- "kind" : " remoteSourceControl" ,
6
- "location" : " https://github.com/segment-integrations/analytics-swift-mixpanel" ,
7
- "state" : {
8
- "revision" : " bc6a9628af225e679a581cc9ac2316eaf42f23a8" ,
9
- "version" : " 1.1.7"
10
- }
11
- },
12
3
{
13
4
"identity" : " jsonsafeencoding-swift" ,
14
5
"kind" : " remoteSourceControl" ,
18
9
"version" : " 2.0.0"
19
10
}
20
11
},
21
- {
22
- "identity" : " mixpanel-swift" ,
23
- "kind" : " remoteSourceControl" ,
24
- "location" : " https://github.com/mixpanel/mixpanel-swift" ,
25
- "state" : {
26
- "revision" : " 48d6668ceaaefc338f94e2b084c3cf77b90182f8" ,
27
- "version" : " 4.3.0"
28
- }
29
- },
30
12
{
31
13
"identity" : " sovran-swift" ,
32
14
"kind" : " remoteSourceControl" ,
Original file line number Diff line number Diff line change @@ -141,6 +141,26 @@ extension Analytics {
141
141
// MARK: - Untyped Event Signatures
142
142
143
143
extension Analytics {
144
+ /// Tracks an event performed by a user, including some additional event properties.
145
+ /// - Parameters:
146
+ /// - messageId: The unique identifier for the TrackEvent
147
+ /// - name: Name of the action, e.g., 'Purchased a T-Shirt'
148
+ /// - properties: A dictionary or properties specific to the named event.
149
+ /// For example, an event with the name 'Purchased a Shirt' might have properties
150
+ /// like revenue or size.
151
+ public func track( messageId: String , name: String , properties: [ String : Any ] ? = nil ) {
152
+ var props : JSON ? = nil
153
+ if let properties = properties {
154
+ do {
155
+ props = try JSON ( properties)
156
+ } catch {
157
+ reportInternalError ( error, fatal: true )
158
+ }
159
+ }
160
+ let event = TrackEvent ( messageId: messageId, event: name, properties: props)
161
+ process ( incomingEvent: event)
162
+ }
163
+
144
164
/// Tracks an event performed by a user, including some additional event properties.
145
165
/// - Parameters:
146
166
/// - name: Name of the action, e.g., 'Purchased a T-Shirt'
Original file line number Diff line number Diff line change @@ -47,7 +47,8 @@ public struct TrackEvent: RawEvent {
47
47
public var event : String
48
48
public var properties : JSON ?
49
49
50
- public init ( event: String , properties: JSON ? ) {
50
+ public init ( messageId: String ? = nil , event: String , properties: JSON ? ) {
51
+ self . messageId = messageId
51
52
self . event = event
52
53
self . properties = properties
53
54
}
@@ -303,7 +304,7 @@ extension RawEvent {
303
304
result. enrichments = enrichments
304
305
result. anonymousId = userInfo. anonymousId
305
306
result. userId = userInfo. userId
306
- result. messageId = UUID ( ) . uuidString
307
+ result. messageId = result . messageId ?? UUID ( ) . uuidString
307
308
result. timestamp = Date ( ) . iso8601 ( )
308
309
result. integrations = try ? JSON ( [ String: Any] ( ) )
309
310
result. _metadata = DestinationMetadata ( )
You can’t perform that action at this time.
0 commit comments