Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Composer/packages/server/src/services/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if (instrumentationKey) {
// do not collect the user's machine name
AppInsights.defaultClient.context.tags[AppInsights.defaultClient.context.keys.cloudRoleInstance] = '';
AppInsights.defaultClient.addTelemetryProcessor((envelope: AppInsights.Contracts.Envelope, context): boolean => {
const { sessionId, telemetry, composerVersion } = getTelemetryContext();
const { sessionId, telemetry, composerVersion, userId } = getTelemetryContext();

if (!telemetry?.allowDataCollection) {
return false;
Expand All @@ -49,6 +49,9 @@ if (instrumentationKey) {
// Add session id
envelope.tags[AppInsights.defaultClient.context.keys.sessionId] = sessionId;

// Add truncated user id
envelope.tags[AppInsights.defaultClient.context.keys.userId] = userId?.slice(0, Math.floor(userId.length * 0.8));

// Remove PII from url
if (envelope.data.baseType === 'RequestData' && data.baseData.url.match(/\/\d+.\d+/i)) {
if (typeof data.baseData.url === 'string') {
Expand Down