@@ -20,6 +20,7 @@ use stremio_core::{
20
20
analytics:: Analytics ,
21
21
models:: { ctx:: Ctx , streaming_server:: StreamingServer } ,
22
22
runtime:: { msg:: Event , Env , EnvError , EnvFuture , EnvFutureExt , TryEnvFuture } ,
23
+ types:: api:: AuthRequest ,
23
24
} ;
24
25
25
26
use crate :: {
@@ -113,35 +114,63 @@ impl AndroidEnv {
113
114
}
114
115
pub fn emit_to_analytics ( event : & AndroidEvent , model : & AndroidModel , path : & str ) {
115
116
let ( name, data) = match event {
116
- AndroidEvent :: CoreEvent ( Event :: PlayerPlaying { load_time, context } ) => (
117
- "playerPlaying" . to_owned ( ) ,
118
- json ! ( {
119
- "loadTime" : load_time,
120
- "player" : context
121
- } ) ,
122
- ) ,
123
- AndroidEvent :: CoreEvent ( Event :: PlayerStopped { context } ) => {
124
- ( "playerStopped" . to_owned ( ) , json ! ( { "player" : context } ) )
125
- }
126
- AndroidEvent :: CoreEvent ( Event :: PlayerEnded {
127
- context,
128
- is_binge_enabled,
129
- is_playing_next_video,
130
- } ) => (
131
- "playerEnded" . to_owned ( ) ,
132
- json ! ( {
133
- "player" : context,
134
- "isBingeEnabled" : is_binge_enabled,
135
- "isPlayingNextVideo" : is_playing_next_video
136
- } ) ,
137
- ) ,
138
- AndroidEvent :: CoreEvent ( Event :: TraktPlaying { context } ) => {
139
- ( "traktPlaying" . to_owned ( ) , json ! ( { "player" : context } ) )
140
- }
141
- AndroidEvent :: CoreEvent ( Event :: TraktPaused { context } ) => {
142
- ( "traktPaused" . to_owned ( ) , json ! ( { "player" : context } ) )
143
- }
144
- _ => return ,
117
+ AndroidEvent :: CoreEvent ( core_event) => match core_event {
118
+ Event :: UserAuthenticated { auth_request } => (
119
+ "login" . to_owned ( ) ,
120
+ json ! ( {
121
+ "type" : match auth_request {
122
+ AuthRequest :: Login { facebook, .. } if * facebook => "facebook" ,
123
+ AuthRequest :: Login { .. } => "login" ,
124
+ AuthRequest :: Facebook { .. } => "authWithFacebook" ,
125
+ AuthRequest :: LoginWithToken { .. } => "loginWithToken" ,
126
+ AuthRequest :: Register { .. } => "register" ,
127
+ } ,
128
+ } ) ,
129
+ ) ,
130
+ Event :: AddonInstalled { transport_url, id } => (
131
+ "installAddon" . to_owned ( ) ,
132
+ json ! ( {
133
+ "addonTransportUrl" : transport_url,
134
+ "addonID" : id
135
+ } ) ,
136
+ ) ,
137
+ Event :: AddonUninstalled { transport_url, id } => (
138
+ "removeAddon" . to_owned ( ) ,
139
+ json ! ( {
140
+ "addonTransportUrl" : transport_url,
141
+ "addonID" : id
142
+ } ) ,
143
+ ) ,
144
+ Event :: PlayerPlaying { load_time, context } => (
145
+ "playerPlaying" . to_owned ( ) ,
146
+ json ! ( {
147
+ "loadTime" : load_time,
148
+ "player" : context
149
+ } ) ,
150
+ ) ,
151
+ Event :: PlayerStopped { context } => {
152
+ ( "playerStopped" . to_owned ( ) , json ! ( { "player" : context } ) )
153
+ }
154
+ Event :: PlayerEnded {
155
+ context,
156
+ is_binge_enabled,
157
+ is_playing_next_video,
158
+ } => (
159
+ "playerEnded" . to_owned ( ) ,
160
+ json ! ( {
161
+ "player" : context,
162
+ "isBingeEnabled" : is_binge_enabled,
163
+ "isPlayingNextVideo" : is_playing_next_video
164
+ } ) ,
165
+ ) ,
166
+ Event :: TraktPlaying { context } => {
167
+ ( "traktPlaying" . to_owned ( ) , json ! ( { "player" : context } ) )
168
+ }
169
+ Event :: TraktPaused { context } => {
170
+ ( "traktPaused" . to_owned ( ) , json ! ( { "player" : context } ) )
171
+ }
172
+ _ => return ,
173
+ } ,
145
174
} ;
146
175
ANALYTICS . emit ( name, data, & model. ctx , & model. streaming_server , path) ;
147
176
}
0 commit comments