Show the debugger survey banner for only a subset of users.#2425
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2425 +/- ##
==========================================
+ Coverage 75.4% 75.49% +0.08%
==========================================
Files 309 309
Lines 14331 14363 +32
Branches 2536 2538 +2
==========================================
+ Hits 10807 10843 +36
+ Misses 3515 3512 -3
+ Partials 9 8 -1
Continue to review full report at Codecov.
|
|
|
||
| // "enabled" state | ||
|
|
||
| public isEnabled(): boolean { |
There was a problem hiding this comment.
It isn't necessarily a cheap operation. A function reflects that.
| createTemporaryFile(extension: string): Promise<TemporaryFile>; | ||
| } | ||
|
|
||
| export const IRuntime = Symbol('IRuntime'); |
There was a problem hiding this comment.
Looks more like utilities than runtime
|
|
||
| public async show(): Promise<void> { | ||
| const appShell = this.serviceContainer.get<IApplicationShell>(IApplicationShell); | ||
| const msg = 'Can you please take 2 minutes to tell us how the Debugger is working for you?'; |
| const yes = 'Yes, take survey now'; | ||
| const no = 'No thanks'; | ||
| const response = await appShell.showInformationMessage('Can you please take 2 minutes to tell us how the Debugger is working for you?', yes, no); | ||
| const later = 'Remind me Later'; |
| ) { } | ||
|
|
||
| public initialize() { | ||
| if (this.initialized) { |
There was a problem hiding this comment.
can it simply init itself in ctor?
There was a problem hiding this comment.
Apparently constructors are meant to contain only trivial initialization operations. Hence a separate initialize() method.
There was a problem hiding this comment.
But it has to be called anyway right after the construction? What does it save?
d3r3kk
left a comment
There was a problem hiding this comment.
I think your solution works. Consider my feedback on caching all the services on init, but it's definitely not necessary. @MikhailArkhipov's suggestions on wording/names are good ideas too.
| // "enabled" state | ||
|
|
||
| public isEnabled(): boolean { | ||
| const factory = this.serviceContainer.get<IPersistentStateFactory>(IPersistentStateFactory); |
There was a problem hiding this comment.
Any way we can cache this at the initialize step in the class? Probably not going to make a huge difference, but perhaps it will speed some things along.
There was a problem hiding this comment.
I'm going to punt on this. :) There are a lot of little improvements that could be made. I had to stop myself. :)
| const runtime = this.serviceContainer.get<IRuntime>(IRuntime); | ||
| const randomSample = runtime.getRandomInt(0, 100); | ||
| selected = randomSample < SAMPLE_SIZE_PER_HUNDRED; | ||
| state.updateValue(selected).ignoreErrors(); |
There was a problem hiding this comment.
You can probably just await this one, no need to use the ignoreErrors I don't think. Consider using a then-clause?
state.updateValue(selected).then(() => {
do_something_on_success();
}, (failReason) => {
do_something_else_on_fail();
}There was a problem hiding this comment.
This was copied from somewhere else.
(fixes #2300)
"1.2.3", not"^1.2.3")package-lock.jsonhas been regenerated if dependencies have changed