Skip to content
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

Include prefix.js into Microsoft.ApplicationInsights.JavaScript #75

Closed
SergeyKanzhelev opened this issue Nov 12, 2015 · 12 comments
Closed
Milestone

Comments

@SergeyKanzhelev
Copy link

It is a good idea to include the snippet as a script into NuGet package as discussed here:

microsoft/ApplicationInsights-aspnetcore#120 (comment)

@RehanSaeed
Copy link
Contributor

The snippet.html file does not seem to be checked-in, although it is referred to in the NuGet.JavaScript.csproj project as ..\JavaScriptSDK\min\snippet_vsix.html. The same can be said for the ai.js and ai.min.js files. Am I missing something?

In fact the JavaScriptSDK.csproj project does not seem to load either.

@SergeyKanzhelev
Copy link
Author

@RehanSaeed
Copy link
Contributor

I see. I'm not much of an expert in PowerShell. I could copy the snippet.ps1 file and create one that generates a .js file but then most of the script will be the same and I'm not sure how you can do code reuse in PowerShell. Am I on the right track?

@MaxShehovtsov
Copy link
Contributor

Can you describe again why do we need this change? (I tried to follow microsoft/ApplicationInsights-aspnetcore#120 (comment) but it didn't really made sense to me)

@RehanSaeed
Copy link
Contributor

I want to add application insights as a separate JavaScript file, rather than inline script. This is to enable Content Security Policy (CSP) HTTP header compatibility (Inline scripts are not allowed without adding a hash or nonce attribute with specially computed values) for better security. According to the link posted by @SergeyKanzhelev, this also helped the Glimpse team achieve better performance.

To achieve this I want to use the gulp-replace plugin to take the instrumentation key from the configuration file and insert it into the application insights JavaScript file in my ASP.NET 5 project template. I could grab a copy of the file but I would have to update it myself when Microsoft changes it. It would be nice if the file came straight from a NuGet package which can be updated.

It would be even better if Microsoft released a Bower package for application insights explicitly for this purpose. @SergeyKanzhelev @MaxShehovtsov, what is Microsoft's appetite for this? Especially as Gulp and Bower are where ASP.NET 5 is headed.

@MaxShehovtsov
Copy link
Contributor

So once again, why prefix.html from nuget doesn't work?

@RehanSaeed
Copy link
Contributor

I need a separate .js file. I could use the .html file but then I would have to strip out the <script> tags using yet another Gulp plugin.

@MaxShehovtsov
Copy link
Contributor

Strip out what? :)

@SergeyKanzhelev
Copy link
Author

<script> tag

@RehanSaeed
Copy link
Contributor

I have updated the ASP.NET MVC Boilerplate project template where you can see my use case in action, please see this issue for more information.

@AlexBulankou AlexBulankou added this to the Post 1.0 release milestone Apr 4, 2016
@RehanSaeed
Copy link
Contributor

RehanSaeed commented May 16, 2016

I have spotted an applicationinsights-js bower package with the snippet.js file in it. I can now use that file in ASP.NET Core. This can be closed, unless someone finds this file useful in ASP.NET 4.6.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants