@@ -16,10 +16,6 @@ struct MyLogger: LoggerComponent {
16
16
}
17
17
18
18
extension TrackingEvent {
19
- static func impletion( _ screen: String ) -> Self {
20
- TrackingEvent ( eventName: " impletion " , parameters: [ " screen " : screen] )
21
- }
22
-
23
19
static var tapIncrement : Self {
24
20
. init( eventName: " tap increment " , parameters: [ : ] )
25
21
}
@@ -30,7 +26,7 @@ extension TrackingEvent {
30
26
}
31
27
32
28
struct TimestampMutation : Mutation {
33
- func transform( _ e: Parchment . Loggable , id: Parchment . LoggerComponentID ) -> Parchment . AnyLoggable {
29
+ func transform( _ e: Loggable , id: LoggerComponentID ) -> AnyLoggable {
34
30
var e = AnyLoggable ( e)
35
31
e. parameters [ " createdAt " ] = Date ( )
36
32
return e
@@ -40,16 +36,34 @@ struct TimestampMutation: Mutation {
40
36
struct UserIDMutation : Mutation {
41
37
let userID = 1
42
38
43
- func transform( _ e: Parchment . Loggable , id: Parchment . LoggerComponentID ) -> Parchment . AnyLoggable {
39
+ func transform( _ e: Loggable , id: LoggerComponentID ) -> AnyLoggable {
44
40
var e = AnyLoggable ( e)
45
41
e. parameters [ " userID " ] = userID
46
42
return e
47
43
}
48
44
}
49
45
46
+ struct ImpletionMutation : Mutation {
47
+ func transform( _ e: Loggable , id: LoggerComponentID ) -> AnyLoggable {
48
+ var e = AnyLoggable ( e)
49
+ if e. isBased ( ImpletionEvent . self) {
50
+ e. eventName = ( e. parameters [ " screen " ] as! String ) + " ScreenEvent "
51
+ e. parameters = [ " event " : " onAppear " ]
52
+ }
53
+ return e
54
+ }
55
+ }
56
+
50
57
let logger = LoggerBundler . make (
51
58
components: [ MyLogger ( ) , DebugLogger ( ) ] ,
52
- bufferFlowController: DefaultBufferFlowController ( pollingInterval: 5 , delayInputLimit: 5 )
59
+ bufferFlowController: DefaultBufferFlowController (
60
+ pollingInterval: 5 , delayInputLimit: 5
61
+ ) ,
62
+ mutations: [
63
+ TimestampMutation ( ) ,
64
+ ImpletionMutation ( ) ,
65
+ UserIDMutation ( )
66
+ ]
53
67
)
54
68
55
69
@main
@@ -84,13 +98,12 @@ struct ExampleAppApp: App {
84
98
. background ( Color . gray)
85
99
. task {
86
100
await logger. startLogging ( )
87
-
88
- await logger. add (
89
- mutations: [ TimestampMutation ( ) , UserIDMutation ( ) ]
90
- )
91
-
92
- await logger. send ( event: . impletion( " home " ) )
93
101
}
102
+ . track (
103
+ screen: " Top " ,
104
+ with: logger,
105
+ option: . init( policy: . immediately)
106
+ )
94
107
}
95
108
}
96
109
}
0 commit comments