Skip to content

Commit

Permalink
Pac-cli bump up, envId changes and telemetry update (#1047)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyaginidhi authored Oct 16, 2024
1 parent 8f1e2c1 commit 96f0aee
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 39 deletions.
2 changes: 1 addition & 1 deletion gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ async function snapshot() {
}
}

const cliVersion = '1.34.4';
const cliVersion = '1.35.1';

const recompile = gulp.series(
clean,
Expand Down
24 changes: 23 additions & 1 deletion src/web/client/WebExtensionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -73,6 +73,8 @@ export interface IWebExtensionContext {
geoName: string;
geoLongName: string;
serviceEndpointCategory: ServiceEndpointCategory;
organizationId: string;
environmentId: string;

// Telemetry and survey
telemetry: WebExtensionTelemetry;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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) {
Expand Down
35 changes: 3 additions & 32 deletions src/web/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<string, string>) {
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);
}
4 changes: 2 additions & 2 deletions src/web/client/telemetry/webExtensionTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down
5 changes: 5 additions & 0 deletions src/web/client/test/integration/webExtensionTelemetry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/web/client/utilities/commonUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -307,7 +307,7 @@ export function getRangeForMultilineMatch(text: string, pattern: string, index:
}

export async function validateWebsitePreviewURL(): Promise<boolean> {
const envId = WebExtensionContext.urlParametersMap?.get(queryParameters.ENV_ID);
const envId = getEnvironmentIdFromUrl();
const serviceEndpointStamp = WebExtensionContext.serviceEndpointCategory;
const websitePreviewId = WebExtensionContext.urlParametersMap?.get(queryParameters.PORTAL_ID);

Expand Down

0 comments on commit 96f0aee

Please sign in to comment.