This commit is contained in:
@ -72,62 +72,82 @@ const CoreMiddleware = (function(){
|
||||
);
|
||||
|
||||
// Log with Raven Sentry
|
||||
Raven.captureException(
|
||||
new Error(message),
|
||||
{
|
||||
extra: data
|
||||
}
|
||||
);
|
||||
if (store.getState().ui.allow_reporting){
|
||||
Raven.captureException(
|
||||
new Error(message),
|
||||
{
|
||||
extra: data
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Log with Analytics
|
||||
ReactGA.event({
|
||||
category: "Error",
|
||||
action: message,
|
||||
label: description,
|
||||
nonInteraction: true
|
||||
});
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({
|
||||
category: "Error",
|
||||
action: message,
|
||||
label: description,
|
||||
nonInteraction: true
|
||||
});
|
||||
}
|
||||
|
||||
store.dispatch(uiActions.createNotification({content: message, type: 'bad', description: description}));
|
||||
console.error(message, description, data);
|
||||
break;
|
||||
|
||||
case 'PLAY_PLAYLIST':
|
||||
ReactGA.event({ category: 'Playlist', action: 'Play', label: action.uri })
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Playlist', action: 'Play', label: action.uri });
|
||||
}
|
||||
next(action)
|
||||
break
|
||||
|
||||
case 'SAVE_PLAYLIST':
|
||||
ReactGA.event({ category: 'Playlist', action: 'Save', label: action.key })
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Playlist', action: 'Save', label: action.key });
|
||||
}
|
||||
next(action)
|
||||
break
|
||||
|
||||
case 'CREATE_PLAYLIST':
|
||||
ReactGA.event({ category: 'Playlist', action: 'Create', label: +action.name })
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Playlist', action: 'Create', label: +action.name });
|
||||
}
|
||||
next(action)
|
||||
break
|
||||
|
||||
case 'REORDER_PLAYLIST_TRACKS':
|
||||
ReactGA.event({ category: 'Playlist', action: 'Reorder tracks', label: action.key })
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Playlist', action: 'Reorder tracks', label: action.key });
|
||||
}
|
||||
next(action)
|
||||
break
|
||||
|
||||
case 'ADD_PLAYLIST_TRACKS':
|
||||
ReactGA.event({ category: 'Playlist', action: 'Add tracks', label: action.playlist_uri })
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Playlist', action: 'Add tracks', label: action.playlist_uri });
|
||||
}
|
||||
next(action)
|
||||
break
|
||||
|
||||
case 'REMOVE_PLAYLIST_TRACKS':
|
||||
ReactGA.event({ category: 'Playlist', action: 'Remove tracks', label: action.playlist_uri })
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Playlist', action: 'Remove tracks', label: action.playlist_uri });
|
||||
}
|
||||
next(action)
|
||||
break
|
||||
|
||||
case 'DELETE_PLAYLIST':
|
||||
ReactGA.event({ category: 'Playlist', action: 'Delete', label: action.uri })
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Playlist', action: 'Delete', label: action.uri });
|
||||
}
|
||||
next(action)
|
||||
break
|
||||
|
||||
case 'SEARCH_STARTED':
|
||||
ReactGA.event({ category: 'Search', action: 'Started', label: action.type+': '+action.query })
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Search', action: 'Started', label: action.type+': '+action.query });
|
||||
}
|
||||
next(action)
|
||||
|
||||
var state = store.getState()
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
|
||||
import ReactGA from 'react-ga'
|
||||
|
||||
var helpers = require('./../../helpers')
|
||||
var lastfmActions = require('./actions')
|
||||
var uiActions = require('../ui/actions')
|
||||
|
||||
@ -220,7 +220,9 @@ const MopidyMiddleware = (function(){
|
||||
break;
|
||||
|
||||
case 'MOPIDY_CONNECTED':
|
||||
ReactGA.event({ category: 'Mopidy', action: 'Connected', label: window.location.hostname });
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Mopidy', action: 'Connected', label: window.location.hostname });
|
||||
}
|
||||
next(action);
|
||||
break;
|
||||
|
||||
@ -2155,7 +2157,9 @@ const MopidyMiddleware = (function(){
|
||||
break
|
||||
|
||||
case 'MOPIDY_DIRECTORY':
|
||||
if (action.data) ReactGA.event({ category: 'Directory', action: 'Load', label: action.data.uri })
|
||||
if (store.getState().ui.allow_reporting && action.data){
|
||||
ReactGA.event({ category: 'Directory', action: 'Load', label: action.data.uri });
|
||||
}
|
||||
next(action)
|
||||
break
|
||||
|
||||
|
||||
@ -215,7 +215,9 @@ const PusherMiddleware = (function(){
|
||||
break;
|
||||
|
||||
case 'PUSHER_CONNECTED':
|
||||
ReactGA.event({ category: 'Pusher', action: 'Connected', label: action.username});
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Pusher', action: 'Connected', label: action.username});
|
||||
}
|
||||
|
||||
store.dispatch(pusherActions.getConfig());
|
||||
store.dispatch(pusherActions.getVersion());
|
||||
@ -375,7 +377,9 @@ const PusherMiddleware = (function(){
|
||||
|
||||
case 'PUSHER_START_RADIO':
|
||||
case 'PUSHER_UPDATE_RADIO':
|
||||
ReactGA.event({ category: 'Pusher', action: 'Start radio', label: action.uris.join() })
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Pusher', action: 'Start radio', label: action.uris.join() });
|
||||
}
|
||||
|
||||
// start our UI process notification
|
||||
if (action.type == 'PUSHER_UPDATE_RADIO'){
|
||||
@ -438,7 +442,10 @@ const PusherMiddleware = (function(){
|
||||
|
||||
case 'PUSHER_STOP_RADIO':
|
||||
store.dispatch(uiActions.createNotification({content: 'Stopping radio'}));
|
||||
ReactGA.event({ category: 'Pusher', action: 'Stop radio' });
|
||||
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Pusher', action: 'Stop radio' });
|
||||
}
|
||||
|
||||
store.dispatch(pusherActions.deliverBroadcast(
|
||||
'notification',
|
||||
@ -503,7 +510,9 @@ const PusherMiddleware = (function(){
|
||||
break
|
||||
|
||||
case 'PUSHER_UPGRADE':
|
||||
ReactGA.event({ category: 'Pusher', action: 'Upgrade', label: '' });
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Pusher', action: 'Upgrade', label: '' });
|
||||
}
|
||||
request(store, 'upgrade')
|
||||
.then(
|
||||
response => {
|
||||
@ -516,7 +525,9 @@ const PusherMiddleware = (function(){
|
||||
break;
|
||||
|
||||
case 'PUSHER_VERSION':
|
||||
ReactGA.event({ category: 'Pusher', action: 'Version', label: action.version.current })
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Pusher', action: 'Version', label: action.version.current });
|
||||
}
|
||||
|
||||
if (action.version.upgrade_available){
|
||||
store.dispatch(uiActions.createNotification({content: 'Version '+action.version.latest+' is available. See settings to upgrade.'}));
|
||||
@ -574,8 +585,10 @@ const PusherMiddleware = (function(){
|
||||
break;
|
||||
|
||||
case 'PUSHER_ERROR':
|
||||
store.dispatch(uiActions.createNotification(action.message, 'bad'))
|
||||
ReactGA.event({ category: 'Pusher', action: 'Error', label: action.message })
|
||||
store.dispatch(uiActions.createNotification(action.message, 'bad'));
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Pusher', action: 'Error', label: action.message });
|
||||
}
|
||||
break
|
||||
|
||||
|
||||
|
||||
@ -18,7 +18,9 @@ const SpotifyMiddleware = (function(){
|
||||
switch(action.type){
|
||||
|
||||
case 'SPOTIFY_AUTHORIZATION_GRANTED':
|
||||
ReactGA.event({category: 'Spotify', action: 'Authorization granted'});
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({category: 'Spotify', action: 'Authorization granted'});
|
||||
}
|
||||
|
||||
// Flush out the previous user's library
|
||||
store.dispatch(spotifyActions.flushLibrary());
|
||||
@ -27,13 +29,16 @@ const SpotifyMiddleware = (function(){
|
||||
break;
|
||||
|
||||
case 'SPOTIFY_AUTHORIZATION_REVOKED':
|
||||
var hashed_username = null
|
||||
if (store.getState().spotify.me){
|
||||
hashed_username = md5(store.getState().spotify.me);
|
||||
ReactGA.set({userId: hashed_username});
|
||||
}
|
||||
ReactGA.event({ category: 'Spotify', action: 'Authorization revoked', label: hashed_username})
|
||||
next(action)
|
||||
if (store.getState().ui.allow_reporting){
|
||||
var hashed_username = null
|
||||
if (store.getState().spotify.me){
|
||||
hashed_username = md5(store.getState().spotify.me);
|
||||
ReactGA.set({userId: hashed_username});
|
||||
}
|
||||
ReactGA.event({ category: 'Spotify', action: 'Authorization revoked', label: hashed_username});
|
||||
}
|
||||
|
||||
next(action);
|
||||
|
||||
// Now dispatch a getMe to get the backend-provided user
|
||||
store.dispatch(spotifyActions.getMe());
|
||||
@ -44,12 +49,14 @@ const SpotifyMiddleware = (function(){
|
||||
break;
|
||||
|
||||
case 'SPOTIFY_IMPORT_AUTHORIZATION':
|
||||
var hashed_username = null
|
||||
if (store.getState().spotify.me){
|
||||
hashed_username = md5(store.getState().spotify.me);
|
||||
ReactGA.set({userId: hashed_username});
|
||||
}
|
||||
ReactGA.event({category: 'Spotify', action: 'Authorization imported', label: hashed_username});
|
||||
if (store.getState().ui.allow_reporting){
|
||||
var hashed_username = null
|
||||
if (store.getState().spotify.me){
|
||||
hashed_username = md5(store.getState().spotify.me);
|
||||
ReactGA.set({userId: hashed_username});
|
||||
}
|
||||
ReactGA.event({category: 'Spotify', action: 'Authorization imported', label: hashed_username});
|
||||
}
|
||||
|
||||
// Flush out the previous user's library
|
||||
store.dispatch(spotifyActions.flushLibrary());
|
||||
@ -58,14 +65,16 @@ const SpotifyMiddleware = (function(){
|
||||
break;
|
||||
|
||||
case 'SPOTIFY_RECOMMENDATIONS_LOADED':
|
||||
if (action.seeds_uris){
|
||||
if (store.getState().ui.allow_reporting && action.seeds_uris){
|
||||
ReactGA.event({ category: 'Spotify', action: 'Recommendations', label: action.seeds_uris.join(',') })
|
||||
}
|
||||
next(action)
|
||||
break;
|
||||
|
||||
case 'SPOTIFY_USER_LOADED':
|
||||
if (action.data) ReactGA.event({ category: 'User', action: 'Load', label: action.data.uri })
|
||||
if (store.getState().ui.allow_reporting && action.data){
|
||||
ReactGA.event({ category: 'User', action: 'Load', label: action.data.uri });
|
||||
}
|
||||
next(action)
|
||||
break;
|
||||
|
||||
@ -414,9 +423,11 @@ const SpotifyMiddleware = (function(){
|
||||
store.dispatch(pusherActions.setUsername(name));
|
||||
}
|
||||
|
||||
var hashed_username = md5(action.data.id);
|
||||
ReactGA.set({userId: hashed_username});
|
||||
ReactGA.event({category: 'Spotify', action: 'Authorization verified', label: hashed_username});
|
||||
if (store.getState().ui.allow_reporting){
|
||||
var hashed_username = md5(action.data.id);
|
||||
ReactGA.set({userId: hashed_username});
|
||||
ReactGA.event({category: 'Spotify', action: 'Authorization verified', label: hashed_username});
|
||||
}
|
||||
|
||||
store.dispatch({
|
||||
type: 'USERS_LOADED',
|
||||
|
||||
@ -28,7 +28,9 @@ const UIMiddleware = (function(){
|
||||
break
|
||||
|
||||
case 'OPEN_MODAL':
|
||||
ReactGA.event({ category: 'Modal', action: 'Opened', label: action.modal.name })
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Modal', action: 'Opened', label: action.modal.name });
|
||||
}
|
||||
$('body').addClass('modal-open')
|
||||
store.dispatch(uiActions.hideContextMenu())
|
||||
store.dispatch(uiActions.hideTouchContextMenu())
|
||||
@ -36,7 +38,9 @@ const UIMiddleware = (function(){
|
||||
break
|
||||
|
||||
case 'CLOSE_MODAL':
|
||||
ReactGA.event({ category: 'Modal', action: 'Closed', label: null })
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Modal', action: 'Closed', label: null });
|
||||
}
|
||||
$('body').removeClass('modal-open')
|
||||
next(action)
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user