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
Report first-time install metric to Particular when a user installs NServiceBus #4280
Conversation
@gbiellem - i'm done. Please review. If happy, go ahead and remove the WIP. |
} | ||
Catch [Exception] { | ||
Write-Warning $error[0] | ||
} | ||
finally { | ||
if ($wc){ | ||
$wc.Dispose() |
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.
Is this guaranteed to work? According to the doco upload async asynchronously uploads without blocking which means the finally block can be executed during the upload.
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.
@danielmarbach - See http://stackoverflow.com/questions/1999858/how-bad-is-it-to-not-dispose-in-powershell
As far as I know, the call will execute asynchronously, even after the package manager is done and back to the console. I tested this by running the backend locally and set a breakpoint. The nuget install completed and got back to the prompt but the code was still invoked and waiting at the breakpoint I set.
Also this is a one time thing. We are not calling this script over and over. IMO, it shouldn't have any impact. What exact changes are you requesting here? Do you have any suggestions of what I can add here in the powershell?
@gbiellem - your thoughts on this?
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.
I think what @danielmarbach is getting at is since the powershell script is never await
ing the result of the async UploadValuesAsync
call, that means the finally block could be executed and dispose the WebClient before the call finishes.
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.
Correct what @bording said
$postData.Add("version", $packageversion) | ||
$wc = New-Object System.Net.WebClient | ||
$wc.UseDefaultCredentials = $true | ||
$wc.UploadValuesAsync($url,"post", $postdata) |
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.
since we don't catch the exception here, what happens with the script if an exception is thrown? is that swallowed the same way as in a c# app or will this break the script?
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.
@timbussmann - I have tested this scenario with a bad url. It does not break the script.
I also tested it by disabling the network adapter and running the nuget install (from local source), errors do not get reported.
I reworked the PS Script as you requested. The way it works now is the majority of the script is run as a background job. The advantages to this approach are:
I'm hoping that as well as addressing what you wanted it may also address the hanging issue in #4235. Since we can't reproduce that issue it's hard to know for sure. I've also turned tracing on in the background job so you can see the execution path.
You'll see in the script if the Job exists in the current PS session the script skips it so for testing you'll need to remove the job between runs...
If you're not familiar with PS Jobs take a look at https://technet.microsoft.com/en-us/library/hh847783(v=wps.620).aspx I've made a few other tweaks to simplify it. Please smoke test it and see what you think |
@indualagarsamy please remove the WIP prefix if you think this one is good to go now. |
@timbussmann It's not ready. @indualagarsamy and I found an issue when smoke testing it. |
@Particular/nservicebus-maintainers - Both @gbiellem and I have tested this PS script. The only change we made in addition to @gbiellem's previous changes were to ensure that we don't display the notice message to an existing user if the user simply uninstalls/reinstalls the nuget package. We've tested this end to end. This should address @danielmarbach's original concern of disposing the httpclient. We are now using the above approach to keep the installing the package completely asynchronous in relation to making the web request call. Please review and merge. |
$platformKeyPath = 'HKCU:SOFTWARE\ParticularSoftware' | ||
|
||
if ((Test-Path $nserviceBusKeyPath) -or (Test-Path $platformKeyPath)) { | ||
New-Event -SourceIdentifier $noticeEvent -Sender "analytics" -MessageData "existing" |
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.
that event doesn't seem to be used, is this still required?
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.
Yes it's used, without it the wait-event at the end of the script would have to wait for the timeout
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.
looks good based on my very limited PS knowledge
@Particular/nservicebus-maintainers - The build is failing on a code inspection check. However, this PR has not made any code changes other than the powershell script. Can you please have a look.
|
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.
LGTM
Relates to Particular/NServiceBus#4280 Relates to #193
* Privacy policy inclusions Relates to Particular/NServiceBus#4280 Relates to #193 * removed the last updated timestamp
Relates to:
https://github.com/Particular/OptimizeTrialExtensions/issues/114
#4262
https://github.com/Particular/Operations.Website.Backend/pull/237
Release Notes
We have removed the page that pops up after installing the NServiceBus NuGet package as the general consensus is that developers don't like it. Examples:
However the page served an alternate purpose which was to indicate when someone has installed the NuGet package for the first time, information we use to determine if we are reaching developers with our message. In place of the popup page, we have added code to the installation PowerShell script that sends a web request to our server to indicate that a first-time installation has occurred to that we can retain this statistic while still removing the post-installation pop-up page.
In, the new reworked PS Script, the majority of the script is now run as a background job. The advantages to this approach are:
Pros:
Cons:
@gbiellem @andreasohlund - please have a look.