Skip to content

Commit 773a83f

Browse files
authored
fix: standardize telemetry property conventions (#599)
2 parents 4c3d3b6 + 9a5cf10 commit 773a83f

9 files changed

Lines changed: 26 additions & 35 deletions

File tree

src/commands/discoveryService.manageCredentials/manageCredentials.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,9 @@ export async function manageCredentials(context: IActionContext, node: TreeEleme
4545
return;
4646
}
4747

48-
try {
49-
// Call the filter function provided by the provider
50-
await provider.configureCredentials(context, node as TreeElement);
48+
// Call the filter function provided by the provider
49+
await provider.configureCredentials(context, node as TreeElement);
5150

52-
// Refresh the discovery branch data provider to show the updated list
53-
ext.discoveryBranchDataProvider.refresh(node as TreeElement);
54-
} catch (error) {
55-
context.telemetry.properties.result = 'Failed';
56-
context.telemetry.properties.errorReason = 'configureCredentialsThrew';
57-
throw error;
58-
}
51+
// Refresh the discovery branch data provider to show the updated list
52+
ext.discoveryBranchDataProvider.refresh(node as TreeElement);
5953
}

src/extension.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,9 @@ export async function activateInternal(
9494

9595
const enableAIQueryGeneration = vscode.workspace
9696
.getConfiguration()
97-
.get<boolean>(ext.settingsKeys.enableAIQueryGeneration, false)
98-
.toString();
97+
.get<boolean>(ext.settingsKeys.enableAIQueryGeneration, false);
9998

100-
telemetryContext.telemetry.properties.enableAIQueryGeneration = enableAIQueryGeneration;
99+
telemetryContext.telemetry.properties.enableAIQueryGeneration = enableAIQueryGeneration ? 'true' : 'false';
101100
});
102101

103102
// Create the DocumentDB Extension API v0.2.0

src/plugins/api-shared/azure/subscriptionFiltering/FilterTenantSubStep.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,9 @@ export class FilterTenantSubStep extends AzureWizardPromptStep<FilteringWizardCo
7979
const totalTenants = context.availableTenants?.length ?? 0;
8080
context.telemetry.measurements.selectedTenantsForFilteringCount = selectedItems.length;
8181
context.telemetry.measurements.unselectedTenantsForFilteringCount = totalTenants - selectedItems.length;
82-
context.telemetry.properties.allTenantsSelectedForFiltering = (
83-
selectedItems.length === totalTenants
84-
).toString();
85-
context.telemetry.properties.noTenantsSelectedForFiltering = (selectedItems.length === 0).toString();
82+
context.telemetry.properties.allTenantsSelectedForFiltering =
83+
selectedItems.length === totalTenants ? 'true' : 'false';
84+
context.telemetry.properties.noTenantsSelectedForFiltering = selectedItems.length === 0 ? 'true' : 'false';
8685
}
8786

