Adding FormProEligibilityId for NPS for better logging (#479)

Adding FormProEligibilityId for NPS for better logging
This commit is contained in:
BidishaMS 2023-03-15 14:44:58 +05:30 коммит произвёл GitHub
Родитель 013f23f76b
Коммит 913072b2b9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 19 добавлений и 5 удалений

Просмотреть файл

@ -5,14 +5,19 @@
/* eslint-disable no-undef */
function renderSurvey(TenantId,UserId, EnvironmentId,Geo,ProductVersion,Culture,DeviceType)
function renderSurvey(TenantId,UserId, EnvironmentId,Geo,ProductVersion,Culture,DeviceType,FormsProEligibilityId)
{
// eslint-disable-next-line no-undef
const se = new window['SurveyEmbed']("v4j5cvGGr0GRqy180BHbRytFqxSnvs1AqKx-mFT6qLBUOE5POUVGTVRDUDI1SEVaOFVaV1RGM0k4VyQlQCN0PWcu",
const se = new window['SurveyEmbed']("v4j5cvGGr0GRqy180BHbRyuriZyTXitBrgQcfjK0plVUOE5POUVGTVRDUDI1SEVaOFVaV1RGM0k4Vy4u",
"https://customervoice.microsoft.com/","https://mfpembedcdnmsit.azureedge.net/mfpembedcontmsit","true");
const context = {
TenantId,UserId, EnvironmentId,Geo,ProductVersion,Culture,DeviceType
TenantId:TenantId,EnvironmentId:EnvironmentId,Geo:Geo,ProductVersion:ProductVersion,Culture:Culture,DeviceType:DeviceType
};
if (FormsProEligibilityId) {
context.FormsProEligibilityId = FormsProEligibilityId;
} else {
context.UserId = UserId;
}
se.renderPopup(context);
}
@ -112,7 +117,8 @@ function applyCustomStyles() {
const culture = el.dataset.culture;
const productVersion = el.dataset.productVersion;
const deviceType = el.dataset.deviceType;
renderSurvey(tenantId,userId,envId,geo,productVersion,culture,deviceType);
const formsProEligibilityId = el.dataset.formsProEligibilityId
renderSurvey(tenantId,userId,envId,geo,productVersion,culture,deviceType,formsProEligibilityId);
resizeSurvey();
applyCustomStyles();
}

Просмотреть файл

@ -64,6 +64,7 @@ class WebExtensionContext implements IWebExtensionContext {
private _telemetry: WebExtensionTelemetry;
private _npsEligibility: boolean;
private _userId: string;
private _formsProEligibilityId: string;
public get schemaDataSourcePropertiesMap() { return this._schemaDataSourcePropertiesMap; }
public get schemaEntitiesMap() { return this._schemaEntitiesMap; }
@ -84,6 +85,7 @@ class WebExtensionContext implements IWebExtensionContext {
public get telemetry() { return this._telemetry; }
public get npsEligibility() { return this._npsEligibility; }
public get userId() { return this._userId; }
public get formsProEligibilityId() {return this._formsProEligibilityId;}
constructor() {
this._schemaDataSourcePropertiesMap = new Map<string, string>();
@ -105,6 +107,7 @@ class WebExtensionContext implements IWebExtensionContext {
this._telemetry = new WebExtensionTelemetry();
this._npsEligibility = false;
this._userId = "";
this._formsProEligibilityId = '';
}
public setWebExtensionContext(entityName: string, entityId: string, queryParamsMap: Map<string, string>) {
@ -275,6 +278,9 @@ class WebExtensionContext implements IWebExtensionContext {
public setUserId(uid: string) {
this._userId = uid;
}
public setFormsProEligibilityId(formsProEligibilityId: string) {
this._formsProEligibilityId = formsProEligibilityId;
}
}
export default new WebExtensionContext();

Просмотреть файл

@ -81,6 +81,7 @@ export class NPSService{
if( result?.Eligibility){
WebExtensionContext.telemetry.sendAPISuccessTelemetry(telemetryEventNames.NPS_USER_ELIGIBLE, "NPS Api",httpMethod.POST,new Date().getTime() - requestSentAtTime);
WebExtensionContext.setNPSEligibility(true);
WebExtensionContext.setFormsProEligibilityId(result?.FormsProEligibilityId);
}
}catch(error){
WebExtensionContext.telemetry.sendErrorTelemetry(telemetryEventNames.NPS_API_FAILED, (error as Error)?.message);

Просмотреть файл

@ -28,6 +28,7 @@ export class NPSWebView {
const culture = vscode.env.language;
const productVersion = process?.env?.BUILD_NAME;
const deviceType = getDeviceType();
const formsProEligibilityId = WebExtensionContext.formsProEligibilityId;
WebExtensionContext.telemetry.sendInfoTelemetry(telemetryEventNames.RENDER_NPS);
return `<!DOCTYPE html>
<html lang="en">
@ -40,7 +41,7 @@ export class NPSWebView {
<div id="surveyDiv"></div>
<script src="https://mfpembedcdnmsit.azureedge.net/mfpembedcontmsit/Embed.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="https://mfpembedcdnmsit.azureedge.net/mfpembedcontmsit/Embed.css" />
<script id="npsContext" data-tid="${tid}" data-uid="${uid}" data-envId="${envId}" data-geo="${geo}" data-deviceType ="${deviceType}" data-culture ="${culture}" data-productVersion ="${productVersion}" nonce="${nonce}" type="module" src="${mainJs}"></script>
<script id="npsContext" data-tid="${tid}" data-uid="${uid}" data-envId="${envId}" data-geo="${geo}" data-deviceType ="${deviceType}" data-culture ="${culture}" data-productVersion ="${productVersion}" data-formsProEligibilityId ="${formsProEligibilityId}" nonce="${nonce}" type="module" src="${mainJs}"></script>
</body>
</html>`;
}catch(error){