Skip to content

Commit 966f74b

Browse files
committed
don't count a jupyter notebook as opened until cells appear -- i.e., make the metric we're tracking much harsher to improve user experience
1 parent c27351f commit 966f74b

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/packages/frontend/jupyter/browser-actions.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,7 @@ export class JupyterActions extends JupyterActions0 {
153153
}
154154
});
155155

156-
// Put an entry in the project log once the jupyter notebook gets opened.
157-
// NOTE: Obviously, the project does NOT need to put entries in the log.
158-
this.syncdb.once("change", () =>
159-
this.redux?.getProjectActions(this.project_id).log_opened_time(this.path),
160-
);
156+
this.initOpenLog();
161157

162158
// project doesn't care about cursors, but browser clients do:
163159
this.syncdb.on("cursor_activity", this.syncdb_cursor_activity);
@@ -176,6 +172,23 @@ export class JupyterActions extends JupyterActions0 {
176172
}
177173
}
178174

175+
initOpenLog = () => {
176+
// Put an entry in the project log once the jupyter notebook gets opened and
177+
// shows cells.
178+
const reportOpened = () => {
179+
if (this._state == "closed") {
180+
return;
181+
}
182+
if (this.syncdb.get_one({ type: "cell" }) != null) {
183+
this.redux
184+
?.getProjectActions(this.project_id)
185+
.log_opened_time(this.path);
186+
this.syncdb.removeListener("change", reportOpened);
187+
}
188+
};
189+
this.syncdb.on("change", reportOpened);
190+
};
191+
179192
initUsageInfo = async () => {
180193
while (this._state != "closed") {
181194
try {

src/packages/sync/editor/generic/sync-doc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@ export class SyncDoc extends EventEmitter {
14631463
log("update interest");
14641464
this.initInterestLoop();
14651465

1466-
log("ensure syncstring exists in database (if not using NATS)");
1466+
log("ensure syncstring exists");
14671467
this.assert_not_closed("initAll -- before ensuring syncstring exists");
14681468
await this.ensure_syncstring_exists_in_db();
14691469

0 commit comments

Comments
 (0)