mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 09:20:16 +00:00
Add telemetry for OpenTerminal success/failure (#192)
* Add telemetry for OpenTerminal success/failure * Address review comments
This commit is contained in:
@@ -48,16 +48,31 @@ export function sendCachedDataMessage<TResponseDataModel>(
|
||||
|
||||
export function sendMessage(data: any): void {
|
||||
if (canSendMessage()) {
|
||||
window.parent.postMessage(
|
||||
{
|
||||
signature: "pcIframe",
|
||||
data: data
|
||||
},
|
||||
window.document.referrer
|
||||
);
|
||||
const dataExplorerWindow = getDataExplorerWindow();
|
||||
if (dataExplorerWindow) {
|
||||
dataExplorerWindow.parent.postMessage(
|
||||
{
|
||||
signature: "pcIframe",
|
||||
data: data
|
||||
},
|
||||
dataExplorerWindow.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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user