Skip to content

Commit 144dc14

Browse files
committed
Improve logging
1 parent 6067a0b commit 144dc14

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

packages/app/src/app/overmind/effects/live/index.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { TextOperation } from 'ot';
1010
import { Socket, Channel } from 'phoenix';
1111
import uuid from 'uuid';
1212

13+
import { logBreadcrumb } from '@codesandbox/common/lib/utils/analytics/sentry';
1314
import clientsFactory from './clients';
1415
import { OPTIMISTIC_ID_PREFIX } from '../utils';
1516

@@ -44,12 +45,22 @@ export default new (class Live {
4445
const live = this;
4546

4647
clients = clientsFactory(
47-
(moduleShortid, revision, operation) =>
48-
live.send('operation', {
48+
(moduleShortid, revision, operation) => {
49+
logBreadcrumb({
50+
type: 'ot',
51+
message: `Sending ${JSON.stringify({
52+
moduleShortid,
53+
revision,
54+
operation,
55+
})}`,
56+
});
57+
58+
return live.send('operation', {
4959
moduleShortid,
5060
operation,
5161
revision,
52-
}),
62+
});
63+
},
5364
(moduleShortid, operation) => {
5465
options.onApplyOperation({
5566
moduleShortid,
@@ -143,6 +154,11 @@ export default new (class Live {
143154
data && data._messageId && sentMessages.delete(data._messageId)
144155
);
145156

157+
if (event === 'phx_reply' || event.startsWith('chan_reply_')) {
158+
// No action listens to this
159+
return data;
160+
}
161+
146162
action({
147163
event: alteredEvent,
148164
_isOwnMessage,

packages/app/src/app/overmind/namespaces/live/liveMessageOperators.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { NotificationStatus } from '@codesandbox/notifications/lib/state';
1111
import { Operator } from 'app/overmind';
1212
import { camelizeKeys } from 'humps';
1313
import { json, mutate } from 'overmind';
14+
import { logError } from '@codesandbox/common/lib/utils/analytics';
1415

1516
export const onJoin: Operator<LiveMessage<{
1617
status: 'connected';
@@ -490,6 +491,9 @@ export const onOperation: Operator<LiveMessage<{
490491
} catch (e) {
491492
// Something went wrong, probably a sync mismatch. Request new version
492493
console.error('Something went wrong with applying OT operation');
494+
495+
logError(e);
496+
493497
effects.live.sendModuleStateSyncRequest();
494498
}
495499
}

0 commit comments

Comments
 (0)