mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 09:20:16 +00:00
Fix telemetry from child windows of Data Explorer (#633)
* Fix telemetry from child windows of Data Explorer * Address feedback
This commit is contained in:
@@ -3,7 +3,7 @@ import { applyExplorerBindings } from "../applyExplorerBindings";
|
||||
import { AuthType } from "../AuthType";
|
||||
import { AccountKind, DefaultAccountExperience } from "../Common/Constants";
|
||||
import { normalizeArmEndpoint } from "../Common/EnvironmentUtility";
|
||||
import { sendReadyMessage } from "../Common/MessageHandler";
|
||||
import { sendMessage, sendReadyMessage } from "../Common/MessageHandler";
|
||||
import { configContext, Platform, updateConfigContext } from "../ConfigContext";
|
||||
import { ActionType, DataExplorerAction } from "../Contracts/ActionContracts";
|
||||
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||
@@ -266,6 +266,8 @@ async function configurePortal(explorerParams: ExplorerParams): Promise<Explorer
|
||||
if (openAction) {
|
||||
handleOpenAction(openAction, explorer.databases(), explorer);
|
||||
}
|
||||
} else if (shouldForwardMessage(message, event.origin)) {
|
||||
sendMessage(message);
|
||||
}
|
||||
},
|
||||
false
|
||||
@@ -275,6 +277,11 @@ async function configurePortal(explorerParams: ExplorerParams): Promise<Explorer
|
||||
});
|
||||
}
|
||||
|
||||
function shouldForwardMessage(message: PortalMessage, messageOrigin: string) {
|
||||
// Only allow forwarding messages from the same origin
|
||||
return messageOrigin === window.document.location.origin && message.type === MessageTypes.TelemetryInfo;
|
||||
}
|
||||
|
||||
function shouldProcessMessage(event: MessageEvent): boolean {
|
||||
if (typeof event.data !== "object") {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user