This will throw an error if `event.data` is falsy. I'd recommend just omitting the `if (data)` check and doing

```js
var context;
try {
    context = JSON.parse(event.data);
} catch (e) {
    context = {};
}
// ...
```

Also, there's no reason to use the truthy ternary or `null`. It's shorter and easier to read as 
```js
emit(context.event, context.data, context.callbackId || null);
```