diff --git a/gulpfile.mjs b/gulpfile.mjs index 9e3036c0..1adedc4d 100644 --- a/gulpfile.mjs +++ b/gulpfile.mjs @@ -355,7 +355,7 @@ async function snapshot() { } } -const cliVersion = '1.34.4'; +const cliVersion = '1.35.1'; const recompile = gulp.series( clean, diff --git a/src/web/client/WebExtensionContext.ts b/src/web/client/WebExtensionContext.ts index 3128fa2e..7377ccc8 100644 --- a/src/web/client/WebExtensionContext.ts +++ b/src/web/client/WebExtensionContext.ts @@ -28,7 +28,7 @@ import { EntityDataMap } from "./context/entityDataMap"; import { FileDataMap } from "./context/fileDataMap"; import { IAttributePath, IEntityInfo } from "./common/interfaces"; import { ConcurrencyHandler } from "./dal/concurrencyHandler"; -import { getMailToPath, getTeamChatURL, isMultifileEnabled } from "./utilities/commonUtil"; +import { getEnvironmentIdFromUrl, getMailToPath, getTeamChatURL, isMultifileEnabled } from "./utilities/commonUtil"; import { IConnectionData, UserDataMap } from "./context/userDataMap"; import { EntityForeignKeyDataMap } from "./context/entityForeignKeyDataMap"; import { QuickPickProvider } from "./webViews/QuickPickProvider"; @@ -73,6 +73,8 @@ export interface IWebExtensionContext { geoName: string; geoLongName: string; serviceEndpointCategory: ServiceEndpointCategory; + organizationId: string; + environmentId: string; // Telemetry and survey telemetry: WebExtensionTelemetry; @@ -111,6 +113,8 @@ class WebExtensionContext implements IWebExtensionContext { private _geoLongName: string; private _clusterLocation: string; private _serviceEndpointCategory: ServiceEndpointCategory; + private _organizationId: string; + private _environmentId: string; private _telemetry: WebExtensionTelemetry; private _npsEligibility: boolean; private _userId: string; @@ -219,6 +223,18 @@ class WebExtensionContext implements IWebExtensionContext { public set serviceEndpointCategory(name: ServiceEndpointCategory) { this._serviceEndpointCategory = name; } + public get organizationId() { + return this._organizationId; + } + public set organizationId(name: string) { + this._organizationId = name; + } + public get environmentId() { + return this._environmentId; + } + public set environmentId(name: string) { + this._environmentId = name; + } public get telemetry() { return this._telemetry; } @@ -290,6 +306,8 @@ class WebExtensionContext implements IWebExtensionContext { this._geoLongName = ""; this._clusterLocation = ""; this._serviceEndpointCategory = ServiceEndpointCategory.NONE; + this._organizationId = ""; + this._environmentId = ""; this._telemetry = new WebExtensionTelemetry(); this._npsEligibility = false; this._userId = ""; @@ -343,6 +361,10 @@ class WebExtensionContext implements IWebExtensionContext { this.schemaEntitiesMap ); this._isContextSet = true; + + // Initialize org details + this._organizationId = queryParamsMap.get(Constants.queryParameters.ORG_ID) as string ?? ""; + this._environmentId = getEnvironmentIdFromUrl(); } public setVscodeWorkspaceState(workspaceState: vscode.Memento) { diff --git a/src/web/client/extension.ts b/src/web/client/extension.ts index 967617de..7557b8cd 100644 --- a/src/web/client/extension.ts +++ b/src/web/client/extension.ts @@ -40,7 +40,6 @@ import { GeoNames } from "../../common/OneDSLoggerTelemetry/telemetryConstants"; import { sendingMessageToWebWorkerForCoPresence } from "./utilities/collaborationUtils"; import { ECSFeaturesClient } from "../../common/ecs-features/ecsFeatureClient"; import { PowerPagesAppName, PowerPagesClientName } from "../../common/ecs-features/constants"; -import { IPortalWebExtensionInitQueryParametersTelemetryData } from "../../common/OneDSLoggerTelemetry/web/client/webExtensionTelemetryInterface"; import { ArtemisService } from "../../common/services/ArtemisService"; import { showErrorDialog } from "../../common/utilities/errorHandlerUtil"; import { EXTENSION_ID } from "../../common/constants"; @@ -115,11 +114,11 @@ export function activate(context: vscode.ExtensionContext): void { queryParamsMap, context.extensionUri ); - logOneDSLogger(queryParamsMap); + const orgId = queryParamsMap.get(queryParameters.ORG_ID) as string; await fetchArtemisData(orgId); WebExtensionContext.telemetry.sendInfoTelemetry(webExtensionTelemetryEventNames.WEB_EXTENSION_ORG_GEO, { orgId: orgId, orgGeo: WebExtensionContext.geoName }); - oneDSLoggerWrapper.instantiate(WebExtensionContext.geoLongName, WebExtensionContext.geoLongName); + oneDSLoggerWrapper.instantiate(WebExtensionContext.geoName, WebExtensionContext.geoLongName); WebExtensionContext.telemetry.sendExtensionInitPathParametersTelemetry( appName, @@ -153,7 +152,7 @@ export function activate(context: vscode.ExtensionContext): void { await ECSFeaturesClient.init(WebExtensionContext.telemetry.getTelemetryReporter(), { AppName: PowerPagesAppName, - EnvID: queryParamsMap.get(queryParameters.ENV_ID) as string, + EnvID: WebExtensionContext.environmentId, UserID: WebExtensionContext.userId, TenantID: queryParamsMap.get(queryParameters.TENANT_ID) as string, Region: queryParamsMap.get(queryParameters.REGION) as string, @@ -681,31 +680,3 @@ async function fetchArtemisData(orgId: string) { WebExtensionContext.serviceEndpointCategory = artemisResponse.stamp; WebExtensionContext.clusterLocation = getECSOrgLocationValue(artemisResponse.response.clusterName, artemisResponse.response.clusterNumber); } - -function logOneDSLogger(queryParamsMap: Map) { - const telemetryData: IPortalWebExtensionInitQueryParametersTelemetryData = { - eventName: webExtensionTelemetryEventNames.WEB_EXTENSION_INIT_QUERY_PARAMETERS, - properties: { - orgId: queryParamsMap.get(queryParameters.ORG_ID), - tenantId: queryParamsMap.get(queryParameters.TENANT_ID), - portalId: queryParamsMap.get(queryParameters.PORTAL_ID), - websiteId: queryParamsMap.get(queryParameters.WEBSITE_ID), - dataSource: queryParamsMap.get(queryParameters.DATA_SOURCE), - schema: queryParamsMap.get(queryParameters.SCHEMA), - referrerSessionId: queryParamsMap.get(queryParameters.REFERRER_SESSION_ID), - referrer: queryParamsMap.get(queryParameters.REFERRER), - siteVisibility: queryParamsMap.get(queryParameters.SITE_VISIBILITY), - region: queryParamsMap.get(queryParameters.REGION), - geo: queryParamsMap.get(queryParameters.GEO), - envId: queryParamsMap.get(queryParameters.ENV_ID), - referrerSource: queryParamsMap.get(queryParameters.REFERRER_SOURCE), - sku: queryParamsMap.get(queryParameters.SKU) - } - } - - if (queryParamsMap.has(queryParameters.ENTITY) && queryParamsMap.has(queryParameters.ENTITY_ID)) { - telemetryData.properties.entity = queryParamsMap.get(queryParameters.ENTITY); - telemetryData.properties.entityId = queryParamsMap.get(queryParameters.ENTITY_ID); - } - oneDSLoggerWrapper.getLogger().traceInfo(telemetryData.eventName, telemetryData.properties); -} diff --git a/src/web/client/telemetry/webExtensionTelemetry.ts b/src/web/client/telemetry/webExtensionTelemetry.ts index 5bb04634..bd5a0a9a 100644 --- a/src/web/client/telemetry/webExtensionTelemetry.ts +++ b/src/web/client/telemetry/webExtensionTelemetry.ts @@ -9,7 +9,7 @@ import { queryParameters } from "../common/constants"; import { sanitizeURL } from "../utilities/urlBuilderUtil"; import { webExtensionTelemetryEventNames } from "../../../common/OneDSLoggerTelemetry/web/client/webExtensionTelemetryEvents"; import { IPortalWebExtensionInitQueryParametersTelemetryData, IWebExtensionAPITelemetryData, IWebExtensionExceptionTelemetryData, IWebExtensionInitPathTelemetryData, IWebExtensionPerfTelemetryData } from "../../../common/OneDSLoggerTelemetry/web/client/webExtensionTelemetryInterface"; -import { isNullOrUndefined } from '../utilities/commonUtil'; +import { getEnvironmentIdFromUrl, isNullOrUndefined } from '../utilities/commonUtil'; import { oneDSLoggerWrapper } from "../../../common/OneDSLoggerTelemetry/oneDSLoggerWrapper"; export class WebExtensionTelemetry { @@ -56,7 +56,7 @@ export class WebExtensionTelemetry { siteVisibility: queryParamsMap.get(queryParameters.SITE_VISIBILITY), region: queryParamsMap.get(queryParameters.REGION), geo: queryParamsMap.get(queryParameters.GEO), - envId: queryParamsMap.get(queryParameters.ENV_ID), + envId: getEnvironmentIdFromUrl(), referrerSource: queryParamsMap.get(queryParameters.REFERRER_SOURCE), sku: queryParamsMap.get(queryParameters.SKU) } diff --git a/src/web/client/test/integration/webExtensionTelemetry.test.ts b/src/web/client/test/integration/webExtensionTelemetry.test.ts index d9a57422..27f38e3b 100644 --- a/src/web/client/test/integration/webExtensionTelemetry.test.ts +++ b/src/web/client/test/integration/webExtensionTelemetry.test.ts @@ -9,6 +9,7 @@ import { sanitizeURL } from "../../utilities/urlBuilderUtil"; import { webExtensionTelemetryEventNames } from "../../../../common/OneDSLoggerTelemetry/web/client/webExtensionTelemetryEvents"; import { WebExtensionTelemetry } from "../../telemetry/webExtensionTelemetry"; import { vscodeExtAppInsightsResourceProvider } from "../../../../common/telemetry-generated/telemetryConfiguration"; +import * as commonUtil from "../../utilities/commonUtil"; import { expect } from "chai"; describe("webExtensionTelemetry", () => { @@ -129,6 +130,10 @@ describe("webExtensionTelemetry", () => { // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any; + stub(commonUtil, "getEnvironmentIdFromUrl").returns( + "c4dc3686-1e6b-e428-b886-16cd0b9f4918" + ); + //Action webExtensionTelemetry.sendExtensionInitQueryParametersTelemetry( queryParamsMap diff --git a/src/web/client/utilities/commonUtil.ts b/src/web/client/utilities/commonUtil.ts index 7d890fb6..c258429d 100644 --- a/src/web/client/utilities/commonUtil.ts +++ b/src/web/client/utilities/commonUtil.ts @@ -219,13 +219,13 @@ export function getWorkSpaceName(websiteId: string): string { // ENV_ID is the last part of the parameter value sent in the vscode URL from studio export function getEnvironmentIdFromUrl() { - return (WebExtensionContext.urlParametersMap.get(queryParameters.ENV_ID) as string).split("/")?.pop() as string; + return (WebExtensionContext.urlParametersMap.get(queryParameters.ENV_ID))?.toString().split("/")?.pop() as string; } export function getBackToStudioURL() { const region = WebExtensionContext.urlParametersMap.get(queryParameters.REGION) as string; - if (isStringUndefinedOrEmpty(WebExtensionContext.urlParametersMap.get(queryParameters.ENV_ID)) || + if (isStringUndefinedOrEmpty(getEnvironmentIdFromUrl()) || isStringUndefinedOrEmpty(WebExtensionContext.urlParametersMap.get(queryParameters.REGION)) || isStringUndefinedOrEmpty(WebExtensionContext.urlParametersMap.get(queryParameters.WEBSITE_ID))) { return undefined; @@ -307,7 +307,7 @@ export function getRangeForMultilineMatch(text: string, pattern: string, index: } export async function validateWebsitePreviewURL(): Promise { - const envId = WebExtensionContext.urlParametersMap?.get(queryParameters.ENV_ID); + const envId = getEnvironmentIdFromUrl(); const serviceEndpointStamp = WebExtensionContext.serviceEndpointCategory; const websitePreviewId = WebExtensionContext.urlParametersMap?.get(queryParameters.PORTAL_ID);