Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit ecff6b6

Browse files
authored
Merge pull request #25 from aws/notebookLogging
chore: notebook event logging to console
2 parents f0eab03 + a6d0b3f commit ecff6b6

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/events.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,6 @@ export interface NotebookEventData {
6363
export const send = (type: NotebookEventTypeValue, payload = '') => {
6464
const event: NotebookEventData = { type, payload };
6565
const parent = window.parent;
66-
67-
const { origin } = window.location;
68-
const jupyterConfigData = JSON.parse(
69-
document.getElementById('jupyter-config-data').textContent
70-
);
71-
fetch(
72-
`${origin}${
73-
jupyterConfigData.baseUrl
74-
}api/contents?postMessage=${JSON.stringify(event)}`
75-
);
7666
parent.postMessage(event, '*');
7767
};
7868

@@ -206,6 +196,19 @@ export const onNotebookEventReceived = (
206196
NotebookUnmount
207197
} = NotebookEventType;
208198

199+
const { origin } = window.location;
200+
const jupyterConfigData = JSON.parse(
201+
document.getElementById('jupyter-config-data').textContent
202+
);
203+
204+
/**
205+
* We call jupyter's contents API; while this call technically does nothing it will log the API call to console which will be
206+
* added to Cloudwatch where we will be able to query if needed.
207+
*/
208+
fetch(
209+
`${origin}${jupyterConfigData.baseUrl}api/contents?postMessage=${type}&origin=${message.origin}`
210+
);
211+
209212
switch (type) {
210213
/**
211214
* The idea for this event is that when the container is initializing the notebook, it can potentially send the state of a

0 commit comments

Comments
 (0)