Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

Sharing code that uses Application Insights

, 15 May 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
So you have a project that uses Application Insights and want to share it with the world. Sure you just post it to CodePlex, GitHub or some other place that allows publishing of code don't you. NO!!! Something that you don't want to do is share your code without removing some of the values under the

So you have a project that uses Application Insights and want to share it with the world. Sure you just post it to CodePlex, GitHub or some other place that allows publishing of code don't you.

NO!!!

Something that you don't want to do is share your code without removing some of the values under the ComponentSettings node in your ApplicationInsights.config. I see 3 possible ways of doing this, possibly each being used in a specific scenario.

1.) Delete and publish

When: I foresee this scenario being for when you have not made any custom changes to your Application Insights configuration.

The first way is to simple delete the Application.config and publish the source code.

image

This will mean that when somebody that downloads your code wants to run it and use the Application Insights bits they will need to add new Application Insights configuration

image

After they have done that they can use your solution with Application Insights no problem

2.) Blank out or token the ComponentSettings section

When: I see this option being for when you have made modifications to the Application Insights config that you feel other users would need in order to effectively use App Insights in the application.

You could for example specify that for the Development Profile you don't want to collection user and machine names.

image

The pieces you will want to blank out or token are below

  • ComponentSettings\ComponentId
  • ComponentSettings\DevelopmentMode\ComponentId
  • ComponentSettings\DevelopmentMode\PortalURI
  • ComponentSettings\DevelopmentMode\DashboardId
  • ComponentSettings\AccountId
  • ComponentSettings\LicenseKey

image

After you have done this you are good to share your code Smile

3.) Split source control

When: You want to share the code but also want to use the application for "real", i.e.: Windows Store Application

What I have started doing for applications that I want to share the source for but also want to use the app in the real world is connecting to a public source control like CodePlex or GitHub and then also to private source control like VSO. The way I do it is to have a public GitHub repo that contains all the logic for my app, this repo is then pushed into a VSO repo as well where I do all my Application Insights stuff. Using this method allows me to work on my app normally as I would with source control and allows the community to be evolved as well with them having to worry about App Insights configuration (sometimes you would want them to be adding App Insights to the code as they add it in which case you will just keep the config separate) and then for when I publish to the store I don't have to have to add a bunch of App Insights code everywhere and keep it out of source control. All I need to do is push to my VSO account, merge any conflicts (which shouldn't happen if I'm just doing App Insights in VSO) and then possible add any additional telemetry that I want and then finally I publish to the store and everything is awesome Open-mouthed smile.

Conclusion

These are just my thoughts and there are probably other ways that people currently do it. One thing you don't want to do is share you keys because then you need to reset them and then update all applications in the wild connected to your account.

if you have other ways of handling this today give me a shout at @GordonBeeming with some details Smile

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Gordon W Beeming
Software Developer Derivco
South Africa South Africa
Gordon Beeming is a Software Developer at Derivco in the sunny city of Durban, South Africa. He spends most his time hacking away at the keyboard in Visual Studio or with his family relaxing. He is a Visual Studio ALM Rangers, Visual Studio ALM MVP and Friend of Red Gate. His blog is at 31og.com and you can follow him on Twitter at twitter.com/gordonbeeming
 
http://31og.com
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150129.1 | Last Updated 15 May 2014
Article Copyright 2014 by Gordon W Beeming
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid