Buildout pre-3.8.1; Anonymise user_id etc, fixes xes #232
This commit is contained in:
@ -99,21 +99,27 @@ const PusherMiddleware = (function(){
|
||||
|
||||
case 'PUSHER_CONNECT':
|
||||
|
||||
if (socket != null) socket.close();
|
||||
// Stagnant socket, close it first
|
||||
if (socket != null){
|
||||
socket.close();
|
||||
}
|
||||
|
||||
store.dispatch({ type: 'PUSHER_CONNECTING' });
|
||||
|
||||
var state = store.getState();
|
||||
var connection = {
|
||||
clientid: helpers.generateGuid(),
|
||||
client_id: helpers.generateGuid(),
|
||||
connection_id: helpers.generateGuid(),
|
||||
username: 'Anonymous'
|
||||
}
|
||||
if (state.pusher.username ) connection.username = state.pusher.username;
|
||||
connection.username = connection.username.replace(/\W/g, '')
|
||||
if (state.pusher.username){
|
||||
connection.username = state.pusher.username;
|
||||
}
|
||||
connection.username = connection.username.replace(/\W/g, '');
|
||||
|
||||
socket = new WebSocket(
|
||||
'ws'+(window.location.protocol === 'https:' ? 's' : '')+'://'+state.mopidy.host+':'+state.mopidy.port+'/iris/ws/',
|
||||
[ connection.clientid, connection.connection_id, connection.username ]
|
||||
[ connection.client_id, connection.connection_id, connection.username ]
|
||||
);
|
||||
|
||||
socket.onmessage = (message) => {
|
||||
@ -135,7 +141,7 @@ const PusherMiddleware = (function(){
|
||||
break;
|
||||
|
||||
case 'PUSHER_CONNECTED':
|
||||
ReactGA.event({ category: 'Pusher', action: 'Connected', label: action.username })
|
||||
ReactGA.event({ category: 'Pusher', action: 'Connected', label: action.username})
|
||||
request(store, 'get_config')
|
||||
.then(
|
||||
response => {
|
||||
@ -145,7 +151,7 @@ const PusherMiddleware = (function(){
|
||||
}
|
||||
|
||||
response.type = 'PUSHER_CONFIG'
|
||||
store.dispatch(response)
|
||||
store.dispatch(response);
|
||||
|
||||
var core = store.getState().core
|
||||
if (!core.country || !core.locale){
|
||||
|
||||
@ -11,6 +11,7 @@ export default function reducer(pusher = {}, action){
|
||||
connected: true,
|
||||
connecting: false,
|
||||
connection_id: action.connection_id,
|
||||
client_id: action.client_id,
|
||||
username: action.username
|
||||
});
|
||||
|
||||
|
||||
@ -18,7 +18,13 @@ const SpotifyMiddleware = (function(){
|
||||
|
||||
case 'SPOTIFY_CONNECTED':
|
||||
var label = null
|
||||
if (store.getState().spotify.me) label = store.getState().spotify.me.id
|
||||
if (store.getState().spotify.me){
|
||||
if (store.getState().core.anonymise_analytics){
|
||||
label = "anonymised_"+store.getState().pusher.client_id;
|
||||
} else {
|
||||
label = store.getState().spotify.me.id;
|
||||
}
|
||||
}
|
||||
ReactGA.event({ category: 'Spotify', action: 'Connected', label: label })
|
||||
|
||||
// TODO: remove this so we don't tap out our API limits before we even get started
|
||||
@ -31,7 +37,7 @@ const SpotifyMiddleware = (function(){
|
||||
break
|
||||
|
||||
case 'SPOTIFY_AUTHORIZATION_GRANTED':
|
||||
ReactGA.event({ category: 'Spotify', action: 'Authorization granted' });
|
||||
ReactGA.event({ category: 'Spotify', action: 'Authorization granted'});
|
||||
|
||||
// Flush out the previous user's library
|
||||
store.dispatch(spotifyActions.flushLibrary());
|
||||
@ -42,9 +48,13 @@ const SpotifyMiddleware = (function(){
|
||||
case 'SPOTIFY_AUTHORIZATION_REVOKED':
|
||||
var label = null
|
||||
if (store.getState().spotify.me){
|
||||
label = store.getState().spotify.me.id;
|
||||
if (store.getState().core.anonymise_analytics){
|
||||
label = "anonymised_"+store.getState().pusher.client_id;
|
||||
} else {
|
||||
label = store.getState().spotify.me.id;
|
||||
}
|
||||
}
|
||||
ReactGA.event({ category: 'Spotify', action: 'Authorization revoked', label: label })
|
||||
ReactGA.event({ category: 'Spotify', action: 'Authorization revoked', label: label})
|
||||
next(action)
|
||||
|
||||
// Now dispatch a getMe to get the backend-provided user
|
||||
@ -58,7 +68,11 @@ const SpotifyMiddleware = (function(){
|
||||
case 'SPOTIFY_IMPORT_AUTHORIZATION':
|
||||
var label = null;
|
||||
if (action.me && action.me.id){
|
||||
label = action.me.id
|
||||
if (store.getState().core.anonymise_analytics){
|
||||
label = "anonymised_"+store.getState().pusher.client_id;
|
||||
} else {
|
||||
label = action.me.id;
|
||||
}
|
||||
}
|
||||
ReactGA.event({ category: 'Spotify', action: 'Authorization imported', label: label });
|
||||
|
||||
@ -420,8 +434,15 @@ const SpotifyMiddleware = (function(){
|
||||
// Use 'me' name as my Pusher username
|
||||
store.dispatch(pusherActions.setUsername(name));
|
||||
}
|
||||
ReactGA.set({userId: action.data.id});
|
||||
ReactGA.event({category: 'Spotify', action: 'Authorization verified', label: action.data.id});
|
||||
|
||||
var label = null;
|
||||
if (store.getState().core.anonymise_analytics){
|
||||
label = "anonymised_"+store.getState().pusher.client_id;
|
||||
} else {
|
||||
ReactGA.set({userId: action.data.id});
|
||||
label = action.data.id;
|
||||
}
|
||||
ReactGA.event({category: 'Spotify', action: 'Authorization verified', label: label});
|
||||
|
||||
store.dispatch({
|
||||
type: 'USERS_LOADED',
|
||||
|
||||
@ -395,7 +395,21 @@ class Settings extends React.Component {
|
||||
name="log_actions"
|
||||
checked={ this.props.ui.clear_tracklist_on_play }
|
||||
onChange={ e => this.props.uiActions.set({ clear_tracklist_on_play: !this.props.ui.clear_tracklist_on_play })} />
|
||||
<span className="label">Clear tracklist on play of URI(s)</span>
|
||||
<span className="label has-tooltip">
|
||||
Clear tracklist on play of URI(s)
|
||||
<span className="tooltip">Playing one or more URIs will clear the current play queue first</span>
|
||||
</span>
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="log_actions"
|
||||
checked={ this.props.core.anonymise_analytics }
|
||||
onChange={ e => this.props.coreActions.set({ anonymise_analytics: !this.props.core.anonymise_analytics })} />
|
||||
<span className="label has-tooltip">
|
||||
Exclude personal data from collection
|
||||
<span className="tooltip">Personal data used for debugging Iris is not collected by Google Analytics</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user