├── .gitattributes ├── .gitignore ├── LICENSE ├── Projects ├── AppInsights_Win10-UAP │ ├── .vs │ │ └── AppInsights_Win10-UAP │ │ │ └── v14 │ │ │ └── .suo │ ├── AppInsights_Win10-UAP.sln │ ├── AppInsights_Win10-UAP │ │ ├── AppInsights_Win10-UAP.vcxproj │ │ ├── AppInsights_Win10-UAP.vcxproj.filters │ │ ├── dllmain.cpp │ │ ├── pch.cpp │ │ ├── pch.h │ │ └── targetver.h │ ├── ApplicationInsights │ │ ├── ApplicationInsights.vcxproj │ │ ├── ApplicationInsights.vcxproj.filters │ │ ├── PageTracking.cpp │ │ ├── PageTracking.h │ │ ├── SessionTracking.cpp │ │ ├── SessionTracking.h │ │ ├── TelemetryClient.cpp │ │ └── TelemetryClient.h │ └── UnitTestApp │ │ ├── Assets │ │ ├── Logo.scale-100.png │ │ ├── SmallLogo.scale-100.png │ │ ├── SplashScreen.scale-100.png │ │ ├── StoreLogo.scale-100.png │ │ └── WideLogo.scale-100.png │ │ ├── Package.appxmanifest │ │ ├── UnitTest.cpp │ │ ├── UnitTestApp.vcxproj │ │ ├── UnitTestApp.vcxproj.filters │ │ ├── UnitTestApp_TemporaryKey.pfx │ │ ├── pch.cpp │ │ └── pch.h └── AppInsights_Win32 │ ├── .vs │ └── application_insights │ │ └── v14 │ │ └── .suo │ ├── application_insights.sln │ ├── core │ ├── core.vcxproj │ └── core.vcxproj.filters │ ├── package │ ├── AppInsights_Win32.autopkg │ ├── README.md │ └── build.bat │ └── test │ ├── core.tests.vcxproj │ └── core.tests.vcxproj.filters ├── ReadMe.md ├── src └── core │ ├── BaseTelemetryContext.cpp │ ├── BaseTelemetryContext.h │ ├── TelemetryClient.cpp │ ├── TelemetryClient.h │ ├── TelemetryClientConfig.h │ ├── TelemetryContext.h │ ├── TelemetryContextOther.cpp │ ├── TelemetryContextWin32.cpp │ ├── TelemetryContextWinPhone.cpp │ ├── TelemetryContextWinStore.cpp │ ├── channel │ ├── TelemetryChannel.cpp │ ├── TelemetryChannel.h │ └── utils │ │ ├── HttpHeaderField.cpp │ │ ├── HttpHeaderField.h │ │ ├── HttpHeaderFields.h │ │ ├── HttpRequest.cpp │ │ ├── HttpRequest.h │ │ ├── HttpResponse.cpp │ │ └── HttpResponse.h │ ├── common │ ├── Common.h │ ├── JsonWriter.cpp │ ├── JsonWriter.h │ ├── Nullable.h │ ├── Serializer.cpp │ ├── Serializer.h │ ├── StreamWriter.cpp │ ├── StreamWriter.h │ ├── StringWriter.cpp │ ├── StringWriter.h │ ├── Utils.cpp │ └── Utils.h │ ├── contracts │ ├── Application.cpp │ ├── Application.h │ ├── Base.cpp │ ├── Base.h │ ├── Contracts.h │ ├── CrashData.cpp │ ├── CrashData.h │ ├── CrashDataBinary.cpp │ ├── CrashDataBinary.h │ ├── CrashDataHeaders.cpp │ ├── CrashDataHeaders.h │ ├── CrashDataThread.cpp │ ├── CrashDataThread.h │ ├── CrashDataThreadFrame.cpp │ ├── CrashDataThreadFrame.h │ ├── Data.cpp │ ├── Data.h │ ├── DataPoint.cpp │ ├── DataPoint.h │ ├── DataPointType.h │ ├── DependencyKind.h │ ├── DependencySourceType.h │ ├── Device.cpp │ ├── Device.h │ ├── Domain.cpp │ ├── Domain.h │ ├── Envelope.cpp │ ├── Envelope.h │ ├── EventData.cpp │ ├── EventData.h │ ├── ExceptionData.cpp │ ├── ExceptionData.h │ ├── ExceptionDetails.cpp │ ├── ExceptionDetails.h │ ├── Internal.cpp │ ├── Internal.h │ ├── Location.cpp │ ├── Location.h │ ├── MessageData.cpp │ ├── MessageData.h │ ├── MetricData.cpp │ ├── MetricData.h │ ├── Operation.cpp │ ├── Operation.h │ ├── PageViewData.cpp │ ├── PageViewData.h │ ├── PageViewPerfData.cpp │ ├── PageViewPerfData.h │ ├── RemoteDependencyData.cpp │ ├── RemoteDependencyData.h │ ├── RequestData.cpp │ ├── RequestData.h │ ├── Session.cpp │ ├── Session.h │ ├── SessionState.h │ ├── SessionStateData.cpp │ ├── SessionStateData.h │ ├── SeverityLevel.h │ ├── StackFrame.cpp │ ├── StackFrame.h │ ├── User.cpp │ └── User.h │ ├── core.vcxproj │ └── core.vcxproj.filters └── test └── core ├── ApplicationInsights ├── TestContext.cpp ├── TestPageTracking.cpp └── TestSessionTracking.cpp ├── Channel └── TestTelemetryChannel.cpp ├── TestBasicEndToEnd.cpp ├── TestTelemetryClient.cpp ├── TestTelemetryClientConfig.cpp ├── TestTelemetryContext.cpp ├── contracts ├── TestApplication.cpp ├── TestBase.cpp ├── TestCrashData.cpp ├── TestCrashDataBinary.cpp ├── TestCrashDataHeaders.cpp ├── TestCrashDataThread.cpp ├── TestCrashDataThreadFrame.cpp ├── TestDataPoint.cpp ├── TestDevice.cpp ├── TestDomain.cpp ├── TestEnvelope.cpp ├── TestEventData.cpp ├── TestExceptionData.cpp ├── TestExceptionDetails.cpp ├── TestInternal.cpp ├── TestLocation.cpp ├── TestMessageData.cpp ├── TestMetricData.cpp ├── TestOperation.cpp ├── TestPageViewData.cpp ├── TestPageViewPerfData.cpp ├── TestRemoteDependencyData.cpp ├── TestRequestData.cpp ├── TestSession.cpp ├── TestSessionStateData.cpp ├── TestStackFrame.cpp └── TestUser.cpp ├── core.tests.vcxproj ├── core.tests.vcxproj.filters ├── specializations.h └── targetver.h /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files for Xcode 5 | DerivedData/ 6 | xcuserdata/ 7 | 8 | # User-specific files 9 | *.suo 10 | *.user 11 | *.sln.docstates 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | x64/ 18 | bld/ 19 | [Bb]in/ 20 | [Oo]bj/ 21 | 22 | # Roslyn cache directories 23 | *.ide/ 24 | 25 | # MSTest test Results 26 | [Tt]est[Rr]esult*/ 27 | [Bb]uild[Ll]og.* 28 | 29 | # Build Results of an ATL Project 30 | [Dd]ebugPS/ 31 | [Rr]eleasePS/ 32 | dlldata.c 33 | 34 | *_i.c 35 | *_p.c 36 | *_i.h 37 | *.ilk 38 | *.meta 39 | *.obj 40 | *.pch 41 | *.pdb 42 | *.pgc 43 | *.pgd 44 | *.rsp 45 | *.sbr 46 | *.tlb 47 | *.tli 48 | *.tlh 49 | *.tmp 50 | *.tmp_proj 51 | *.log 52 | *.vspscc 53 | *.vssscc 54 | .builds 55 | *.pidb 56 | *.svclog 57 | *.scc 58 | 59 | # Visual C++ cache files 60 | ipch/ 61 | *.aps 62 | *.ncb 63 | *.opensdf 64 | *.sdf 65 | *.cachefile 66 | 67 | # Visual Studio profiler 68 | *.psess 69 | *.vsp 70 | *.vspx 71 | 72 | # Backup & report files from converting an old project file 73 | # to a newer Visual Studio version. Backup files are not needed, 74 | # because we have git ;-) 75 | _UpgradeReport_Files/ 76 | Backup*/ 77 | UpgradeLog*.XML 78 | UpgradeLog*.htm 79 | 80 | include/ 81 | lib/ 82 | ssl/ 83 | .deps/ 84 | *.opendb 85 | *.db 86 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Application Insights-Cpp 2 | 3 | Copyright (c) Microsoft Corporation 4 | 5 | All rights reserved. 6 | 7 | MIT License 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in all 17 | copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | SOFTWARE. 26 | -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/.vs/AppInsights_Win10-UAP/v14/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/ApplicationInsights-CPP/93395c9d5358db2ec62790a4cd9d1e48cb30563a/Projects/AppInsights_Win10-UAP/.vs/AppInsights_Win10-UAP/v14/.suo -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/AppInsights_Win10-UAP.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.22724.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppInsights_Win10-UAP", "AppInsights_Win10-UAP\AppInsights_Win10-UAP.vcxproj", "{64C33816-C431-4CA3-BFF6-7D09334AC6FE}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTestApp", "UnitTestApp\UnitTestApp.vcxproj", "{840D8C80-EF88-4A42-BBC5-786FFA3424D5}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ApplicationInsights", "ApplicationInsights\ApplicationInsights.vcxproj", "{96DB2B84-5A04-42CE-AD6B-421B199FD193}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|ARM = Debug|ARM 15 | Debug|x64 = Debug|x64 16 | Debug|x86 = Debug|x86 17 | Release|ARM = Release|ARM 18 | Release|x64 = Release|x64 19 | Release|x86 = Release|x86 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {64C33816-C431-4CA3-BFF6-7D09334AC6FE}.Debug|ARM.ActiveCfg = Debug|ARM 23 | {64C33816-C431-4CA3-BFF6-7D09334AC6FE}.Debug|ARM.Build.0 = Debug|ARM 24 | {64C33816-C431-4CA3-BFF6-7D09334AC6FE}.Debug|x64.ActiveCfg = Debug|x64 25 | {64C33816-C431-4CA3-BFF6-7D09334AC6FE}.Debug|x64.Build.0 = Debug|x64 26 | {64C33816-C431-4CA3-BFF6-7D09334AC6FE}.Debug|x86.ActiveCfg = Debug|Win32 27 | {64C33816-C431-4CA3-BFF6-7D09334AC6FE}.Debug|x86.Build.0 = Debug|Win32 28 | {64C33816-C431-4CA3-BFF6-7D09334AC6FE}.Release|ARM.ActiveCfg = Release|ARM 29 | {64C33816-C431-4CA3-BFF6-7D09334AC6FE}.Release|ARM.Build.0 = Release|ARM 30 | {64C33816-C431-4CA3-BFF6-7D09334AC6FE}.Release|x64.ActiveCfg = Release|x64 31 | {64C33816-C431-4CA3-BFF6-7D09334AC6FE}.Release|x64.Build.0 = Release|x64 32 | {64C33816-C431-4CA3-BFF6-7D09334AC6FE}.Release|x86.ActiveCfg = Release|Win32 33 | {64C33816-C431-4CA3-BFF6-7D09334AC6FE}.Release|x86.Build.0 = Release|Win32 34 | {840D8C80-EF88-4A42-BBC5-786FFA3424D5}.Debug|ARM.ActiveCfg = Debug|ARM 35 | {840D8C80-EF88-4A42-BBC5-786FFA3424D5}.Debug|ARM.Build.0 = Debug|ARM 36 | {840D8C80-EF88-4A42-BBC5-786FFA3424D5}.Debug|ARM.Deploy.0 = Debug|ARM 37 | {840D8C80-EF88-4A42-BBC5-786FFA3424D5}.Debug|x64.ActiveCfg = Debug|Win32 38 | {840D8C80-EF88-4A42-BBC5-786FFA3424D5}.Debug|x86.ActiveCfg = Debug|Win32 39 | {840D8C80-EF88-4A42-BBC5-786FFA3424D5}.Debug|x86.Build.0 = Debug|Win32 40 | {840D8C80-EF88-4A42-BBC5-786FFA3424D5}.Debug|x86.Deploy.0 = Debug|Win32 41 | {840D8C80-EF88-4A42-BBC5-786FFA3424D5}.Release|ARM.ActiveCfg = Release|ARM 42 | {840D8C80-EF88-4A42-BBC5-786FFA3424D5}.Release|ARM.Build.0 = Release|ARM 43 | {840D8C80-EF88-4A42-BBC5-786FFA3424D5}.Release|ARM.Deploy.0 = Release|ARM 44 | {840D8C80-EF88-4A42-BBC5-786FFA3424D5}.Release|x64.ActiveCfg = Release|Win32 45 | {840D8C80-EF88-4A42-BBC5-786FFA3424D5}.Release|x86.ActiveCfg = Release|Win32 46 | {840D8C80-EF88-4A42-BBC5-786FFA3424D5}.Release|x86.Build.0 = Release|Win32 47 | {840D8C80-EF88-4A42-BBC5-786FFA3424D5}.Release|x86.Deploy.0 = Release|Win32 48 | {96DB2B84-5A04-42CE-AD6B-421B199FD193}.Debug|ARM.ActiveCfg = Debug|ARM 49 | {96DB2B84-5A04-42CE-AD6B-421B199FD193}.Debug|ARM.Build.0 = Debug|ARM 50 | {96DB2B84-5A04-42CE-AD6B-421B199FD193}.Debug|x64.ActiveCfg = Debug|x64 51 | {96DB2B84-5A04-42CE-AD6B-421B199FD193}.Debug|x64.Build.0 = Debug|x64 52 | {96DB2B84-5A04-42CE-AD6B-421B199FD193}.Debug|x86.ActiveCfg = Debug|Win32 53 | {96DB2B84-5A04-42CE-AD6B-421B199FD193}.Debug|x86.Build.0 = Debug|Win32 54 | {96DB2B84-5A04-42CE-AD6B-421B199FD193}.Release|ARM.ActiveCfg = Release|ARM 55 | {96DB2B84-5A04-42CE-AD6B-421B199FD193}.Release|ARM.Build.0 = Release|ARM 56 | {96DB2B84-5A04-42CE-AD6B-421B199FD193}.Release|x64.ActiveCfg = Release|x64 57 | {96DB2B84-5A04-42CE-AD6B-421B199FD193}.Release|x64.Build.0 = Release|x64 58 | {96DB2B84-5A04-42CE-AD6B-421B199FD193}.Release|x86.ActiveCfg = Release|Win32 59 | {96DB2B84-5A04-42CE-AD6B-421B199FD193}.Release|x86.Build.0 = Release|Win32 60 | EndGlobalSection 61 | GlobalSection(SolutionProperties) = preSolution 62 | HideSolutionNode = FALSE 63 | EndGlobalSection 64 | EndGlobal 65 | -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/AppInsights_Win10-UAP/dllmain.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | 3 | BOOL APIENTRY DllMain(HMODULE /* hModule */, DWORD ul_reason_for_call, LPVOID /* lpReserved */) 4 | { 5 | switch (ul_reason_for_call) 6 | { 7 | case DLL_PROCESS_ATTACH: 8 | case DLL_THREAD_ATTACH: 9 | case DLL_THREAD_DETACH: 10 | case DLL_PROCESS_DETACH: 11 | break; 12 | } 13 | return TRUE; 14 | } 15 | -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/AppInsights_Win10-UAP/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/AppInsights_Win10-UAP/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "targetver.h" 4 | 5 | #ifndef WIN32_LEAN_AND_MEAN 6 | #define WIN32_LEAN_AND_MEAN 7 | #endif 8 | 9 | #include 10 | -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/AppInsights_Win10-UAP/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/ApplicationInsights/ApplicationInsights.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 997db092-9645-4c01-b131-2c35bc8e9047 6 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/ApplicationInsights/PageTracking.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace ApplicationInsights 5 | { 6 | namespace CX 7 | { 8 | [Windows::Foundation::Metadata::WebHostHiddenAttribute] 9 | public ref class PageTracking sealed 10 | { 11 | public: 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | PageTracking(); 16 | 17 | /// 18 | /// Finalizes an instance of the class. 19 | /// 20 | virtual ~PageTracking(); 21 | 22 | /// 23 | /// Initializes the specified frame. 24 | /// 25 | /// The frame. 26 | /// The iKey. 27 | void Initialize(Windows::UI::Xaml::Controls::Frame^ frame, Platform::String^ iKey); 28 | 29 | /// 30 | /// Called when [navigating]. 31 | /// 32 | /// The sender. 33 | /// The e. 34 | void OnNavigating(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigatingCancelEventArgs ^e); 35 | 36 | /// 37 | /// Called when [navigated]. 38 | /// 39 | /// The sender. 40 | /// The e. 41 | void OnNavigated(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationEventArgs ^e); 42 | private: 43 | Windows::UI::Xaml::Controls::Frame^ m_frame; 44 | Platform::String^ m_iKey; 45 | TelemetryClient^ m_tc; 46 | }; 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/ApplicationInsights/SessionTracking.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "PageTracking.h" 4 | 5 | namespace ApplicationInsights 6 | { 7 | namespace CX 8 | { 9 | [Windows::Foundation::Metadata::WebHostHiddenAttribute] 10 | public ref class SessionTracking sealed 11 | { 12 | public: 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | SessionTracking(); 17 | 18 | /// 19 | /// Initializes the specified application. 20 | /// 21 | /// The application. 22 | /// The frame. 23 | /// The iKey. 24 | void Initialize(Windows::UI::Xaml::Application^ application, Windows::UI::Xaml::Controls::Frame^ frame, Platform::String^ iKey); 25 | 26 | /// 27 | /// Called when [suspending]. 28 | /// 29 | /// The sender. 30 | /// The e. 31 | void OnSuspending(Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e); 32 | 33 | /// 34 | /// Called when [resume]. 35 | /// 36 | /// The sender. 37 | /// The e. 38 | void OnResume(Object^ sender, Platform::Object^ e); 39 | 40 | private: 41 | Windows::UI::Xaml::Application^ m_app; 42 | Platform::String^ m_iKey; 43 | PageTracking^ m_page; 44 | ApplicationInsights::CX::TelemetryClient^ m_tc; 45 | }; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/ApplicationInsights/TelemetryClient.cpp: -------------------------------------------------------------------------------- 1 | #include "TelemetryClient.h" 2 | #include "../../../src/core/contracts/SessionStateData.h" 3 | 4 | using namespace ApplicationInsights::CX; 5 | using namespace Platform; 6 | 7 | /// 8 | /// Initializes a new instance of the class. 9 | /// 10 | /// The iKey. 11 | TelemetryClient::TelemetryClient(String^ iKey) 12 | { 13 | std::wstring iKeyString = iKey->Data(); 14 | m_tc = new ApplicationInsights::core::TelemetryClient(iKeyString); 15 | } 16 | 17 | /// 18 | /// Finalizes an instance of the class. 19 | /// 20 | /// 21 | TelemetryClient::~TelemetryClient() 22 | { 23 | delete m_tc; 24 | } 25 | 26 | /// 27 | /// Tracks the event. 28 | /// 29 | /// Name of the event. 30 | void TelemetryClient::TrackEvent(String^ eventName) 31 | { 32 | std::wstring name = eventName->Data(); 33 | m_tc->TrackEvent(name); 34 | } 35 | 36 | /// 37 | /// Tracks the trace. 38 | /// 39 | /// The message. 40 | void TelemetryClient::TrackTrace(String^ message) 41 | { 42 | std::wstring msg = message->Data(); 43 | m_tc->TrackTrace(msg); 44 | } 45 | 46 | /// 47 | /// Tracks the metric. 48 | /// 49 | /// The name. 50 | /// The value. 51 | void TelemetryClient::TrackMetric(String^ name, double value) 52 | { 53 | std::wstring metricName = name->Data(); 54 | m_tc->TrackMetric(metricName, value); 55 | } 56 | 57 | /// 58 | /// Tracks the page view. 59 | /// 60 | /// Name of the page. 61 | void TelemetryClient::TrackPageView(String^ pageName) 62 | { 63 | std::wstring name = pageName->Data(); 64 | m_tc->TrackPageView(name); 65 | } 66 | 67 | /// 68 | /// Tracks the page view. 69 | /// 70 | /// Name of the page. 71 | /// The duration. 72 | void TelemetryClient::TrackPageView(String^ pageName, String^ duration) 73 | { 74 | std::wstring name = pageName->Data(); 75 | std::wstring durationString = duration->Data(); 76 | m_tc->TrackPageView(name, durationString); 77 | } 78 | 79 | /// 80 | /// Tracks the session start. 81 | /// 82 | void TelemetryClient::TrackSessionStart() 83 | { 84 | //Send start session 85 | m_tc->TrackSessionStart(); 86 | } 87 | 88 | /// 89 | /// Flushes this queue. 90 | /// 91 | void TelemetryClient::Flush() 92 | { 93 | m_tc->Flush(); 94 | } 95 | 96 | /// 97 | /// Disables all tracking. 98 | /// 99 | void TelemetryClient::DisableTracking() 100 | { 101 | m_tc->DisableTracking(); 102 | } 103 | 104 | /// 105 | /// Enables all tracking. 106 | /// 107 | void TelemetryClient::EnableTracking() 108 | { 109 | m_tc->EnableTracking(); 110 | } 111 | 112 | /// 113 | /// Renews the session. 114 | /// 115 | void TelemetryClient::RenewSession() 116 | { 117 | m_tc->GetContext()->RenewSession(); 118 | } -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/ApplicationInsights/TelemetryClient.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../../src/core/TelemetryClient.h" 3 | namespace ApplicationInsights 4 | { 5 | namespace CX 6 | { 7 | [Windows::Foundation::Metadata::WebHostHiddenAttribute] 8 | public ref class TelemetryClient sealed 9 | { 10 | public: 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The iKey. 15 | TelemetryClient(Platform::String^ iKey); 16 | 17 | /// 18 | /// Finalizes an instance of the class. 19 | /// 20 | /// 21 | virtual ~TelemetryClient(); 22 | 23 | /// 24 | /// Tracks the event. 25 | /// 26 | /// Name of the event. 27 | void TrackEvent(Platform::String^ eventName); 28 | 29 | /// 30 | /// Tracks the trace. 31 | /// 32 | /// The message. 33 | void TrackTrace(Platform::String^ message); 34 | 35 | /// 36 | /// Tracks the metric. 37 | /// 38 | /// The name. 39 | /// The value. 40 | void TrackMetric(Platform::String^ name, double value); 41 | 42 | /// 43 | /// Tracks the page view. 44 | /// 45 | /// Name of the page. 46 | void TrackPageView(Platform::String^ pageName); 47 | 48 | /// 49 | /// Tracks the page view. 50 | /// 51 | /// Name of the page. 52 | /// The duration. 53 | void TrackPageView(Platform::String^ pageName, Platform::String^ duration); 54 | 55 | /// 56 | /// Tracks the session start. 57 | /// 58 | void TrackSessionStart(); 59 | 60 | /// 61 | /// Flushes this queue. 62 | /// 63 | void Flush(); 64 | 65 | /// 66 | /// Disables all tracking. 67 | /// 68 | void DisableTracking(); 69 | 70 | /// 71 | /// Enables all tracking. 72 | /// 73 | void EnableTracking(); 74 | 75 | /// 76 | /// Renews the session. 77 | /// 78 | void RenewSession(); 79 | private: 80 | ApplicationInsights::core::TelemetryClient *m_tc; 81 | }; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/UnitTestApp/Assets/Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/ApplicationInsights-CPP/93395c9d5358db2ec62790a4cd9d1e48cb30563a/Projects/AppInsights_Win10-UAP/UnitTestApp/Assets/Logo.scale-100.png -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/UnitTestApp/Assets/SmallLogo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/ApplicationInsights-CPP/93395c9d5358db2ec62790a4cd9d1e48cb30563a/Projects/AppInsights_Win10-UAP/UnitTestApp/Assets/SmallLogo.scale-100.png -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/UnitTestApp/Assets/SplashScreen.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/ApplicationInsights-CPP/93395c9d5358db2ec62790a4cd9d1e48cb30563a/Projects/AppInsights_Win10-UAP/UnitTestApp/Assets/SplashScreen.scale-100.png -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/UnitTestApp/Assets/StoreLogo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/ApplicationInsights-CPP/93395c9d5358db2ec62790a4cd9d1e48cb30563a/Projects/AppInsights_Win10-UAP/UnitTestApp/Assets/StoreLogo.scale-100.png -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/UnitTestApp/Assets/WideLogo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/ApplicationInsights-CPP/93395c9d5358db2ec62790a4cd9d1e48cb30563a/Projects/AppInsights_Win10-UAP/UnitTestApp/Assets/WideLogo.scale-100.png -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/UnitTestApp/Package.appxmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 13 | 14 | 15 | 16 | 17 | UnitTestApp 18 | crystk 19 | Assets\StoreLogo.png 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 41 | 42 | 43 | 44 | 47 | 54 | 55 | 56 | 57 | 60 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/UnitTestApp/UnitTest.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "CppUnitTest.h" 3 | 4 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 5 | 6 | namespace UnitTestApp 7 | { 8 | TEST_CLASS(UnitTest1) 9 | { 10 | public: 11 | TEST_METHOD(TestMethod1) 12 | { 13 | // TODO: Your test code here 14 | } 15 | }; 16 | } -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/UnitTestApp/UnitTestApp_TemporaryKey.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/ApplicationInsights-CPP/93395c9d5358db2ec62790a4cd9d1e48cb30563a/Projects/AppInsights_Win10-UAP/UnitTestApp/UnitTestApp_TemporaryKey.pfx -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/UnitTestApp/pch.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // pch.cpp 3 | // Include the standard header and generate the precompiled header. 4 | // 5 | 6 | #include "pch.h" 7 | -------------------------------------------------------------------------------- /Projects/AppInsights_Win10-UAP/UnitTestApp/pch.h: -------------------------------------------------------------------------------- 1 | // 2 | // pch.h 3 | // Header for standard system include files. 4 | // 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | -------------------------------------------------------------------------------- /Projects/AppInsights_Win32/.vs/application_insights/v14/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/ApplicationInsights-CPP/93395c9d5358db2ec62790a4cd9d1e48cb30563a/Projects/AppInsights_Win32/.vs/application_insights/v14/.suo -------------------------------------------------------------------------------- /Projects/AppInsights_Win32/application_insights.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25123.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core", "core\core.vcxproj", "{F2377726-D69D-4A26-A3AF-969FD0399427}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core.tests", "test\core.tests.vcxproj", "{D9D00C85-E6BA-496E-AC7E-C3744AD38194}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B9DFD4EA-B8B3-49CD-84E8-2EC46444FD5A}" 11 | EndProject 12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{288A8E49-E064-439B-8682-DB010CBDF609}" 13 | EndProject 14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "package", "package", "{D08D10AB-DE85-4A6E-8EF7-F61AD2C98387}" 15 | ProjectSection(SolutionItems) = preProject 16 | package\AppInsights_Win32.autopkg = package\AppInsights_Win32.autopkg 17 | package\build.bat = package\build.bat 18 | package\package.ps1 = package\package.ps1 19 | package\README.md = package\README.md 20 | EndProjectSection 21 | EndProject 22 | Global 23 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 24 | Debug|ARM = Debug|ARM 25 | Debug|Win32 = Debug|Win32 26 | Debug|x64 = Debug|x64 27 | Release|ARM = Release|ARM 28 | Release|Win32 = Release|Win32 29 | Release|x64 = Release|x64 30 | EndGlobalSection 31 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 32 | {F2377726-D69D-4A26-A3AF-969FD0399427}.Debug|ARM.ActiveCfg = Debug|Win32 33 | {F2377726-D69D-4A26-A3AF-969FD0399427}.Debug|Win32.ActiveCfg = Debug|Win32 34 | {F2377726-D69D-4A26-A3AF-969FD0399427}.Debug|Win32.Build.0 = Debug|Win32 35 | {F2377726-D69D-4A26-A3AF-969FD0399427}.Debug|x64.ActiveCfg = Debug|x64 36 | {F2377726-D69D-4A26-A3AF-969FD0399427}.Debug|x64.Build.0 = Debug|x64 37 | {F2377726-D69D-4A26-A3AF-969FD0399427}.Release|ARM.ActiveCfg = Release|Win32 38 | {F2377726-D69D-4A26-A3AF-969FD0399427}.Release|Win32.ActiveCfg = Release|Win32 39 | {F2377726-D69D-4A26-A3AF-969FD0399427}.Release|Win32.Build.0 = Release|Win32 40 | {F2377726-D69D-4A26-A3AF-969FD0399427}.Release|x64.ActiveCfg = Release|x64 41 | {F2377726-D69D-4A26-A3AF-969FD0399427}.Release|x64.Build.0 = Release|x64 42 | {D9D00C85-E6BA-496E-AC7E-C3744AD38194}.Debug|ARM.ActiveCfg = Debug|Win32 43 | {D9D00C85-E6BA-496E-AC7E-C3744AD38194}.Debug|Win32.ActiveCfg = Debug|Win32 44 | {D9D00C85-E6BA-496E-AC7E-C3744AD38194}.Debug|Win32.Build.0 = Debug|Win32 45 | {D9D00C85-E6BA-496E-AC7E-C3744AD38194}.Debug|x64.ActiveCfg = Debug|x64 46 | {D9D00C85-E6BA-496E-AC7E-C3744AD38194}.Debug|x64.Build.0 = Debug|x64 47 | {D9D00C85-E6BA-496E-AC7E-C3744AD38194}.Release|ARM.ActiveCfg = Release|Win32 48 | {D9D00C85-E6BA-496E-AC7E-C3744AD38194}.Release|Win32.ActiveCfg = Release|Win32 49 | {D9D00C85-E6BA-496E-AC7E-C3744AD38194}.Release|Win32.Build.0 = Release|Win32 50 | {D9D00C85-E6BA-496E-AC7E-C3744AD38194}.Release|x64.ActiveCfg = Release|x64 51 | {D9D00C85-E6BA-496E-AC7E-C3744AD38194}.Release|x64.Build.0 = Release|x64 52 | EndGlobalSection 53 | GlobalSection(SolutionProperties) = preSolution 54 | HideSolutionNode = FALSE 55 | EndGlobalSection 56 | GlobalSection(NestedProjects) = preSolution 57 | {F2377726-D69D-4A26-A3AF-969FD0399427} = {B9DFD4EA-B8B3-49CD-84E8-2EC46444FD5A} 58 | {D9D00C85-E6BA-496E-AC7E-C3744AD38194} = {288A8E49-E064-439B-8682-DB010CBDF609} 59 | EndGlobalSection 60 | EndGlobal 61 | -------------------------------------------------------------------------------- /Projects/AppInsights_Win32/package/AppInsights_Win32.autopkg: -------------------------------------------------------------------------------- 1 | configurations 2 | { 3 | Toolset 4 | { 5 | key : "PlatformToolset"; 6 | choices : { v140, v120, v110 }; 7 | }; 8 | }; 9 | 10 | nuget 11 | { 12 | nuspec 13 | { 14 | id : AppInsights_Win32; 15 | version : 1.0.0-beta-1; 16 | title : Microsoft Application Insights Library for C++; 17 | authors: { Microsoft }; 18 | owners: { Microsoft }; 19 | licenseUrl: "https://github.com/Microsoft/ApplicationInsights-CPP/blob/master/LICENSE"; 20 | iconUrl: "http://appanacdn.blob.core.windows.net/cdn/icons/aic.png"; 21 | requireLicenseAcceptance:false; 22 | summary: Microsoft Application Insights Library for C++; 23 | description: @"Application Insights for C++ applications. 24 | See http://go.microsoft.com/fwlink/?LinkID=510752 for more information. 25 | Project on Githib: https://github.com/Microsoft/ApplicationInsights-CPP 26 | Fork on Github: https://github.com/keiichi-morisato/ApplicationInsights-CPP"; 27 | releaseNotes: "This package includes both the release and the debug versions of the library to allow for debugging. The PDB files are also included."; 28 | projectUrl: "https://azure.microsoft.com/en-us/documentation/articles/app-insights-get-started/"; 29 | copyright: Copyright (c) Microsoft. All rights reserved; 30 | tags: { Analytics, ApplicationInsights, Telemetry, AppInsights, native }; 31 | }; 32 | 33 | dependencies 34 | { 35 | packages: 36 | { 37 | }; 38 | }; 39 | 40 | files 41 | { 42 | include: 43 | { 44 | ..\..\..\src\core\*.h; 45 | ..\..\..\src\core\channel\*.h; 46 | ..\..\..\src\core\channel\utils\*.h; 47 | ..\..\..\src\core\common\*.h; 48 | ..\..\..\src\core\contracts\*.h; 49 | }; 50 | 51 | [x64,v140,v120,release,static] 52 | { 53 | lib: 54 | { 55 | ..\x64\Release\core.lib; 56 | } 57 | symbols: 58 | { 59 | } 60 | bin: 61 | { 62 | } 63 | }; 64 | 65 | [x64,v140,v120,debug,static] 66 | { 67 | lib: 68 | { 69 | ..\x64\Debug\core.lib; 70 | } 71 | symbols: 72 | { 73 | ..\x64\Debug\core.pdb; 74 | } 75 | bin: 76 | { 77 | } 78 | }; 79 | }; 80 | } -------------------------------------------------------------------------------- /Projects/AppInsights_Win32/package/README.md: -------------------------------------------------------------------------------- 1 | Build and Package Notes 2 | ======================= 3 | 4 | # Build 5 | 6 | - Visual Studio 2015 Community Edition or Pro/Enterprise. 7 | - Windows Vista x64 or better. 8 | - Powershell 3.0 or better. 9 | - You will need the [CoApp Powershell Tools](http://coapp.org/index.html) which can be downloaded from this [link](http://coapp.org/files/CoApp.Tools.Powershell.msi). 10 | - If you are using Nuget to publish, you will need to update the package.ps1 file with the server and your ApiKey. 11 | 12 | ## How-to 13 | 14 | 1. Change to the `package/` directory under `ApplicationInsights-CPP/Projects/AppInsights_Win32/` 15 | 1. Run the `build.bat` file from the Visual Studio Command Prompt (x64 build environment). 16 | 17 | 18 | ``` 19 | 20 | ``` 21 | 22 | ## Package 23 | 24 | 25 | 26 | # References 27 | 28 | -------------------------------------------------------------------------------- /Projects/AppInsights_Win32/package/build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | @echo .............................................................................. 3 | @echo Restoring the nuget packages.. 4 | nuget restore ..\application_insights.sln 5 | @echo .............................................................................. 6 | @echo Building the debug version.. 7 | msbuild /t:Rebuild /p:Configuration=Debug ../application_insights.sln /m 8 | @echo .............................................................................. 9 | @echo Building the releaseversion.. 10 | msbuild /t:Rebuild /p:Configuration=Release ../application_insights.sln /m 11 | @echo .............................................................................. 12 | @echo Packaging.. 13 | rem powershell -File .\package.ps1 14 | -------------------------------------------------------------------------------- /src/core/BaseTelemetryContext.h: -------------------------------------------------------------------------------- 1 | #ifndef BASETELEMETRYCONTEXT_H 2 | #define BASETELEMETRYCONTEXT_H 3 | 4 | #include 5 | #include "TelemetryClientConfig.h" 6 | #include "Contracts/Contracts.h" 7 | #include "Common/Common.h" 8 | 9 | namespace ApplicationInsights 10 | { 11 | namespace core 12 | { 13 | class TELEMETRYCLIENT_API BaseTelemetryContext 14 | { 15 | public: 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The i key. 20 | BaseTelemetryContext(const std::wstring& iKey); 21 | 22 | /// 23 | /// Finalizes an instance of the class. 24 | /// 25 | virtual ~BaseTelemetryContext(); 26 | 27 | /// 28 | /// Initializes the context. 29 | /// 30 | virtual void InitContext(); 31 | 32 | /// 33 | /// Gets the user. 34 | /// 35 | /// the user context 36 | User& GetUser() { return user; } 37 | const User& GetUser() const { return user; } 38 | 39 | /// 40 | /// Gets the device. 41 | /// 42 | /// tne device context 43 | Device& GetDevice() { return device; } 44 | const Device& GetDevice() const { return device; } 45 | 46 | /// 47 | /// Gets the application. 48 | /// 49 | /// the application context 50 | Application& GetApplication() { return app; } 51 | const Application& GetApplication() const { return app; } 52 | 53 | /// 54 | /// Gets the session. 55 | /// 56 | /// the session context 57 | Session& GetSession() { return session; } 58 | const Session& GetSession() const { return session; } 59 | 60 | /// 61 | /// Renews the session. 62 | /// 63 | void RenewSession(); 64 | 65 | /// 66 | /// Gets the context tags. 67 | /// 68 | /// The tags. 69 | /// RESULT_OK if succedded 70 | RESULT GetContextTags(wstring_wstring_map& buffer); 71 | 72 | protected: 73 | /// 74 | /// Initializes the user context. 75 | /// 76 | virtual void InitUser(); 77 | 78 | /// 79 | /// Initializes the device context. 80 | /// 81 | virtual void InitDevice(); 82 | 83 | /// 84 | /// Initializes the application. 85 | /// 86 | virtual void InitApplication(); 87 | 88 | /// 89 | /// Initializes the session. 90 | /// 91 | virtual void InitSession(); 92 | 93 | User user; 94 | Device device; 95 | Application app; 96 | Session session; 97 | std::wstring m_iKey; 98 | }; 99 | } 100 | } 101 | #endif 102 | -------------------------------------------------------------------------------- /src/core/TelemetryClientConfig.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEMETRYCLIENTCONFIG_H 2 | #define TELEMETRYCLIENTCONFIG_H 3 | 4 | #include "Common/Common.h" 5 | #include 6 | 7 | namespace ApplicationInsights 8 | { 9 | namespace core 10 | { 11 | struct TELEMETRYCLIENT_API TelemetryClientConfig 12 | { 13 | public: 14 | /// 15 | /// Initializes a new instance of the struct. 16 | /// 17 | /// The i key. 18 | TelemetryClientConfig(const std::wstring& iKey) { 19 | m_instrumentationKey = iKey; 20 | } 21 | 22 | /// 23 | /// Sets the iKey. 24 | /// 25 | /// The iKey. 26 | void SetIKey(const std::wstring& iKey) { m_instrumentationKey = iKey; } 27 | 28 | /// 29 | /// Gets the iKey. 30 | /// 31 | /// the iKey 32 | const std::wstring& GetIKey() const { return m_instrumentationKey; } 33 | 34 | private: 35 | /** 36 | * The instrumentation key for this telemetryContext 37 | */ 38 | std::wstring m_instrumentationKey; 39 | }; 40 | } 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /src/core/TelemetryContext.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEMETRYCONTEXT_H 2 | #define TELEMETRYCONTEXT_H 3 | 4 | #include "BaseTelemetryContext.h" 5 | #include 6 | #include "TelemetryClientConfig.h" 7 | #include "Contracts/Contracts.h" 8 | #include "Common/Common.h" 9 | 10 | namespace ApplicationInsights 11 | { 12 | namespace core 13 | { 14 | class TELEMETRYCLIENT_API TelemetryContext : public BaseTelemetryContext 15 | { 16 | public: 17 | /// 18 | /// Stores the context. 19 | /// 20 | /// The iKey. 21 | /// 22 | TelemetryContext(const std::wstring& iKey); 23 | 24 | /// 25 | /// Finalizes an instance of the class. 26 | /// 27 | /// 28 | virtual ~TelemetryContext(); 29 | 30 | /// 31 | /// Initializes the user. 32 | /// 33 | virtual void InitUser(); 34 | 35 | /// 36 | /// Initializes the device. 37 | /// 38 | virtual void InitDevice(); 39 | 40 | /// 41 | /// Initializes the application. 42 | /// 43 | virtual void InitApplication(); 44 | 45 | /// 46 | /// Initializes the session. 47 | /// 48 | virtual void InitSession(); 49 | }; 50 | } 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /src/core/TelemetryContextOther.cpp: -------------------------------------------------------------------------------- 1 | #include "TelemetryContext.h" 2 | 3 | #ifndef WINAPI_FAMILY_PARTITION // Not Windows 4 | 5 | using namespace ApplicationInsights::core; 6 | 7 | /// 8 | /// Stores the context. 9 | /// 10 | /// 11 | TelemetryContext::TelemetryContext(std::wstring& iKey) : 12 | BaseTelemetryContext(iKey) 13 | { 14 | } 15 | 16 | /// 17 | /// Finalizes an instance of the class. 18 | /// 19 | /// 20 | TelemetryContext::~TelemetryContext() 21 | { 22 | } 23 | 24 | /// 25 | /// Initializes the device. 26 | /// 27 | void TelemetryContext::InitDevice() 28 | { 29 | //Nullable strDevId = L"TODO"; 30 | //device.SetId(strDevId); 31 | //device.SetLanguage(); 32 | //device.SetLocale(); 33 | //device.SetMachineName(); 34 | //device.SetModel(); 35 | //device.SetNetwork(); 36 | //device.SetOemName(); 37 | Nullable strOs; 38 | strOs.SetValue(L"Windows"); 39 | device.SetOs(strOs); 40 | 41 | //device.SetOsVersion(); 42 | //device.SetScreenResolution(); 43 | 44 | Nullable strType; 45 | strType.SetValue(L"Other"); 46 | device.SetType(strType); 47 | } 48 | 49 | /// 50 | /// Initializes the application. 51 | /// 52 | void TelemetryContext::InitApplication() 53 | { 54 | //TODO 55 | } 56 | 57 | /// 58 | /// Initializes the user. 59 | /// 60 | void TelemetryContext::InitUser() 61 | { 62 | //TODO 63 | } 64 | 65 | /// 66 | /// Initializes the session. 67 | /// 68 | void TelemetryContext::InitSession() 69 | { 70 | //TODO 71 | } 72 | 73 | #endif -------------------------------------------------------------------------------- /src/core/TelemetryContextWin32.cpp: -------------------------------------------------------------------------------- 1 | #include "TelemetryContext.h" 2 | #include "common/Utils.h" 3 | #include 4 | #include 5 | 6 | #ifdef WINAPI_FAMILY_PARTITION // it's SOME kind of Windows 7 | #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) // desktop, no store or phone 8 | 9 | using namespace ApplicationInsights::core; 10 | 11 | /// 12 | /// Stores the context. 13 | /// 14 | /// The iKey. 15 | /// 16 | TelemetryContext::TelemetryContext(const std::wstring& iKey) : 17 | BaseTelemetryContext(iKey) 18 | { 19 | } 20 | 21 | /// 22 | /// Finalizes an instance of the class. 23 | /// 24 | /// 25 | TelemetryContext::~TelemetryContext() 26 | { 27 | } 28 | 29 | /// 30 | /// Initializes the device. 31 | /// 32 | void TelemetryContext::InitDevice() 33 | { 34 | Nullable strOs; 35 | strOs.SetValue(L"Windows"); 36 | device.SetOs(strOs); 37 | 38 | Nullable strType; 39 | strType.SetValue(L"Other"); 40 | device.SetType(strType); 41 | } 42 | 43 | /// 44 | /// Initializes the application. 45 | /// 46 | void TelemetryContext::InitApplication() 47 | { 48 | BaseTelemetryContext::InitApplication(); 49 | } 50 | 51 | /// 52 | /// Initializes the user. 53 | /// 54 | void TelemetryContext::InitUser() 55 | { 56 | BaseTelemetryContext::InitUser(); 57 | } 58 | 59 | /// 60 | /// Initializes the session. 61 | /// 62 | void TelemetryContext::InitSession() 63 | { 64 | BaseTelemetryContext::InitSession(); 65 | } 66 | #endif 67 | #endif -------------------------------------------------------------------------------- /src/core/TelemetryContextWinPhone.cpp: -------------------------------------------------------------------------------- 1 | #if _WIN32 2 | #include 3 | #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP 4 | #include "TelemetryContext.h" 5 | 6 | using namespace ApplicationInsights::core; 7 | 8 | /// 9 | /// Stores the context. 10 | /// 11 | /// The iKey. 12 | /// 13 | TelemetryContext::TelemetryContext(const std::wstring& iKey) : 14 | BaseTelemetryContext(iKey) 15 | { 16 | } 17 | 18 | /// 19 | /// Finalizes an instance of the class. 20 | /// 21 | /// 22 | TelemetryContext::~TelemetryContext() 23 | { 24 | } 25 | 26 | /// 27 | /// Initializes the device. 28 | /// 29 | void TelemetryContext::InitDevice() 30 | { 31 | Nullable strOs; 32 | strOs.SetValue(L"Windows"); 33 | device.SetOs(strOs); 34 | 35 | Nullable strType; 36 | strType.SetValue(L"Other"); 37 | device.SetType(strType); 38 | } 39 | 40 | /// 41 | /// Initializes the application. 42 | /// 43 | void TelemetryContext::InitApplication() 44 | { 45 | //TODO 46 | } 47 | 48 | /// 49 | /// Initializes the user. 50 | /// 51 | void TelemetryContext::InitUser() 52 | { 53 | //TODO 54 | } 55 | 56 | #endif 57 | #endif 58 | -------------------------------------------------------------------------------- /src/core/channel/TelemetryChannel.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEMETRYCHANNEL_H 2 | #define TELEMETRYCHANNEL_H 3 | 4 | #include 5 | #include 6 | #include "../TelemetryClientConfig.h" 7 | #include "../TelemetryContext.h" 8 | #include "../Contracts/Contracts.h" 9 | #include "../Common/Common.h" 10 | #include "Utils/HttpRequest.h" 11 | 12 | #ifdef WINAPI_FAMILY_PARTITION 13 | #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) // Windows phone or store 14 | #include 15 | #endif 16 | #endif 17 | 18 | namespace ApplicationInsights 19 | { 20 | namespace core 21 | { 22 | class TELEMETRYCLIENT_API TelemetryChannel 23 | { 24 | public: 25 | /// 26 | /// Initializes a new instance of the class. 27 | /// 28 | /// The configuration. 29 | TelemetryChannel(TelemetryClientConfig &config); 30 | 31 | /// 32 | /// Finalizes an instance of the class. 33 | /// 34 | virtual ~TelemetryChannel(); 35 | 36 | /// 37 | /// Enqueues the specified context. 38 | /// 39 | /// The context. 40 | /// The telemetry. 41 | void Enqueue(TelemetryContext &context, Domain &telemetry); 42 | 43 | /// 44 | /// Sends this instance. 45 | /// 46 | void Send(); 47 | 48 | protected: 49 | int m_channelId; 50 | int m_seqNum; 51 | int m_maxBufferSize; 52 | TelemetryClientConfig *m_config; 53 | std::vector m_buffer; 54 | 55 | HttpResponse resp; 56 | 57 | #ifdef WINAPI_FAMILY_PARTITION 58 | #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) // Windows phone or store 59 | HANDLE hRespRecv; 60 | #endif 61 | #endif 62 | }; 63 | } 64 | } 65 | #endif -------------------------------------------------------------------------------- /src/core/channel/utils/HttpHeaderField.cpp: -------------------------------------------------------------------------------- 1 | #include "HttpHeaderField.h" 2 | #include 3 | #include 4 | 5 | using namespace ApplicationInsights::core; 6 | 7 | /// 8 | /// Initializes a new instance of the class. 9 | /// 10 | /// The name. 11 | /// The value. 12 | HttpHeaderField::HttpHeaderField(const std::wstring& name, const std::wstring& value) 13 | : m_strName(name), 14 | m_strValue(value) 15 | { 16 | } 17 | 18 | /// 19 | /// Convert header fields to the string. 20 | /// 21 | /// string representation of the fields 22 | std::string HttpHeaderField::ToString() const 23 | { 24 | std::wstring str = m_strName + L": " + m_strValue; 25 | 26 | // Return the ANSI version of the string we built 27 | std::wstring_convert> converter; 28 | return converter.to_bytes(str); 29 | } 30 | 31 | /// 32 | /// Convert header fields to the string. 33 | /// 34 | /// wstring representation of the fields 35 | std::wstring HttpHeaderField::ToWString() const 36 | { 37 | return (m_strName + L": " + m_strValue); 38 | } 39 | -------------------------------------------------------------------------------- /src/core/channel/utils/HttpHeaderField.h: -------------------------------------------------------------------------------- 1 | #ifndef HTTPHEADERFIELD_H 2 | #define HTTPHEADERFIELD_H 3 | 4 | #include "../../Common/Common.h" 5 | #include 6 | namespace ApplicationInsights 7 | { 8 | namespace core 9 | { 10 | /// 11 | /// 12 | /// 13 | class TELEMETRYCLIENT_API HttpHeaderField 14 | { 15 | public: 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The name. 20 | /// The value. 21 | HttpHeaderField(const std::wstring& name = L"", const std::wstring& value = L""); 22 | 23 | /// 24 | /// Gets the field name. 25 | /// 26 | /// the field name 27 | const std::wstring& GetName() const { 28 | return m_strName; 29 | } 30 | 31 | /// 32 | /// Gets the field value. 33 | /// 34 | /// the value of the field 35 | const std::wstring& GetValue() const { 36 | return m_strValue; 37 | } 38 | 39 | /// 40 | /// Determine if two header fields have the same name (value may differ) 41 | /// 42 | /// The field. 43 | /// true if the fields match, otherwise false 44 | bool operator ==(const HttpHeaderField& field) const { 45 | #if WINAPI_FAMILY || _WIN32 46 | return _wcsicmp(m_strName.c_str(), field.m_strName.c_str()) == 0; 47 | #else 48 | return wcscasecmp(m_strName.c_str(), field.m_strName.c_str()) == 0; 49 | #endif 50 | } 51 | 52 | /// 53 | /// Determine if two header fields different names (value might be the same) 54 | /// 55 | /// The field. 56 | /// true if the fields DO NOT match, otherwise false 57 | bool operator !=(const HttpHeaderField& field) const { 58 | #if WINAPI_FAMILY || _WIN32 59 | return _wcsicmp(m_strName.c_str(), field.m_strName.c_str()) != 0; 60 | #else 61 | return wcscasecmp(m_strName.c_str(), field.m_strName.c_str()) != 0; 62 | #endif 63 | } 64 | 65 | /// 66 | /// Convert header fields to the string. 67 | /// 68 | /// string representation of the fields 69 | std::string ToString() const; 70 | 71 | /// 72 | /// Convert header fields to the string. 73 | /// 74 | /// wstring representation of the fields 75 | std::wstring ToWString() const; 76 | 77 | private: 78 | std::wstring m_strName; 79 | std::wstring m_strValue; 80 | }; 81 | } 82 | } 83 | #endif -------------------------------------------------------------------------------- /src/core/channel/utils/HttpHeaderFields.h: -------------------------------------------------------------------------------- 1 | #ifndef HTTPHEADERFIELDS_H 2 | #define HTTPHEADERFIELDS_H 3 | 4 | #include 5 | #include 6 | #include "HttpHeaderField.h" 7 | 8 | namespace ApplicationInsights 9 | { 10 | namespace core 11 | { 12 | class TELEMETRYCLIENT_API HttpHeaderFields 13 | { 14 | public: 15 | /// 16 | /// Gets all the fields. 17 | /// 18 | /// the constant list of field 19 | const std::list& GetFields() const { 20 | return m_Fields; 21 | } 22 | 23 | /// 24 | /// Determine if a field with the specified name exists. 25 | /// 26 | /// Name of the field. 27 | /// true if it contains a field with fieldName, otherwise false 28 | bool HasField(const std::wstring& fieldName) const { 29 | return std::find(m_Fields.cbegin(), m_Fields.cend(), HttpHeaderField(fieldName)) != m_Fields.end(); 30 | } 31 | 32 | /// 33 | /// Gets the operator with the specified name. 34 | /// 35 | /// Name of the field. 36 | /// constant field for fieldName 37 | const HttpHeaderField& operator [](const std::wstring& fieldName) const { 38 | return *std::find(m_Fields.cbegin(), m_Fields.cend(), HttpHeaderField(fieldName)); 39 | } 40 | 41 | /// 42 | /// Gets the field. 43 | /// 44 | /// Name of the field. 45 | /// constant Fields 46 | const HttpHeaderField& GetField(const std::wstring& fieldName) const { 47 | return *std::find(m_Fields.cbegin(), m_Fields.cend(), HttpHeaderField(fieldName)); 48 | } 49 | 50 | /// 51 | /// Sets the field. 52 | /// 53 | /// Name of the field. 54 | /// The field value. 55 | void SetField(const std::wstring& fieldName, const std::wstring& fieldValue) { 56 | auto iter = std::find(m_Fields.cbegin(), m_Fields.cend(), HttpHeaderField(fieldName)); 57 | if (iter != m_Fields.end()) 58 | { 59 | m_Fields.remove(*iter); 60 | } 61 | 62 | m_Fields.push_back(HttpHeaderField(fieldName, fieldValue)); 63 | } 64 | 65 | private: 66 | std::list m_Fields; 67 | }; 68 | } 69 | } 70 | #endif -------------------------------------------------------------------------------- /src/core/channel/utils/HttpRequest.h: -------------------------------------------------------------------------------- 1 | #ifndef HTTPREQUEST_H 2 | #define HTTPREQUEST_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "HttpResponse.h" 10 | #include "HttpHeaderFields.h" 11 | 12 | namespace ApplicationInsights 13 | { 14 | namespace core 15 | { 16 | enum class HTTP_REQUEST_METHOD 17 | { 18 | GET, 19 | POST, 20 | PUT 21 | }; 22 | 23 | class TELEMETRYCLIENT_API HttpRequest 24 | { 25 | public: 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The method. 30 | /// The hostname. 31 | /// The request URI. 32 | /// The json payload. 33 | HttpRequest(HTTP_REQUEST_METHOD method, const std::wstring& hostname = L"", const std::wstring& requestUri = L"*", const std::wstring& jsonPayload = L""); 34 | 35 | /// 36 | /// Finalizes an instance of the class. 37 | /// 38 | virtual ~HttpRequest(); 39 | 40 | /// 41 | /// Gets the request method. 42 | /// 43 | /// the method 44 | HTTP_REQUEST_METHOD GetMethod() const { 45 | return m_Method; 46 | } 47 | 48 | /// 49 | /// Gets the request URI. 50 | /// 51 | /// the request uri 52 | std::wstring GetRequestUri() const { 53 | return m_RequestUri; 54 | } 55 | 56 | /// 57 | /// Gets the hostname. 58 | /// 59 | /// the hostname 60 | std::wstring GetHostname() const { 61 | return m_Hostname; 62 | } 63 | 64 | /// 65 | /// Gets the header fields. 66 | /// 67 | /// constant header fields 68 | const HttpHeaderFields& GetHeaderFields() const { 69 | return m_HeaderFields; 70 | } 71 | 72 | /// 73 | /// Gets the header fields. 74 | /// 75 | /// the header fields 76 | HttpHeaderFields& GetHeaderFields() { 77 | return m_HeaderFields; 78 | } 79 | 80 | /// 81 | /// Gets the payload. 82 | /// 83 | /// the payload 84 | const std::wstring GetPayload() const { return m_JsonPayload; } 85 | 86 | /// 87 | /// Sends the request and then calls the completion callback. 88 | /// 89 | /// The completion callback. 90 | /// error code 91 | int Send(const std::function &completionCallback) const; 92 | 93 | private: 94 | void *m_impl; 95 | HTTP_REQUEST_METHOD m_Method; 96 | std::wstring m_RequestUri; 97 | HttpHeaderFields m_HeaderFields; 98 | std::wstring m_JsonPayload; 99 | std::wstring m_Hostname; 100 | }; 101 | } 102 | } 103 | #endif -------------------------------------------------------------------------------- /src/core/channel/utils/HttpResponse.cpp: -------------------------------------------------------------------------------- 1 | #include "HttpResponse.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | /// 6 | /// Initializes a new instance of the class. 7 | /// 8 | HttpResponse::HttpResponse() 9 | { 10 | } 11 | 12 | /// 13 | /// Finalizes an instance of the class. 14 | /// 15 | HttpResponse::~HttpResponse() 16 | { 17 | } 18 | 19 | /// 20 | /// Sets the error code. 21 | /// 22 | /// The error. 23 | void HttpResponse::SetErrorCode(int error) 24 | { 25 | m_errorCode = error; 26 | } 27 | 28 | /// 29 | /// Gets the error code. 30 | /// 31 | /// the error code 32 | int HttpResponse::GetErrorCode() const 33 | { 34 | return m_errorCode; 35 | } 36 | 37 | /// 38 | /// Sets the payload. 39 | /// 40 | /// The payload. 41 | void HttpResponse::SetPayload(std::string payload) 42 | { 43 | m_payload = payload; 44 | } 45 | 46 | /// 47 | /// Gets the payload. 48 | /// 49 | /// sthe payload 50 | const char *HttpResponse::GetPayload() const 51 | { 52 | return m_payload.c_str(); 53 | } 54 | -------------------------------------------------------------------------------- /src/core/channel/utils/HttpResponse.h: -------------------------------------------------------------------------------- 1 | #ifndef HTTPRESPONSE_H 2 | #define HTTPRESPONSE_H 3 | 4 | #include 5 | #include "../../Common/Common.h" 6 | 7 | namespace ApplicationInsights 8 | { 9 | namespace core 10 | { 11 | enum class HTTP_RESPONSE_CODE 12 | { 13 | HTTP_OK = 200, 14 | HTTP_SVR_ERROR = 500 15 | }; 16 | 17 | class TELEMETRYCLIENT_API HttpResponse 18 | { 19 | public: 20 | /// 21 | /// Initializes a new instance of the class. 22 | /// 23 | HttpResponse(); 24 | 25 | /// 26 | /// Finalizes an instance of the class. 27 | /// 28 | virtual ~HttpResponse(); 29 | 30 | /// 31 | /// Sets the error code. 32 | /// 33 | /// The error. 34 | void SetErrorCode(int error); 35 | 36 | /// 37 | /// Gets the error code. 38 | /// 39 | /// the error code 40 | int GetErrorCode() const; 41 | 42 | /// 43 | /// Sets the payload. 44 | /// 45 | /// The payload. 46 | void SetPayload(std::string payload); 47 | 48 | /// 49 | /// Gets the payload. 50 | /// 51 | /// sthe payload 52 | const char *GetPayload() const; 53 | 54 | private: 55 | int m_errorCode; 56 | std::string m_payload; 57 | }; 58 | } 59 | } 60 | #endif 61 | -------------------------------------------------------------------------------- /src/core/common/Common.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_H 2 | #define COMMON_H 3 | 4 | #ifdef WIN32 5 | #include 6 | #endif 7 | #include 8 | #include 9 | 10 | namespace ApplicationInsights 11 | { 12 | namespace core 13 | { 14 | #ifdef TELEMETRY_CLIENT_DLL_EXPORT 15 | #define TELEMETRYCLIENT_API __declspec(dllexport) 16 | #else 17 | #define TELEMETRYCLIENT_API 18 | #endif 19 | 20 | typedef std::map wstring_wstring_map; 21 | 22 | typedef long RESULT; 23 | 24 | #define RESULT_OK (0L) 25 | #define RESULT_ERR (-1L) 26 | #define RESULT_ERR_NOT_CONNECTED (-2L) 27 | #define RESULT_ERR_MAX_RETRIES (-3L) 28 | } 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /src/core/common/JsonWriter.cpp: -------------------------------------------------------------------------------- 1 | #include "StreamWriter.h" 2 | #include "JsonWriter.h" 3 | 4 | using namespace ApplicationInsights::core; 5 | 6 | /// 7 | /// Initializes a new instance of the class. 8 | /// 9 | /// The writer. 10 | JsonWriter::JsonWriter(StreamWriter &writer) : 11 | Serializer(writer) 12 | { 13 | } 14 | 15 | /// 16 | /// Finalizes an instance of the class. 17 | /// 18 | JsonWriter::~JsonWriter() 19 | { 20 | } 21 | 22 | /// 23 | /// Adds a comma if needed 24 | /// 25 | /// The kind. 26 | void JsonWriter::PrepareValue(StackEntry kind) 27 | { 28 | if (seenElement) { 29 | writer.Write(L","); 30 | } 31 | } 32 | 33 | /// 34 | /// Begins the dictionary value. 35 | /// 36 | void JsonWriter::BeginDictionaryValue() 37 | { 38 | Serializer::BeginDictionaryValue(); 39 | writer.Write(L"{"); 40 | } 41 | 42 | /// 43 | /// Writes the name of the property. 44 | /// 45 | /// The name. 46 | void JsonWriter::WritePropertyName(const std::wstring &name) 47 | { 48 | Serializer::WritePropertyName(name); 49 | writer.Write((L"\"" + name + L"\":").c_str()); 50 | } 51 | 52 | /// 53 | /// Ends the dictionary value. 54 | /// 55 | void JsonWriter::EndDictionaryValue() 56 | { 57 | Serializer::EndDictionaryValue(); 58 | writer.Write(L"}"); 59 | } 60 | 61 | /// 62 | /// Begins the array value. 63 | /// 64 | void JsonWriter::BeginArrayValue() 65 | { 66 | Serializer::BeginArrayValue(); 67 | writer.Write(L"["); 68 | } 69 | 70 | /// 71 | /// Ends the array value. 72 | /// 73 | void JsonWriter::EndArrayValue() 74 | { 75 | Serializer::EndArrayValue(); 76 | writer.Write(L"]"); 77 | } 78 | 79 | /// 80 | /// Writes the bool value. 81 | /// 82 | /// if set to true [value]. 83 | void JsonWriter::WriteBoolValue(bool value) 84 | { 85 | Serializer::WriteBoolValue(value); 86 | writer.Write(value ? L"true" : L"false"); 87 | } 88 | 89 | /// 90 | /// Writes the integer value. 91 | /// 92 | /// The value. 93 | void JsonWriter::WriteIntegerValue(int value) 94 | { 95 | Serializer::WriteIntegerValue(value); 96 | writer.Write(std::to_wstring(value).c_str()); 97 | } 98 | 99 | /// 100 | /// Writes the double value. 101 | /// 102 | /// The value. 103 | void JsonWriter::WriteDoubleValue(double value) 104 | { 105 | Serializer::WriteDoubleValue(value); 106 | writer.Write(std::to_wstring(value).c_str()); 107 | } 108 | 109 | /// 110 | /// Writes the string value. 111 | /// 112 | /// The value. 113 | void JsonWriter::WriteStringValue(const std::wstring &value) 114 | { 115 | Serializer::WriteStringValue(value); 116 | writer.Write((L"\"" + value + L"\"").c_str()); 117 | } 118 | -------------------------------------------------------------------------------- /src/core/common/JsonWriter.h: -------------------------------------------------------------------------------- 1 | #ifndef JSONWRITER_H 2 | #define JSONWRITER_H 3 | 4 | #include "../Common/Common.h" 5 | #include "../Common/Serializer.h" 6 | #include 7 | 8 | namespace ApplicationInsights 9 | { 10 | namespace core 11 | { 12 | class TELEMETRYCLIENT_API JsonWriter : public Serializer 13 | { 14 | public: 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The writer. 19 | JsonWriter(StreamWriter &writer); 20 | 21 | /// 22 | /// Finalizes an instance of the class. 23 | /// 24 | virtual ~JsonWriter(); 25 | 26 | /// 27 | /// Begins the dictionary value. 28 | /// 29 | virtual void BeginDictionaryValue(); 30 | 31 | /// 32 | /// Writes the name of the property. 33 | /// 34 | /// The name. 35 | virtual void WritePropertyName(const std::wstring &name); 36 | 37 | /// 38 | /// Ends the dictionary value. 39 | /// 40 | virtual void EndDictionaryValue(); 41 | 42 | /// 43 | /// Begins the array value. 44 | /// 45 | virtual void BeginArrayValue(); 46 | 47 | /// 48 | /// Ends the array value. 49 | /// 50 | virtual void EndArrayValue(); 51 | 52 | /// 53 | /// Writes the bool value. 54 | /// 55 | /// if set to true [value]. 56 | virtual void WriteBoolValue(bool value); 57 | 58 | /// 59 | /// Writes the integer value. 60 | /// 61 | /// The value. 62 | virtual void WriteIntegerValue(int value); 63 | 64 | /// 65 | /// Writes the double value. 66 | /// 67 | /// The value. 68 | virtual void WriteDoubleValue(double value); 69 | 70 | /// 71 | /// Writes the string value. 72 | /// 73 | /// The value. 74 | virtual void WriteStringValue(const std::wstring &value); 75 | 76 | protected: 77 | /// 78 | /// Adds a comma if needed 79 | /// 80 | /// The kind. 81 | virtual void PrepareValue(StackEntry kind); 82 | }; 83 | } 84 | } 85 | #endif 86 | -------------------------------------------------------------------------------- /src/core/common/StreamWriter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "StreamWriter.h" 3 | #include "string.h" 4 | 5 | using namespace ApplicationInsights::core; 6 | 7 | /// 8 | /// Initializes a new instance of the class. 9 | /// 10 | StreamWriter::StreamWriter() 11 | { 12 | } 13 | 14 | /// 15 | /// Finalizes an instance of the class. 16 | /// 17 | StreamWriter::~StreamWriter() 18 | { 19 | } 20 | 21 | /// 22 | /// Writes the bool value. 23 | /// 24 | /// if set to true [value]. 25 | void StreamWriter::Write(bool value) 26 | { 27 | if (value) 28 | { 29 | return this->Write(L"True"); 30 | } 31 | 32 | return this->Write(L"False"); 33 | } 34 | 35 | /// 36 | /// Writes the int value. 37 | /// 38 | /// The value. 39 | void StreamWriter::Write(int value) 40 | { 41 | wchar_t buffer[128]; 42 | #if WIN32 43 | swprintf_s(buffer, 128, L"%d", value); 44 | #else 45 | swprintf(buffer, 128, L"%d", value); 46 | #endif 47 | return this->Write(buffer); 48 | } 49 | 50 | /// 51 | /// Writes the float value. 52 | /// 53 | /// The value. 54 | void StreamWriter::Write(float value) 55 | { 56 | wchar_t buffer[128]; 57 | #if WIN32 58 | swprintf_s(buffer, 128, L"%f", value); 59 | #else 60 | swprintf(buffer, 128, L"%f", value); 61 | #endif 62 | return this->Write(buffer); 63 | } 64 | 65 | /// 66 | /// Writes the specified value. 67 | /// 68 | /// The value. 69 | void StreamWriter::Write(double value) 70 | { 71 | wchar_t buffer[128]; 72 | #if WIN32 73 | swprintf_s(buffer, 128, L"%ld", value); 74 | #else 75 | swprintf(buffer, 128, L"%ld", value); 76 | #endif 77 | return this->Write(buffer); 78 | } -------------------------------------------------------------------------------- /src/core/common/StreamWriter.h: -------------------------------------------------------------------------------- 1 | #ifndef STREAMWRITER_H 2 | #define STREAMWRITER_H 3 | 4 | #include "Common.h" 5 | 6 | namespace ApplicationInsights 7 | { 8 | namespace core 9 | { 10 | class TELEMETRYCLIENT_API StreamWriter 11 | { 12 | protected: 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | StreamWriter(); 17 | 18 | public: 19 | /// 20 | /// Finalizes an instance of the class. 21 | /// 22 | virtual ~StreamWriter(); 23 | 24 | /// 25 | /// Writes the bool value. 26 | /// 27 | /// if set to true [value]. 28 | void Write(bool value); 29 | 30 | /// 31 | /// Writes the int value. 32 | /// 33 | /// The value. 34 | void Write(int value); 35 | 36 | /// 37 | /// Writes the float value. 38 | /// 39 | /// The value. 40 | void Write(float value); 41 | 42 | /// 43 | /// Writes the specified value. 44 | /// 45 | /// The value. 46 | void Write(double value); 47 | 48 | virtual void Write(wchar_t value) = 0; 49 | virtual void Write(const wchar_t* value) = 0; 50 | }; 51 | } 52 | } 53 | #endif 54 | -------------------------------------------------------------------------------- /src/core/common/StringWriter.cpp: -------------------------------------------------------------------------------- 1 | #include "StringWriter.h" 2 | #include "Utils.h" 3 | #include 4 | 5 | using namespace ApplicationInsights::core; 6 | 7 | /// 8 | /// Initializes a new instance of the class. 9 | /// 10 | /// The builder. 11 | StringWriter::StringWriter(std::wstring* builder) 12 | : StreamWriter() 13 | { 14 | if (builder == nullptr) 15 | { 16 | Utils::WriteDebugLine(L"ERROR: StringWriter: Specified builder is NULL"); 17 | return; 18 | } 19 | 20 | this->builder = builder; 21 | } 22 | 23 | /// 24 | /// Finalizes an instance of the class. 25 | /// 26 | StringWriter::~StringWriter() 27 | { 28 | this->builder = nullptr; 29 | } 30 | 31 | /// 32 | /// Writes the specified value. 33 | /// 34 | /// The value. 35 | void StringWriter::Write(wchar_t value) 36 | { 37 | this->builder->append(1, value); 38 | } 39 | 40 | /// 41 | /// Writes the specified value. 42 | /// 43 | /// The value. 44 | void StringWriter::Write(const wchar_t* value) 45 | { 46 | this->builder->append(value); 47 | } 48 | -------------------------------------------------------------------------------- /src/core/common/StringWriter.h: -------------------------------------------------------------------------------- 1 | #ifndef STRINGWRITER_H 2 | #define STRINGWRITER_H 3 | 4 | #include "StreamWriter.h" 5 | #include 6 | 7 | namespace ApplicationInsights 8 | { 9 | namespace core 10 | { 11 | class TELEMETRYCLIENT_API StringWriter : 12 | public StreamWriter 13 | { 14 | std::wstring *builder; 15 | 16 | public: 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The builder. 21 | StringWriter(std::wstring* builder); 22 | 23 | /// 24 | /// Finalizes an instance of the class. 25 | /// 26 | virtual ~StringWriter(); 27 | 28 | 29 | /// 30 | /// Gets the wstring represenation of the contents of the class 31 | /// 32 | /// The wstring represenation of the contents 33 | std::wstring ToString() const { 34 | return *builder; 35 | } 36 | 37 | /// 38 | /// Writes the specified value. 39 | /// 40 | /// The value. 41 | virtual void Write(wchar_t value); 42 | 43 | /// 44 | /// Writes the specified value. 45 | /// 46 | /// The value. 47 | virtual void Write(const wchar_t* value); 48 | }; 49 | } 50 | } 51 | #endif 52 | -------------------------------------------------------------------------------- /src/core/common/Utils.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_H 2 | #define UTILS_H 3 | 4 | #include "../Common/Common.h" 5 | #include 6 | 7 | #define _ARRAY_SIZE(_array) (sizeof(_array) / sizeof(_array[0])) 8 | 9 | namespace ApplicationInsights 10 | { 11 | namespace core 12 | { 13 | class TELEMETRYCLIENT_API Utils 14 | { 15 | public: 16 | /// 17 | /// Gets the current date time. 18 | /// 19 | /// wstring represenation of the current time 20 | static std::wstring GetCurrentDateTime(); 21 | 22 | /// 23 | /// Generates the random UUID. 24 | /// 25 | /// wstring respresentationof the generated UUID 26 | static std::wstring GenerateRandomUUID(); 27 | 28 | /// 29 | /// Writes the debug line. 30 | /// 31 | /// The output. 32 | static void WriteDebugLine(const std::wstring &output); 33 | 34 | 35 | 36 | #ifdef WINAPI_FAMILY_PARTITION // it's SOME kind of Windows 37 | #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) // Desktop 38 | /// 39 | /// Opens the reg key for application Insights. 40 | /// 41 | /// The hKey. 42 | /// The iKey. 43 | /// 44 | static bool Utils::OpenRegKey(HKEY &hKey, std::wstring iKey); 45 | #else 46 | // store or phone 47 | /// 48 | /// Gets the local settings container. 49 | /// 50 | /// the local settings container for AppInsights 51 | static Windows::Foundation::Collections::IPropertySet^ GetLocalSettingsContainer(); 52 | #endif 53 | #endif 54 | }; 55 | } 56 | } 57 | #endif -------------------------------------------------------------------------------- /src/core/contracts/Application.cpp: -------------------------------------------------------------------------------- 1 | #include "Application.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | Application::Application() 6 | { 7 | } 8 | 9 | Application::~Application() 10 | { 11 | } 12 | 13 | void Application::Serialize(Serializer& serializer) const 14 | { 15 | if (m_ver.HasValue()) 16 | { 17 | serializer.WritePropertyName(L"ai.application.ver"); 18 | serializer.WriteStringValue(m_ver.GetValue()); 19 | } 20 | 21 | if (m_build.HasValue()) 22 | { 23 | serializer.WritePropertyName(L"ai.application.build"); 24 | serializer.WriteStringValue(m_build.GetValue()); 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /src/core/contracts/Application.h: -------------------------------------------------------------------------------- 1 | #ifndef APPLICATION_H 2 | #define APPLICATION_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include 9 | #include 10 | 11 | #include 12 | namespace ApplicationInsights 13 | { 14 | namespace core 15 | { 16 | class TELEMETRYCLIENT_API Application : public ISerializable 17 | { 18 | private: 19 | Nullable m_ver; 20 | Nullable m_build; 21 | 22 | public: 23 | Application(); 24 | virtual ~Application(); 25 | 26 | const Nullable& GetVer() const { return m_ver; } 27 | void SetVer(const Nullable& value) { m_ver = value; } 28 | 29 | const Nullable& GetBuild() const { return m_build; } 30 | void SetBuild(const Nullable& value) { m_build = value; } 31 | 32 | virtual void Serialize(Serializer& serializer) const; 33 | }; 34 | } 35 | } 36 | #endif 37 | -------------------------------------------------------------------------------- /src/core/contracts/Base.cpp: -------------------------------------------------------------------------------- 1 | #include "Base.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | Base::Base() 6 | { 7 | } 8 | 9 | Base::~Base() 10 | { 11 | } 12 | 13 | void Base::Serialize(Serializer& serializer) const 14 | { 15 | if (!m_baseType.empty()) 16 | { 17 | serializer.WritePropertyName(L"baseType"); 18 | serializer.WriteStringValue(m_baseType); 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /src/core/contracts/Base.h: -------------------------------------------------------------------------------- 1 | #ifndef BASE_H 2 | #define BASE_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include 9 | #include 10 | #include 11 | 12 | namespace ApplicationInsights 13 | { 14 | namespace core 15 | { 16 | class TELEMETRYCLIENT_API Base : public ISerializable 17 | { 18 | private: 19 | std::wstring m_baseType; 20 | 21 | public: 22 | Base(); 23 | virtual ~Base(); 24 | 25 | const std::wstring& GetBaseType() const { return m_baseType; } 26 | void SetBaseType(const std::wstring& value) { m_baseType = value; } 27 | 28 | virtual void Serialize(Serializer& serializer) const; 29 | }; 30 | } 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /src/core/contracts/Contracts.h: -------------------------------------------------------------------------------- 1 | #include "Domain.h" 2 | #include "Base.h" 3 | #include "Data.h" 4 | #include "Envelope.h" 5 | #include "DependencyKind.h" 6 | #include "SeverityLevel.h" 7 | #include "Domain.h" 8 | #include "Base.h" 9 | #include "Data.h" 10 | #include "Envelope.h" 11 | #include "CrashDataHeaders.h" 12 | #include "CrashDataThreadFrame.h" 13 | #include "CrashDataThread.h" 14 | #include "CrashDataBinary.h" 15 | #include "CrashData.h" 16 | #include "DataPoint.h" 17 | #include "MetricData.h" 18 | #include "RemoteDependencyData.h" 19 | #include "RequestData.h" 20 | #include "StackFrame.h" 21 | #include "ExceptionDetails.h" 22 | #include "ExceptionData.h" 23 | #include "MessageData.h" 24 | #include "EventData.h" 25 | #include "PageViewData.h" 26 | #include "PageViewPerfData.h" 27 | #include "DataPointType.h" 28 | #include "DependencySourceType.h" 29 | #include "Application.h" 30 | #include "Device.h" 31 | #include "Location.h" 32 | #include "Operation.h" 33 | #include "Session.h" 34 | #include "User.h" 35 | #include "Internal.h" 36 | #include "Domain.h" 37 | #include "Base.h" 38 | #include "Data.h" 39 | #include "Envelope.h" 40 | #include "DependencyKind.h" 41 | #include "SeverityLevel.h" 42 | #include "Domain.h" 43 | #include "Base.h" 44 | #include "Data.h" 45 | #include "Envelope.h" 46 | #include "CrashDataHeaders.h" 47 | #include "CrashDataThreadFrame.h" 48 | #include "CrashDataThread.h" 49 | #include "CrashDataBinary.h" 50 | #include "CrashData.h" 51 | #include "DataPoint.h" 52 | #include "MetricData.h" 53 | #include "RemoteDependencyData.h" 54 | #include "RequestData.h" 55 | #include "StackFrame.h" 56 | #include "ExceptionDetails.h" 57 | #include "ExceptionData.h" 58 | #include "MessageData.h" 59 | #include "EventData.h" 60 | #include "PageViewData.h" 61 | #include "PageViewPerfData.h" 62 | #include "DataPointType.h" 63 | #include "DependencySourceType.h" 64 | #include "SessionStateData.h" 65 | #include "SessionState.h" 66 | -------------------------------------------------------------------------------- /src/core/contracts/CrashData.cpp: -------------------------------------------------------------------------------- 1 | #include "CrashData.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | CrashData::CrashData() : 6 | CrashData(L"Microsoft.ApplicationInsights.Crash", L"CrashData") 7 | { 8 | } 9 | 10 | CrashData::CrashData(std::wstring envelopeName, std::wstring baseType) : 11 | Domain(envelopeName, baseType), 12 | m_ver(2) 13 | { 14 | } 15 | 16 | CrashData::~CrashData() 17 | { 18 | } 19 | 20 | void CrashData::Serialize(Serializer& serializer) const 21 | { 22 | Domain::Serialize(serializer); 23 | serializer.WritePropertyName(L"ver"); 24 | serializer.WriteIntegerValue(m_ver); 25 | 26 | serializer.WritePropertyName(L"headers"); 27 | serializer.WriteObjectValue(m_headers); 28 | 29 | if (m_threads.size() > 0) 30 | { 31 | serializer.WritePropertyName(L"threads"); 32 | serializer.BeginArrayValue(); 33 | for (auto &it : m_threads) 34 | { 35 | serializer.WriteObjectValue(it); 36 | } 37 | serializer.EndArrayValue(); 38 | } 39 | 40 | if (m_binaries.size() > 0) 41 | { 42 | serializer.WritePropertyName(L"binaries"); 43 | serializer.BeginArrayValue(); 44 | for (auto &it : m_binaries) 45 | { 46 | serializer.WriteObjectValue(it); 47 | } 48 | serializer.EndArrayValue(); 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/core/contracts/CrashData.h: -------------------------------------------------------------------------------- 1 | #ifndef CRASHDATA_H 2 | #define CRASHDATA_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include "CrashDataBinary.h" 9 | #include "CrashDataHeaders.h" 10 | #include "CrashDataThread.h" 11 | #include "Domain.h" 12 | #include 13 | #include 14 | #include 15 | 16 | namespace ApplicationInsights 17 | { 18 | namespace core 19 | { 20 | class TELEMETRYCLIENT_API CrashData : public Domain 21 | { 22 | private: 23 | int m_ver; 24 | CrashDataHeaders* m_headers; 25 | std::vector m_threads; 26 | std::vector m_binaries; 27 | 28 | public: 29 | CrashData(); 30 | CrashData(std::wstring envelopeName, std::wstring dataType); 31 | virtual ~CrashData(); 32 | 33 | const int& GetVer() const { return m_ver; } 34 | void SetVer(const int& value) { m_ver = value; } 35 | 36 | CrashDataHeaders* GetHeaders() const { return m_headers; } 37 | void SetHeaders(CrashDataHeaders* value) { m_headers = value; } 38 | 39 | const std::vector& GetThreads() const { return m_threads; } 40 | void SetThreads(const std::vector& value) { m_threads = value; } 41 | 42 | const std::vector& GetBinaries() const { return m_binaries; } 43 | void SetBinaries(const std::vector& value) { m_binaries = value; } 44 | 45 | virtual void Serialize(Serializer& serializer) const; 46 | }; 47 | } 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/core/contracts/CrashDataBinary.cpp: -------------------------------------------------------------------------------- 1 | #include "CrashDataBinary.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | CrashDataBinary::CrashDataBinary() 6 | { 7 | } 8 | 9 | CrashDataBinary::~CrashDataBinary() 10 | { 11 | } 12 | 13 | void CrashDataBinary::Serialize(Serializer& serializer) const 14 | { 15 | if (!m_startAddress.empty()) 16 | { 17 | serializer.WritePropertyName(L"startAddress"); 18 | serializer.WriteStringValue(m_startAddress); 19 | } 20 | 21 | if (!m_endAddress.empty()) 22 | { 23 | serializer.WritePropertyName(L"endAddress"); 24 | serializer.WriteStringValue(m_endAddress); 25 | } 26 | 27 | if (!m_name.empty()) 28 | { 29 | serializer.WritePropertyName(L"name"); 30 | serializer.WriteStringValue(m_name); 31 | } 32 | 33 | serializer.WritePropertyName(L"cpuType"); 34 | serializer.WriteDoubleValue(m_cpuType); 35 | 36 | serializer.WritePropertyName(L"cpuSubType"); 37 | serializer.WriteDoubleValue(m_cpuSubType); 38 | 39 | if (!m_uuid.empty()) 40 | { 41 | serializer.WritePropertyName(L"uuid"); 42 | serializer.WriteStringValue(m_uuid); 43 | } 44 | 45 | if (!m_path.empty()) 46 | { 47 | serializer.WritePropertyName(L"path"); 48 | serializer.WriteStringValue(m_path); 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/core/contracts/CrashDataBinary.h: -------------------------------------------------------------------------------- 1 | #ifndef CRASHDATABINARY_H 2 | #define CRASHDATABINARY_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include 9 | #include 10 | 11 | #include 12 | namespace ApplicationInsights 13 | { 14 | namespace core 15 | { 16 | class TELEMETRYCLIENT_API CrashDataBinary : public ISerializable 17 | { 18 | private: 19 | std::wstring m_startAddress; 20 | std::wstring m_endAddress; 21 | std::wstring m_name; 22 | long m_cpuType; 23 | long m_cpuSubType; 24 | std::wstring m_uuid; 25 | std::wstring m_path; 26 | 27 | public: 28 | CrashDataBinary(); 29 | virtual ~CrashDataBinary(); 30 | 31 | const std::wstring& GetStartAddress() const { return m_startAddress; } 32 | void SetStartAddress(const std::wstring& value) { m_startAddress = value; } 33 | 34 | const std::wstring& GetEndAddress() const { return m_endAddress; } 35 | void SetEndAddress(const std::wstring& value) { m_endAddress = value; } 36 | 37 | const std::wstring& GetName() const { return m_name; } 38 | void SetName(const std::wstring& value) { m_name = value; } 39 | 40 | const long& GetCpuType() const { return m_cpuType; } 41 | void SetCpuType(const long& value) { m_cpuType = value; } 42 | 43 | const long& GetCpuSubType() const { return m_cpuSubType; } 44 | void SetCpuSubType(const long& value) { m_cpuSubType = value; } 45 | 46 | const std::wstring& GetUuid() const { return m_uuid; } 47 | void SetUuid(const std::wstring& value) { m_uuid = value; } 48 | 49 | const std::wstring& GetPath() const { return m_path; } 50 | void SetPath(const std::wstring& value) { m_path = value; } 51 | 52 | virtual void Serialize(Serializer& serializer) const; 53 | }; 54 | } 55 | } 56 | #endif 57 | -------------------------------------------------------------------------------- /src/core/contracts/CrashDataHeaders.cpp: -------------------------------------------------------------------------------- 1 | #include "CrashDataHeaders.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | CrashDataHeaders::CrashDataHeaders() : 6 | m_processId(0), 7 | m_parentProcessId(0), 8 | m_crashThread(0) 9 | { 10 | } 11 | 12 | CrashDataHeaders::~CrashDataHeaders() 13 | { 14 | } 15 | 16 | void CrashDataHeaders::Serialize(Serializer& serializer) const 17 | { 18 | serializer.WritePropertyName(L"id"); 19 | serializer.WriteStringValue(m_id); 20 | 21 | if (!m_process.empty()) 22 | { 23 | serializer.WritePropertyName(L"process"); 24 | serializer.WriteStringValue(m_process); 25 | } 26 | 27 | serializer.WritePropertyName(L"processId"); 28 | serializer.WriteIntegerValue(m_processId); 29 | 30 | if (!m_parentProcess.empty()) 31 | { 32 | serializer.WritePropertyName(L"parentProcess"); 33 | serializer.WriteStringValue(m_parentProcess); 34 | } 35 | 36 | serializer.WritePropertyName(L"parentProcessId"); 37 | serializer.WriteIntegerValue(m_parentProcessId); 38 | 39 | serializer.WritePropertyName(L"crashThread"); 40 | serializer.WriteIntegerValue(m_crashThread); 41 | 42 | if (!m_applicationPath.empty()) 43 | { 44 | serializer.WritePropertyName(L"applicationPath"); 45 | serializer.WriteStringValue(m_applicationPath); 46 | } 47 | 48 | if (!m_applicationIdentifier.empty()) 49 | { 50 | serializer.WritePropertyName(L"applicationIdentifier"); 51 | serializer.WriteStringValue(m_applicationIdentifier); 52 | } 53 | 54 | if (!m_applicationBuild.empty()) 55 | { 56 | serializer.WritePropertyName(L"applicationBuild"); 57 | serializer.WriteStringValue(m_applicationBuild); 58 | } 59 | 60 | if (!m_exceptionType.empty()) 61 | { 62 | serializer.WritePropertyName(L"exceptionType"); 63 | serializer.WriteStringValue(m_exceptionType); 64 | } 65 | 66 | if (!m_exceptionCode.empty()) 67 | { 68 | serializer.WritePropertyName(L"exceptionCode"); 69 | serializer.WriteStringValue(m_exceptionCode); 70 | } 71 | 72 | if (!m_exceptionAddress.empty()) 73 | { 74 | serializer.WritePropertyName(L"exceptionAddress"); 75 | serializer.WriteStringValue(m_exceptionAddress); 76 | } 77 | 78 | if (!m_exceptionReason.empty()) 79 | { 80 | serializer.WritePropertyName(L"exceptionReason"); 81 | serializer.WriteStringValue(m_exceptionReason); 82 | } 83 | } 84 | 85 | -------------------------------------------------------------------------------- /src/core/contracts/CrashDataHeaders.h: -------------------------------------------------------------------------------- 1 | #ifndef CRASHDATAHEADERS_H 2 | #define CRASHDATAHEADERS_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include 9 | #include 10 | #include 11 | 12 | namespace ApplicationInsights 13 | { 14 | namespace core 15 | { 16 | class TELEMETRYCLIENT_API CrashDataHeaders : public ISerializable 17 | { 18 | private: 19 | std::wstring m_id; 20 | std::wstring m_process; 21 | int m_processId; 22 | std::wstring m_parentProcess; 23 | int m_parentProcessId; 24 | int m_crashThread; 25 | std::wstring m_applicationPath; 26 | std::wstring m_applicationIdentifier; 27 | std::wstring m_applicationBuild; 28 | std::wstring m_exceptionType; 29 | std::wstring m_exceptionCode; 30 | std::wstring m_exceptionAddress; 31 | std::wstring m_exceptionReason; 32 | 33 | public: 34 | CrashDataHeaders(); 35 | virtual ~CrashDataHeaders(); 36 | 37 | const std::wstring& GetId() const { return m_id; } 38 | void SetId(const std::wstring& value) { m_id = value; } 39 | 40 | const std::wstring& GetProcess() const { return m_process; } 41 | void SetProcess(const std::wstring& value) { m_process = value; } 42 | 43 | const int& GetProcessId() const { return m_processId; } 44 | void SetProcessId(const int& value) { m_processId = value; } 45 | 46 | const std::wstring& GetParentProcess() const { return m_parentProcess; } 47 | void SetParentProcess(const std::wstring& value) { m_parentProcess = value; } 48 | 49 | const int& GetParentProcessId() const { return m_parentProcessId; } 50 | void SetParentProcessId(const int& value) { m_parentProcessId = value; } 51 | 52 | const int& GetCrashThread() const { return m_crashThread; } 53 | void SetCrashThread(const int& value) { m_crashThread = value; } 54 | 55 | const std::wstring& GetApplicationPath() const { return m_applicationPath; } 56 | void SetApplicationPath(const std::wstring& value) { m_applicationPath = value; } 57 | 58 | const std::wstring& GetApplicationIdentifier() const { return m_applicationIdentifier; } 59 | void SetApplicationIdentifier(const std::wstring& value) { m_applicationIdentifier = value; } 60 | 61 | const std::wstring& GetApplicationBuild() const { return m_applicationBuild; } 62 | void SetApplicationBuild(const std::wstring& value) { m_applicationBuild = value; } 63 | 64 | const std::wstring& GetExceptionType() const { return m_exceptionType; } 65 | void SetExceptionType(const std::wstring& value) { m_exceptionType = value; } 66 | 67 | const std::wstring& GetCrashExceptionCode() const { return m_exceptionCode; } 68 | void SetCrashExceptionCode(const std::wstring& value) { m_exceptionCode = value; } 69 | 70 | const std::wstring& GetExceptionAddress() const { return m_exceptionAddress; } 71 | void SetExceptionAddress(const std::wstring& value) { m_exceptionAddress = value; } 72 | 73 | const std::wstring& GetExceptionReason() const { return m_exceptionReason; } 74 | void SetExceptionReason(const std::wstring& value) { m_exceptionReason = value; } 75 | 76 | virtual void Serialize(Serializer& serializer) const; 77 | }; 78 | } 79 | } 80 | #endif 81 | -------------------------------------------------------------------------------- /src/core/contracts/CrashDataThread.cpp: -------------------------------------------------------------------------------- 1 | #include "CrashDataThread.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | CrashDataThread::CrashDataThread() 6 | { 7 | } 8 | 9 | CrashDataThread::~CrashDataThread() 10 | { 11 | } 12 | 13 | void CrashDataThread::Serialize(Serializer& serializer) const 14 | { 15 | serializer.WritePropertyName(L"id"); 16 | serializer.WriteIntegerValue(m_id); 17 | 18 | if (m_frames.size() > 0) 19 | { 20 | serializer.WritePropertyName(L"frames"); 21 | serializer.BeginArrayValue(); 22 | for (auto &it : m_frames) 23 | { 24 | serializer.WriteObjectValue(it); 25 | } 26 | serializer.EndArrayValue(); 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /src/core/contracts/CrashDataThread.h: -------------------------------------------------------------------------------- 1 | #ifndef CRASHDATATHREAD_H 2 | #define CRASHDATATHREAD_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include "CrashDataThreadFrame.h" 9 | #include 10 | #include 11 | #include 12 | 13 | namespace ApplicationInsights 14 | { 15 | namespace core 16 | { 17 | class TELEMETRYCLIENT_API CrashDataThread : public ISerializable 18 | { 19 | private: 20 | int m_id; 21 | std::vector m_frames; 22 | 23 | public: 24 | CrashDataThread(); 25 | virtual ~CrashDataThread(); 26 | 27 | const int& GetId() const { return m_id; } 28 | void SetId(const int& value) { m_id = value; } 29 | 30 | const std::vector& GetFrames() const { return m_frames; } 31 | void SetFrames(const std::vector& value) { m_frames = value; } 32 | 33 | virtual void Serialize(Serializer& serializer) const; 34 | }; 35 | } 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /src/core/contracts/CrashDataThreadFrame.cpp: -------------------------------------------------------------------------------- 1 | #include "CrashDataThreadFrame.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | CrashDataThreadFrame::CrashDataThreadFrame() 6 | { 7 | } 8 | 9 | CrashDataThreadFrame::~CrashDataThreadFrame() 10 | { 11 | } 12 | 13 | void CrashDataThreadFrame::Serialize(Serializer& serializer) const 14 | { 15 | serializer.WritePropertyName(L"address"); 16 | serializer.WriteStringValue(m_address); 17 | 18 | if (!m_symbol.empty()) 19 | { 20 | serializer.WritePropertyName(L"symbol"); 21 | serializer.WriteStringValue(m_symbol); 22 | } 23 | 24 | if (m_registers.size() > 0) 25 | { 26 | serializer.WritePropertyName(L"registers"); 27 | serializer.BeginDictionaryValue(); 28 | for (auto &it : m_registers) 29 | { 30 | serializer.WritePropertyName(it.first); 31 | serializer.WriteStringValue(it.second); 32 | } 33 | serializer.EndDictionaryValue(); 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/core/contracts/CrashDataThreadFrame.h: -------------------------------------------------------------------------------- 1 | #ifndef CRASHDATATHREADFRAME_H 2 | #define CRASHDATATHREADFRAME_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include 9 | #include 10 | #include 11 | 12 | namespace ApplicationInsights 13 | { 14 | namespace core 15 | { 16 | class TELEMETRYCLIENT_API CrashDataThreadFrame : public ISerializable 17 | { 18 | private: 19 | std::wstring m_address; 20 | std::wstring m_symbol; 21 | std::map m_registers; 22 | 23 | public: 24 | CrashDataThreadFrame(); 25 | virtual ~CrashDataThreadFrame(); 26 | 27 | const std::wstring& GetAddress() const { return m_address; } 28 | void SetAddress(const std::wstring& value) { m_address = value; } 29 | 30 | const std::wstring& GetSymbol() const { return m_symbol; } 31 | void SetSymbol(const std::wstring& value) { m_symbol = value; } 32 | 33 | const std::map& GetRegisters() const { return m_registers; } 34 | void SetRegisters(const std::map& value) { m_registers = value; } 35 | 36 | virtual void Serialize(Serializer& serializer) const; 37 | }; 38 | } 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /src/core/contracts/Data.cpp: -------------------------------------------------------------------------------- 1 | #include "Data.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | Data::Data() 6 | { 7 | } 8 | 9 | Data::~Data() 10 | { 11 | } 12 | 13 | void Data::Serialize(Serializer& serializer) const 14 | { 15 | Base::Serialize(serializer); 16 | serializer.WritePropertyName(L"baseData"); 17 | serializer.WriteObjectValue(m_baseData); 18 | } 19 | 20 | -------------------------------------------------------------------------------- /src/core/contracts/Data.h: -------------------------------------------------------------------------------- 1 | #ifndef DATA_H 2 | #define DATA_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include "Base.h" 9 | #include "Domain.h" 10 | #include 11 | #include 12 | #include 13 | 14 | namespace ApplicationInsights 15 | { 16 | namespace core 17 | { 18 | class TELEMETRYCLIENT_API Data : public Base 19 | { 20 | private: 21 | Domain* m_baseData; 22 | 23 | public: 24 | Data(); 25 | virtual ~Data(); 26 | 27 | Domain* GetBaseData() const { return m_baseData; } 28 | void SetBaseData(Domain& value) { m_baseData = &value; } 29 | 30 | virtual void Serialize(Serializer& serializer) const; 31 | }; 32 | } 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /src/core/contracts/DataPoint.cpp: -------------------------------------------------------------------------------- 1 | #include "DataPoint.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | DataPoint::DataPoint() : 6 | m_kind(Measurement) 7 | { 8 | } 9 | 10 | DataPoint::~DataPoint() 11 | { 12 | } 13 | 14 | void DataPoint::Serialize(Serializer& serializer) const 15 | { 16 | serializer.WritePropertyName(L"name"); 17 | serializer.WriteStringValue(m_name); 18 | 19 | serializer.WritePropertyName(L"kind"); 20 | serializer.WriteIntegerValue(m_kind); 21 | 22 | serializer.WritePropertyName(L"value"); 23 | serializer.WriteDoubleValue(m_value); 24 | 25 | if (m_count.HasValue()) 26 | { 27 | serializer.WritePropertyName(L"count"); 28 | serializer.WriteIntegerValue(m_count.GetValue()); 29 | } 30 | 31 | if (m_min.HasValue()) 32 | { 33 | serializer.WritePropertyName(L"min"); 34 | serializer.WriteDoubleValue(m_min.GetValue()); 35 | } 36 | 37 | if (m_max.HasValue()) 38 | { 39 | serializer.WritePropertyName(L"max"); 40 | serializer.WriteDoubleValue(m_max.GetValue()); 41 | } 42 | 43 | if (m_stdDev.HasValue()) 44 | { 45 | serializer.WritePropertyName(L"stdDev"); 46 | serializer.WriteDoubleValue(m_stdDev.GetValue()); 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /src/core/contracts/DataPoint.h: -------------------------------------------------------------------------------- 1 | #ifndef DATAPOINT_H 2 | #define DATAPOINT_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include "DataPointType.h" 9 | #include 10 | #include 11 | #include 12 | 13 | namespace ApplicationInsights 14 | { 15 | namespace core 16 | { 17 | class TELEMETRYCLIENT_API DataPoint : public ISerializable 18 | { 19 | private: 20 | std::wstring m_name; 21 | DataPointType m_kind; 22 | double m_value; 23 | Nullable m_count; 24 | Nullable m_min; 25 | Nullable m_max; 26 | Nullable m_stdDev; 27 | 28 | public: 29 | DataPoint(); 30 | virtual ~DataPoint(); 31 | 32 | const std::wstring& GetName() const { return m_name; } 33 | void SetName(const std::wstring& value) { m_name = value; } 34 | 35 | const DataPointType& GetKind() const { return m_kind; } 36 | void SetKind(const DataPointType& value) { m_kind = value; } 37 | 38 | const double& GetValue() const { return m_value; } 39 | void SetValue(const double& value) { m_value = value; } 40 | 41 | const Nullable& GetCount() const { return m_count; } 42 | void SetCount(const Nullable& value) { m_count = value; } 43 | 44 | const Nullable& GetMin() const { return m_min; } 45 | void SetMin(const Nullable& value) { m_min = value; } 46 | 47 | const Nullable& GetMax() const { return m_max; } 48 | void SetMax(const Nullable& value) { m_max = value; } 49 | 50 | const Nullable& GetStdDev() const { return m_stdDev; } 51 | void SetStdDev(const Nullable& value) { m_stdDev = value; } 52 | 53 | virtual void Serialize(Serializer& serializer) const; 54 | }; 55 | } 56 | } 57 | #endif 58 | -------------------------------------------------------------------------------- /src/core/contracts/DataPointType.h: -------------------------------------------------------------------------------- 1 | #ifndef DATAPOINTTYPE_H 2 | #define DATAPOINTTYPE_H 3 | namespace ApplicationInsights 4 | { 5 | namespace core 6 | { 7 | enum DataPointType 8 | { 9 | Measurement = 0, 10 | Aggregation = 1, 11 | }; 12 | } 13 | } 14 | #endif 15 | -------------------------------------------------------------------------------- /src/core/contracts/DependencyKind.h: -------------------------------------------------------------------------------- 1 | #ifndef DEPENDENCYKIND_H 2 | #define DEPENDENCYKIND_H 3 | 4 | namespace ApplicationInsights 5 | { 6 | namespace core 7 | { 8 | enum DependencyKind 9 | { 10 | SQL = 0, 11 | Http = 1, 12 | Other = 2, 13 | }; 14 | } 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /src/core/contracts/DependencySourceType.h: -------------------------------------------------------------------------------- 1 | #ifndef DEPENDENCYSOURCETYPE_H 2 | #define DEPENDENCYSOURCETYPE_H 3 | 4 | namespace ApplicationInsights 5 | { 6 | namespace core 7 | { 8 | enum DependencySourceType 9 | { 10 | Undefined = 0, 11 | Aic = 1, 12 | Apmc = 2, 13 | }; 14 | } 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /src/core/contracts/Device.cpp: -------------------------------------------------------------------------------- 1 | #include "Device.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | Device::Device() 6 | { 7 | } 8 | 9 | Device::~Device() 10 | { 11 | } 12 | 13 | void Device::Serialize(Serializer& serializer) const 14 | { 15 | if (m_id.HasValue()) 16 | { 17 | serializer.WritePropertyName(L"ai.device.id"); 18 | serializer.WriteStringValue(m_id.GetValue()); 19 | } 20 | 21 | if (m_ip.HasValue()) 22 | { 23 | serializer.WritePropertyName(L"ai.device.ip"); 24 | serializer.WriteStringValue(m_ip.GetValue()); 25 | } 26 | 27 | if (m_language.HasValue()) 28 | { 29 | serializer.WritePropertyName(L"ai.device.language"); 30 | serializer.WriteStringValue(m_language.GetValue()); 31 | } 32 | 33 | if (m_locale.HasValue()) 34 | { 35 | serializer.WritePropertyName(L"ai.device.locale"); 36 | serializer.WriteStringValue(m_locale.GetValue()); 37 | } 38 | 39 | if (m_model.HasValue()) 40 | { 41 | serializer.WritePropertyName(L"ai.device.model"); 42 | serializer.WriteStringValue(m_model.GetValue()); 43 | } 44 | 45 | if (m_network.HasValue()) 46 | { 47 | serializer.WritePropertyName(L"ai.device.network"); 48 | serializer.WriteStringValue(m_network.GetValue()); 49 | } 50 | 51 | if (m_oemName.HasValue()) 52 | { 53 | serializer.WritePropertyName(L"ai.device.oemName"); 54 | serializer.WriteStringValue(m_oemName.GetValue()); 55 | } 56 | 57 | if (m_os.HasValue()) 58 | { 59 | serializer.WritePropertyName(L"ai.device.os"); 60 | serializer.WriteStringValue(m_os.GetValue()); 61 | } 62 | 63 | if (m_osVersion.HasValue()) 64 | { 65 | serializer.WritePropertyName(L"ai.device.osVersion"); 66 | serializer.WriteStringValue(m_osVersion.GetValue()); 67 | } 68 | 69 | if (m_roleInstance.HasValue()) 70 | { 71 | serializer.WritePropertyName(L"ai.device.roleInstance"); 72 | serializer.WriteStringValue(m_roleInstance.GetValue()); 73 | } 74 | 75 | if (m_roleName.HasValue()) 76 | { 77 | serializer.WritePropertyName(L"ai.device.roleName"); 78 | serializer.WriteStringValue(m_roleName.GetValue()); 79 | } 80 | 81 | if (m_screenResolution.HasValue()) 82 | { 83 | serializer.WritePropertyName(L"ai.device.screenResolution"); 84 | serializer.WriteStringValue(m_screenResolution.GetValue()); 85 | } 86 | 87 | if (m_type.HasValue()) 88 | { 89 | serializer.WritePropertyName(L"ai.device.type"); 90 | serializer.WriteStringValue(m_type.GetValue()); 91 | } 92 | 93 | if (m_machineName.HasValue()) 94 | { 95 | serializer.WritePropertyName(L"ai.device.machineName"); 96 | serializer.WriteStringValue(m_machineName.GetValue()); 97 | } 98 | } 99 | 100 | -------------------------------------------------------------------------------- /src/core/contracts/Device.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICE_H 2 | #define DEVICE_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include 9 | #include 10 | #include 11 | 12 | namespace ApplicationInsights 13 | { 14 | namespace core 15 | { 16 | class TELEMETRYCLIENT_API Device : public ISerializable 17 | { 18 | private: 19 | Nullable m_id; 20 | Nullable m_ip; 21 | Nullable m_language; 22 | Nullable m_locale; 23 | Nullable m_model; 24 | Nullable m_network; 25 | Nullable m_oemName; 26 | Nullable m_os; 27 | Nullable m_osVersion; 28 | Nullable m_roleInstance; 29 | Nullable m_roleName; 30 | Nullable m_screenResolution; 31 | Nullable m_type; 32 | Nullable m_machineName; 33 | 34 | public: 35 | Device(); 36 | virtual ~Device(); 37 | 38 | const Nullable& GetId() const { return m_id; } 39 | void SetId(const Nullable& value) { m_id = value; } 40 | 41 | const Nullable& GetIp() const { return m_ip; } 42 | void SetIp(const Nullable& value) { m_ip = value; } 43 | 44 | const Nullable& GetLanguage() const { return m_language; } 45 | void SetLanguage(const Nullable& value) { m_language = value; } 46 | 47 | const Nullable& GetLocale() const { return m_locale; } 48 | void SetLocale(const Nullable& value) { m_locale = value; } 49 | 50 | const Nullable& GetModel() const { return m_model; } 51 | void SetModel(const Nullable& value) { m_model = value; } 52 | 53 | const Nullable& GetNetwork() const { return m_network; } 54 | void SetNetwork(const Nullable& value) { m_network = value; } 55 | 56 | const Nullable& GetOemName() const { return m_oemName; } 57 | void SetOemName(const Nullable& value) { m_oemName = value; } 58 | 59 | const Nullable& GetOs() const { return m_os; } 60 | void SetOs(const Nullable& value) { m_os = value; } 61 | 62 | const Nullable& GetOsVersion() const { return m_osVersion; } 63 | void SetOsVersion(const Nullable& value) { m_osVersion = value; } 64 | 65 | const Nullable& GetRoleInstance() const { return m_roleInstance; } 66 | void SetRoleInstance(const Nullable& value) { m_roleInstance = value; } 67 | 68 | const Nullable& GetRoleName() const { return m_roleName; } 69 | void SetRoleName(const Nullable& value) { m_roleName = value; } 70 | 71 | const Nullable& GetScreenResolution() const { return m_screenResolution; } 72 | void SetScreenResolution(const Nullable& value) { m_screenResolution = value; } 73 | 74 | const Nullable& GetType() const { return m_type; } 75 | void SetType(const Nullable& value) { m_type = value; } 76 | 77 | const Nullable& GetMachineName() const { return m_machineName; } 78 | void SetMachineName(const Nullable& value) { m_machineName = value; } 79 | 80 | virtual void Serialize(Serializer& serializer) const; 81 | }; 82 | } 83 | } 84 | #endif 85 | -------------------------------------------------------------------------------- /src/core/contracts/Domain.cpp: -------------------------------------------------------------------------------- 1 | #include "Domain.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | Domain::Domain(std::wstring envelopeName, std::wstring baseType) : 6 | m_envelopeName(envelopeName), 7 | m_baseType(baseType) 8 | { 9 | } 10 | 11 | Domain::~Domain() 12 | { 13 | } 14 | 15 | void Domain::Serialize(Serializer& serializer) const 16 | { 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/core/contracts/Domain.h: -------------------------------------------------------------------------------- 1 | #ifndef DOMAIN_H 2 | #define DOMAIN_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include 9 | #include 10 | #include 11 | 12 | namespace ApplicationInsights 13 | { 14 | namespace core 15 | { 16 | class TELEMETRYCLIENT_API Domain : public ISerializable 17 | { 18 | private: 19 | std::wstring m_envelopeName; 20 | std::wstring m_baseType; 21 | 22 | public: 23 | Domain(std::wstring envelopeName, std::wstring dataType); 24 | virtual ~Domain(); 25 | 26 | const std::wstring& GetEnvelopeName() const { return m_envelopeName; } 27 | const std::wstring& GetBaseType() const { return m_baseType; } 28 | virtual void Serialize(Serializer& serializer) const; 29 | }; 30 | } 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /src/core/contracts/Envelope.cpp: -------------------------------------------------------------------------------- 1 | #include "Envelope.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | Envelope::Envelope() : 6 | m_ver(1), 7 | m_sampleRate(100.0) 8 | { 9 | } 10 | 11 | Envelope::~Envelope() 12 | { 13 | } 14 | 15 | void Envelope::Serialize(Serializer& serializer) const 16 | { 17 | serializer.WritePropertyName(L"ver"); 18 | serializer.WriteIntegerValue(m_ver); 19 | 20 | serializer.WritePropertyName(L"name"); 21 | serializer.WriteStringValue(m_name); 22 | 23 | serializer.WritePropertyName(L"time"); 24 | serializer.WriteStringValue(m_time); 25 | 26 | serializer.WritePropertyName(L"sampleRate"); 27 | serializer.WriteDoubleValue(m_sampleRate); 28 | 29 | if (!m_seq.empty()) 30 | { 31 | serializer.WritePropertyName(L"seq"); 32 | serializer.WriteStringValue(m_seq); 33 | } 34 | 35 | if (!m_iKey.empty()) 36 | { 37 | serializer.WritePropertyName(L"iKey"); 38 | serializer.WriteStringValue(m_iKey); 39 | } 40 | 41 | serializer.WritePropertyName(L"flags"); 42 | serializer.WriteDoubleValue(m_flags); 43 | 44 | if (!m_deviceId.empty()) 45 | { 46 | serializer.WritePropertyName(L"deviceId"); 47 | serializer.WriteStringValue(m_deviceId); 48 | } 49 | 50 | if (!m_os.empty()) 51 | { 52 | serializer.WritePropertyName(L"os"); 53 | serializer.WriteStringValue(m_os); 54 | } 55 | 56 | if (!m_osVer.empty()) 57 | { 58 | serializer.WritePropertyName(L"osVer"); 59 | serializer.WriteStringValue(m_osVer); 60 | } 61 | 62 | if (!m_appId.empty()) 63 | { 64 | serializer.WritePropertyName(L"appId"); 65 | serializer.WriteStringValue(m_appId); 66 | } 67 | 68 | if (!m_appVer.empty()) 69 | { 70 | serializer.WritePropertyName(L"appVer"); 71 | serializer.WriteStringValue(m_appVer); 72 | } 73 | 74 | if (!m_userId.empty()) 75 | { 76 | serializer.WritePropertyName(L"userId"); 77 | serializer.WriteStringValue(m_userId); 78 | } 79 | 80 | if (m_tags.size() > 0) 81 | { 82 | serializer.WritePropertyName(L"tags"); 83 | serializer.BeginDictionaryValue(); 84 | for (auto &it : m_tags) 85 | { 86 | serializer.WritePropertyName(it.first); 87 | serializer.WriteStringValue(it.second); 88 | } 89 | serializer.EndDictionaryValue(); 90 | } 91 | 92 | serializer.WritePropertyName(L"data"); 93 | serializer.WriteObjectValue(m_data); 94 | } 95 | 96 | -------------------------------------------------------------------------------- /src/core/contracts/Envelope.h: -------------------------------------------------------------------------------- 1 | #ifndef ENVELOPE_H 2 | #define ENVELOPE_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include "Base.h" 9 | #include 10 | #include 11 | #include 12 | 13 | namespace ApplicationInsights 14 | { 15 | namespace core 16 | { 17 | class TELEMETRYCLIENT_API Envelope : public ISerializable 18 | { 19 | private: 20 | int m_ver; 21 | std::wstring m_name; 22 | std::wstring m_time; 23 | double m_sampleRate; 24 | std::wstring m_seq; 25 | std::wstring m_iKey; 26 | long m_flags; 27 | std::wstring m_deviceId; 28 | std::wstring m_os; 29 | std::wstring m_osVer; 30 | std::wstring m_appId; 31 | std::wstring m_appVer; 32 | std::wstring m_userId; 33 | std::map m_tags; 34 | Base* m_data; 35 | 36 | public: 37 | Envelope(); 38 | virtual ~Envelope(); 39 | 40 | const int& GetVer() const { return m_ver; } 41 | void SetVer(const int& value) { m_ver = value; } 42 | 43 | const std::wstring& GetName() const { return m_name; } 44 | void SetName(const std::wstring& value) { m_name = value; } 45 | 46 | const std::wstring& GetTime() const { return m_time; } 47 | void SetTime(const std::wstring& value) { m_time = value; } 48 | 49 | const double& GetSampleRate() const { return m_sampleRate; } 50 | void SetSampleRate(const double& value) { m_sampleRate = value; } 51 | 52 | const std::wstring& GetSeq() const { return m_seq; } 53 | void SetSeq(const std::wstring& value) { m_seq = value; } 54 | 55 | const std::wstring& GetIKey() const { return m_iKey; } 56 | void SetIKey(const std::wstring& value) { m_iKey = value; } 57 | 58 | const long& GetFlags() const { return m_flags; } 59 | void SetFlags(const long& value) { m_flags = value; } 60 | 61 | const std::wstring& GetDeviceId() const { return m_deviceId; } 62 | void SetDeviceId(const std::wstring& value) { m_deviceId = value; } 63 | 64 | const std::wstring& GetOs() const { return m_os; } 65 | void SetOs(const std::wstring& value) { m_os = value; } 66 | 67 | const std::wstring& GetOsVer() const { return m_osVer; } 68 | void SetOsVer(const std::wstring& value) { m_osVer = value; } 69 | 70 | const std::wstring& GetAppId() const { return m_appId; } 71 | void SetAppId(const std::wstring& value) { m_appId = value; } 72 | 73 | const std::wstring& GetAppVer() const { return m_appVer; } 74 | void SetAppVer(const std::wstring& value) { m_appVer = value; } 75 | 76 | const std::wstring& GetUserId() const { return m_userId; } 77 | void SetUserId(const std::wstring& value) { m_userId = value; } 78 | 79 | const std::map& GetTags() const { return m_tags; } 80 | void SetTags(const std::map& value) { m_tags = value; } 81 | 82 | Base* GetData() const { return m_data; } 83 | void SetData(Base &value) { m_data = &value; } 84 | 85 | virtual void Serialize(Serializer& serializer) const; 86 | }; 87 | } 88 | } 89 | #endif 90 | -------------------------------------------------------------------------------- /src/core/contracts/EventData.cpp: -------------------------------------------------------------------------------- 1 | #include "EventData.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | EventData::EventData() : 6 | EventData(L"Microsoft.ApplicationInsights.Event", L"EventData") 7 | { 8 | } 9 | 10 | EventData::EventData(std::wstring envelopeName, std::wstring baseType) : 11 | Domain(envelopeName, baseType), 12 | m_ver(2) 13 | { 14 | } 15 | 16 | EventData::~EventData() 17 | { 18 | } 19 | 20 | void EventData::Serialize(Serializer& serializer) const 21 | { 22 | Domain::Serialize(serializer); 23 | serializer.WritePropertyName(L"ver"); 24 | serializer.WriteIntegerValue(m_ver); 25 | 26 | serializer.WritePropertyName(L"name"); 27 | serializer.WriteStringValue(m_name); 28 | 29 | if (m_properties.size() > 0) 30 | { 31 | serializer.WritePropertyName(L"properties"); 32 | serializer.BeginDictionaryValue(); 33 | for (auto &it : m_properties) 34 | { 35 | serializer.WritePropertyName(it.first); 36 | serializer.WriteStringValue(it.second); 37 | } 38 | serializer.EndDictionaryValue(); 39 | } 40 | 41 | if (m_measurements.size() > 0) 42 | { 43 | serializer.WritePropertyName(L"measurements"); 44 | serializer.BeginDictionaryValue(); 45 | for (auto &it : m_measurements) 46 | { 47 | serializer.WritePropertyName(it.first); 48 | serializer.WriteDoubleValue(it.second); 49 | } 50 | serializer.EndDictionaryValue(); 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /src/core/contracts/EventData.h: -------------------------------------------------------------------------------- 1 | #ifndef EVENTDATA_H 2 | #define EVENTDATA_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include "Domain.h" 9 | #include 10 | #include 11 | #include 12 | 13 | namespace ApplicationInsights 14 | { 15 | namespace core 16 | { 17 | class TELEMETRYCLIENT_API EventData : public Domain 18 | { 19 | private: 20 | int m_ver; 21 | std::wstring m_name; 22 | std::map m_properties; 23 | std::map m_measurements; 24 | 25 | public: 26 | EventData(); 27 | EventData(std::wstring envelopeName, std::wstring dataType); 28 | virtual ~EventData(); 29 | 30 | const int& GetVer() const { return m_ver; } 31 | void SetVer(const int& value) { m_ver = value; } 32 | 33 | const std::wstring& GetName() const { return m_name; } 34 | void SetName(const std::wstring& value) { m_name = value; } 35 | 36 | const std::map& GetProperties() const { return m_properties; } 37 | void SetProperties(const std::map& value) { m_properties = value; } 38 | 39 | const std::map& GetMeasurements() const { return m_measurements; } 40 | void SetMeasurements(const std::map& value) { m_measurements = value; } 41 | 42 | virtual void Serialize(Serializer& serializer) const; 43 | }; 44 | } 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /src/core/contracts/ExceptionData.cpp: -------------------------------------------------------------------------------- 1 | #include "ExceptionData.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | ExceptionData::ExceptionData() : 6 | ExceptionData(L"Microsoft.ApplicationInsights.Exception", L"ExceptionData") 7 | { 8 | } 9 | 10 | ExceptionData::ExceptionData(std::wstring envelopeName, std::wstring baseType) : 11 | Domain(envelopeName, baseType), 12 | m_ver(2) 13 | { 14 | } 15 | 16 | ExceptionData::~ExceptionData() 17 | { 18 | } 19 | 20 | void ExceptionData::Serialize(Serializer& serializer) const 21 | { 22 | Domain::Serialize(serializer); 23 | serializer.WritePropertyName(L"ver"); 24 | serializer.WriteIntegerValue(m_ver); 25 | 26 | serializer.WritePropertyName(L"handledAt"); 27 | serializer.WriteStringValue(m_handledAt); 28 | 29 | serializer.WritePropertyName(L"exceptions"); 30 | serializer.BeginArrayValue(); 31 | for (auto &it : m_exceptions) 32 | { 33 | serializer.WriteObjectValue(it); 34 | } 35 | serializer.EndArrayValue(); 36 | 37 | if (m_severityLevel.HasValue()) 38 | { 39 | serializer.WritePropertyName(L"severityLevel"); 40 | serializer.WriteIntegerValue(m_severityLevel.GetValue()); 41 | } 42 | 43 | if (!m_problemId.empty()) 44 | { 45 | serializer.WritePropertyName(L"problemId"); 46 | serializer.WriteStringValue(m_problemId); 47 | } 48 | 49 | serializer.WritePropertyName(L"crashThreadId"); 50 | serializer.WriteIntegerValue(m_crashThreadId); 51 | 52 | if (m_properties.size() > 0) 53 | { 54 | serializer.WritePropertyName(L"properties"); 55 | serializer.BeginDictionaryValue(); 56 | for (auto &it : m_properties) 57 | { 58 | serializer.WritePropertyName(it.first); 59 | serializer.WriteStringValue(it.second); 60 | } 61 | serializer.EndDictionaryValue(); 62 | } 63 | 64 | if (m_measurements.size() > 0) 65 | { 66 | serializer.WritePropertyName(L"measurements"); 67 | serializer.BeginDictionaryValue(); 68 | for (auto &it : m_measurements) 69 | { 70 | serializer.WritePropertyName(it.first); 71 | serializer.WriteDoubleValue(it.second); 72 | } 73 | serializer.EndDictionaryValue(); 74 | } 75 | } 76 | 77 | -------------------------------------------------------------------------------- /src/core/contracts/ExceptionData.h: -------------------------------------------------------------------------------- 1 | #ifndef EXCEPTIONDATA_H 2 | #define EXCEPTIONDATA_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include "Domain.h" 9 | #include "ExceptionDetails.h" 10 | #include "SeverityLevel.h" 11 | #include 12 | #include 13 | #include 14 | 15 | namespace ApplicationInsights 16 | { 17 | namespace core 18 | { 19 | class TELEMETRYCLIENT_API ExceptionData : public Domain 20 | { 21 | private: 22 | int m_ver; 23 | std::wstring m_handledAt; 24 | std::vector m_exceptions; 25 | Nullable m_severityLevel; 26 | std::wstring m_problemId; 27 | int m_crashThreadId; 28 | std::map m_properties; 29 | std::map m_measurements; 30 | 31 | public: 32 | ExceptionData(); 33 | ExceptionData(std::wstring envelopeName, std::wstring dataType); 34 | virtual ~ExceptionData(); 35 | 36 | const int& GetVer() const { return m_ver; } 37 | void SetVer(const int& value) { m_ver = value; } 38 | 39 | const std::wstring& GetHandledAt() const { return m_handledAt; } 40 | void SetHandledAt(const std::wstring& value) { m_handledAt = value; } 41 | 42 | const std::vector& GetExceptions() const { return m_exceptions; } 43 | void SetExceptions(const std::vector& value) { m_exceptions = value; } 44 | 45 | const Nullable& GetSeverityLevel() const { return m_severityLevel; } 46 | void SetSeverityLevel(const Nullable& value) { m_severityLevel = value; } 47 | 48 | const std::wstring& GetProblemId() const { return m_problemId; } 49 | void SetProblemId(const std::wstring& value) { m_problemId = value; } 50 | 51 | const int& GetCrashThreadId() const { return m_crashThreadId; } 52 | void SetCrashThreadId(const int& value) { m_crashThreadId = value; } 53 | 54 | const std::map& GetProperties() const { return m_properties; } 55 | void SetProperties(const std::map& value) { m_properties = value; } 56 | 57 | const std::map& GetMeasurements() const { return m_measurements; } 58 | void SetMeasurements(const std::map& value) { m_measurements = value; } 59 | 60 | virtual void Serialize(Serializer& serializer) const; 61 | }; 62 | } 63 | } 64 | #endif 65 | -------------------------------------------------------------------------------- /src/core/contracts/ExceptionDetails.cpp: -------------------------------------------------------------------------------- 1 | #include "ExceptionDetails.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | ExceptionDetails::ExceptionDetails() : 6 | m_hasFullStack(true) 7 | { 8 | } 9 | 10 | ExceptionDetails::~ExceptionDetails() 11 | { 12 | } 13 | 14 | void ExceptionDetails::Serialize(Serializer& serializer) const 15 | { 16 | serializer.WritePropertyName(L"id"); 17 | serializer.WriteIntegerValue(m_id); 18 | 19 | serializer.WritePropertyName(L"outerId"); 20 | serializer.WriteIntegerValue(m_outerId); 21 | 22 | serializer.WritePropertyName(L"typeName"); 23 | serializer.WriteStringValue(m_typeName); 24 | 25 | serializer.WritePropertyName(L"message"); 26 | serializer.WriteStringValue(m_message); 27 | 28 | serializer.WritePropertyName(L"hasFullStack"); 29 | serializer.WriteBoolValue(m_hasFullStack); 30 | 31 | if (!m_stack.empty()) 32 | { 33 | serializer.WritePropertyName(L"stack"); 34 | serializer.WriteStringValue(m_stack); 35 | } 36 | 37 | if (m_parsedStack.size() > 0) 38 | { 39 | serializer.WritePropertyName(L"parsedStack"); 40 | serializer.BeginArrayValue(); 41 | for (auto &it : m_parsedStack) 42 | { 43 | serializer.WriteObjectValue(it); 44 | } 45 | serializer.EndArrayValue(); 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /src/core/contracts/ExceptionDetails.h: -------------------------------------------------------------------------------- 1 | #ifndef EXCEPTIONDETAILS_H 2 | #define EXCEPTIONDETAILS_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include "StackFrame.h" 9 | #include 10 | #include 11 | #include 12 | 13 | namespace ApplicationInsights 14 | { 15 | namespace core 16 | { 17 | class TELEMETRYCLIENT_API ExceptionDetails : public ISerializable 18 | { 19 | private: 20 | int m_id; 21 | int m_outerId; 22 | std::wstring m_typeName; 23 | std::wstring m_message; 24 | bool m_hasFullStack; 25 | std::wstring m_stack; 26 | std::vector m_parsedStack; 27 | 28 | public: 29 | ExceptionDetails(); 30 | virtual ~ExceptionDetails(); 31 | 32 | const int& GetId() const { return m_id; } 33 | void SetId(const int& value) { m_id = value; } 34 | 35 | const int& GetOuterId() const { return m_outerId; } 36 | void SetOuterId(const int& value) { m_outerId = value; } 37 | 38 | const std::wstring& GetTypeName() const { return m_typeName; } 39 | void SetTypeName(const std::wstring& value) { m_typeName = value; } 40 | 41 | const std::wstring& GetMessage() const { return m_message; } 42 | void SetMessage(const std::wstring& value) { m_message = value; } 43 | 44 | const bool& GetHasFullStack() const { return m_hasFullStack; } 45 | void SetHasFullStack(const bool& value) { m_hasFullStack = value; } 46 | 47 | const std::wstring& GetStack() const { return m_stack; } 48 | void SetStack(const std::wstring& value) { m_stack = value; } 49 | 50 | const std::vector& GetParsedStack() const { return m_parsedStack; } 51 | void SetParsedStack(const std::vector& value) { m_parsedStack = value; } 52 | 53 | virtual void Serialize(Serializer& serializer) const; 54 | }; 55 | } 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/core/contracts/Internal.cpp: -------------------------------------------------------------------------------- 1 | #include "Internal.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | Internal::Internal() 6 | { 7 | } 8 | 9 | Internal::~Internal() 10 | { 11 | } 12 | 13 | void Internal::Serialize(Serializer& serializer) const 14 | { 15 | if (m_sdkVersion.HasValue()) 16 | { 17 | serializer.WritePropertyName(L"ai.internal.sdkVersion"); 18 | serializer.WriteStringValue(m_sdkVersion.GetValue()); 19 | } 20 | 21 | if (m_agentVersion.HasValue()) 22 | { 23 | serializer.WritePropertyName(L"ai.internal.agentVersion"); 24 | serializer.WriteStringValue(m_agentVersion.GetValue()); 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /src/core/contracts/Internal.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERNAL_H 2 | #define INTERNAL_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include 9 | #include 10 | #include 11 | 12 | namespace ApplicationInsights 13 | { 14 | namespace core 15 | { 16 | class TELEMETRYCLIENT_API Internal : public ISerializable 17 | { 18 | private: 19 | Nullable m_sdkVersion; 20 | Nullable m_agentVersion; 21 | 22 | public: 23 | Internal(); 24 | virtual ~Internal(); 25 | 26 | const Nullable& GetSdkVersion() const { return m_sdkVersion; } 27 | void SetSdkVersion(const Nullable& value) { m_sdkVersion = value; } 28 | 29 | const Nullable& GetAgentVersion() const { return m_agentVersion; } 30 | void SetAgentVersion(const Nullable& value) { m_agentVersion = value; } 31 | 32 | virtual void Serialize(Serializer& serializer) const; 33 | }; 34 | } 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/core/contracts/Location.cpp: -------------------------------------------------------------------------------- 1 | #include "Location.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | Location::Location() 6 | { 7 | } 8 | 9 | Location::~Location() 10 | { 11 | } 12 | 13 | void Location::Serialize(Serializer& serializer) const 14 | { 15 | if (m_ip.HasValue()) 16 | { 17 | serializer.WritePropertyName(L"ai.location.ip"); 18 | serializer.WriteStringValue(m_ip.GetValue()); 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /src/core/contracts/Location.h: -------------------------------------------------------------------------------- 1 | #ifndef LOCATION_H 2 | #define LOCATION_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include 9 | #include 10 | #include 11 | 12 | namespace ApplicationInsights 13 | { 14 | namespace core 15 | { 16 | class TELEMETRYCLIENT_API Location : public ISerializable 17 | { 18 | private: 19 | Nullable m_ip; 20 | 21 | public: 22 | Location(); 23 | virtual ~Location(); 24 | 25 | const Nullable& GetIp() const { return m_ip; } 26 | void SetIp(const Nullable& value) { m_ip = value; } 27 | 28 | virtual void Serialize(Serializer& serializer) const; 29 | }; 30 | } 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /src/core/contracts/MessageData.cpp: -------------------------------------------------------------------------------- 1 | #include "MessageData.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | MessageData::MessageData() : 6 | MessageData(L"Microsoft.ApplicationInsights.Message", L"MessageData") 7 | { 8 | } 9 | 10 | MessageData::MessageData(std::wstring envelopeName, std::wstring baseType) : 11 | Domain(envelopeName, baseType), 12 | m_ver(2) 13 | { 14 | } 15 | 16 | MessageData::~MessageData() 17 | { 18 | } 19 | 20 | void MessageData::Serialize(Serializer& serializer) const 21 | { 22 | Domain::Serialize(serializer); 23 | serializer.WritePropertyName(L"ver"); 24 | serializer.WriteIntegerValue(m_ver); 25 | 26 | serializer.WritePropertyName(L"message"); 27 | serializer.WriteStringValue(m_message); 28 | 29 | if (m_severityLevel.HasValue()) 30 | { 31 | serializer.WritePropertyName(L"severityLevel"); 32 | serializer.WriteIntegerValue(m_severityLevel.GetValue()); 33 | } 34 | 35 | if (m_properties.size() > 0) 36 | { 37 | serializer.WritePropertyName(L"properties"); 38 | serializer.BeginDictionaryValue(); 39 | for (auto &it : m_properties) 40 | { 41 | serializer.WritePropertyName(it.first); 42 | serializer.WriteStringValue(it.second); 43 | } 44 | serializer.EndDictionaryValue(); 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /src/core/contracts/MessageData.h: -------------------------------------------------------------------------------- 1 | #ifndef MESSAGEDATA_H 2 | #define MESSAGEDATA_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include "Domain.h" 9 | #include "SeverityLevel.h" 10 | #include 11 | #include 12 | #include 13 | 14 | namespace ApplicationInsights 15 | { 16 | namespace core 17 | { 18 | class TELEMETRYCLIENT_API MessageData : public Domain 19 | { 20 | private: 21 | int m_ver; 22 | std::wstring m_message; 23 | Nullable m_severityLevel; 24 | std::map m_properties; 25 | 26 | public: 27 | MessageData(); 28 | MessageData(std::wstring envelopeName, std::wstring dataType); 29 | virtual ~MessageData(); 30 | 31 | const int& GetVer() const { return m_ver; } 32 | void SetVer(const int& value) { m_ver = value; } 33 | 34 | const std::wstring& GetMessage() const { return m_message; } 35 | void SetMessage(const std::wstring& value) { m_message = value; } 36 | 37 | const Nullable& GetSeverityLevel() const { return m_severityLevel; } 38 | void SetSeverityLevel(const Nullable& value) { m_severityLevel = value; } 39 | 40 | const std::map& GetProperties() const { return m_properties; } 41 | void SetProperties(const std::map& value) { m_properties = value; } 42 | 43 | virtual void Serialize(Serializer& serializer) const; 44 | }; 45 | } 46 | } 47 | #endif 48 | -------------------------------------------------------------------------------- /src/core/contracts/MetricData.cpp: -------------------------------------------------------------------------------- 1 | #include "MetricData.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | MetricData::MetricData() : 6 | MetricData(L"Microsoft.ApplicationInsights.Metric", L"MetricData") 7 | { 8 | } 9 | 10 | MetricData::MetricData(std::wstring envelopeName, std::wstring baseType) : 11 | Domain(envelopeName, baseType), 12 | m_ver(2) 13 | { 14 | } 15 | 16 | MetricData::~MetricData() 17 | { 18 | } 19 | 20 | void MetricData::Serialize(Serializer& serializer) const 21 | { 22 | Domain::Serialize(serializer); 23 | serializer.WritePropertyName(L"ver"); 24 | serializer.WriteIntegerValue(m_ver); 25 | 26 | serializer.WritePropertyName(L"metrics"); 27 | serializer.BeginArrayValue(); 28 | for (auto &it : m_metrics) 29 | { 30 | serializer.WriteObjectValue(it); 31 | } 32 | serializer.EndArrayValue(); 33 | 34 | if (m_properties.size() > 0) 35 | { 36 | serializer.WritePropertyName(L"properties"); 37 | serializer.BeginDictionaryValue(); 38 | for (auto &it : m_properties) 39 | { 40 | serializer.WritePropertyName(it.first); 41 | serializer.WriteStringValue(it.second); 42 | } 43 | serializer.EndDictionaryValue(); 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /src/core/contracts/MetricData.h: -------------------------------------------------------------------------------- 1 | #ifndef METRICDATA_H 2 | #define METRICDATA_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include "DataPoint.h" 9 | #include "Domain.h" 10 | #include 11 | #include 12 | #include 13 | 14 | namespace ApplicationInsights 15 | { 16 | namespace core 17 | { 18 | class TELEMETRYCLIENT_API MetricData : public Domain 19 | { 20 | private: 21 | int m_ver; 22 | std::vector m_metrics; 23 | std::map m_properties; 24 | 25 | public: 26 | MetricData(); 27 | MetricData(std::wstring envelopeName, std::wstring dataType); 28 | virtual ~MetricData(); 29 | 30 | const int& GetVer() const { return m_ver; } 31 | void SetVer(const int& value) { m_ver = value; } 32 | 33 | const std::vector& GetMetrics() const { return m_metrics; } 34 | void SetMetrics(const std::vector& value) { m_metrics = value; } 35 | 36 | const std::map& GetProperties() const { return m_properties; } 37 | void SetProperties(const std::map& value) { m_properties = value; } 38 | 39 | virtual void Serialize(Serializer& serializer) const; 40 | }; 41 | } 42 | } 43 | #endif 44 | -------------------------------------------------------------------------------- /src/core/contracts/Operation.cpp: -------------------------------------------------------------------------------- 1 | #include "Operation.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | Operation::Operation() 6 | { 7 | } 8 | 9 | Operation::~Operation() 10 | { 11 | } 12 | 13 | void Operation::Serialize(Serializer& serializer) const 14 | { 15 | if (m_id.HasValue()) 16 | { 17 | serializer.WritePropertyName(L"ai.operation.id"); 18 | serializer.WriteStringValue(m_id.GetValue()); 19 | } 20 | 21 | if (m_name.HasValue()) 22 | { 23 | serializer.WritePropertyName(L"ai.operation.name"); 24 | serializer.WriteStringValue(m_name.GetValue()); 25 | } 26 | 27 | if (m_parentId.HasValue()) 28 | { 29 | serializer.WritePropertyName(L"ai.operation.parentId"); 30 | serializer.WriteStringValue(m_parentId.GetValue()); 31 | } 32 | 33 | if (m_rootId.HasValue()) 34 | { 35 | serializer.WritePropertyName(L"ai.operation.rootId"); 36 | serializer.WriteStringValue(m_rootId.GetValue()); 37 | } 38 | 39 | if (m_syntheticSource.HasValue()) 40 | { 41 | serializer.WritePropertyName(L"ai.operation.syntheticSource"); 42 | serializer.WriteStringValue(m_syntheticSource.GetValue()); 43 | } 44 | 45 | if (m_isSynthetic.HasValue()) 46 | { 47 | serializer.WritePropertyName(L"ai.operation.isSynthetic"); 48 | serializer.WriteStringValue(m_isSynthetic.GetValue()); 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/core/contracts/Operation.h: -------------------------------------------------------------------------------- 1 | #ifndef OPERATION_H 2 | #define OPERATION_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include 9 | #include 10 | #include 11 | 12 | namespace ApplicationInsights 13 | { 14 | namespace core 15 | { 16 | class TELEMETRYCLIENT_API Operation : public ISerializable 17 | { 18 | private: 19 | Nullable m_id; 20 | Nullable m_name; 21 | Nullable m_parentId; 22 | Nullable m_rootId; 23 | Nullable m_syntheticSource; 24 | Nullable m_isSynthetic; 25 | 26 | public: 27 | Operation(); 28 | virtual ~Operation(); 29 | 30 | const Nullable& GetId() const { return m_id; } 31 | void SetId(const Nullable& value) { m_id = value; } 32 | 33 | const Nullable& GetName() const { return m_name; } 34 | void SetName(const Nullable& value) { m_name = value; } 35 | 36 | const Nullable& GetParentId() const { return m_parentId; } 37 | void SetParentId(const Nullable& value) { m_parentId = value; } 38 | 39 | const Nullable& GetRootId() const { return m_rootId; } 40 | void SetRootId(const Nullable& value) { m_rootId = value; } 41 | 42 | const Nullable& GetSyntheticSource() const { return m_syntheticSource; } 43 | void SetSyntheticSource(const Nullable& value) { m_syntheticSource = value; } 44 | 45 | const Nullable& GetIsSynthetic() const { return m_isSynthetic; } 46 | void SetIsSynthetic(const Nullable& value) { m_isSynthetic = value; } 47 | 48 | virtual void Serialize(Serializer& serializer) const; 49 | }; 50 | } 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /src/core/contracts/PageViewData.cpp: -------------------------------------------------------------------------------- 1 | #include "PageViewData.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | PageViewData::PageViewData() : 6 | PageViewData(L"Microsoft.ApplicationInsights.PageView", L"PageViewData") 7 | { 8 | } 9 | 10 | PageViewData::PageViewData(std::wstring envelopeName, std::wstring baseType) : 11 | EventData(envelopeName, baseType) 12 | { 13 | } 14 | 15 | PageViewData::~PageViewData() 16 | { 17 | } 18 | 19 | void PageViewData::Serialize(Serializer& serializer) const 20 | { 21 | EventData::Serialize(serializer); 22 | if (!m_url.empty()) 23 | { 24 | serializer.WritePropertyName(L"url"); 25 | serializer.WriteStringValue(m_url); 26 | } 27 | 28 | if (!m_duration.empty()) 29 | { 30 | serializer.WritePropertyName(L"duration"); 31 | serializer.WriteStringValue(m_duration); 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /src/core/contracts/PageViewData.h: -------------------------------------------------------------------------------- 1 | #ifndef PAGEVIEWDATA_H 2 | #define PAGEVIEWDATA_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include "EventData.h" 9 | #include 10 | #include 11 | #include 12 | 13 | namespace ApplicationInsights 14 | { 15 | namespace core 16 | { 17 | class TELEMETRYCLIENT_API PageViewData : public EventData 18 | { 19 | private: 20 | std::wstring m_url; 21 | std::wstring m_duration; 22 | 23 | public: 24 | PageViewData(); 25 | PageViewData(std::wstring envelopeName, std::wstring dataType); 26 | virtual ~PageViewData(); 27 | 28 | const std::wstring& GetUrl() const { return m_url; } 29 | void SetUrl(const std::wstring& value) { m_url = value; } 30 | 31 | const std::wstring& GetDuration() const { return m_duration; } 32 | void SetDuration(const std::wstring& value) { m_duration = value; } 33 | 34 | virtual void Serialize(Serializer& serializer) const; 35 | }; 36 | } 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /src/core/contracts/PageViewPerfData.cpp: -------------------------------------------------------------------------------- 1 | #include "PageViewPerfData.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | PageViewPerfData::PageViewPerfData() : 6 | PageViewPerfData(L"Microsoft.ApplicationInsights.PageViewPerf", L"PageViewPerfData") 7 | { 8 | } 9 | 10 | PageViewPerfData::PageViewPerfData(std::wstring envelopeName, std::wstring baseType) : 11 | PageViewData(envelopeName, baseType) 12 | { 13 | } 14 | 15 | PageViewPerfData::~PageViewPerfData() 16 | { 17 | } 18 | 19 | void PageViewPerfData::Serialize(Serializer& serializer) const 20 | { 21 | PageViewData::Serialize(serializer); 22 | if (!m_perfTotal.empty()) 23 | { 24 | serializer.WritePropertyName(L"perfTotal"); 25 | serializer.WriteStringValue(m_perfTotal); 26 | } 27 | 28 | if (!m_networkConnect.empty()) 29 | { 30 | serializer.WritePropertyName(L"networkConnect"); 31 | serializer.WriteStringValue(m_networkConnect); 32 | } 33 | 34 | if (!m_sentRequest.empty()) 35 | { 36 | serializer.WritePropertyName(L"sentRequest"); 37 | serializer.WriteStringValue(m_sentRequest); 38 | } 39 | 40 | if (!m_receivedResponse.empty()) 41 | { 42 | serializer.WritePropertyName(L"receivedResponse"); 43 | serializer.WriteStringValue(m_receivedResponse); 44 | } 45 | 46 | if (!m_domProcessing.empty()) 47 | { 48 | serializer.WritePropertyName(L"domProcessing"); 49 | serializer.WriteStringValue(m_domProcessing); 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /src/core/contracts/PageViewPerfData.h: -------------------------------------------------------------------------------- 1 | #ifndef PAGEVIEWPERFDATA_H 2 | #define PAGEVIEWPERFDATA_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include "PageViewData.h" 9 | #include 10 | #include 11 | #include 12 | 13 | namespace ApplicationInsights 14 | { 15 | namespace core 16 | { 17 | class TELEMETRYCLIENT_API PageViewPerfData : public PageViewData 18 | { 19 | private: 20 | std::wstring m_perfTotal; 21 | std::wstring m_networkConnect; 22 | std::wstring m_sentRequest; 23 | std::wstring m_receivedResponse; 24 | std::wstring m_domProcessing; 25 | 26 | public: 27 | PageViewPerfData(); 28 | PageViewPerfData(std::wstring envelopeName, std::wstring dataType); 29 | virtual ~PageViewPerfData(); 30 | 31 | const std::wstring& GetPerfTotal() const { return m_perfTotal; } 32 | void SetPerfTotal(const std::wstring& value) { m_perfTotal = value; } 33 | 34 | const std::wstring& GetNetworkConnect() const { return m_networkConnect; } 35 | void SetNetworkConnect(const std::wstring& value) { m_networkConnect = value; } 36 | 37 | const std::wstring& GetSentRequest() const { return m_sentRequest; } 38 | void SetSentRequest(const std::wstring& value) { m_sentRequest = value; } 39 | 40 | const std::wstring& GetReceivedResponse() const { return m_receivedResponse; } 41 | void SetReceivedResponse(const std::wstring& value) { m_receivedResponse = value; } 42 | 43 | const std::wstring& GetDomProcessing() const { return m_domProcessing; } 44 | void SetDomProcessing(const std::wstring& value) { m_domProcessing = value; } 45 | 46 | virtual void Serialize(Serializer& serializer) const; 47 | }; 48 | } 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /src/core/contracts/RemoteDependencyData.cpp: -------------------------------------------------------------------------------- 1 | #include "RemoteDependencyData.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | RemoteDependencyData::RemoteDependencyData() : 6 | RemoteDependencyData(L"Microsoft.ApplicationInsights.RemoteDependency", L"RemoteDependencyData") 7 | { 8 | } 9 | 10 | RemoteDependencyData::RemoteDependencyData(std::wstring envelopeName, std::wstring baseType) : 11 | Domain(envelopeName, baseType), 12 | m_ver(2), 13 | m_kind(Measurement), 14 | m_dependencyKind(Other), 15 | m_success(true), 16 | m_dependencySource(Undefined) 17 | { 18 | } 19 | 20 | RemoteDependencyData::~RemoteDependencyData() 21 | { 22 | } 23 | 24 | void RemoteDependencyData::Serialize(Serializer& serializer) const 25 | { 26 | Domain::Serialize(serializer); 27 | serializer.WritePropertyName(L"ver"); 28 | serializer.WriteIntegerValue(m_ver); 29 | 30 | serializer.WritePropertyName(L"name"); 31 | serializer.WriteStringValue(m_name); 32 | 33 | serializer.WritePropertyName(L"kind"); 34 | serializer.WriteIntegerValue(m_kind); 35 | 36 | serializer.WritePropertyName(L"value"); 37 | serializer.WriteDoubleValue(m_value); 38 | 39 | if (m_count.HasValue()) 40 | { 41 | serializer.WritePropertyName(L"count"); 42 | serializer.WriteIntegerValue(m_count.GetValue()); 43 | } 44 | 45 | if (m_min.HasValue()) 46 | { 47 | serializer.WritePropertyName(L"min"); 48 | serializer.WriteDoubleValue(m_min.GetValue()); 49 | } 50 | 51 | if (m_max.HasValue()) 52 | { 53 | serializer.WritePropertyName(L"max"); 54 | serializer.WriteDoubleValue(m_max.GetValue()); 55 | } 56 | 57 | if (m_stdDev.HasValue()) 58 | { 59 | serializer.WritePropertyName(L"stdDev"); 60 | serializer.WriteDoubleValue(m_stdDev.GetValue()); 61 | } 62 | 63 | serializer.WritePropertyName(L"dependencyKind"); 64 | serializer.WriteIntegerValue(m_dependencyKind); 65 | 66 | if (m_success.HasValue()) 67 | { 68 | serializer.WritePropertyName(L"success"); 69 | serializer.WriteBoolValue(m_success.GetValue()); 70 | } 71 | 72 | if (m_async.HasValue()) 73 | { 74 | serializer.WritePropertyName(L"async"); 75 | serializer.WriteBoolValue(m_async.GetValue()); 76 | } 77 | 78 | serializer.WritePropertyName(L"dependencySource"); 79 | serializer.WriteIntegerValue(m_dependencySource); 80 | 81 | if (!m_commandName.empty()) 82 | { 83 | serializer.WritePropertyName(L"commandName"); 84 | serializer.WriteStringValue(m_commandName); 85 | } 86 | 87 | if (!m_dependencyTypeName.empty()) 88 | { 89 | serializer.WritePropertyName(L"dependencyTypeName"); 90 | serializer.WriteStringValue(m_dependencyTypeName); 91 | } 92 | 93 | if (m_properties.size() > 0) 94 | { 95 | serializer.WritePropertyName(L"properties"); 96 | serializer.BeginDictionaryValue(); 97 | for (auto &it : m_properties) 98 | { 99 | serializer.WritePropertyName(it.first); 100 | serializer.WriteStringValue(it.second); 101 | } 102 | serializer.EndDictionaryValue(); 103 | } 104 | } 105 | 106 | -------------------------------------------------------------------------------- /src/core/contracts/RemoteDependencyData.h: -------------------------------------------------------------------------------- 1 | #ifndef REMOTEDEPENDENCYDATA_H 2 | #define REMOTEDEPENDENCYDATA_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include "PageViewData.h" 9 | #include "DependencySourceType.h" 10 | #include "DependencyKind.h" 11 | #include "DataPointType.h" 12 | #include 13 | #include 14 | #include 15 | 16 | namespace ApplicationInsights 17 | { 18 | namespace core 19 | { 20 | class TELEMETRYCLIENT_API RemoteDependencyData : public Domain 21 | { 22 | private: 23 | int m_ver; 24 | std::wstring m_name; 25 | DataPointType m_kind; 26 | double m_value; 27 | Nullable m_count; 28 | Nullable m_min; 29 | Nullable m_max; 30 | Nullable m_stdDev; 31 | DependencyKind m_dependencyKind; 32 | Nullable m_success; 33 | Nullable m_async; 34 | DependencySourceType m_dependencySource; 35 | std::wstring m_commandName; 36 | std::wstring m_dependencyTypeName; 37 | std::map m_properties; 38 | 39 | public: 40 | RemoteDependencyData(); 41 | RemoteDependencyData(std::wstring envelopeName, std::wstring dataType); 42 | virtual ~RemoteDependencyData(); 43 | 44 | const int& GetVer() const { return m_ver; } 45 | void SetVer(const int& value) { m_ver = value; } 46 | 47 | const std::wstring& GetName() const { return m_name; } 48 | void SetName(const std::wstring& value) { m_name = value; } 49 | 50 | const DataPointType& GetKind() const { return m_kind; } 51 | void SetKind(const DataPointType& value) { m_kind = value; } 52 | 53 | const double& GetValue() const { return m_value; } 54 | void SetValue(const double& value) { m_value = value; } 55 | 56 | const Nullable& GetCount() const { return m_count; } 57 | void SetCount(const Nullable& value) { m_count = value; } 58 | 59 | const Nullable& GetMin() const { return m_min; } 60 | void SetMin(const Nullable& value) { m_min = value; } 61 | 62 | const Nullable& GetMax() const { return m_max; } 63 | void SetMax(const Nullable& value) { m_max = value; } 64 | 65 | const Nullable& GetStdDev() const { return m_stdDev; } 66 | void SetStdDev(const Nullable& value) { m_stdDev = value; } 67 | 68 | const DependencyKind& GetDependencyKind() const { return m_dependencyKind; } 69 | void SetDependencyKind(const DependencyKind& value) { m_dependencyKind = value; } 70 | 71 | const Nullable& GetSuccess() const { return m_success; } 72 | void SetSuccess(const Nullable& value) { m_success = value; } 73 | 74 | const Nullable& GetAsync() const { return m_async; } 75 | void SetAsync(const Nullable& value) { m_async = value; } 76 | 77 | const DependencySourceType& GetDependencySource() const { return m_dependencySource; } 78 | void SetDependencySource(const DependencySourceType& value) { m_dependencySource = value; } 79 | 80 | const std::wstring& GetCommandName() const { return m_commandName; } 81 | void SetCommandName(const std::wstring& value) { m_commandName = value; } 82 | 83 | const std::wstring& GetDependencyTypeName() const { return m_dependencyTypeName; } 84 | void SetDependencyTypeName(const std::wstring& value) { m_dependencyTypeName = value; } 85 | 86 | const std::map& GetProperties() const { return m_properties; } 87 | void SetProperties(const std::map& value) { m_properties = value; } 88 | 89 | virtual void Serialize(Serializer& serializer) const; 90 | }; 91 | } 92 | } 93 | #endif 94 | -------------------------------------------------------------------------------- /src/core/contracts/RequestData.cpp: -------------------------------------------------------------------------------- 1 | #include "RequestData.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | RequestData::RequestData() : 6 | RequestData(L"Microsoft.ApplicationInsights.Request", L"RequestData") 7 | { 8 | } 9 | 10 | RequestData::RequestData(std::wstring envelopeName, std::wstring baseType) : 11 | Domain(envelopeName, baseType), 12 | m_ver(2) 13 | { 14 | } 15 | 16 | RequestData::~RequestData() 17 | { 18 | } 19 | 20 | void RequestData::Serialize(Serializer& serializer) const 21 | { 22 | Domain::Serialize(serializer); 23 | serializer.WritePropertyName(L"ver"); 24 | serializer.WriteIntegerValue(m_ver); 25 | 26 | serializer.WritePropertyName(L"id"); 27 | serializer.WriteStringValue(m_id); 28 | 29 | if (!m_name.empty()) 30 | { 31 | serializer.WritePropertyName(L"name"); 32 | serializer.WriteStringValue(m_name); 33 | } 34 | 35 | serializer.WritePropertyName(L"startTime"); 36 | serializer.WriteStringValue(m_startTime); 37 | 38 | serializer.WritePropertyName(L"duration"); 39 | serializer.WriteStringValue(m_duration); 40 | 41 | serializer.WritePropertyName(L"responseCode"); 42 | serializer.WriteStringValue(m_responseCode); 43 | 44 | serializer.WritePropertyName(L"success"); 45 | serializer.WriteBoolValue(m_success); 46 | 47 | if (!m_httpMethod.empty()) 48 | { 49 | serializer.WritePropertyName(L"httpMethod"); 50 | serializer.WriteStringValue(m_httpMethod); 51 | } 52 | 53 | if (!m_url.empty()) 54 | { 55 | serializer.WritePropertyName(L"url"); 56 | serializer.WriteStringValue(m_url); 57 | } 58 | 59 | if (m_properties.size() > 0) 60 | { 61 | serializer.WritePropertyName(L"properties"); 62 | serializer.BeginDictionaryValue(); 63 | for (auto &it : m_properties) 64 | { 65 | serializer.WritePropertyName(it.first); 66 | serializer.WriteStringValue(it.second); 67 | } 68 | serializer.EndDictionaryValue(); 69 | } 70 | 71 | if (m_measurements.size() > 0) 72 | { 73 | serializer.WritePropertyName(L"measurements"); 74 | serializer.BeginDictionaryValue(); 75 | for (auto &it : m_measurements) 76 | { 77 | serializer.WritePropertyName(it.first); 78 | serializer.WriteDoubleValue(it.second); 79 | } 80 | serializer.EndDictionaryValue(); 81 | } 82 | } 83 | 84 | -------------------------------------------------------------------------------- /src/core/contracts/RequestData.h: -------------------------------------------------------------------------------- 1 | #ifndef REQUESTDATA_H 2 | #define REQUESTDATA_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include "Domain.h" 9 | #include 10 | #include 11 | #include 12 | 13 | namespace ApplicationInsights 14 | { 15 | namespace core 16 | { 17 | class TELEMETRYCLIENT_API RequestData : public Domain 18 | { 19 | private: 20 | int m_ver; 21 | std::wstring m_id; 22 | std::wstring m_name; 23 | std::wstring m_startTime; 24 | std::wstring m_duration; 25 | std::wstring m_responseCode; 26 | bool m_success; 27 | std::wstring m_httpMethod; 28 | std::wstring m_url; 29 | std::map m_properties; 30 | std::map m_measurements; 31 | 32 | public: 33 | RequestData(); 34 | RequestData(std::wstring envelopeName, std::wstring dataType); 35 | virtual ~RequestData(); 36 | 37 | const int& GetVer() const { return m_ver; } 38 | void SetVer(const int& value) { m_ver = value; } 39 | 40 | const std::wstring& GetId() const { return m_id; } 41 | void SetId(const std::wstring& value) { m_id = value; } 42 | 43 | const std::wstring& GetName() const { return m_name; } 44 | void SetName(const std::wstring& value) { m_name = value; } 45 | 46 | const std::wstring& GetStartTime() const { return m_startTime; } 47 | void SetStartTime(const std::wstring& value) { m_startTime = value; } 48 | 49 | const std::wstring& GetDuration() const { return m_duration; } 50 | void SetDuration(const std::wstring& value) { m_duration = value; } 51 | 52 | const std::wstring& GetResponseCode() const { return m_responseCode; } 53 | void SetResponseCode(const std::wstring& value) { m_responseCode = value; } 54 | 55 | const bool& GetSuccess() const { return m_success; } 56 | void SetSuccess(const bool& value) { m_success = value; } 57 | 58 | const std::wstring& GetHttpMethod() const { return m_httpMethod; } 59 | void SetHttpMethod(const std::wstring& value) { m_httpMethod = value; } 60 | 61 | const std::wstring& GetUrl() const { return m_url; } 62 | void SetUrl(const std::wstring& value) { m_url = value; } 63 | 64 | const std::map& GetProperties() const { return m_properties; } 65 | void SetProperties(const std::map& value) { m_properties = value; } 66 | 67 | const std::map& GetMeasurements() const { return m_measurements; } 68 | void SetMeasurements(const std::map& value) { m_measurements = value; } 69 | 70 | virtual void Serialize(Serializer& serializer) const; 71 | }; 72 | } 73 | } 74 | #endif 75 | -------------------------------------------------------------------------------- /src/core/contracts/Session.h: -------------------------------------------------------------------------------- 1 | #ifndef SESSION_H 2 | #define SESSION_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include 9 | #include 10 | #include 11 | 12 | namespace ApplicationInsights 13 | { 14 | namespace core 15 | { 16 | class TELEMETRYCLIENT_API Session : public ISerializable 17 | { 18 | private: 19 | Nullable m_id; 20 | Nullable m_isFirst; 21 | Nullable m_isNew; 22 | 23 | public: 24 | Session(); 25 | virtual ~Session(); 26 | 27 | const Nullable& GetId(); 28 | void SetId(const Nullable& value); 29 | 30 | const Nullable& GetIsFirst(); 31 | void SetIsFirst(const Nullable& value); 32 | 33 | const Nullable& GetIsNew(); 34 | void SetIsNew(const Nullable& value); 35 | 36 | virtual void Serialize(Serializer& serializer) const; 37 | }; 38 | } 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /src/core/contracts/SessionState.h: -------------------------------------------------------------------------------- 1 | #ifndef SESSIONSTATE_H 2 | #define SESSIONSTATE_H 3 | 4 | namespace ApplicationInsights 5 | { 6 | namespace core 7 | { 8 | enum SessionState 9 | { 10 | Start = 0, 11 | End = 1, 12 | }; 13 | } 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /src/core/contracts/SessionStateData.cpp: -------------------------------------------------------------------------------- 1 | #include "SessionStateData.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | SessionStateData::SessionStateData() : 6 | SessionStateData(L"Microsoft.ApplicationInsights.SessionState", L"SessionStateData") 7 | { 8 | } 9 | 10 | SessionStateData::SessionStateData(std::wstring envelopeName, std::wstring baseType) : 11 | Domain(envelopeName, baseType), 12 | m_ver(2), 13 | m_state(Start) 14 | { 15 | } 16 | 17 | SessionStateData::~SessionStateData() 18 | { 19 | } 20 | 21 | void SessionStateData::Serialize(Serializer& serializer) const 22 | { 23 | Domain::Serialize(serializer); 24 | serializer.WritePropertyName(L"ver"); 25 | serializer.WriteIntegerValue(m_ver); 26 | 27 | serializer.WritePropertyName(L"state"); 28 | serializer.WriteIntegerValue(m_state); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /src/core/contracts/SessionStateData.h: -------------------------------------------------------------------------------- 1 | #ifndef SESSIONSTATEDATA_H 2 | #define SESSIONSTATEDATA_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include "Domain.h" 9 | #include "SessionState.h" 10 | #include 11 | #include 12 | #include 13 | 14 | namespace ApplicationInsights 15 | { 16 | namespace core 17 | { 18 | class TELEMETRYCLIENT_API SessionStateData : public Domain 19 | { 20 | private: 21 | int m_ver; 22 | SessionState m_state; 23 | 24 | public: 25 | SessionStateData(); 26 | SessionStateData(std::wstring envelopeName, std::wstring dataType); 27 | virtual ~SessionStateData(); 28 | 29 | const int& GetVer() const { return m_ver; } 30 | void SetVer(const int& value) { m_ver = value; } 31 | 32 | const SessionState& GetState() const { return m_state; } 33 | void SetState(const SessionState& value) { m_state = value; } 34 | 35 | virtual void Serialize(Serializer& serializer) const; 36 | }; 37 | } 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /src/core/contracts/SeverityLevel.h: -------------------------------------------------------------------------------- 1 | #ifndef SEVERITYLEVEL_H 2 | #define SEVERITYLEVEL_H 3 | 4 | namespace ApplicationInsights 5 | { 6 | namespace core 7 | { 8 | enum SeverityLevel 9 | { 10 | Verbose = 0, 11 | Information = 1, 12 | Warning = 2, 13 | Error = 3, 14 | Critical = 4, 15 | }; 16 | } 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /src/core/contracts/StackFrame.cpp: -------------------------------------------------------------------------------- 1 | #include "StackFrame.h" 2 | 3 | using namespace ApplicationInsights::core; 4 | 5 | StackFrame::StackFrame() 6 | { 7 | } 8 | 9 | StackFrame::~StackFrame() 10 | { 11 | } 12 | 13 | void StackFrame::Serialize(Serializer& serializer) const 14 | { 15 | serializer.WritePropertyName(L"level"); 16 | serializer.WriteIntegerValue(m_level); 17 | 18 | serializer.WritePropertyName(L"method"); 19 | serializer.WriteStringValue(m_method); 20 | 21 | if (!m_assembly.empty()) 22 | { 23 | serializer.WritePropertyName(L"assembly"); 24 | serializer.WriteStringValue(m_assembly); 25 | } 26 | 27 | if (!m_fileName.empty()) 28 | { 29 | serializer.WritePropertyName(L"fileName"); 30 | serializer.WriteStringValue(m_fileName); 31 | } 32 | 33 | serializer.WritePropertyName(L"line"); 34 | serializer.WriteIntegerValue(m_line); 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/core/contracts/StackFrame.h: -------------------------------------------------------------------------------- 1 | #ifndef STACKFRAME_H 2 | #define STACKFRAME_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include 9 | #include 10 | #include 11 | 12 | namespace ApplicationInsights 13 | { 14 | namespace core 15 | { 16 | class TELEMETRYCLIENT_API StackFrame : public ISerializable 17 | { 18 | private: 19 | int m_level; 20 | std::wstring m_method; 21 | std::wstring m_assembly; 22 | std::wstring m_fileName; 23 | int m_line; 24 | 25 | public: 26 | StackFrame(); 27 | virtual ~StackFrame(); 28 | 29 | const int& GetLevel() const { return m_level; } 30 | void SetLevel(const int& value) { m_level = value; } 31 | 32 | const std::wstring& GetMethod() const { return m_method; } 33 | void SetMethod(const std::wstring& value) { m_method = value; } 34 | 35 | const std::wstring& GetAssembly() const { return m_assembly; } 36 | void SetAssembly(const std::wstring& value) { m_assembly = value; } 37 | 38 | const std::wstring& GetFileName() const { return m_fileName; } 39 | void SetFileName(const std::wstring& value) { m_fileName = value; } 40 | 41 | const int& GetLine() const { return m_line; } 42 | void SetLine(const int& value) { m_line = value; } 43 | 44 | virtual void Serialize(Serializer& serializer) const; 45 | }; 46 | } 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /src/core/contracts/User.h: -------------------------------------------------------------------------------- 1 | #ifndef USER_H 2 | #define USER_H 3 | 4 | #include "../common/Common.h" 5 | #include "../common/JsonWriter.h" 6 | #include "../common/Nullable.h" 7 | #include "../common/Serializer.h" 8 | #include 9 | #include 10 | #include 11 | 12 | namespace ApplicationInsights 13 | { 14 | namespace core 15 | { 16 | class TELEMETRYCLIENT_API User : public ISerializable 17 | { 18 | private: 19 | Nullable m_accountAcquisitionDate; 20 | Nullable m_accountId; 21 | Nullable m_userAgent; 22 | Nullable m_id; 23 | Nullable m_storeRegion; 24 | 25 | public: 26 | User(); 27 | virtual ~User(); 28 | 29 | const Nullable& GetAccountAcquisitionDate(); 30 | void SetAccountAcquisitionDate(const Nullable& value); 31 | 32 | const Nullable& GetAccountId(); 33 | void SetAccountId(const Nullable& value); 34 | 35 | const Nullable& GetUserAgent(); 36 | void SetUserAgent(const Nullable& value); 37 | 38 | const Nullable& GetId(); 39 | void SetId(const Nullable& value); 40 | 41 | const Nullable& GetStoreRegion(); 42 | void SetStoreRegion(const Nullable& value); 43 | 44 | virtual void Serialize(Serializer& serializer) const; 45 | }; 46 | } 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /test/core/ApplicationInsights/TestContext.cpp: -------------------------------------------------------------------------------- 1 | #include "../targetver.h" 2 | #include "../specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "TelemetryClient.h" 5 | #include "Contracts/Session.h" 6 | 7 | 8 | using namespace ApplicationInsights::CX; 9 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 10 | using namespace Platform; 11 | using namespace Windows::ApplicationModel; 12 | using namespace Windows::Foundation; 13 | using namespace Windows::Storage; 14 | using namespace Windows::UI::Xaml; 15 | using namespace Windows::UI::Xaml::Controls; 16 | 17 | namespace core { 18 | namespace tests 19 | { 20 | namespace ApplicationInsights 21 | { 22 | TEST_CLASS(TestContext) 23 | { 24 | public: 25 | TEST_METHOD(SessionContextWorksAsExpected) 26 | { 27 | Session item; 28 | Nullable expectedId(L"loQoJqjW"); 29 | Nullable expectedIsFirst(L"XoyYwPiz"); 30 | Nullable expectedIsNew(L"zFBXDCpK"); 31 | 32 | item.SetId(expectedId); 33 | item.SetIsFirst(expectedIsFirst); 34 | item.SetIsNew(expectedIsNew); 35 | 36 | Session item2; 37 | Assert::AreEqual(expectedId, item2.GetId(), L"Session ids don't match"); 38 | Assert::AreEqual(expectedIsFirst, item2.GetIsFirst(), L"Session isFirsts don't match"); 39 | Assert::AreEqual(expectedIsNew, item2.GetIsNew(), L"Session isNews don't match"); 40 | }; 41 | 42 | TEST_METHOD(UserContextWorksAsExpected) 43 | { 44 | User item; 45 | Nullable accountAcquisitionDate(L"kQRXjtex"); 46 | Nullable accountId(L"KvBXxURr"); 47 | Nullable userAgent(L"WSOZIoCZ"); 48 | Nullable id(L"yqjDGfyE"); 49 | Nullable storeRegion(L"bCyqrnEO"); 50 | 51 | item.SetAccountAcquisitionDate(accountAcquisitionDate); 52 | item.SetAccountId(accountId); 53 | item.SetUserAgent(userAgent); 54 | item.SetId(id); 55 | item.SetStoreRegion(storeRegion); 56 | 57 | User item2; 58 | Assert::AreEqual(accountAcquisitionDate, item2.GetAccountAcquisitionDate(), L"User acquisition dates don't match"); 59 | Assert::AreEqual(accountId, item2.GetAccountId(), L"User account ids don't match"); 60 | Assert::AreEqual(userAgent, item2.GetUserAgent(), L"User agents don't match"); 61 | Assert::AreEqual(id, item2.GetId(), L"User ids don't match"); 62 | Assert::AreEqual(storeRegion, item2.GetStoreRegion(), L"User store regions don't match"); 63 | }; 64 | }; 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /test/core/ApplicationInsights/TestPageTracking.cpp: -------------------------------------------------------------------------------- 1 | #include "../targetver.h" 2 | #include "../specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "TelemetryClient.h" 5 | 6 | 7 | using namespace ApplicationInsights::CX; 8 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 9 | using namespace Platform; 10 | using namespace Windows::ApplicationModel; 11 | using namespace Windows::Foundation; 12 | using namespace Windows::Storage; 13 | using namespace Windows::UI::Xaml; 14 | using namespace Windows::UI::Xaml::Controls; 15 | 16 | namespace core { 17 | namespace tests 18 | { 19 | namespace ApplicationInsights 20 | { 21 | TEST_CLASS(TestPageTracking) 22 | { 23 | public: 24 | 25 | TEST_METHOD(CtorWorksAsExpected) 26 | { 27 | PageTracking ^session = ref new PageTracking(); 28 | }; 29 | 30 | TEST_METHOD(InitializeWorksAsExpected) 31 | { 32 | String^ iKey = L"IKEYSTRING"; 33 | PageTracking ^page = ref new PageTracking(); 34 | page->Initialize(nullptr, iKey); 35 | }; 36 | 37 | TEST_METHOD(InitializeWorksWithNullsAsExpected) 38 | { 39 | PageTracking ^page = ref new PageTracking(); 40 | page->Initialize(nullptr, nullptr); 41 | }; 42 | 43 | TEST_METHOD(NavigatingWorksAsExpected) 44 | { 45 | String^ iKey = L"IKEYSTRING"; 46 | PageTracking ^page = ref new PageTracking(); 47 | page->Initialize(nullptr, iKey); 48 | 49 | Windows::Globalization::Calendar^ beforeCal = ref new Windows::Globalization::Calendar(); 50 | Windows::Foundation::DateTime before = beforeCal->GetDateTime(); 51 | 52 | page->OnNavigating(nullptr, nullptr); 53 | 54 | Windows::Globalization::Calendar^ afterCal = ref new Windows::Globalization::Calendar(); 55 | Windows::Foundation::DateTime after = afterCal->GetDateTime(); 56 | 57 | ApplicationDataContainer^ localSettings = ApplicationData::Current->LocalSettings; 58 | ApplicationDataContainer^ container = localSettings->CreateContainer("AppInsights", ApplicationDataCreateDisposition::Always); 59 | auto values = localSettings->Containers->Lookup("AppInsights")->Values; 60 | 61 | DateTime startPageLoad; 62 | if (values->HasKey("StartPageLoad")) 63 | { 64 | startPageLoad = (DateTime)values->Lookup("StartPageLoad"); 65 | } 66 | else 67 | { 68 | Assert::IsTrue(false, L"Failed to get start of page load time"); 69 | } 70 | 71 | Assert::IsTrue(startPageLoad.UniversalTime > before.UniversalTime); 72 | Assert::IsTrue(startPageLoad.UniversalTime < after.UniversalTime); 73 | }; 74 | 75 | TEST_METHOD(NavigatedWorksAsExpected) 76 | { 77 | String^ iKey = L"IKEYSTRING"; 78 | PageTracking ^page = ref new PageTracking(); 79 | page->Initialize(nullptr, iKey); 80 | 81 | page->OnNavigating(nullptr, nullptr); 82 | 83 | page->OnNavigated(nullptr, nullptr); 84 | 85 | ApplicationDataContainer^ localSettings = ApplicationData::Current->LocalSettings; 86 | ApplicationDataContainer^ container = localSettings->CreateContainer("AppInsights", ApplicationDataCreateDisposition::Always); 87 | auto values = localSettings->Containers->Lookup("AppInsights")->Values; 88 | 89 | Assert::IsFalse(values->HasKey("StartPageLoad")); 90 | }; 91 | }; 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /test/core/ApplicationInsights/TestSessionTracking.cpp: -------------------------------------------------------------------------------- 1 | #include "../targetver.h" 2 | #include "../specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "TelemetryClient.h" 5 | 6 | using namespace ApplicationInsights::CX; 7 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 8 | using namespace Platform; 9 | using namespace Windows::ApplicationModel; 10 | using namespace Windows::Foundation; 11 | using namespace Windows::Storage; 12 | 13 | namespace core { 14 | namespace tests 15 | { 16 | namespace ApplicationInsights 17 | { 18 | TEST_CLASS(TestSessionTracking) 19 | { 20 | public: 21 | 22 | TEST_METHOD(CtorWorksAsExpected) 23 | { 24 | SessionTracking ^session = ref new SessionTracking(); 25 | }; 26 | 27 | TEST_METHOD(InitializeWorksAsExpected) 28 | { 29 | String^ iKey = L"IKEYSTRING"; 30 | SessionTracking ^session = ref new SessionTracking(); 31 | session->Initialize(nullptr, nullptr, iKey); 32 | }; 33 | 34 | TEST_METHOD(InitializeWorksWithNullsAsExpected) 35 | { 36 | SessionTracking ^session = ref new SessionTracking(); 37 | session->Initialize(nullptr, nullptr, nullptr); 38 | }; 39 | 40 | TEST_METHOD(SuspendWorksAsExpected) 41 | { 42 | String^ iKey = L"IKEYSTRING"; 43 | String^ object = L"OBJECT"; 44 | SessionTracking ^session = ref new SessionTracking(); 45 | session->Initialize(nullptr, nullptr, iKey); 46 | 47 | Windows::Globalization::Calendar^ beforeCal = ref new Windows::Globalization::Calendar(); 48 | Windows::Foundation::DateTime before = beforeCal->GetDateTime(); 49 | 50 | session->OnSuspending(object, nullptr); 51 | 52 | Windows::Globalization::Calendar^ afterCal = ref new Windows::Globalization::Calendar(); 53 | Windows::Foundation::DateTime after = afterCal->GetDateTime(); 54 | 55 | ApplicationDataContainer^ localSettings = ApplicationData::Current->LocalSettings; 56 | ApplicationDataContainer^ container = localSettings->CreateContainer("AppInsights", ApplicationDataCreateDisposition::Always); 57 | auto values = localSettings->Containers->Lookup("AppInsights")->Values; 58 | 59 | DateTime lastBackground; 60 | if (values->HasKey("lastBackground")) 61 | { 62 | lastBackground = (DateTime)values->Lookup("lastBackground"); 63 | } 64 | else 65 | { 66 | Assert::IsTrue(false, L"Failed to get last backgrounded time"); 67 | } 68 | 69 | Assert::IsTrue(lastBackground.UniversalTime > before.UniversalTime); 70 | Assert::IsTrue(lastBackground.UniversalTime < after.UniversalTime); 71 | }; 72 | 73 | TEST_METHOD(ResumeWithoutRenewWorksAsExpected) 74 | { 75 | String^ object = L"OBJECT"; 76 | String^ iKey = L"IKEYSTRING"; 77 | SessionTracking ^session = ref new SessionTracking(); 78 | session->Initialize(nullptr, nullptr, iKey); 79 | 80 | session->OnSuspending(object, nullptr); 81 | session->OnResume(object, object); 82 | }; 83 | 84 | /*TEST_METHOD(ResumeWithRenewWorksAsExpected) 85 | { 86 | String^ object = L"OBJECT"; 87 | String^ iKey = L"IKEYSTRING"; 88 | SessionTracking ^session = ref new SessionTracking(); 89 | session->Initialize(nullptr, iKey); 90 | 91 | session->OnSuspending(object, nullptr); 92 | Sleep(21 * 1000); 93 | session->OnResume(object, object); 94 | };*/ 95 | }; 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /test/core/TestTelemetryClient.cpp: -------------------------------------------------------------------------------- 1 | #include "targetver.h" 2 | #include "specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "TelemetryContext.h" 5 | #include "TelemetryClient.h" 6 | #include "Contracts/Contracts.h" 7 | 8 | using namespace ApplicationInsights::core; 9 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 10 | 11 | typedef std::wstring wstr; 12 | 13 | namespace core { 14 | namespace tests 15 | { 16 | namespace telemetryClient 17 | { 18 | class MockTelemetryChannel : public TelemetryChannel 19 | { 20 | public: 21 | MockTelemetryChannel(TelemetryClientConfig config) 22 | : TelemetryChannel(config), recvTelemetry(nullptr) 23 | { 24 | } 25 | 26 | std::vector GetBuffer() 27 | { 28 | return m_buffer; 29 | } 30 | 31 | private: 32 | Domain* recvTelemetry; 33 | }; 34 | 35 | class MockTelemetryClient : public TelemetryClient 36 | { 37 | public: 38 | MockTelemetryClient(std::wstring& iKey) : 39 | TelemetryClient(iKey) 40 | { 41 | } 42 | 43 | MockTelemetryChannel *GetChannel() const { return (MockTelemetryChannel*)m_channel.get(); } 44 | 45 | }; 46 | 47 | TEST_CLASS(TestTelemetryClient) 48 | { 49 | public: 50 | 51 | TEST_METHOD(GetConfigWorksAsExpected) 52 | { 53 | std::wstring iKey = L"MY IKEY"; 54 | TelemetryClient tc(iKey); 55 | TelemetryClientConfig *config = tc.GetConfig(); 56 | 57 | Assert::AreEqual(iKey, config->GetIKey()); 58 | }; 59 | 60 | TEST_METHOD(TrackEventWorksAsExpected) 61 | { 62 | std::wstring eventName = L"MY TRACK EVENT"; 63 | std::wstring iKey = L"MY_IKEY"; 64 | MockTelemetryClient tc(iKey); 65 | tc.Flush(); 66 | tc.TrackEvent(eventName); 67 | 68 | std::vector data = tc.GetChannel()->GetBuffer(); 69 | Assert::AreEqual(1, (int)data.size()); 70 | Assert::IsTrue(data[0].find(eventName) != std::string::npos, L"Unable to find track event name"); 71 | }; 72 | 73 | TEST_METHOD(DisableTrackingWorksAsExpected) 74 | { 75 | std::wstring eventName = L"MY TRACK EVENT"; 76 | std::wstring iKey = L"MY_IKEY"; 77 | MockTelemetryClient tc(iKey); 78 | tc.Flush(); 79 | tc.DisableTracking(); 80 | 81 | tc.TrackEvent(eventName); 82 | 83 | std::vector data = tc.GetChannel()->GetBuffer(); 84 | Assert::AreEqual(0, (int)data.size()); 85 | } 86 | 87 | TEST_METHOD(TogglingTrackingWorksAsExpected) 88 | { 89 | std::wstring eventName = L"MY TRACK EVENT"; 90 | std::wstring iKey = L"MY_IKEY"; 91 | MockTelemetryClient tc(iKey); 92 | tc.Flush(); 93 | tc.DisableTracking(); 94 | tc.TrackEvent(eventName); 95 | std::vector data = tc.GetChannel()->GetBuffer(); 96 | Assert::AreEqual(0, (int)data.size()); 97 | 98 | tc.EnableTracking(); 99 | tc.TrackEvent(eventName); 100 | data = tc.GetChannel()->GetBuffer(); 101 | Assert::AreEqual(1, (int)data.size()); 102 | Assert::IsTrue(data[0].find(eventName) != std::string::npos, L"Unable to find track event name"); 103 | } 104 | }; 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /test/core/TestTelemetryClientConfig.cpp: -------------------------------------------------------------------------------- 1 | #include "targetver.h" 2 | #include "specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "TelemetryClientConfig.h" 5 | 6 | using namespace ApplicationInsights::core; 7 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 8 | 9 | typedef std::wstring wstr; 10 | 11 | namespace core { 12 | namespace tests 13 | { 14 | TEST_CLASS(TestTelemetryClientConfig) 15 | { 16 | public: 17 | 18 | TEST_METHOD(CtorWorksAsExpected) 19 | { 20 | wstr expected = L"foo"; 21 | TelemetryClientConfig config(expected); 22 | Assert::AreEqual(expected, config.GetIKey()); 23 | }; 24 | 25 | TEST_METHOD(IKeyWorksAsExpected) 26 | { 27 | wstr initial = L"bar"; 28 | TelemetryClientConfig config(initial); 29 | Assert::AreEqual(initial, config.GetIKey()); 30 | 31 | wstr expected = L"foo"; 32 | config.SetIKey(expected); 33 | 34 | Assert::AreEqual(expected, config.GetIKey()); 35 | }; 36 | }; 37 | }} 38 | -------------------------------------------------------------------------------- /test/core/contracts/TestApplication.cpp: -------------------------------------------------------------------------------- 1 | #include "../targetver.h" 2 | #include "../specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "Contracts/Application.h" 5 | 6 | using namespace ApplicationInsights::core; 7 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 8 | 9 | namespace core { namespace tests { namespace contracts 10 | { 11 | TEST_CLASS(TestApplication) 12 | { 13 | public: 14 | 15 | TEST_METHOD(VerWorksAsExpected) 16 | { 17 | Application item; 18 | Nullable expected1(L"GLvyAJsZ"); 19 | 20 | item.SetVer(expected1); 21 | Nullable actual = item.GetVer(); 22 | Assert::AreEqual(expected1, actual); 23 | 24 | Nullable expected2(L"eMtJfeXF"); 25 | 26 | item.SetVer(expected2); 27 | actual = item.GetVer(); 28 | Assert::AreEqual(expected2, actual); 29 | }; 30 | 31 | TEST_METHOD(BuildWorksAsExpected) 32 | { 33 | Application item; 34 | Nullable expected1(L"GQZwnwSD"); 35 | 36 | item.SetBuild(expected1); 37 | Nullable actual = item.GetBuild(); 38 | Assert::AreEqual(expected1, actual); 39 | 40 | Nullable expected2(L"bkKvAVtR"); 41 | 42 | item.SetBuild(expected2); 43 | actual = item.GetBuild(); 44 | Assert::AreEqual(expected2, actual); 45 | }; 46 | 47 | TEST_METHOD(SerializationWorksAsExpected) 48 | { 49 | Application item; 50 | Nullable ver(L"GLvyAJsZ"); 51 | Nullable build(L"GQZwnwSD"); 52 | 53 | item.SetVer(ver); 54 | item.SetBuild(build); 55 | 56 | std::wstring expected = L"{\"ai.application.ver\":\"GLvyAJsZ\",\"ai.application.build\":\"GQZwnwSD\"}"; 57 | 58 | std::wstring actual; 59 | StringWriter writer(&actual); 60 | JsonWriter serializer(writer); 61 | serializer.WriteObjectValue(&item); 62 | 63 | Assert::AreEqual(expected, actual); 64 | } 65 | }; 66 | }}} 67 | -------------------------------------------------------------------------------- /test/core/contracts/TestBase.cpp: -------------------------------------------------------------------------------- 1 | #include "../targetver.h" 2 | #include "../specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "Contracts/Base.h" 5 | 6 | using namespace ApplicationInsights::core; 7 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 8 | 9 | namespace core { namespace tests { namespace contracts 10 | { 11 | TEST_CLASS(TestBase) 12 | { 13 | public: 14 | 15 | TEST_METHOD(BaseTypeWorksAsExpected) 16 | { 17 | Base item; 18 | std::wstring expected1 = L"DkiuYcvD"; 19 | 20 | item.SetBaseType(expected1); 21 | std::wstring actual = item.GetBaseType(); 22 | Assert::AreEqual(expected1, actual); 23 | 24 | std::wstring expected2 = L"cMlRgUYh"; 25 | 26 | item.SetBaseType(expected2); 27 | actual = item.GetBaseType(); 28 | Assert::AreEqual(expected2, actual); 29 | }; 30 | 31 | TEST_METHOD(SerializationWorksAsExpected) 32 | { 33 | Base item; 34 | std::wstring baseType = L"DkiuYcvD"; 35 | 36 | item.SetBaseType(baseType); 37 | 38 | std::wstring expected = L"{\"baseType\":\"DkiuYcvD\"}"; 39 | 40 | std::wstring actual; 41 | StringWriter writer(&actual); 42 | JsonWriter serializer(writer); 43 | serializer.WriteObjectValue(&item); 44 | 45 | Assert::AreEqual(expected, actual); 46 | } 47 | }; 48 | }}} 49 | -------------------------------------------------------------------------------- /test/core/contracts/TestCrashData.cpp: -------------------------------------------------------------------------------- 1 | #include "../targetver.h" 2 | #include "../specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "Contracts/CrashData.h" 5 | 6 | using namespace ApplicationInsights::core; 7 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 8 | 9 | namespace core { namespace tests { namespace contracts 10 | { 11 | TEST_CLASS(TestCrashData) 12 | { 13 | public: 14 | 15 | TEST_METHOD(VerWorksAsExpected) 16 | { 17 | CrashData item; 18 | int expected1 = 5; 19 | 20 | item.SetVer(expected1); 21 | int actual = item.GetVer(); 22 | Assert::AreEqual(expected1, actual); 23 | 24 | int expected2 = 63; 25 | 26 | item.SetVer(expected2); 27 | actual = item.GetVer(); 28 | Assert::AreEqual(expected2, actual); 29 | }; 30 | 31 | TEST_METHOD(HeadersWorksAsExpected) 32 | { 33 | CrashData item; 34 | CrashDataHeaders* expected1 = new CrashDataHeaders(); 35 | 36 | item.SetHeaders(expected1); 37 | CrashDataHeaders* actual = item.GetHeaders(); 38 | Assert::AreEqual(expected1, actual); 39 | 40 | CrashDataHeaders* expected2 = new CrashDataHeaders(); 41 | 42 | item.SetHeaders(expected2); 43 | actual = item.GetHeaders(); 44 | Assert::AreEqual(expected2, actual); 45 | }; 46 | 47 | TEST_METHOD(ThreadsWorksAsExpected) 48 | { 49 | CrashData item; 50 | std::vector expected1 = { }; 51 | 52 | item.SetThreads(expected1); 53 | std::vector actual = item.GetThreads(); 54 | Assert::AreEqual(expected1, actual); 55 | 56 | std::vector expected2 = { }; 57 | 58 | item.SetThreads(expected2); 59 | actual = item.GetThreads(); 60 | Assert::AreEqual(expected2, actual); 61 | }; 62 | 63 | TEST_METHOD(BinariesWorksAsExpected) 64 | { 65 | CrashData item; 66 | std::vector expected1 = { }; 67 | 68 | item.SetBinaries(expected1); 69 | std::vector actual = item.GetBinaries(); 70 | Assert::AreEqual(expected1, actual); 71 | 72 | std::vector expected2 = { }; 73 | 74 | item.SetBinaries(expected2); 75 | actual = item.GetBinaries(); 76 | Assert::AreEqual(expected2, actual); 77 | }; 78 | 79 | TEST_METHOD(SerializationWorksAsExpected) 80 | { 81 | CrashData item; 82 | int ver = 5; 83 | CrashDataHeaders* headers = new CrashDataHeaders(); 84 | std::vector threads = { }; 85 | std::vector binaries = { }; 86 | 87 | item.SetVer(ver); 88 | item.SetHeaders(headers); 89 | item.SetThreads(threads); 90 | item.SetBinaries(binaries); 91 | 92 | std::wstring expected = L"{\"ver\":5,\"headers\":{\"id\":\"\",\"processId\":0,\"parentProcessId\":0,\"crashThread\":0}}"; 93 | 94 | std::wstring actual; 95 | StringWriter writer(&actual); 96 | JsonWriter serializer(writer); 97 | serializer.WriteObjectValue(&item); 98 | 99 | Assert::AreEqual(expected, actual); 100 | } 101 | }; 102 | }}} 103 | -------------------------------------------------------------------------------- /test/core/contracts/TestCrashDataThread.cpp: -------------------------------------------------------------------------------- 1 | #include "../targetver.h" 2 | #include "../specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "Contracts/CrashDataThread.h" 5 | 6 | using namespace ApplicationInsights::core; 7 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 8 | 9 | namespace core { namespace tests { namespace contracts 10 | { 11 | TEST_CLASS(TestCrashDataThread) 12 | { 13 | public: 14 | 15 | TEST_METHOD(IdWorksAsExpected) 16 | { 17 | CrashDataThread item; 18 | int expected1 = 55; 19 | 20 | item.SetId(expected1); 21 | int actual = item.GetId(); 22 | Assert::AreEqual(expected1, actual); 23 | 24 | int expected2 = 82; 25 | 26 | item.SetId(expected2); 27 | actual = item.GetId(); 28 | Assert::AreEqual(expected2, actual); 29 | }; 30 | 31 | TEST_METHOD(FramesWorksAsExpected) 32 | { 33 | CrashDataThread item; 34 | std::vector expected1 = { }; 35 | 36 | item.SetFrames(expected1); 37 | std::vector actual = item.GetFrames(); 38 | Assert::AreEqual(expected1, actual); 39 | 40 | std::vector expected2 = { }; 41 | 42 | item.SetFrames(expected2); 43 | actual = item.GetFrames(); 44 | Assert::AreEqual(expected2, actual); 45 | }; 46 | 47 | TEST_METHOD(SerializationWorksAsExpected) 48 | { 49 | CrashDataThread item; 50 | int id = 55; 51 | std::vector frames = { }; 52 | 53 | item.SetId(id); 54 | item.SetFrames(frames); 55 | 56 | std::wstring expected = L"{\"id\":55}"; 57 | 58 | std::wstring actual; 59 | StringWriter writer(&actual); 60 | JsonWriter serializer(writer); 61 | serializer.WriteObjectValue(&item); 62 | 63 | Assert::AreEqual(expected, actual); 64 | } 65 | }; 66 | }}} 67 | -------------------------------------------------------------------------------- /test/core/contracts/TestCrashDataThreadFrame.cpp: -------------------------------------------------------------------------------- 1 | #include "../targetver.h" 2 | #include "../specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "Contracts/CrashDataThreadFrame.h" 5 | 6 | using namespace ApplicationInsights::core; 7 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 8 | 9 | namespace core { namespace tests { namespace contracts 10 | { 11 | TEST_CLASS(TestCrashDataThreadFrame) 12 | { 13 | public: 14 | 15 | TEST_METHOD(AddressWorksAsExpected) 16 | { 17 | CrashDataThreadFrame item; 18 | std::wstring expected1 = L"FZTIRgix"; 19 | 20 | item.SetAddress(expected1); 21 | std::wstring actual = item.GetAddress(); 22 | Assert::AreEqual(expected1, actual); 23 | 24 | std::wstring expected2 = L"MYWQuomQ"; 25 | 26 | item.SetAddress(expected2); 27 | actual = item.GetAddress(); 28 | Assert::AreEqual(expected2, actual); 29 | }; 30 | 31 | TEST_METHOD(SymbolWorksAsExpected) 32 | { 33 | CrashDataThreadFrame item; 34 | std::wstring expected1 = L"ZVoZDKeb"; 35 | 36 | item.SetSymbol(expected1); 37 | std::wstring actual = item.GetSymbol(); 38 | Assert::AreEqual(expected1, actual); 39 | 40 | std::wstring expected2 = L"bjirGekl"; 41 | 42 | item.SetSymbol(expected2); 43 | actual = item.GetSymbol(); 44 | Assert::AreEqual(expected2, actual); 45 | }; 46 | 47 | TEST_METHOD(RegistersWorksAsExpected) 48 | { 49 | CrashDataThreadFrame item; 50 | std::map expected1 = { { L"izdG", L"SSuLuTVh" } }; 51 | 52 | item.SetRegisters(expected1); 53 | std::map actual = item.GetRegisters(); 54 | Assert::AreEqual(expected1, actual); 55 | 56 | std::map expected2 = { { L"PFNL", L"SSuLuTVh" } }; 57 | 58 | item.SetRegisters(expected2); 59 | actual = item.GetRegisters(); 60 | Assert::AreEqual(expected2, actual); 61 | }; 62 | 63 | TEST_METHOD(SerializationWorksAsExpected) 64 | { 65 | CrashDataThreadFrame item; 66 | std::wstring address = L"FZTIRgix"; 67 | std::wstring symbol = L"ZVoZDKeb"; 68 | std::map registers = { { L"izdG", L"SSuLuTVh" } }; 69 | 70 | item.SetAddress(address); 71 | item.SetSymbol(symbol); 72 | item.SetRegisters(registers); 73 | 74 | std::wstring expected = L"{\"address\":\"FZTIRgix\",\"symbol\":\"ZVoZDKeb\",\"registers\":{\"izdG\":\"SSuLuTVh\"}}"; 75 | 76 | std::wstring actual; 77 | StringWriter writer(&actual); 78 | JsonWriter serializer(writer); 79 | serializer.WriteObjectValue(&item); 80 | 81 | Assert::AreEqual(expected, actual); 82 | } 83 | }; 84 | }}} 85 | -------------------------------------------------------------------------------- /test/core/contracts/TestDomain.cpp: -------------------------------------------------------------------------------- 1 | #include "../targetver.h" 2 | #include "../specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "Contracts/Domain.h" 5 | 6 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 7 | 8 | namespace core { namespace tests { namespace contracts 9 | { 10 | TEST_CLASS(TestDomain) 11 | { 12 | public: 13 | 14 | TEST_METHOD(SerializationWorksAsExpected) 15 | { 16 | Domain item(L"", L""); 17 | 18 | 19 | std::wstring expected = L"{}"; 20 | 21 | std::wstring actual; 22 | StringWriter writer(&actual); 23 | JsonWriter serializer(writer); 24 | serializer.WriteObjectValue(&item); 25 | 26 | Assert::AreEqual(expected, actual); 27 | } 28 | }; 29 | }}} 30 | -------------------------------------------------------------------------------- /test/core/contracts/TestEventData.cpp: -------------------------------------------------------------------------------- 1 | #include "../targetver.h" 2 | #include "../specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "Contracts/EventData.h" 5 | 6 | using namespace ApplicationInsights::core; 7 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 8 | 9 | namespace core { namespace tests { namespace contracts 10 | { 11 | TEST_CLASS(TestEventData) 12 | { 13 | public: 14 | 15 | TEST_METHOD(VerWorksAsExpected) 16 | { 17 | EventData item; 18 | int expected1 = 63; 19 | 20 | item.SetVer(expected1); 21 | int actual = item.GetVer(); 22 | Assert::AreEqual(expected1, actual); 23 | 24 | int expected2 = 21; 25 | 26 | item.SetVer(expected2); 27 | actual = item.GetVer(); 28 | Assert::AreEqual(expected2, actual); 29 | }; 30 | 31 | TEST_METHOD(NameWorksAsExpected) 32 | { 33 | EventData item; 34 | std::wstring expected1 = L"FPkYRwor"; 35 | 36 | item.SetName(expected1); 37 | std::wstring actual = item.GetName(); 38 | Assert::AreEqual(expected1, actual); 39 | 40 | std::wstring expected2 = L"mwxmSpxU"; 41 | 42 | item.SetName(expected2); 43 | actual = item.GetName(); 44 | Assert::AreEqual(expected2, actual); 45 | }; 46 | 47 | TEST_METHOD(PropertiesWorksAsExpected) 48 | { 49 | EventData item; 50 | std::map expected1 = { { L"fEUK", L"CmlXfTfm" } }; 51 | 52 | item.SetProperties(expected1); 53 | std::map actual = item.GetProperties(); 54 | Assert::AreEqual(expected1, actual); 55 | 56 | std::map expected2 = { { L"iEHE", L"CmlXfTfm" } }; 57 | 58 | item.SetProperties(expected2); 59 | actual = item.GetProperties(); 60 | Assert::AreEqual(expected2, actual); 61 | }; 62 | 63 | TEST_METHOD(MeasurementsWorksAsExpected) 64 | { 65 | EventData item; 66 | std::map expected1 = { { L"WxIM", 4.509 } }; 67 | 68 | item.SetMeasurements(expected1); 69 | std::map actual = item.GetMeasurements(); 70 | Assert::AreEqual(expected1, actual); 71 | 72 | std::map expected2 = { { L"VpiD", 4.509 } }; 73 | 74 | item.SetMeasurements(expected2); 75 | actual = item.GetMeasurements(); 76 | Assert::AreEqual(expected2, actual); 77 | }; 78 | 79 | TEST_METHOD(SerializationWorksAsExpected) 80 | { 81 | EventData item; 82 | int ver = 63; 83 | std::wstring name = L"FPkYRwor"; 84 | std::map properties = { { L"fEUK", L"CmlXfTfm" } }; 85 | std::map measurements = { { L"WxIM", 4.509 } }; 86 | 87 | item.SetVer(ver); 88 | item.SetName(name); 89 | item.SetProperties(properties); 90 | item.SetMeasurements(measurements); 91 | 92 | std::wstring expected = L"{\"ver\":63,\"name\":\"FPkYRwor\",\"properties\":{\"fEUK\":\"CmlXfTfm\"},\"measurements\":{\"WxIM\":4.509000}}"; 93 | 94 | std::wstring actual; 95 | StringWriter writer(&actual); 96 | JsonWriter serializer(writer); 97 | serializer.WriteObjectValue(&item); 98 | 99 | Assert::AreEqual(expected, actual); 100 | } 101 | }; 102 | }}} 103 | -------------------------------------------------------------------------------- /test/core/contracts/TestInternal.cpp: -------------------------------------------------------------------------------- 1 | #include "../targetver.h" 2 | #include "../specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "Contracts/Internal.h" 5 | 6 | using namespace ApplicationInsights::core; 7 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 8 | 9 | namespace core { namespace tests { namespace contracts 10 | { 11 | TEST_CLASS(TestInternal) 12 | { 13 | public: 14 | 15 | TEST_METHOD(SdkVersionWorksAsExpected) 16 | { 17 | Internal item; 18 | Nullable expected1(L"fmwchHWF"); 19 | 20 | item.SetSdkVersion(expected1); 21 | Nullable actual = item.GetSdkVersion(); 22 | Assert::AreEqual(expected1, actual); 23 | 24 | Nullable expected2(L"eqmowGLD"); 25 | 26 | item.SetSdkVersion(expected2); 27 | actual = item.GetSdkVersion(); 28 | Assert::AreEqual(expected2, actual); 29 | }; 30 | 31 | TEST_METHOD(AgentVersionWorksAsExpected) 32 | { 33 | Internal item; 34 | Nullable expected1(L"eMUeMREZ"); 35 | 36 | item.SetAgentVersion(expected1); 37 | Nullable actual = item.GetAgentVersion(); 38 | Assert::AreEqual(expected1, actual); 39 | 40 | Nullable expected2(L"QkYKBHbG"); 41 | 42 | item.SetAgentVersion(expected2); 43 | actual = item.GetAgentVersion(); 44 | Assert::AreEqual(expected2, actual); 45 | }; 46 | 47 | TEST_METHOD(SerializationWorksAsExpected) 48 | { 49 | Internal item; 50 | Nullable sdkVersion(L"fmwchHWF"); 51 | Nullable agentVersion(L"eMUeMREZ"); 52 | 53 | item.SetSdkVersion(sdkVersion); 54 | item.SetAgentVersion(agentVersion); 55 | 56 | std::wstring expected = L"{\"ai.internal.sdkVersion\":\"fmwchHWF\",\"ai.internal.agentVersion\":\"eMUeMREZ\"}"; 57 | 58 | std::wstring actual; 59 | StringWriter writer(&actual); 60 | JsonWriter serializer(writer); 61 | serializer.WriteObjectValue(&item); 62 | 63 | Assert::AreEqual(expected, actual); 64 | } 65 | }; 66 | }}} 67 | -------------------------------------------------------------------------------- /test/core/contracts/TestLocation.cpp: -------------------------------------------------------------------------------- 1 | #include "../targetver.h" 2 | #include "../specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "Contracts/Location.h" 5 | 6 | using namespace ApplicationInsights::core; 7 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 8 | 9 | namespace core { namespace tests { namespace contracts 10 | { 11 | TEST_CLASS(TestLocation) 12 | { 13 | public: 14 | 15 | TEST_METHOD(IpWorksAsExpected) 16 | { 17 | Location item; 18 | Nullable expected1(L"hmrnPNLx"); 19 | 20 | item.SetIp(expected1); 21 | Nullable actual = item.GetIp(); 22 | Assert::AreEqual(expected1, actual); 23 | 24 | Nullable expected2(L"WjNsWtwq"); 25 | 26 | item.SetIp(expected2); 27 | actual = item.GetIp(); 28 | Assert::AreEqual(expected2, actual); 29 | }; 30 | 31 | TEST_METHOD(SerializationWorksAsExpected) 32 | { 33 | Location item; 34 | Nullable ip(L"hmrnPNLx"); 35 | 36 | item.SetIp(ip); 37 | 38 | std::wstring expected = L"{\"ai.location.ip\":\"hmrnPNLx\"}"; 39 | 40 | std::wstring actual; 41 | StringWriter writer(&actual); 42 | JsonWriter serializer(writer); 43 | serializer.WriteObjectValue(&item); 44 | 45 | Assert::AreEqual(expected, actual); 46 | } 47 | }; 48 | }}} 49 | -------------------------------------------------------------------------------- /test/core/contracts/TestMessageData.cpp: -------------------------------------------------------------------------------- 1 | #include "../targetver.h" 2 | #include "../specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "Contracts/MessageData.h" 5 | 6 | using namespace ApplicationInsights::core; 7 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 8 | 9 | namespace core { namespace tests { namespace contracts 10 | { 11 | TEST_CLASS(TestMessageData) 12 | { 13 | public: 14 | 15 | TEST_METHOD(VerWorksAsExpected) 16 | { 17 | MessageData item; 18 | int expected1 = 38; 19 | 20 | item.SetVer(expected1); 21 | int actual = item.GetVer(); 22 | Assert::AreEqual(expected1, actual); 23 | 24 | int expected2 = 92; 25 | 26 | item.SetVer(expected2); 27 | actual = item.GetVer(); 28 | Assert::AreEqual(expected2, actual); 29 | }; 30 | 31 | TEST_METHOD(MessageWorksAsExpected) 32 | { 33 | MessageData item; 34 | std::wstring expected1 = L"cYQXvzXJ"; 35 | 36 | item.SetMessage(expected1); 37 | std::wstring actual = item.GetMessage(); 38 | Assert::AreEqual(expected1, actual); 39 | 40 | std::wstring expected2 = L"ULhtEnAd"; 41 | 42 | item.SetMessage(expected2); 43 | actual = item.GetMessage(); 44 | Assert::AreEqual(expected2, actual); 45 | }; 46 | 47 | TEST_METHOD(SeverityLevelWorksAsExpected) 48 | { 49 | MessageData item; 50 | Nullable expected1((SeverityLevel)91); 51 | 52 | item.SetSeverityLevel(expected1); 53 | Nullable actual = item.GetSeverityLevel(); 54 | Assert::AreEqual(expected1, actual); 55 | 56 | Nullable expected2((SeverityLevel)30); 57 | 58 | item.SetSeverityLevel(expected2); 59 | actual = item.GetSeverityLevel(); 60 | Assert::AreEqual(expected2, actual); 61 | }; 62 | 63 | TEST_METHOD(PropertiesWorksAsExpected) 64 | { 65 | MessageData item; 66 | std::map expected1 = { { L"yCBA", L"KevMpBvm" } }; 67 | 68 | item.SetProperties(expected1); 69 | std::map actual = item.GetProperties(); 70 | Assert::AreEqual(expected1, actual); 71 | 72 | std::map expected2 = { { L"IMVY", L"KevMpBvm" } }; 73 | 74 | item.SetProperties(expected2); 75 | actual = item.GetProperties(); 76 | Assert::AreEqual(expected2, actual); 77 | }; 78 | 79 | TEST_METHOD(SerializationWorksAsExpected) 80 | { 81 | MessageData item; 82 | int ver = 38; 83 | std::wstring message = L"cYQXvzXJ"; 84 | Nullable severityLevel((SeverityLevel)91); 85 | std::map properties = { { L"yCBA", L"KevMpBvm" } }; 86 | 87 | item.SetVer(ver); 88 | item.SetMessage(message); 89 | item.SetSeverityLevel(severityLevel); 90 | item.SetProperties(properties); 91 | 92 | std::wstring expected = L"{\"ver\":38,\"message\":\"cYQXvzXJ\",\"severityLevel\":91,\"properties\":{\"yCBA\":\"KevMpBvm\"}}"; 93 | 94 | std::wstring actual; 95 | StringWriter writer(&actual); 96 | JsonWriter serializer(writer); 97 | serializer.WriteObjectValue(&item); 98 | 99 | Assert::AreEqual(expected, actual); 100 | } 101 | }; 102 | }}} 103 | -------------------------------------------------------------------------------- /test/core/contracts/TestMetricData.cpp: -------------------------------------------------------------------------------- 1 | #include "../targetver.h" 2 | #include "../specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "Contracts/MetricData.h" 5 | 6 | using namespace ApplicationInsights::core; 7 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 8 | 9 | namespace core { namespace tests { namespace contracts 10 | { 11 | TEST_CLASS(TestMetricData) 12 | { 13 | public: 14 | 15 | TEST_METHOD(VerWorksAsExpected) 16 | { 17 | MetricData item; 18 | int expected1 = 56; 19 | 20 | item.SetVer(expected1); 21 | int actual = item.GetVer(); 22 | Assert::AreEqual(expected1, actual); 23 | 24 | int expected2 = 38; 25 | 26 | item.SetVer(expected2); 27 | actual = item.GetVer(); 28 | Assert::AreEqual(expected2, actual); 29 | }; 30 | 31 | TEST_METHOD(MetricsWorksAsExpected) 32 | { 33 | MetricData item; 34 | std::vector expected1 = { }; 35 | 36 | item.SetMetrics(expected1); 37 | std::vector actual = item.GetMetrics(); 38 | Assert::AreEqual(expected1, actual); 39 | 40 | std::vector expected2 = { }; 41 | 42 | item.SetMetrics(expected2); 43 | actual = item.GetMetrics(); 44 | Assert::AreEqual(expected2, actual); 45 | }; 46 | 47 | TEST_METHOD(PropertiesWorksAsExpected) 48 | { 49 | MetricData item; 50 | std::map expected1 = { { L"nUVt", L"UsxiClbK" } }; 51 | 52 | item.SetProperties(expected1); 53 | std::map actual = item.GetProperties(); 54 | Assert::AreEqual(expected1, actual); 55 | 56 | std::map expected2 = { { L"GxCS", L"UsxiClbK" } }; 57 | 58 | item.SetProperties(expected2); 59 | actual = item.GetProperties(); 60 | Assert::AreEqual(expected2, actual); 61 | }; 62 | 63 | TEST_METHOD(SerializationWorksAsExpected) 64 | { 65 | MetricData item; 66 | int ver = 56; 67 | std::vector metrics = { }; 68 | std::map properties = { { L"nUVt", L"UsxiClbK" } }; 69 | 70 | item.SetVer(ver); 71 | item.SetMetrics(metrics); 72 | item.SetProperties(properties); 73 | 74 | std::wstring expected = L"{\"ver\":56,\"metrics\":[],\"properties\":{\"nUVt\":\"UsxiClbK\"}}"; 75 | 76 | std::wstring actual; 77 | StringWriter writer(&actual); 78 | JsonWriter serializer(writer); 79 | serializer.WriteObjectValue(&item); 80 | 81 | Assert::AreEqual(expected, actual); 82 | } 83 | }; 84 | }}} 85 | -------------------------------------------------------------------------------- /test/core/contracts/TestPageViewData.cpp: -------------------------------------------------------------------------------- 1 | #include "../targetver.h" 2 | #include "../specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "Contracts/PageViewData.h" 5 | 6 | using namespace ApplicationInsights::core; 7 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 8 | 9 | namespace core { namespace tests { namespace contracts 10 | { 11 | TEST_CLASS(TestPageViewData) 12 | { 13 | public: 14 | 15 | TEST_METHOD(UrlWorksAsExpected) 16 | { 17 | PageViewData item; 18 | std::wstring expected1 = L"nxcKNxAq"; 19 | 20 | item.SetUrl(expected1); 21 | std::wstring actual = item.GetUrl(); 22 | Assert::AreEqual(expected1, actual); 23 | 24 | std::wstring expected2 = L"bjKAYrGi"; 25 | 26 | item.SetUrl(expected2); 27 | actual = item.GetUrl(); 28 | Assert::AreEqual(expected2, actual); 29 | }; 30 | 31 | TEST_METHOD(DurationWorksAsExpected) 32 | { 33 | PageViewData item; 34 | std::wstring expected1 = L"WaazkJXv"; 35 | 36 | item.SetDuration(expected1); 37 | std::wstring actual = item.GetDuration(); 38 | Assert::AreEqual(expected1, actual); 39 | 40 | std::wstring expected2 = L"NjcZUfcw"; 41 | 42 | item.SetDuration(expected2); 43 | actual = item.GetDuration(); 44 | Assert::AreEqual(expected2, actual); 45 | }; 46 | 47 | TEST_METHOD(SerializationWorksAsExpected) 48 | { 49 | PageViewData item; 50 | int ver = 63; 51 | std::wstring name = L"FPkYRwor"; 52 | std::map properties = { { L"fEUK", L"CmlXfTfm" } }; 53 | std::map measurements = { { L"WxIM", 4.509 } }; 54 | std::wstring url = L"nxcKNxAq"; 55 | std::wstring duration = L"WaazkJXv"; 56 | 57 | item.SetVer(ver); 58 | item.SetName(name); 59 | item.SetProperties(properties); 60 | item.SetMeasurements(measurements); 61 | item.SetUrl(url); 62 | item.SetDuration(duration); 63 | 64 | std::wstring expected = L"{\"ver\":63,\"name\":\"FPkYRwor\",\"properties\":{\"fEUK\":\"CmlXfTfm\"},\"measurements\":{\"WxIM\":4.509000},\"url\":\"nxcKNxAq\",\"duration\":\"WaazkJXv\"}"; 65 | 66 | std::wstring actual; 67 | StringWriter writer(&actual); 68 | JsonWriter serializer(writer); 69 | serializer.WriteObjectValue(&item); 70 | 71 | Assert::AreEqual(expected, actual); 72 | } 73 | }; 74 | }}} 75 | -------------------------------------------------------------------------------- /test/core/contracts/TestSession.cpp: -------------------------------------------------------------------------------- 1 | #include "../targetver.h" 2 | #include "../specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "Contracts/Session.h" 5 | 6 | using namespace ApplicationInsights::core; 7 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 8 | 9 | namespace core { namespace tests { namespace contracts 10 | { 11 | TEST_CLASS(TestSession) 12 | { 13 | public: 14 | 15 | TEST_METHOD(IdWorksAsExpected) 16 | { 17 | Session item; 18 | Nullable expected1(L"loQoJqjW"); 19 | 20 | item.SetId(expected1); 21 | Nullable actual = item.GetId(); 22 | Assert::AreEqual(expected1, actual); 23 | 24 | Nullable expected2(L"wqzRpTBu"); 25 | 26 | item.SetId(expected2); 27 | actual = item.GetId(); 28 | Assert::AreEqual(expected2, actual); 29 | }; 30 | 31 | TEST_METHOD(IsFirstWorksAsExpected) 32 | { 33 | Session item; 34 | Nullable expected1(L"XoyYwPiz"); 35 | 36 | item.SetIsFirst(expected1); 37 | Nullable actual = item.GetIsFirst(); 38 | Assert::AreEqual(expected1, actual); 39 | 40 | Nullable expected2(L"hZyQkrHb"); 41 | 42 | item.SetIsFirst(expected2); 43 | actual = item.GetIsFirst(); 44 | Assert::AreEqual(expected2, actual); 45 | }; 46 | 47 | TEST_METHOD(IsNewWorksAsExpected) 48 | { 49 | Session item; 50 | Nullable expected1(L"zFBXDCpK"); 51 | 52 | item.SetIsNew(expected1); 53 | Nullable actual = item.GetIsNew(); 54 | Assert::AreEqual(expected1, actual); 55 | 56 | Nullable expected2(L"VpGpWUFE"); 57 | 58 | item.SetIsNew(expected2); 59 | actual = item.GetIsNew(); 60 | Assert::AreEqual(expected2, actual); 61 | }; 62 | 63 | TEST_METHOD(SerializationWorksAsExpected) 64 | { 65 | Session item; 66 | Nullable id(L"loQoJqjW"); 67 | Nullable isFirst(L"XoyYwPiz"); 68 | Nullable isNew(L"zFBXDCpK"); 69 | 70 | item.SetId(id); 71 | item.SetIsFirst(isFirst); 72 | item.SetIsNew(isNew); 73 | 74 | std::wstring expected = L"{\"ai.session.id\":\"loQoJqjW\",\"ai.session.isFirst\":\"XoyYwPiz\",\"ai.session.isNew\":\"zFBXDCpK\"}"; 75 | 76 | std::wstring actual; 77 | StringWriter writer(&actual); 78 | JsonWriter serializer(writer); 79 | serializer.WriteObjectValue(&item); 80 | 81 | Assert::AreEqual(expected, actual); 82 | } 83 | }; 84 | }}} 85 | -------------------------------------------------------------------------------- /test/core/contracts/TestSessionStateData.cpp: -------------------------------------------------------------------------------- 1 | #include "../targetver.h" 2 | #include "../specializations.h" 3 | #include "CppUnitTest.h" 4 | #include "Contracts/SessionStateData.h" 5 | 6 | using namespace ApplicationInsights::core; 7 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 8 | 9 | namespace core { namespace tests { namespace contracts 10 | { 11 | TEST_CLASS(TestSessionStateData) 12 | { 13 | public: 14 | 15 | TEST_METHOD(VerWorksAsExpected) 16 | { 17 | SessionStateData item; 18 | int expected1 = 4; 19 | 20 | item.SetVer(expected1); 21 | int actual = item.GetVer(); 22 | Assert::AreEqual(expected1, actual); 23 | 24 | int expected2 = 35; 25 | 26 | item.SetVer(expected2); 27 | actual = item.GetVer(); 28 | Assert::AreEqual(expected2, actual); 29 | }; 30 | 31 | TEST_METHOD(StateWorksAsExpected) 32 | { 33 | SessionStateData item; 34 | SessionState expected1 = (SessionState)52; 35 | 36 | item.SetState(expected1); 37 | SessionState actual = item.GetState(); 38 | Assert::AreEqual(expected1, actual); 39 | 40 | SessionState expected2 = (SessionState)87; 41 | 42 | item.SetState(expected2); 43 | actual = item.GetState(); 44 | Assert::AreEqual(expected2, actual); 45 | }; 46 | 47 | TEST_METHOD(SerializationWorksAsExpected) 48 | { 49 | SessionStateData item; 50 | int ver = 4; 51 | SessionState state = (SessionState)52; 52 | 53 | item.SetVer(ver); 54 | item.SetState(state); 55 | 56 | std::wstring expected = L"{\"ver\":4,\"state\":52}"; 57 | 58 | std::wstring actual; 59 | StringWriter writer(&actual); 60 | JsonWriter serializer(writer); 61 | serializer.WriteObjectValue(&item); 62 | 63 | Assert::AreEqual(expected, actual); 64 | } 65 | }; 66 | }}} 67 | -------------------------------------------------------------------------------- /test/core/core.tests.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {7e2a60f6-a7e0-449f-b1d2-0382a91b7967} 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | contracts 15 | 16 | 17 | contracts 18 | 19 | 20 | contracts 21 | 22 | 23 | contracts 24 | 25 | 26 | contracts 27 | 28 | 29 | contracts 30 | 31 | 32 | contracts 33 | 34 | 35 | contracts 36 | 37 | 38 | contracts 39 | 40 | 41 | contracts 42 | 43 | 44 | contracts 45 | 46 | 47 | contracts 48 | 49 | 50 | contracts 51 | 52 | 53 | contracts 54 | 55 | 56 | contracts 57 | 58 | 59 | contracts 60 | 61 | 62 | contracts 63 | 64 | 65 | contracts 66 | 67 | 68 | contracts 69 | 70 | 71 | contracts 72 | 73 | 74 | contracts 75 | 76 | 77 | contracts 78 | 79 | 80 | contracts 81 | 82 | 83 | contracts 84 | 85 | 86 | contracts 87 | 88 | 89 | contracts 90 | 91 | 92 | contracts 93 | 94 | 95 | contracts 96 | 97 | 98 | contracts 99 | 100 | 101 | contracts 102 | 103 | 104 | contracts 105 | 106 | 107 | -------------------------------------------------------------------------------- /test/core/specializations.h: -------------------------------------------------------------------------------- 1 | #ifndef SPECIALIZATIONS_H 2 | #define SPECIALIZATIONS_H 3 | 4 | #include "CppUnitTest.h" 5 | #include "common/StringWriter.h" 6 | #include "Contracts/Base.h" 7 | #include "Contracts/CrashDataHeaders.h" 8 | #include "Contracts/DependencySourceType.h" 9 | #include "Contracts/DataPointType.h" 10 | #include "Contracts/DependencyKind.h" 11 | #include "Contracts/StackFrame.h" 12 | #include "Contracts/ExceptionDetails.h" 13 | #include "Contracts/DataPoint.h" 14 | #include "Contracts/CrashDataThreadFrame.h" 15 | #include "Contracts/CrashDataThread.h" 16 | #include "Contracts/CrashDataBinary.h" 17 | #include "Contracts/SeverityLevel.h" 18 | #include "Contracts/SessionState.h" 19 | #include "TelemetryClient.h" 20 | 21 | using namespace ApplicationInsights::core; 22 | namespace Microsoft{ namespace VisualStudio { namespace CppUnitTestFramework { 23 | template<> inline std::wstring ToString (TelemetryClient* t) { RETURN_WIDE_STRING(t); } 24 | template<> inline std::wstring ToString (CrashDataHeaders* t) { RETURN_WIDE_STRING(t); } 25 | template<> inline std::wstring ToString (Base* t) { RETURN_WIDE_STRING(t); } 26 | template<> inline std::wstring ToString (const DependencySourceType& t) { RETURN_WIDE_STRING(t); } 27 | template<> inline std::wstring ToString (const DataPointType& t) { RETURN_WIDE_STRING(t); } 28 | template<> inline std::wstring ToString (const DependencyKind& t) { RETURN_WIDE_STRING(t); } 29 | template<> inline std::wstring ToString (const SessionState& t) { RETURN_WIDE_STRING(t); } 30 | template<> inline std::wstring ToString> (const std::map& t) { RETURN_WIDE_STRING("dictionary"); } 31 | template<> inline std::wstring ToString> (const std::map& t) { RETURN_WIDE_STRING("dictionary"); } 32 | template<> inline std::wstring ToString> (const std::vector& t) { RETURN_WIDE_STRING("vector"); } 33 | template<> inline std::wstring ToString> (const std::vector& t) { RETURN_WIDE_STRING("vector"); } 34 | template<> inline std::wstring ToString> (const std::vector& t) { RETURN_WIDE_STRING("vector"); } 35 | template<> inline std::wstring ToString> (const std::vector& t) { RETURN_WIDE_STRING("vector"); } 36 | template<> inline std::wstring ToString> (const std::vector& t) { RETURN_WIDE_STRING("vector"); } 37 | template<> inline std::wstring ToString> (const std::vector& t) { RETURN_WIDE_STRING("vector"); } 38 | template<> inline std::wstring ToString> (const Nullable& t) { RETURN_WIDE_STRING("nullable"); } 39 | template<> inline std::wstring ToString> (const Nullable& t) { RETURN_WIDE_STRING("nullable"); } 40 | template<> inline std::wstring ToString> (const Nullable& t) { RETURN_WIDE_STRING("nullable"); } 41 | template<> inline std::wstring ToString> (const Nullable& t) { RETURN_WIDE_STRING("nullable"); } 42 | template<> inline std::wstring ToString> (const Nullable& t) { RETURN_WIDE_STRING("nullable"); } 43 | }}}; 44 | 45 | #endif -------------------------------------------------------------------------------- /test/core/targetver.h: -------------------------------------------------------------------------------- 1 | #ifndef TARGETVER_H 2 | #define TARGETVER_H 3 | 4 | // Including SDKDDKVer.h defines the highest available Windows platform. 5 | 6 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 7 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 8 | 9 | #include 10 | 11 | #endif --------------------------------------------------------------------------------