8887
public shouldPrompt(): boolean {

src/plugins/api-shared/azure/subscriptionFiltering/InitializeFilteringStep.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class InitializeFilteringStep extends AzureWizardPromptStep<FilteringWiza
119119
// Determine the flow based on tenant count, but let's look at the actual subscriptions,
120120
// so that in case of a tenant without subscriptions, we don't bother the user with these.
121121
const uniqueTenants = this.getUniqueTenants(context.allSubscriptions);
122-
context.telemetry.properties.tenantCountFromSubscriptions = uniqueTenants.length.toString();
122+
context.telemetry.measurements.tenantCountFromSubscriptions = uniqueTenants.length;
123123

124124
if (uniqueTenants.length > 1) {
125125
context.telemetry.properties.filteringFlow = 'multiTenant';

src/plugins/service-azure-mongo-ru/utils/ruClusterHelpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export async function extractCredentialsFromRUAccount(
9595
};
9696

9797
// Add telemetry properties from subscription
98-
context.telemetry.properties.isCustomCloud = subscription.isCustomCloud.toString();
98+
context.telemetry.properties.isCustomCloud = subscription.isCustomCloud ? 'true' : 'false';
9999

100100
return clusterCredentials;
101101
}

src/plugins/service-azure-mongo-vcore/utils/clusterHelpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export function extractCredentialsFromCluster(
100100

101101
const allowedModes = clusterInformation.properties?.authConfig?.allowedModes ?? [];
102102
context.telemetry.properties.receivedAuthMethods = allowedModes.join(',');
103-
context.telemetry.properties.receivedAuthMethodsCount = allowedModes.length.toString();
103+
context.telemetry.measurements.receivedAuthMethodsCount = allowedModes.length;
104104

105105
credentials.availableAuthMethods = allowedModes.filter(isSupportedAuthMethod);
106106

@@ -115,7 +115,7 @@ export function extractCredentialsFromCluster(
115115
}
116116

117117
// Add telemetry properties from subscription
118-
context.telemetry.properties.isCustomCloud = subscription.isCustomCloud.toString();
118+
context.telemetry.properties.isCustomCloud = subscription.isCustomCloud ? 'true' : 'false';
119119

120120
return credentials;
121121
}

src/services/taskService/tasks/copy-and-paste/CopyPasteCollectionTask.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,8 @@ export class CopyPasteCollectionTask extends Task implements ResourceTrackingTas
189189
// Add copy-paste specific telemetry properties
190190
if (context) {
191191
context.telemetry.properties.onConflict = this.config.onConflict;
192-
context.telemetry.properties.isCrossConnection = (
193-
this.config.source.clusterId !== this.config.target.clusterId
194-
).toString();
192+
context.telemetry.properties.isCrossConnection =
193+
this.config.source.clusterId !== this.config.target.clusterId ? 'true' : 'false';
195194

196195
// Collect cluster metadata for source and target connections and await their completion (non-blocking for errors)
197196
const metadataPromises = [this.collectClusterMetadata(this.config.source.clusterId, 'source', context)];
@@ -229,7 +228,7 @@ export class CopyPasteCollectionTask extends Task implements ResourceTrackingTas
229228

230229
// Add telemetry about whether the target was created
231230
if (context) {
232-
context.telemetry.properties.targetWasCreated = ensureTargetResult.targetWasCreated.toString();
231+
context.telemetry.properties.targetWasCreated = ensureTargetResult.targetWasCreated ? 'true' : 'false';
233232
}
234233
} catch (error) {
235234
throw new Error(vscode.l10n.t('Failed to ensure the target collection exists.'), {

src/utils/survey.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ export function countUsageForSurvey(score: UsageImpact | number): void {
108108
*/
109109
export async function promptAfterActionEventually(score: UsageImpact | number, triggerAction?: string): Promise<void> {
110110
await callWithTelemetryAndErrorHandling('survey.measure-score', async (context: IActionContext) => {
111-
context.telemetry.properties.triggerActionScore = score.toString();
111+
context.telemetry.measurements.triggerActionScore = typeof score === 'number' ? score : Number(score);
112112
context.telemetry.properties.triggerAction = triggerAction;
113113

114114
const globalOptOut = getIsSurveyDisabledGlobally();
115-
context.telemetry.properties.isSurveyDisabledGlobally = globalOptOut.toString();
116-
context.telemetry.properties.wasPromptedInSession = surveyState.wasPromptedInSession.toString();
115+
context.telemetry.properties.isSurveyDisabledGlobally = globalOptOut ? 'true' : 'false';
116+
context.telemetry.properties.wasPromptedInSession = surveyState.wasPromptedInSession ? 'true' : 'false';
117117

118118
if (globalOptOut || surveyState.wasPromptedInSession) {
119119
return;
@@ -122,14 +122,14 @@ export async function promptAfterActionEventually(score: UsageImpact | number, t
122122
countUsageForSurvey(score);
123123

124124
const fullScore = surveyState.usageScore;
125-
context.telemetry.properties.fullScore = fullScore.toString();
125+
context.telemetry.measurements.fullScore = fullScore;
126126

127127
const scoreTargetReached = fullScore >= SurveyConfig.scoring.REQUIRED_SCORE;
128-
context.telemetry.properties.scoreTargetReached = scoreTargetReached.toString();
128+
context.telemetry.properties.scoreTargetReached = scoreTargetReached ? 'true' : 'false';
129129

130130
if (scoreTargetReached) {
131131
const isCandidate = await getIsSurveyCandidate();
132-
context.telemetry.properties.isCandidate = isCandidate.toString();
132+
context.telemetry.properties.isCandidate = isCandidate ? 'true' : 'false';
133133
await surveyPromptIfCandidate(triggerAction);
134134
}
135135
});
@@ -154,7 +154,7 @@ async function initSurvey(): Promise<void> {
154154
): boolean => {
155155
surveyState.isCandidate = isCandidate;
156156
context.telemetry.properties.reason = reason;
157-
context.telemetry.properties.isCandidate = isCandidate.toString();
157+
context.telemetry.properties.isCandidate = isCandidate ? 'true' : 'false';
158158

159159
// Add any additional properties
160160
Object.entries(extraProps).forEach(([key, value]) => {
@@ -257,7 +257,7 @@ async function initSurvey(): Promise<void> {
257257
const acceptedForABTest = normalized < SurveyConfig.settings.A_B_TEST_SELECTION;
258258

259259
return setCandidateStatus(acceptedForABTest, '07_not_in_ab_test_group', {
260-
acceptedForABTest: acceptedForABTest.toString(),
260+
acceptedForABTest: acceptedForABTest ? 'true' : 'false',
261261
normalizedValue: normalized.toFixed(6),
262262
});
263263
} catch (error) {
@@ -277,7 +277,7 @@ async function surveyPromptIfCandidate(triggerAction?: string): Promise<void> {
277277
}
278278
await callWithTelemetryAndErrorHandling('survey.prompt', async (context: IActionContext) => {
279279
const isCandidate = await getIsSurveyCandidate();
280-
context.telemetry.properties.isCandidate = isCandidate.toString();
280+
context.telemetry.properties.isCandidate = isCandidate ? 'true' : 'false';
281281
context.telemetry.properties.triggerAction = triggerAction;
282282
context.telemetry.properties.userAsked = 'false'; // this will be set to 'true' later if the user interacts with the prompt
283283
surveyState.wasPromptedInSession = true; // disarm for the rest of the session

src/webviews/documentdb/collectionView/collectionViewRouter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export const collectionsViewRouter = router({
271271
void callWithTelemetryAndErrorHandling('documentDB.query.executionIntent', (telemetryCtx) => {
272272
telemetryCtx.errorHandling.suppressDisplay = true;
273273
telemetryCtx.telemetry.properties.intent = executionIntent;
274-
telemetryCtx.telemetry.properties.pageNumber = input.pageNumber.toString();
274+
telemetryCtx.telemetry.measurements.pageNumber = input.pageNumber;
275275
telemetryCtx.telemetry.measurements.documentCount = size;
276276
});
277277

0 commit comments

Comments
 (0)