You should defend against data not existing on the event object. I.e. wrap all of the logic in here around a conditional:
```JavaScript
 var receiveEvent = function(event) {
    if(event && data in event) {
        var data = JSON.parse(event.data);
        // Do other stuff
    } else {
        mediator.emit('module:error', 'Invalid data returned from socket, 'modules/websocket.js');
    }
}