Skip to content

Commit

Permalink
Turf most tracking
Browse files Browse the repository at this point in the history
Get rid of tests which are no longer relevant
  • Loading branch information
chainlink committed Sep 20, 2022
1 parent d421573 commit 02b96c6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,52 +56,6 @@ describe('telemetry plugin', () => {
);
});

it('should track app commands', async () => {
await telemetry.activate(app);
app.commands.addCommand('fake:command', {execute: jest.fn()});
await app.commands.execute('fake:command', {fake: 'args'});

expect(track).toHaveBeenCalledWith('command', {
id: 'fake:command',
args: {fake: 'args'},
});
});

it('should track notebook commands with a prompt', async () => {
await telemetry.activate(app);

expect(track).toHaveBeenCalledWith('command', {
id: 'notebook:action:executed',
args: {
action: 'pachctl version',
},
});
});

it('should track notebook commands without a prompt', async () => {
getNotebookAction.mockImplementation(() => ({
cell: {
inputArea: {
node: {
innerText: 'Hello Telemetry',
},
},
promptNode: {
innerText: '',
},
},
}));

await telemetry.activate(app);

expect(track).toHaveBeenCalledWith('command', {
id: 'notebook:action:executed',
args: {
action: 'Hello Telemetry',
},
});
});

it('should track clicks', () => {
const {getByTestId, getByText} = render(
<>
Expand Down
42 changes: 0 additions & 42 deletions jupyter-extension/src/plugins/telemetry/telemetry.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,9 @@
import {JupyterFrontEnd} from '@jupyterlab/application';
import {NotebookActions} from '@jupyterlab/notebook';
import debounce from 'lodash/debounce';
import {load, track} from 'rudder-sdk-js';

export const CLICK_TIMEOUT = 500;

/**
* TODO: This captures a lot of events. Some we might want to filter out.
* Some events don't get captured if clicked from top level menus.
* We'll need to figure out if menu command tracking is different,
* or maybe even add custom tracking for them.
*/
const initCommandTracking = (app: JupyterFrontEnd): void => {
app.commands.commandExecuted.connect((_, command) => {
track('command', {
id: command.id,
// We have to copy the args to a plain object
args: JSON.parse(JSON.stringify(command.args)),
});
});
};

const initNotebookTracking = () => {
NotebookActions.executed.connect((_, action) => {
// This transforms '[1]: pachctl version' to 'pachctl version'
const promptText = action.cell.promptNode.innerText;
const actionText = action.cell.inputArea.node.innerText.replace(
promptText ? promptText + '\n' : '',
'',
);

track('command', {
id: 'notebook:action:executed',
args: {
action: actionText,
},
});
});
};

const initTerminalTracking = () => {
// TODO: what info do we want to track from a terminal?
};

const handleClick = debounce(
(evt: Event) => {
const element = evt.target as HTMLElement;
Expand Down Expand Up @@ -72,8 +33,5 @@ export const init = (app: JupyterFrontEnd): void => {
'20C6D2xFLRmyFTqtvYDEgNfwcRG',
'https://pachyderm-dataplane.rudderstack.com',
);
initCommandTracking(app);
initNotebookTracking();
initTerminalTracking();
initClickTracking();
};

0 comments on commit 02b96c6

Please sign in to comment.