Revert "Add telemetry for OpenTerminal success/failure (#192)" (#198)

This reverts commit 83b13de685.
This commit is contained in:
Tanuj Mittal 2020-09-11 23:12:28 -07:00 committed by GitHub
parent 728eeefa17
commit c4257bf4a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 48 deletions

View File

@ -48,31 +48,16 @@ export function sendCachedDataMessage<TResponseDataModel>(
export function sendMessage(data: any): void {
if (canSendMessage()) {
const dataExplorerWindow = getDataExplorerWindow();
if (dataExplorerWindow) {
dataExplorerWindow.parent.postMessage(
window.parent.postMessage(
{
signature: "pcIframe",
data: data
},
dataExplorerWindow.document.referrer
window.document.referrer
);
}
}
}
const getDataExplorerWindow = (): Window => {
// Traverse up the window to find a window with `dataExplorerPlatform` property
let dataExplorerWindow: Window = window;
// TODO: Need to `any` here since the window imports Explorer which can't be in strict mode yet
// eslint-disable-next-line @typescript-eslint/no-explicit-any
while (!(dataExplorerWindow as any).dataExplorerPlatform && dataExplorerWindow.parent) {
dataExplorerWindow = dataExplorerWindow.parent;
}
return dataExplorerWindow;
};
export function canSendMessage(): boolean {
return window.parent !== window;
}

View File

@ -70,8 +70,7 @@ export enum Action {
NotebooksGitHubManualRepoAdd,
NotebooksGitHubManageRepo,
NotebooksGitHubCommit,
NotebooksGitHubDisconnect,
OpenTerminal
NotebooksGitHubDisconnect
}
export const ActionModifiers = {

View File

@ -4,8 +4,6 @@ import "@jupyterlab/terminal/style/index.css";
import "./index.css";
import { ServerConnection } from "@jupyterlab/services";
import { JupyterLabAppFactory } from "./JupyterLabAppFactory";
import { Action } from "../Shared/Telemetry/TelemetryConstants";
import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
const getUrlVars = (): { [key: string]: string } => {
const vars: { [key: string]: string } = {};
@ -16,7 +14,10 @@ const getUrlVars = (): { [key: string]: string } => {
return vars;
};
const createServerSettings = (urlVars: { [key: string]: string }): ServerConnection.ISettings => {
const main = (): void => {
const urlVars = getUrlVars();
console.log("URL parameters", urlVars);
let body: BodyInit;
if (urlVars.hasOwnProperty("terminalEndpoint")) {
body = JSON.stringify({
@ -38,29 +39,14 @@ const createServerSettings = (urlVars: { [key: string]: string }): ServerConnect
fetch: window.parent.fetch
};
}
const serverSettings = ServerConnection.makeSettings(options);
return ServerConnection.makeSettings(options);
};
const main = async (): Promise<void> => {
const urlVars = getUrlVars();
const serverSettings = createServerSettings(urlVars);
const startTime = TelemetryProcessor.traceStart(Action.OpenTerminal, {
baseUrl: serverSettings.baseUrl
});
try {
if (urlVars.hasOwnProperty("terminal")) {
await JupyterLabAppFactory.createTerminalApp(serverSettings);
} else {
throw new Error("Only terminal is supported");
JupyterLabAppFactory.createTerminalApp(serverSettings);
return;
}
TelemetryProcessor.traceSuccess(Action.OpenTerminal, startTime);
} catch (error) {
TelemetryProcessor.traceFailure(Action.OpenTerminal, startTime);
}
throw new Error("Only terminal is supported");
};
window.addEventListener("load", main);