Skip to content

Commit 6c258f6

Browse files
committed
Improve breadcrumbs
1 parent ff86562 commit 6c258f6

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class CodeSandboxOTClient extends OTClient {
5757
return this.onSendOperation(revision, operation)
5858
.then(() => {
5959
logBreadcrumb({
60-
type: 'ot',
60+
category: 'ot',
6161
message: `Acknowledging ${JSON.stringify({
6262
moduleShortid: this.moduleShortid,
6363
revision,
@@ -111,6 +111,16 @@ export class CodeSandboxOTClient extends OTClient {
111111
}
112112

113113
applyClient(operation: TextOperation) {
114+
logBreadcrumb({
115+
category: 'ot',
116+
message: `Apply Client ${JSON.stringify({
117+
moduleShortid: this.moduleShortid,
118+
currentRevision: this.revision,
119+
currentState: this.state.name,
120+
operation,
121+
})}`,
122+
});
123+
114124
super.applyClient(operation);
115125
}
116126

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,28 +123,28 @@ class Live {
123123
revision: number,
124124
operation: TextOperation
125125
) => {
126+
// If we are to await a send, we do it. It will be resolved
127+
// related to number of connections changing
128+
if (this.isLiveBlockerExperiement() && this.awaitSend) {
129+
await this.awaitSend.promise;
130+
}
131+
126132
logBreadcrumb({
127-
type: 'ot',
133+
category: 'ot',
128134
message: `Sending ${JSON.stringify({
129135
moduleShortid,
130136
revision,
131137
operation,
132138
})}`,
133139
});
134140

135-
// If we are to await a send, we do it. It will be resolved
136-
// related to number of connections changing
137-
if (this.isLiveBlockerExperiement() && this.awaitSend) {
138-
await this.awaitSend.promise;
139-
}
140-
141141
return this.send('operation', {
142142
moduleShortid,
143143
operation: this.operationToElixir(operation.toJSON()),
144144
revision,
145145
}).catch(error => {
146146
logBreadcrumb({
147-
type: 'ot',
147+
category: 'ot',
148148
message: `ERROR ${JSON.stringify({
149149
moduleShortid,
150150
revision,

packages/app/src/app/overmind/effects/live/ot/client.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import { TextOperation } from 'ot';
55

66
interface IState {
7+
name: string;
78
applyClient(client: OTClient, operation: TextOperation): IState;
89
applyServer(client: OTClient, operation: TextOperation): IState;
910
serverAck(client: OTClient): IState;
@@ -14,6 +15,8 @@ interface IState {
1415
// In the 'Synchronized' state, there is no pending operation that the client
1516
// has sent to the server.
1617
class Synchronized implements IState {
18+
name = 'Synchronized';
19+
1720
applyClient(client: OTClient, operation: TextOperation) {
1821
// When the user makes an edit, send the operation to the server and
1922
// switch to the 'AwaitingConfirm' state
@@ -45,6 +48,7 @@ export const synchronized_ = new Synchronized();
4548
// to the server and is still waiting for an acknowledgement.
4649
class AwaitingConfirm implements IState {
4750
outstanding: TextOperation;
51+
name = 'AwaitingConfirm';
4852

4953
constructor(outstanding: TextOperation) {
5054
// Save the pending operation
@@ -96,6 +100,8 @@ class AwaitingWithBuffer implements IState {
96100
outstanding: TextOperation;
97101
buffer: TextOperation;
98102

103+
name = 'AwaitingWithBuffer';
104+
99105
constructor(outstanding: TextOperation, buffer: TextOperation) {
100106
// Save the pending operation and the user's edits since then
101107
this.outstanding = outstanding;

0 commit comments

Comments
 (0)