New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
debug: filter exceptions from DAP telemetry on web #97627
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/vs/workbench/contrib/debug/test/browser/telemetry.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as assert from 'assert'; | ||
import { MockDebugAdapter, createMockDebugModel } from 'vs/workbench/contrib/debug/test/common/mockDebug'; | ||
import { DebugModel } from 'vs/workbench/contrib/debug/common/debugModel'; | ||
import { DebugSession } from 'vs/workbench/contrib/debug/browser/debugSession'; | ||
import { generateUuid } from 'vs/base/common/uuid'; | ||
import { NullOpenerService } from 'vs/platform/opener/common/opener'; | ||
import { RawDebugSession } from 'vs/workbench/contrib/debug/browser/rawDebugSession'; | ||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; | ||
import { stub, SinonStub } from 'sinon'; | ||
import { timeout } from 'vs/base/common/async'; | ||
|
||
suite('Debug - DebugSession telemetry', () => { | ||
let model: DebugModel; | ||
let session: DebugSession; | ||
let adapter: MockDebugAdapter; | ||
let telemetry: { isOptedIn: boolean; sendErrorTelemetry: boolean; publicLog: SinonStub }; | ||
|
||
setup(() => { | ||
telemetry = { isOptedIn: true, sendErrorTelemetry: true, publicLog: stub() }; | ||
adapter = new MockDebugAdapter(); | ||
model = createMockDebugModel(); | ||
|
||
const telemetryService = telemetry as Partial<ITelemetryService> as ITelemetryService; | ||
session = new DebugSession(generateUuid(), undefined!, undefined!, model, undefined, undefined!, telemetryService, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, NullOpenerService, undefined!, undefined!); | ||
session.initializeForTest(new RawDebugSession(adapter, undefined!, undefined!, telemetryService, undefined!, undefined!, undefined!)); | ||
}); | ||
|
||
test('does not send telemetry when opted out', async () => { | ||
telemetry.isOptedIn = false; | ||
adapter.sendEventBody('output', { | ||
category: 'telemetry', | ||
output: 'someEvent', | ||
data: { foo: 'bar', '!err': 'oh no!' } | ||
}); | ||
|
||
await timeout(0); | ||
assert.strictEqual(telemetry.publicLog.callCount, 0); | ||
}); | ||
|
||
test('logs telemetry and exceptions when enabled', async () => { | ||
adapter.sendEventBody('output', { | ||
category: 'telemetry', | ||
output: 'someEvent', | ||
data: { foo: 'bar', '!err': 'oh no!' } | ||
}); | ||
|
||
await timeout(0); | ||
assert.deepStrictEqual(telemetry.publicLog.args[0], [ | ||
'someEvent', | ||
{ foo: 'bar', '!err': 'oh no!' } | ||
]); | ||
}); | ||
|
||
test('filters exceptions when error reporting disabled', async () => { | ||
telemetry.sendErrorTelemetry = false; | ||
|
||
adapter.sendEventBody('output', { | ||
category: 'telemetry', | ||
output: 'someEvent', | ||
data: { foo: 'bar', '!err': 'oh no!' } | ||
}); | ||
|
||
await timeout(0); | ||
assert.deepStrictEqual(telemetry.publicLog.args[0], [ | ||
'someEvent', | ||
{ foo: 'bar' } | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to move this out to a helper method which would live in
debugTelemetry.ts
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The DebugTelemetry class isn't very accessible here; that's used for the top-level of the session and sends to the global(?) telemetry service, and for this bit of telemetry we're sending to a separate instance of the service created from the
aiKey
inside the debug extension's package.json.So perhaps not a method, but I did pop this to its own helper function in debugUtils.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I like that!