diff --git a/src/common/copilot/PowerPagesCopilot.ts b/src/common/copilot/PowerPagesCopilot.ts index 17efa9e9..4c804628 100644 --- a/src/common/copilot/PowerPagesCopilot.ts +++ b/src/common/copilot/PowerPagesCopilot.ts @@ -341,8 +341,9 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { if (session) { intelligenceApiToken = session.accessToken; userName = getUserName(session.account.label); - userID = session?.account.id.split("/").pop() ?? - session?.account.id; + userID = session?.account.id.split(/[./]/).shift() ?? + session?.account.id ?? + ""; } else { intelligenceApiToken = ""; userName = ""; diff --git a/src/common/services/AuthenticationProvider.ts b/src/common/services/AuthenticationProvider.ts index 8c0ba021..ab4995df 100644 --- a/src/common/services/AuthenticationProvider.ts +++ b/src/common/services/AuthenticationProvider.ts @@ -66,7 +66,7 @@ export async function intelligenceAPIAuthentication(telemetry: ITelemetry, sessi } accessToken = session?.accessToken ?? ''; user = session.account.label; - userId = session?.account.id.split("/").pop() ?? + userId = session?.account.id.split(/[./]/).shift() ?? session?.account.id ?? ""; if (!accessToken) { @@ -112,7 +112,7 @@ export async function dataverseAuthentication( } accessToken = session?.accessToken ?? ""; - userId = session?.account.id.split("/").pop() ?? + userId = session?.account.id.split(/[./]/).shift() ?? session?.account.id ?? ""; if (!accessToken) { @@ -220,7 +220,7 @@ export async function graphClientAuthentication( sendTelemetryEvent(telemetry, { eventName: VSCODE_EXTENSION_GRAPH_CLIENT_AUTHENTICATION_COMPLETED, userId: - session?.account.id.split("/").pop() ?? + session?.account.id.split(/[./]/).shift() ?? session?.account.id ?? "", }); @@ -269,7 +269,7 @@ export async function bapServiceAuthentication( sendTelemetryEvent(telemetry, { eventName: VSCODE_EXTENSION_BAP_SERVICE_AUTHENTICATION_COMPLETED, userId: - session?.account.id.split("/").pop() ?? + session?.account.id.split(/[./]/).shift() ?? session?.account.id ?? "", });