{"id":1733,"date":"2014-03-13T19:30:00","date_gmt":"2014-03-13T19:30:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/2014\/03\/13\/using-application-insights-for-windows-phone-8-0-direct3d-c-apps\/"},"modified":"2022-07-18T02:12:42","modified_gmt":"2022-07-18T10:12:42","slug":"using-application-insights-for-windows-phone-8-0-direct3d-c-apps","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/using-application-insights-for-windows-phone-8-0-direct3d-c-apps\/","title":{"rendered":"Using Application Insights for Windows Phone 8.0 Direct3D C++ Apps"},"content":{"rendered":"<p>You can currently use Application Insights to find out how people use your <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dn509554.aspx\">Windows 8.1 Store Apps<\/a> &amp; <a href=\"http:\/\/msdn.microsoft.com\/library\/dn481093.aspx\">Managed Windows Phone 8.0 Apps<\/a>. We\u2019ve been asked about Phone 8.0 Direct3D C++ Apps as well, which the NuGet Package currently does not support. Here is a workaround that can enable you to use Application Insights for these apps.<\/p>\n<h3>Download the NuGet Package<\/h3>\n<p><a href=\"https:\/\/www.nuget.org\/api\/v2\/package\/Microsoft.ApplicationInsights.Telemetry.WindowsPhone\/\">Download<\/a> the \u201cApplication Insights Telemetry SDK for Windows Phone Apps\u201d NuGet package which contains the reference files we will use for our Direct3D C++ App. Once the package is downloaded, unzip and copy the \u201c\/build\/wp80\u201d folder to the solution directory or anywhere you want to keep the reference files. Open the \u201cwp80\u201d folder and rename \u201cx86\u201d to \u201cWin32\u201d. Here is what you will eventually get:<\/p>\n<p><img decoding=\"async\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" title=\"Pic 1\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/03\/6076.Pic-1_thumb_38C0FDA9.png\" alt=\"Pic 1\" width=\"724\" height=\"165\" border=\"0\" \/><\/p>\n<h3>Add Reference<\/h3>\n<p>Right click your Windows Phone 8.0 Direct3D C++ App project, select <strong>Add<\/strong>, <strong>Reference<\/strong>, <strong>Add New Reference<\/strong>,** Browse** and select <strong>Microsoft.ApplicationInsights.Telemetry.WindowsStoreInternal.winmd<\/strong> from either the \u201cArm\u201d or the \u201cWin32\u201d folder.<\/p>\n<p><img decoding=\"async\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" title=\"Pic 2\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/03\/0284.Pic-2_thumb_3F74072C.png\" alt=\"Pic 2\" width=\"724\" height=\"396\" border=\"0\" \/><\/p>\n<p>At this stage you will be able to use the Application Insights APIs for one specific platform (ARM or Win32). But you might want to switch the target platform between developing, testing, deploying, and packaging. You can ensure that the correct platform specific reference file gets picked up automatically:<\/p>\n<ol>\n<li>Right click the project in Solution Explorer and select <strong>Unload Project<\/strong>.<\/li>\n<li>Right click the project again and select <strong>Edit <strong><em>yourProject<\/em><\/strong>.vcxproj<\/strong>.<\/li>\n<li>In the .vcxproj file, find the \u201cMicrosoft.ApplicationInsights.Telemetry.WindowsStoreInternal\u201d reference.<\/li>\n<li>In that reference block, edit the \u201cHintPath\u201d by replacing the name of the platform folder (e.g. Arm or Win32) with \u201c$(Platform)\u201d.<\/li>\n<li>Save the file and reload the project by right clicking on the project name in Solution Explorer.<\/li>\n<\/ol>\n<p>For example, in my case, I have the following reference added:<\/p>\n<p class=\"MsoNormal\" style=\"margin: 0cm 0cm 0pt;line-height: normal\">\n  <span style=\"font-family: consolas\"><span><span style=\"color: #0000ff\"><span style=\"font-size: 9.5pt\"><<\/span><\/span><\/span><span style=\"font-size: 9.5pt\"><span><span style=\"color: #a31515\">Reference <\/span><\/span><span><span style=\"color: #ff0000\">Include<\/span><\/span><span><span style=\"color: #0000ff\">=<\/span><\/span><span>&#8220;<\/span><span><span style=\"color: #0000ff\">Microsoft.ApplicationInsights.Telemetry.WindowsStoreInternal<\/span><\/span><span>&#8220;<\/span><\/span><span><span style=\"font-size: 9.5pt;color: #0000ff\">><\/span><\/span><\/span>\n<\/p>\n<p class=\"MsoNormal\" style=\"margin: 0cm 0cm 0pt;line-height: normal\">\n  <span style=\"font-family: consolas\"><span><span style=\"color: #0000ff\"><span><span style=\"font-size: 9.5pt\">\u00a0\u00a0\u00a0 <\/span><\/span><span style=\"font-size: 9.5pt\"><<\/span><\/span><\/span><span style=\"font-size: 9.5pt\"><span><span style=\"color: #a31515\">HintPath<\/span><\/span><span><span style=\"color: #0000ff\">><\/span><\/span><span>&#8230;&#8230;&#8230;.DownloadsMicrosoft.ApplicationInsights.Telemetry.WindowsPhone.0.6.56.3buildwp80<\/span><span><span style=\"background-color: #ff0000\">Win32<\/span><\/span><span>Microsoft.ApplicationInsights.Telemetry.WindowsStoreInternal.winmd<\/span><span><span style=\"color: #0000ff\"><\/<\/span><\/span><span><span style=\"color: #a31515\">HintPath<\/span><\/span><\/span><span><span style=\"font-size: 9.5pt;color: #0000ff\">><\/span><\/span><\/span>\n<\/p>\n<p class=\"MsoNormal\" style=\"margin: 0cm 0cm 0pt;line-height: normal\">\n  <span style=\"font-family: consolas\"><span><span style=\"color: #0000ff\"><span><span style=\"font-size: 9.5pt\">\u00a0\u00a0\u00a0 <\/span><\/span><span style=\"font-size: 9.5pt\"><<\/span><\/span><\/span><span style=\"font-size: 9.5pt\"><span><span style=\"color: #a31515\">IsWinMDFile<\/span><\/span><span><span style=\"color: #0000ff\">><\/span><\/span><span>true<\/span><span><span style=\"color: #0000ff\"><\/<\/span><\/span><span><span style=\"color: #a31515\">IsWinMDFile<\/span><\/span><\/span><span><span style=\"font-size: 9.5pt;color: #0000ff\">><\/span><\/span><\/span>\n<\/p>\n<p class=\"MsoNormal\" style=\"margin: 0cm 0cm 8pt;line-height: 12pt\">\n  <span style=\"font-family: consolas\"><span style=\"line-height: 10pt\"><span style=\"color: #0000ff\"><span style=\"font-size: 9.5pt\"><\/<\/span><\/span><\/span><span style=\"font-size: 9.5pt\"><span style=\"line-height: 10pt\"><span style=\"color: #a31515\">Reference<\/span><\/span><\/span><span style=\"line-height: 10pt\"><span style=\"font-size: 9.5pt;color: #0000ff\">><\/span><\/span><\/span>\n<\/p>\n<p>And I will edit that to get this:<\/p>\n<p class=\"MsoNormal\" style=\"margin: 0cm 0cm 0pt;line-height: normal\">\n  <span style=\"font-family: consolas\"><span><span style=\"color: #0000ff\"><span style=\"font-size: 9.5pt\"><<\/span><\/span><\/span><span style=\"font-size: 9.5pt\"><span><span style=\"color: #a31515\">Reference <\/span><\/span><span><span style=\"color: #ff0000\">Include<\/span><\/span><span><span style=\"color: #0000ff\">=<\/span><\/span><span>&#8220;<\/span><span><span style=\"color: #0000ff\">Microsoft.ApplicationInsights.Telemetry.WindowsStoreInternal<\/span><\/span><span>&#8220;<\/span><\/span><span><span style=\"font-size: 9.5pt;color: #0000ff\">><\/span><\/span><\/span>\n<\/p>\n<p class=\"MsoNormal\" style=\"margin: 0cm 0cm 0pt;line-height: normal\">\n  <span style=\"font-family: consolas\"><span><span style=\"color: #0000ff\"><span><span style=\"font-size: 9.5pt\">\u00a0\u00a0\u00a0 <\/span><\/span><span style=\"font-size: 9.5pt\"><<\/span><\/span><\/span><span style=\"font-size: 9.5pt\"><span><span style=\"color: #a31515\">HintPath<\/span><\/span><span><span style=\"color: #0000ff\">><\/span><\/span><span>&#8230;&#8230;&#8230;.DownloadsMicrosoft.ApplicationInsights.Telemetry.WindowsPhone.0.6.56.3buildwp80<\/span><span><span style=\"background-color: #00ff00\">$(Platform)<\/span><\/span><span>Microsoft.ApplicationInsights.Telemetry.WindowsStoreInternal.winmd<\/span><span><span style=\"color: #0000ff\"><\/<\/span><\/span><span><span style=\"color: #a31515\">HintPath<\/span><\/span><\/span><span><span style=\"font-size: 9.5pt;color: #0000ff\">><\/span><\/span><\/span>\n<\/p>\n<p class=\"MsoNormal\" style=\"margin: 0cm 0cm 0pt;line-height: normal\">\n  <span style=\"font-family: consolas\"><span><span style=\"color: #0000ff\"><span><span style=\"font-size: 9.5pt\">\u00a0\u00a0\u00a0 <\/span><\/span><span style=\"font-size: 9.5pt\"><<\/span><\/span><\/span><span style=\"font-size: 9.5pt\"><span><span style=\"color: #a31515\">IsWinMDFile<\/span><\/span><span><span style=\"color: #0000ff\">><\/span><\/span><span>true<\/span><span><span style=\"color: #0000ff\"><\/<\/span><\/span><span><span style=\"color: #a31515\">IsWinMDFile<\/span><\/span><\/span><span><span style=\"font-size: 9.5pt;color: #0000ff\">><\/span><\/span><\/span>\n<\/p>\n<p class=\"MsoNormal\" style=\"margin: 0cm 0cm 8pt;line-height: 12pt\">\n  <span style=\"font-family: consolas\"><span style=\"line-height: 10pt\"><span style=\"color: #0000ff\"><span style=\"font-size: 9.5pt\"><\/<\/span><\/span><\/span><span style=\"font-size: 9.5pt\"><span style=\"line-height: 10pt\"><span style=\"color: #a31515\">Reference<\/span><\/span><\/span><span style=\"line-height: 10pt\"><span style=\"font-size: 9.5pt;color: #0000ff\">><\/span><\/span><\/span>\n<\/p>\n<p>Now the correct reference will be picked up automatically, based on the target platform.<\/p>\n<h3>Get your Application Insights component ID<\/h3>\n<p>The next step is to provide an ID to the SDK that ensures that your data appears under your application component name in Application Insights.<\/p>\n<ul>\n<li>Sign in to your visualstudio.com account and go to <strong>Application Insights<\/strong>.<\/li>\n<li>Choose <strong>Add Application<\/strong> and then \u201cclick here\u201d in Step 1.<\/li>\n<\/ul>\n<p><img decoding=\"async\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" title=\"Pic 3\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/03\/3348.Pic-3_thumb_5B189322.png\" alt=\"Pic 3\" width=\"724\" height=\"182\" border=\"0\" \/><\/p>\n<ul>\n<li>Choose <strong>Windows Phone 8 App<\/strong> Type and click to show further instructions.<\/li>\n<\/ul>\n<p><img decoding=\"async\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" title=\"Pic 4\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/03\/2313.Pic-4_thumb_149A4159.png\" alt=\"Pic 4\" width=\"554\" height=\"414\" border=\"0\" \/><\/p>\n<ul>\n<li>Ignore most of the instructions! You just want to get the component ID. Give a name to your application and choose \u201cCreate\u201d (this is the application component in which you will see the usage reports once the data starts flowing).<\/li>\n<\/ul>\n<p><img decoding=\"async\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" title=\"Pic 5\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/03\/8764.Pic-5_thumb_2676D526.png\" alt=\"Pic 5\" width=\"554\" height=\"368\" border=\"0\" \/><\/p>\n<ul>\n<li>Copy the component ID from the code snippet.<\/li>\n<\/ul>\n<p><img decoding=\"async\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" title=\"Pic 6\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/03\/0743.Pic-6_thumb_7B323E1E.png\" alt=\"Pic 6\" width=\"554\" height=\"198\" border=\"0\" \/><\/p>\n<h3>Initialize the code with your component ID<\/h3>\n<p>Let\u2019s come back to the project code to continue.<\/p>\n<ul>\n<li>Find your app\u2019s Initialize() method in <em>yourProjectName<\/em>.cpp.<\/li>\n<li>Insert this at the top of the file:<\/li>\n<\/ul>\n<blockquote>\n<p><span style=\"font-family: consolas\"><span style=\"line-height: 10pt\"><span style=\"color: #0000ff\"><span style=\"font-size: 9.5pt\">using <\/span><\/span><\/span><span style=\"font-size: 9.5pt\"><span style=\"line-height: 10pt\"><span style=\"color: #0000ff\">namespace<\/span><\/span><\/span><span style=\"line-height: 10pt\"><span style=\"font-size: 9.5pt\"> Microsoft::ApplicationInsights::Telemetry::WindowsStoreInternal;<\/span><\/span><\/span><\/p>\n<\/blockquote>\n<ul>\n<li>At the end of the \u201cInitialize\u201d method, insert:<\/li>\n<\/ul>\n<blockquote>\n<p><span style=\"font-family: consolas\"><span style=\"line-height: 10pt\"><span style=\"color: #2b91af\"><span style=\"font-size: 9.5pt\">ClientAnalyticsSession<\/span><\/span><\/span><span style=\"font-size: 9.5pt\"><span style=\"line-height: 10pt\">::Default->Start(<\/span><span style=\"line-height: 10pt\"><span style=\"color: #a31515\">&#8220;<ApplicationInsightsId>&#8220;<\/span><\/span><\/span><span style=\"line-height: 10pt\"><span style=\"font-size: 9.5pt\">);<\/span><\/span><\/span><\/p>\n<\/blockquote>\n<ul>\n<li>Replace the <ApplicationInsightsId> with the component ID you copied from Application Insights Portal.<\/li>\n<li>Build and run the app on either Emulator or Device.<\/li>\n<\/ul>\n<h3>Get basic data<\/h3>\n<p>To see data in Application Insights:<\/p>\n<ol>\n<li>Run the app<\/li>\n<li>Terminate it using Back Key<\/li>\n<li>Re-launch the app<\/li>\n<li>Wait for 15-30 minutes, and then look for data in Application Insights under USAGE, with your application component selected. If you see a configuration page, you can \u201cclick to dismiss\u201d the page.<\/li>\n<\/ol>\n<p>Data is saved in a file in Isolated Storage when the app suspends or terminates, and is only sent to Application Insights when the app launches or resumes.<\/p>\n<p>At this stage, the basic telemetry data will be collected &#8211; for example: OS Name, Application Version, Device Language, Network Type, etc. This will result in a variety of (insightful!) user and environment reports which you can browse through on the portal.<\/p>\n<p>To get a sense of what the SDK is doing, check the Debug Messages in Output Window. You\u2019ll see what telemetry is collected and sent to the collection server.<\/p>\n<h3>Get more data<\/h3>\n<p>To log additional data, use the following functions from the SDK for custom telemetry:<\/p>\n<ul>\n<li><span style=\"text-decoration: underline\">Point Events<\/span>: <span style=\"font-family: consolas\"><span style=\"line-height: 10pt\"><span style=\"color: #2b91af\"><span style=\"font-size: 9.5pt\">ClientAnalyticsChannel<\/span><\/span><\/span><span style=\"font-size: 9.5pt\"><span style=\"line-height: 10pt\">::Default-><\/span><\/span><span style=\"line-height: 10pt\"><span style=\"font-size: 9.5pt\">LogEvent<\/span><\/span><\/span><\/li>\n<li><span style=\"text-decoration: underline\">Timed Events<\/span>: <span style=\"font-family: consolas\"><span style=\"line-height: 10pt\"><span style=\"color: #2b91af\"><span style=\"font-size: 9.5pt\">ClientAnalyticsChannel<\/span><\/span><\/span><span style=\"font-size: 9.5pt\"><span style=\"line-height: 10pt\">::Default-><\/span><\/span><span style=\"line-height: 10pt\"><span style=\"font-size: 9.5pt\">LogTimedEvent<\/span><\/span><\/span><\/li>\n<li><span style=\"text-decoration: underline\">Page Views<\/span>: <span style=\"font-family: consolas\"><span style=\"line-height: 10pt\"><span style=\"color: #2b91af\"><span style=\"font-size: 9.5pt\">ClientAnalyticsChannel<\/span><\/span><\/span><span style=\"font-size: 9.5pt\"><span style=\"line-height: 10pt\">::Default-><\/span><\/span><span style=\"line-height: 10pt\"><span style=\"font-size: 9.5pt\">LogPageView<\/span><\/span><\/span><\/li>\n<\/ul>\n<p><a href=\"http:\/\/msdn.microsoft.com\/library\/dn481093.aspx#logEvent\">MSDN<\/a> has details for similar methods in C# apps.<\/p>\n<p>You\u2019ll need the using statement in any file where you use those methods.<\/p>\n<h3>Conclusion<\/h3>\n<p>With this workaround, I hope you will be able to use Application Insights for your Windows Phone 8.0 Direct3D C++ Apps and start getting meaningful insights into your app\u2019s usage. Please note that this is still a workaround and not a fully supported scenario. For questions and\/or feedback, please visit the <a href=\"http:\/\/social.msdn.microsoft.com\/Forums\/en-US\/ApplicationInsights\/\">Application Insights Forum<\/a> and for feature requests check out our <a href=\"http:\/\/visualstudio.uservoice.com\/forums\/121579-visual-studio\/category\/77108-application-insights\">User Voice<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can currently use Application Insights to find out how people use your Windows 8.1 Store Apps &amp; Managed Windows Phone 8.0 Apps. We\u2019ve been asked about Phone 8.0 Direct3D C++ Apps as well, which the NuGet Package currently does not support. Here is a workaround that can enable you to use Application Insights for [&hellip;]<\/p>\n","protected":false},"author":157,"featured_media":45953,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[224,1],"tags":[],"class_list":["post-1733","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","category-devops"],"acf":[],"blog_post_summary":"<p>You can currently use Application Insights to find out how people use your Windows 8.1 Store Apps &amp; Managed Windows Phone 8.0 Apps. We\u2019ve been asked about Phone 8.0 Direct3D C++ Apps as well, which the NuGet Package currently does not support. Here is a workaround that can enable you to use Application Insights for [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/1733","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/157"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=1733"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/1733\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/45953"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=1733"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=1733"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=1733"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}