Commit 508f3f1 dashdashzako
committed
1 parent 3570e4a commit 508f3f1 Copy full SHA for 508f3f1
File tree 1 file changed +10
-12
lines changed
1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -13,29 +13,27 @@ const analytics: Middleware = (store) => (next) => (
13
13
) => {
14
14
if ( loggedActions . includes ( action . type ) ) {
15
15
const state : IAianaState = store . getState ( ) ;
16
+ const partialState = {
17
+ ...state . player ,
18
+ ...state . preferences
19
+ } ;
16
20
17
21
const playerEvent = {
18
22
createdAt : Date . now ( ) ,
19
- payload : action . payload ,
20
23
mediaId : state . player . mediaId ,
21
- state,
24
+ payload : action . payload ,
25
+ state : partialState ,
22
26
type : action . type ,
23
27
userId : getUserId ( )
24
28
} ;
25
29
26
30
const strData = JSON . stringify ( playerEvent ) ;
31
+ const loggerEndpoint = ( window as any ) . loggerEndpoint ;
27
32
28
- if ( process . env . NODE_ENV !== 'production' ) {
33
+ if ( process . env . NODE_ENV !== 'production' && ! loggerEndpoint ) {
29
34
console . log ( strData ) ;
30
- } else {
31
- const loggerEndpoint = ( window as any ) . loggerEndpoint ;
32
- const blob = new Blob ( [ strData ] , {
33
- type : 'application/json; charset=UTF-8'
34
- } ) ;
35
-
36
- if ( loggerEndpoint ) {
37
- navigator . sendBeacon ( loggerEndpoint , blob ) ;
38
- }
35
+ } else if ( loggerEndpoint ) {
36
+ navigator . sendBeacon ( loggerEndpoint , strData ) ;
39
37
}
40
38
}
41
39
You can’t perform that action at this time.
0 commit comments