Skip to content

Commit

Permalink
Add snippet.js to NPM package
Browse files Browse the repository at this point in the history
This file is useful if someone wants to use application insights from a separate file instead of using inline JavaScript (For performance and security reasons) using a Gulp pipeline.
  • Loading branch information
RehanSaeed committed Nov 27, 2016
1 parent 243596c commit 3c110ae
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion JavaScript/.npmignore
Expand Up @@ -3,4 +3,5 @@
*

# ... but these files
!/JavaScriptSDK.Module/AppInsightsModule.js
!/JavaScriptSDK.Module/AppInsightsModule.js
!/JavaScriptSDK/snippet.js

2 comments on commit 3c110ae

@cmatskas
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get an example on how to use this external file? @RehanSaeed thanks

@RehanSaeed
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a project using this project template for a full working example or take a look at the gulpfile.js. In summary:

  1. I read my ASP.NET Core config.js file using require('./config.json').
  2. Read the CDN URL and Instrumentation key from there.
  3. Use gulp-replace-task to replace these values in snippet.js
  4. Do the usual uglify etc. to output an application-insights.js file.

Please sign in to comment.