diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/AI.XamarinSDK.Abstractions.csproj b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/AI.XamarinSDK.Abstractions.csproj new file mode 100644 index 0000000..0b26a97 --- /dev/null +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/AI.XamarinSDK.Abstractions.csproj @@ -0,0 +1,54 @@ + + + + Debug + AnyCPU + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + {5DAA7398-7822-44A5-993B-D595A6921D50} + Library + AI.XamarinSDK.Abstractions + AI.XamarinSDK.Abstractions + Profile49 + v4.5 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + + + true + bin\Release + prompt + 4 + false + + + + + + + + + + + + + ..\..\packages\Xamarin.Forms.1.4.3.6374\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Core.dll + + + ..\..\packages\Xamarin.Forms.1.4.3.6374\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Xaml.dll + + + ..\..\packages\Xamarin.Forms.1.4.3.6374\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Platform.dll + + + + + + \ No newline at end of file diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/ApplicationInsights.cs b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/ApplicationInsights.cs similarity index 87% rename from ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/ApplicationInsights.cs rename to ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/ApplicationInsights.cs index e9f7a1e..3ef6a39 100644 --- a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/ApplicationInsights.cs +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/ApplicationInsights.cs @@ -1,11 +1,6 @@ using System; -#if __ANDROID__ -using Android.App; -using Android.Content; -#endif - -namespace AI.XamarinSDK +namespace AI.XamarinSDK.Abstractions { /// /// This class exposes methods to configure and start the SDK. This is required in order to enable auto collection, crash reporting, and sending of telemetry data. @@ -17,7 +12,6 @@ public class ApplicationInsights private ApplicationInsights() {} - #if __IOS__ /// /// Setup the SDK with the instrumentation key of your app. /// @@ -27,19 +21,6 @@ public static void Setup (string instrumentationKey) target.Setup (instrumentationKey); } - #elif __ANDROID__ - /// - /// Setup the SDK with the instrumentation key of your app. - /// - /// The application context needed to access app ressources. - /// The application needed for auto collecting telemetry data. - /// The instrumentation key of your app. - public static void Setup (Context context, Application application, string instrumentationKey) - { - target.Setup (context, application, instrumentationKey); - } - #endif - /// /// Starts the SDK. This should be called after setup(). /// diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/IApplicationInsights.cs b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/IApplicationInsights.cs similarity index 78% rename from ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/IApplicationInsights.cs rename to ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/IApplicationInsights.cs index 177977a..5808413 100644 --- a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/IApplicationInsights.cs +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/IApplicationInsights.cs @@ -1,20 +1,11 @@ using System; -#if __ANDROID__ -using Android.App; -using Android.Content; -#endif - -namespace AI.XamarinSDK +namespace AI.XamarinSDK.Abstractions { public interface IApplicationInsights { void Setup (string instrumentationKey); - #if __ANDROID__ - void Setup (Context context, Application application, string instrumentationKey); - #endif - void Start (); string GetServerUrl (); diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/ITelemetryManager.cs b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/ITelemetryManager.cs similarity index 95% rename from ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/ITelemetryManager.cs rename to ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/ITelemetryManager.cs index af9d68f..ee6bf68 100644 --- a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/ITelemetryManager.cs +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/ITelemetryManager.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace AI.XamarinSDK +namespace AI.XamarinSDK.Abstractions { public interface ITelemetryManager { diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/Properties/AssemblyInfo.cs b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2602085 --- /dev/null +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/Properties/AssemblyInfo.cs @@ -0,0 +1,27 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle ("AI.XamarinSDK.Abstractions")] +[assembly: AssemblyDescription ("")] +[assembly: AssemblyConfiguration ("")] +[assembly: AssemblyCompany ("")] +[assembly: AssemblyProduct ("")] +[assembly: AssemblyCopyright ("christophwendt")] +[assembly: AssemblyTrademark ("")] +[assembly: AssemblyCulture ("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion ("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/TelemetryManager.cs b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/TelemetryManager.cs similarity index 99% rename from ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/TelemetryManager.cs rename to ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/TelemetryManager.cs index 0c8729f..35d3be1 100644 --- a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/TelemetryManager.cs +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/TelemetryManager.cs @@ -2,7 +2,7 @@ using Xamarin.Forms; using System.Collections.Generic; -namespace AI.XamarinSDK +namespace AI.XamarinSDK.Abstractions { /// /// This class exposes functions to track differnt types of telemetry data. Tracked data will be created, persisted, and sent to the server. diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/packages.config b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/packages.config new file mode 100644 index 0000000..1ec4409 --- /dev/null +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Abstractions/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/AI.XamarinSDK.Android.csproj b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/AI.XamarinSDK.Android.csproj index c43b7ec..7959dad 100644 --- a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/AI.XamarinSDK.Android.csproj +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/AI.XamarinSDK.Android.csproj @@ -11,9 +11,8 @@ Resources Resource Resources\Resource.designer.cs - True + False AI.XamarinSDK.Android - v5.0 true @@ -46,29 +45,24 @@ ..\..\packages\Xamarin.Forms.1.4.3.6374\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll - False ..\..\packages\Xamarin.Forms.1.4.3.6374\lib\MonoAndroid10\FormsViewGroup.dll - False ..\..\packages\Xamarin.Forms.1.4.3.6374\lib\MonoAndroid10\Xamarin.Forms.Core.dll - False ..\..\packages\Xamarin.Forms.1.4.3.6374\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll - False ..\..\packages\Xamarin.Forms.1.4.3.6374\lib\MonoAndroid10\Xamarin.Forms.Platform.dll - False - - + + @@ -77,11 +71,14 @@ - + + {5DAA7398-7822-44A5-993B-D595A6921D50} + AI.XamarinSDK.Abstractions + {E1779521-C094-4CA0-ACFA-B26A1B2B80F3} AI.XamarinSDK.AndroidBindings diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/ApplicationInsightsAndroid.cs b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/ApplicationInsights.cs similarity index 86% rename from ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/ApplicationInsightsAndroid.cs rename to ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/ApplicationInsights.cs index 2ce9b1e..8a4d138 100644 --- a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/ApplicationInsightsAndroid.cs +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/ApplicationInsights.cs @@ -1,26 +1,24 @@ using System; +using Android; using Android.Runtime; using Android.App; using Android.Content; +using Xamarin.Forms; +using AI.XamarinSDK.Abstractions; -[assembly: Xamarin.Forms.Dependency (typeof (AI.XamarinSDK.Android.ApplicationInsightsAndroid))] - +[assembly: Xamarin.Forms.Dependency (typeof (AI.XamarinSDK.Android.ApplicationInsights))] namespace AI.XamarinSDK.Android { - public class ApplicationInsightsAndroid : Java.Lang.Object, IApplicationInsights + [Preserve(AllMembers=true)] + public class ApplicationInsights : Java.Lang.Object, IApplicationInsights { private static bool _crashManagerDisabled = false; - public ApplicationInsightsAndroid (){} + public ApplicationInsights (){} public void Setup(string instrumentationKey) { - Com.Microsoft.Applicationinsights.Library.ApplicationInsights.Setup (Application.Context, null, instrumentationKey); - } - - public void Setup (Context context, Application application, string instrumentationKey) - { - Com.Microsoft.Applicationinsights.Library.ApplicationInsights.Setup (context, application, instrumentationKey); + Com.Microsoft.Applicationinsights.Library.ApplicationInsights.Setup (((Activity)Forms.Context).Application, ((Activity)Forms.Context).Application, instrumentationKey); } public void Start () @@ -70,7 +68,7 @@ public void SetAutoSessionManagementDisabled (bool autoSessionManagementDisabled public void SetUserId (string userId) { - ApplicationInsights.SetUserId (userId); + Com.Microsoft.Applicationinsights.Library.ApplicationInsights.SetUserId (userId); } public void StartNewSession (){ @@ -108,7 +106,7 @@ public void OnUnhandledExceptionRaiser(object sender, RaiseThrowableEventArgs e) { Exception managedException = (Exception)e.Exception; if (managedException != null) { - TelemetryManager.TrackManagedException (managedException, false); + AI.XamarinSDK.Abstractions.TelemetryManager.TrackManagedException (managedException, false); } } } diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/TelemetryManagerAndroid.cs b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/TelemetryManager.cs similarity index 90% rename from ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/TelemetryManagerAndroid.cs rename to ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/TelemetryManager.cs index 54c4cd5..0b21e58 100644 --- a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/TelemetryManagerAndroid.cs +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/TelemetryManager.cs @@ -5,15 +5,16 @@ using Android.Content; using System.Collections.Generic; using Com.Microsoft.Applicationinsights.Library; +using AI.XamarinSDK.Abstractions; -[assembly: Xamarin.Forms.Dependency (typeof (AI.XamarinSDK.Android.TelemetryManagerAndroid))] - +[assembly: Xamarin.Forms.Dependency (typeof (AI.XamarinSDK.Android.TelemetryManager))] namespace AI.XamarinSDK.Android { - public class TelemetryManagerAndroid : Java.Lang.Object, ITelemetryManager + [Preserve(AllMembers=true)] + public class TelemetryManager : Java.Lang.Object, ITelemetryManager { - public TelemetryManagerAndroid(){} + public TelemetryManager(){} public void TrackEvent (string eventName) { diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/packages.config b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/packages.config index cee5c79..ea8c260 100644 --- a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/packages.config +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.Android/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.AndroidBindings/AI.XamarinSDK.AndroidBindings.csproj b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.AndroidBindings/AI.XamarinSDK.AndroidBindings.csproj index 3bfb30e..a537f41 100644 --- a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.AndroidBindings/AI.XamarinSDK.AndroidBindings.csproj +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.AndroidBindings/AI.XamarinSDK.AndroidBindings.csproj @@ -11,7 +11,6 @@ Assets False AI.XamarinSDK.AndroidBindings - v4.0.3 true @@ -42,26 +41,6 @@ ..\..\packages\Xamarin.Android.Support.v4.22.2.0.0\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll False - - ..\..\packages\Xamarin.Forms.1.4.3.6374\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll - False - - - ..\..\packages\Xamarin.Forms.1.4.3.6374\lib\MonoAndroid10\FormsViewGroup.dll - False - - - ..\..\packages\Xamarin.Forms.1.4.3.6374\lib\MonoAndroid10\Xamarin.Forms.Core.dll - False - - - ..\..\packages\Xamarin.Forms.1.4.3.6374\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll - False - - - ..\..\packages\Xamarin.Forms.1.4.3.6374\lib\MonoAndroid10\Xamarin.Forms.Platform.dll - False - diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.AndroidBindings/packages.config b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.AndroidBindings/packages.config index 82e8f8a..ea8c260 100644 --- a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.AndroidBindings/packages.config +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.AndroidBindings/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.WinPhone/AI.XamarinSDK.WinPhone.csproj b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.WinPhone/AI.XamarinSDK.WinPhone.csproj new file mode 100644 index 0000000..9e73c4d --- /dev/null +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.WinPhone/AI.XamarinSDK.WinPhone.csproj @@ -0,0 +1,61 @@ + + + + Debug + AnyCPU + {CAA8B410-05A3-4F2C-89F0-031806199D19} + Library + AI.XamarinSDK.WinPhone + AI.XamarinSDK.WinPhone + v4.5 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + + + full + true + bin\Release + prompt + 4 + false + + + + + ..\..\packages\Xamarin.Forms.1.4.3.6374\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Core.dll + False + + + ..\..\packages\Xamarin.Forms.1.4.3.6374\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Xaml.dll + False + + + ..\..\packages\Xamarin.Forms.1.4.3.6374\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Platform.dll + False + + + + + + + + + + + + + + + {5DAA7398-7822-44A5-993B-D595A6921D50} + AI.XamarinSDK.Abstractions + + + \ No newline at end of file diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.WinPhone/ApplicationInsights.cs b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.WinPhone/ApplicationInsights.cs new file mode 100644 index 0000000..c51fd35 --- /dev/null +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.WinPhone/ApplicationInsights.cs @@ -0,0 +1,71 @@ +using System; +using AI.XamarinSDK.Abstractions; + +[assembly: Xamarin.Forms.Dependency (typeof (AI.XamarinSDK.WinPhone.ApplicationInsights))] + +namespace AI.XamarinSDK.WinPhone +{ + public class ApplicationInsights : IApplicationInsights + { + + public ApplicationInsights (){} + + public void Setup(string instrumentationKey) + { + } + + public void Start () + { + } + + public string GetServerUrl () + { + return null; + } + + public void SetServerUrl (string serverUrl) + { + } + + public void SetCrashManagerDisabled (bool crashManagerDisabled) + { + } + + public void SetTelemetryManagerDisabled (bool telemetryManagerDisabled) + { + } + + public void SetAutoPageViewTrackingDisabled (bool autoPageViewTrackingDisabled) + { + } + + public void SetAutoSessionManagementDisabled (bool autoSessionManagementDisabled) + { + } + + public void SetUserId (string userId) + { + } + + public void StartNewSession (){ + } + + public void SetSessionExpirationTime (int appBackgroundTime) + { + } + + public void RenewSessionWithId (string sessionId) + { + } + + public bool GetDebugLogEnabled() + { + return false; + } + + public void SetDebugLogEnabled(bool debugLogEnabled) + { + } + } +} + diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.WinPhone/Properties/AssemblyInfo.cs b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.WinPhone/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5da4955 --- /dev/null +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.WinPhone/Properties/AssemblyInfo.cs @@ -0,0 +1,27 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle ("AI.XamarinSDK.WinPhone")] +[assembly: AssemblyDescription ("")] +[assembly: AssemblyConfiguration ("")] +[assembly: AssemblyCompany ("")] +[assembly: AssemblyProduct ("")] +[assembly: AssemblyCopyright ("christophwendt")] +[assembly: AssemblyTrademark ("")] +[assembly: AssemblyCulture ("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion ("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.WinPhone/TelemetryManager.cs b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.WinPhone/TelemetryManager.cs new file mode 100644 index 0000000..13d55ba --- /dev/null +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.WinPhone/TelemetryManager.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using AI.XamarinSDK.Abstractions; + +[assembly: Xamarin.Forms.Dependency (typeof (AI.XamarinSDK.WinPhone.TelemetryManager))] + +namespace AI.XamarinSDK.WinPhone +{ + + public class TelemetryManager : ITelemetryManager + { + + public TelemetryManager(){} + + public void TrackEvent (string eventName) + { + } + + public void TrackEvent (string eventName, Dictionary properties) + { + } + + public void TrackTrace (string message) + { + } + + public void TrackTrace (string message, Dictionary properties) + { + } + + public void TrackMetric (string metricName, double value) + { + } + + public void TrackMetric (string metricName, double value, Dictionary properties) + { + } + + public void TrackPageView (string pageName) + { + } + + public void TrackPageView (string pageName, int duration) + { + } + + public void TrackPageView (string pageName, int duration, Dictionary properties) + { + } + + public void TrackManagedException (Exception exception, bool handled) + { + } + } +} + diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.WinPhone/packages.config b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.WinPhone/packages.config new file mode 100644 index 0000000..702ccb7 --- /dev/null +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.WinPhone/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.iOS/AI.XamarinSDK.iOS.csproj b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.iOS/AI.XamarinSDK.iOS.csproj index f25b2b1..78debc5 100644 --- a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.iOS/AI.XamarinSDK.iOS.csproj +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.iOS/AI.XamarinSDK.iOS.csproj @@ -56,11 +56,11 @@ - - libApplicationInsights.a + + @@ -68,7 +68,6 @@ - @@ -78,4 +77,10 @@ + + + {5DAA7398-7822-44A5-993B-D595A6921D50} + AI.XamarinSDK.Abstractions + + \ No newline at end of file diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.iOS/ApplicationInsightsIOS.cs b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.iOS/ApplicationInsights.cs similarity index 90% rename from ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.iOS/ApplicationInsightsIOS.cs rename to ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.iOS/ApplicationInsights.cs index 666fd2f..bbf583f 100644 --- a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.iOS/ApplicationInsightsIOS.cs +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.iOS/ApplicationInsights.cs @@ -4,15 +4,15 @@ using Foundation; using System.Collections.Generic; using Xamarin.Forms; -using AI.XamarinSDK; -using AI.XamarinSDK.iOS; using System.Runtime.InteropServices; +using AI.XamarinSDK.Abstractions; -[assembly: Xamarin.Forms.Dependency (typeof (AI.XamarinSDK.iOS.ApplicationInsightsIOS))] +[assembly: Xamarin.Forms.Dependency (typeof (AI.XamarinSDK.iOS.ApplicationInsights))] namespace AI.XamarinSDK.iOS { - public class ApplicationInsightsIOS : IApplicationInsights + [Preserve(AllMembers=true)] + public class ApplicationInsights : IApplicationInsights { [DllImport ("libc")] @@ -25,7 +25,11 @@ enum Signal { private static bool _crashManagerDisabled = false; - public ApplicationInsightsIOS(){} + public ApplicationInsights(){} + + public static void Init(){ + var forceLoad = new ApplicationInsights (); + } public void Setup (string instrumentationKey) { @@ -119,7 +123,7 @@ public void OnUnhandledException(object e, System.UnhandledExceptionEventArgs ar Exception managedException = (Exception) args.ExceptionObject; Console.WriteLine (managedException.Source); if (managedException != null && !managedException.Source.Equals("Xamarin.iOS")) { - TelemetryManager.TrackManagedException (managedException, false); + AI.XamarinSDK.Abstractions.TelemetryManager.TrackManagedException (managedException, false); } } } diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.iOS/TelemetryManagerIOS.cs b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.iOS/TelemetryManager.cs similarity index 90% rename from ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.iOS/TelemetryManagerIOS.cs rename to ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.iOS/TelemetryManager.cs index ae6a8f0..15be7be 100644 --- a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.iOS/TelemetryManagerIOS.cs +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK.iOS/TelemetryManager.cs @@ -2,17 +2,16 @@ using UIKit; using ObjCRuntime; using Foundation; -using System.Collections.Generic; - -[assembly: Xamarin.Forms.Dependency (typeof (AI.XamarinSDK.iOS.TelemetryManagerIOS))] +using System.Collections.Generic;using AI.XamarinSDK.Abstractions; +[assembly: Xamarin.Forms.Dependency (typeof (AI.XamarinSDK.iOS.TelemetryManager))] namespace AI.XamarinSDK.iOS { - - public class TelemetryManagerIOS : ITelemetryManager + [Preserve(AllMembers=true)] + public class TelemetryManager : ITelemetryManager { - public TelemetryManagerIOS(){} + public TelemetryManager(){} public void TrackEvent (string eventName) { diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/AI.XamarinSDK.projitems b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/AI.XamarinSDK.projitems deleted file mode 100644 index d10211b..0000000 --- a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/AI.XamarinSDK.projitems +++ /dev/null @@ -1,17 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - {C146023A-3BA3-4697-84C8-FFD30C984EFE} - - - AI.XamarinSDK - - - - - - - - \ No newline at end of file diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/AI.XamarinSDK.shproj b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/AI.XamarinSDK.shproj deleted file mode 100644 index 3462688..0000000 --- a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/AI.XamarinSDK.shproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - {C146023A-3BA3-4697-84C8-FFD30C984EFE} - - - - - - - \ No newline at end of file diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/Shared.projitems b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/Shared.projitems deleted file mode 100644 index d10211b..0000000 --- a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/AI.XamarinSDK/Shared.projitems +++ /dev/null @@ -1,17 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - {C146023A-3BA3-4697-84C8-FFD30C984EFE} - - - AI.XamarinSDK - - - - - - - - \ No newline at end of file diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/NuGet/AI.XamarinSDK.nuspec b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/NuGet/AI.XamarinSDK.nuspec new file mode 100644 index 0000000..6b14839 --- /dev/null +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/NuGet/AI.XamarinSDK.nuspec @@ -0,0 +1,41 @@ + + + + Microsoft.ApplicationInsights.Xamarin + 1.0.0-alpha2 + ApplicationInsights SDK for Xamarin.Forms + Microsoft + + + + https://github.com/Microsoft/ApplicationInsights-Xamarin + https://github.com/Microsoft/ApplicationInsights-Xamarin/blob/master/LICENSE + licenseUrl + false + + This project provides an Xamarin SDK for Application Insights. + + + This project provides an Xamarin SDK for Application Insights. Application Insights is a service that allows developers to keep their applications available, performing, and succeeding. This SDK allows your Xamarin apps to send telemetry of various kinds (events, traces, exceptions, etc.) to the Application Insights service where your data can be visualized in the Azure Portal. Currently, we provide support for iOS and Android. + + xamarin, xamarin.forms, android, ios, windows phone, application insights + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/NuGet/Microsoft.ApplicationInsights.Xamarin.1.0.0-alpha2.nupkg b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/NuGet/Microsoft.ApplicationInsights.Xamarin.1.0.0-alpha2.nupkg new file mode 100644 index 0000000..ab79a24 Binary files /dev/null and b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarin/NuGet/Microsoft.ApplicationInsights.Xamarin.1.0.0-alpha2.nupkg differ diff --git a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarinSDK.sln b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarinSDK.sln index 93b24f3..05475ee 100644 --- a/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarinSDK.sln +++ b/ApplicationInsightsXamarinSDK/ApplicationInsightsXamarinSDK.sln @@ -13,14 +13,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DummyLibrary.iOS", "DemoApp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DummyLibrary.Android", "DemoApp\DummyLibrary.Android\DummyLibrary.Android.csproj", "{68E5289F-6819-4757-812B-6D7AAF78FD7B}" EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "AI.XamarinSDK", "ApplicationInsightsXamarin\AI.XamarinSDK\AI.XamarinSDK.shproj", "{C146023A-3BA3-4697-84C8-FFD30C984EFE}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AI.XamarinSDK.Android", "ApplicationInsightsXamarin\AI.XamarinSDK.Android\AI.XamarinSDK.Android.csproj", "{25DFBE50-3DE9-402E-B6E0-C089F1425B45}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AI.XamarinSDK.AndroidBindings", "ApplicationInsightsXamarin\AI.XamarinSDK.AndroidBindings\AI.XamarinSDK.AndroidBindings.csproj", "{E1779521-C094-4CA0-ACFA-B26A1B2B80F3}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AI.XamarinSDK.iOS", "ApplicationInsightsXamarin\AI.XamarinSDK.iOS\AI.XamarinSDK.iOS.csproj", "{4B57344D-C4B3-44F8-8E15-CC5B3AF1CC24}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AI.XamarinSDK.Abstractions", "ApplicationInsightsXamarin\AI.XamarinSDK.Abstractions\AI.XamarinSDK.Abstractions.csproj", "{5DAA7398-7822-44A5-993B-D595A6921D50}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AI.XamarinSDK.WinPhone", "ApplicationInsightsXamarin\AI.XamarinSDK.WinPhone\AI.XamarinSDK.WinPhone.csproj", "{CAA8B410-05A3-4F2C-89F0-031806199D19}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -67,6 +69,18 @@ Global {4B57344D-C4B3-44F8-8E15-CC5B3AF1CC24}.Release|iPhone.Build.0 = Release|Any CPU {4B57344D-C4B3-44F8-8E15-CC5B3AF1CC24}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {4B57344D-C4B3-44F8-8E15-CC5B3AF1CC24}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {5DAA7398-7822-44A5-993B-D595A6921D50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5DAA7398-7822-44A5-993B-D595A6921D50}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5DAA7398-7822-44A5-993B-D595A6921D50}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {5DAA7398-7822-44A5-993B-D595A6921D50}.Debug|iPhone.Build.0 = Debug|Any CPU + {5DAA7398-7822-44A5-993B-D595A6921D50}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {5DAA7398-7822-44A5-993B-D595A6921D50}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {5DAA7398-7822-44A5-993B-D595A6921D50}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5DAA7398-7822-44A5-993B-D595A6921D50}.Release|Any CPU.Build.0 = Release|Any CPU + {5DAA7398-7822-44A5-993B-D595A6921D50}.Release|iPhone.ActiveCfg = Release|Any CPU + {5DAA7398-7822-44A5-993B-D595A6921D50}.Release|iPhone.Build.0 = Release|Any CPU + {5DAA7398-7822-44A5-993B-D595A6921D50}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {5DAA7398-7822-44A5-993B-D595A6921D50}.Release|iPhoneSimulator.Build.0 = Release|Any CPU {61F00129-88E6-460D-8D52-407C794A0D9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {61F00129-88E6-460D-8D52-407C794A0D9E}.Debug|Any CPU.Build.0 = Debug|Any CPU {61F00129-88E6-460D-8D52-407C794A0D9E}.Debug|iPhone.ActiveCfg = Debug|Any CPU @@ -91,6 +105,18 @@ Global {68E5289F-6819-4757-812B-6D7AAF78FD7B}.Release|iPhone.Build.0 = Release|Any CPU {68E5289F-6819-4757-812B-6D7AAF78FD7B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {68E5289F-6819-4757-812B-6D7AAF78FD7B}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {CAA8B410-05A3-4F2C-89F0-031806199D19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CAA8B410-05A3-4F2C-89F0-031806199D19}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CAA8B410-05A3-4F2C-89F0-031806199D19}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {CAA8B410-05A3-4F2C-89F0-031806199D19}.Debug|iPhone.Build.0 = Debug|Any CPU + {CAA8B410-05A3-4F2C-89F0-031806199D19}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {CAA8B410-05A3-4F2C-89F0-031806199D19}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {CAA8B410-05A3-4F2C-89F0-031806199D19}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CAA8B410-05A3-4F2C-89F0-031806199D19}.Release|Any CPU.Build.0 = Release|Any CPU + {CAA8B410-05A3-4F2C-89F0-031806199D19}.Release|iPhone.ActiveCfg = Release|Any CPU + {CAA8B410-05A3-4F2C-89F0-031806199D19}.Release|iPhone.Build.0 = Release|Any CPU + {CAA8B410-05A3-4F2C-89F0-031806199D19}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {CAA8B410-05A3-4F2C-89F0-031806199D19}.Release|iPhoneSimulator.Build.0 = Release|Any CPU {CCA3EAB7-9B83-4F48-9CBF-CA3155A5969F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CCA3EAB7-9B83-4F48-9CBF-CA3155A5969F}.Debug|Any CPU.Build.0 = Debug|Any CPU {CCA3EAB7-9B83-4F48-9CBF-CA3155A5969F}.Debug|iPhone.ActiveCfg = Debug|Any CPU diff --git a/ApplicationInsightsXamarinSDK/DemoApp/Droid/XamarinTest.Droid.csproj b/ApplicationInsightsXamarinSDK/DemoApp/Droid/XamarinTest.Droid.csproj index d35cf2a..baf9922 100644 --- a/ApplicationInsightsXamarinSDK/DemoApp/Droid/XamarinTest.Droid.csproj +++ b/ApplicationInsightsXamarinSDK/DemoApp/Droid/XamarinTest.Droid.csproj @@ -25,8 +25,8 @@ DEBUG; prompt 4 - None false + None full @@ -36,6 +36,7 @@ 4 false false + Full @@ -94,13 +95,17 @@ + + {25DFBE50-3DE9-402E-B6E0-C089F1425B45} + AI.XamarinSDK.Android + {68E5289F-6819-4757-812B-6D7AAF78FD7B} DummyLibrary.Android - - {25DFBE50-3DE9-402E-B6E0-C089F1425B45} - AI.XamarinSDK.Android + + {5DAA7398-7822-44A5-993B-D595A6921D50} + AI.XamarinSDK.Abstractions \ No newline at end of file diff --git a/ApplicationInsightsXamarinSDK/DemoApp/UITests/XamarinTest.UITests.csproj b/ApplicationInsightsXamarinSDK/DemoApp/UITests/XamarinTest.UITests.csproj index 80f53a5..fecdf47 100644 --- a/ApplicationInsightsXamarinSDK/DemoApp/UITests/XamarinTest.UITests.csproj +++ b/ApplicationInsightsXamarinSDK/DemoApp/UITests/XamarinTest.UITests.csproj @@ -43,20 +43,6 @@ - - - {E8CEA150-C65D-4C92-B24B-C4C292B2FF7C} - XamarinTest.iOS - False - False - - - {2DE004DF-68B0-40D8-B1E1-0195FB694550} - XamarinTest.Droid - False - False - - diff --git a/ApplicationInsightsXamarinSDK/DemoApp/XamarinTest.cs b/ApplicationInsightsXamarinSDK/DemoApp/XamarinTest.cs index 28f604a..3359a67 100644 --- a/ApplicationInsightsXamarinSDK/DemoApp/XamarinTest.cs +++ b/ApplicationInsightsXamarinSDK/DemoApp/XamarinTest.cs @@ -1,13 +1,10 @@ using System; using Xamarin.Forms; -using AI.XamarinSDK; - -#if __ANDROID__ -using Android; -#endif +using AI.XamarinSDK.Abstractions; namespace XamarinTest { + public class App : Application { public App () @@ -18,18 +15,17 @@ public App () protected override void OnStart () { - #if __IOS__ - - ApplicationInsights.Setup (""); + string iKey = null; + Device.OnPlatform( + Android: () =>{ + iKey = ""; + }, + iOS: () =>{ + iKey = ""; + } + ); + ApplicationInsights.Setup (iKey); ApplicationInsights.Start (); - - #elif __ANDROID__ - - Android.App.Application app = ((Android.App.Activity)Forms.Context).Application; - ApplicationInsights.Setup (Android.App.Application.Context, app, ""); - ApplicationInsights.Start (); - - #endif } protected override void OnSleep () @@ -41,6 +37,7 @@ protected override void OnResume () { // Handle when your app resumes } + } } diff --git a/ApplicationInsightsXamarinSDK/DemoApp/XamarinTestMasterView.cs b/ApplicationInsightsXamarinSDK/DemoApp/XamarinTestMasterView.cs index 182e506..63f5f8b 100644 --- a/ApplicationInsightsXamarinSDK/DemoApp/XamarinTestMasterView.cs +++ b/ApplicationInsightsXamarinSDK/DemoApp/XamarinTestMasterView.cs @@ -1,6 +1,6 @@ using System; using Xamarin.Forms; -using AI.XamarinSDK; +using AI.XamarinSDK.Abstractions; using System.Collections.Generic; namespace XamarinTest diff --git a/ApplicationInsightsXamarinSDK/DemoApp/iOS/AppDelegate.cs b/ApplicationInsightsXamarinSDK/DemoApp/iOS/AppDelegate.cs index 7a43800..84cb64b 100644 --- a/ApplicationInsightsXamarinSDK/DemoApp/iOS/AppDelegate.cs +++ b/ApplicationInsightsXamarinSDK/DemoApp/iOS/AppDelegate.cs @@ -18,7 +18,7 @@ public override bool FinishedLaunching (UIApplication app, NSDictionary options) // #if ENABLE_TEST_CLOUD // Xamarin.Calabash.Start(); // #endif - + AI.XamarinSDK.iOS.ApplicationInsights.Init(); LoadApplication (new App ()); return base.FinishedLaunching (app, options); } diff --git a/ApplicationInsightsXamarinSDK/DemoApp/iOS/XamarinTest.iOS.csproj b/ApplicationInsightsXamarinSDK/DemoApp/iOS/XamarinTest.iOS.csproj index 2f386cd..9f4fee9 100644 --- a/ApplicationInsightsXamarinSDK/DemoApp/iOS/XamarinTest.iOS.csproj +++ b/ApplicationInsightsXamarinSDK/DemoApp/iOS/XamarinTest.iOS.csproj @@ -49,7 +49,6 @@ 4 i386 false - None iPhone Developer true @@ -135,13 +134,17 @@ + + {4B57344D-C4B3-44F8-8E15-CC5B3AF1CC24} + AI.XamarinSDK.iOS + {CCA3EAB7-9B83-4F48-9CBF-CA3155A5969F} DummyLibrary.iOS - - {4B57344D-C4B3-44F8-8E15-CC5B3AF1CC24} - AI.XamarinSDK.iOS + + {5DAA7398-7822-44A5-993B-D595A6921D50} + AI.XamarinSDK.Abstractions \ No newline at end of file diff --git a/ApplicationInsightsXamarinSDK/DemoApp/iOS/XamarinTest.iOS.sln b/ApplicationInsightsXamarinSDK/DemoApp/iOS/XamarinTest.iOS.sln new file mode 100644 index 0000000..4de9514 --- /dev/null +++ b/ApplicationInsightsXamarinSDK/DemoApp/iOS/XamarinTest.iOS.sln @@ -0,0 +1,23 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamarinTest.iOS", "XamarinTest.iOS.csproj", "{E8CEA150-C65D-4C92-B24B-C4C292B2FF7C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|iPhoneSimulator = Debug|iPhoneSimulator + Release|iPhone = Release|iPhone + Release|iPhoneSimulator = Release|iPhoneSimulator + Debug|iPhone = Debug|iPhone + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E8CEA150-C65D-4C92-B24B-C4C292B2FF7C}.Debug|iPhone.ActiveCfg = Debug|iPhone + {E8CEA150-C65D-4C92-B24B-C4C292B2FF7C}.Debug|iPhone.Build.0 = Debug|iPhone + {E8CEA150-C65D-4C92-B24B-C4C292B2FF7C}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator + {E8CEA150-C65D-4C92-B24B-C4C292B2FF7C}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator + {E8CEA150-C65D-4C92-B24B-C4C292B2FF7C}.Release|iPhone.ActiveCfg = Release|iPhone + {E8CEA150-C65D-4C92-B24B-C4C292B2FF7C}.Release|iPhone.Build.0 = Release|iPhone + {E8CEA150-C65D-4C92-B24B-C4C292B2FF7C}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator + {E8CEA150-C65D-4C92-B24B-C4C292B2FF7C}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator + EndGlobalSection +EndGlobal diff --git a/NOTES.md b/NOTES.md new file mode 100644 index 0000000..368f424 --- /dev/null +++ b/NOTES.md @@ -0,0 +1,15 @@ +# Release Notes + +## 1.0-alpha.2 +* Add NuGet support +* Prevent linker from stripping SDK assemblies (release builds on iOS) +* Align public interface (remove additional parameters of setup()-method on Android) +* Add license and release notes + +## 1.0-alpha.1 +* Android and iOS support + * **Auto collection** (sessions and page views) + * **Tracking of telemetry** data (events, metrics, traces, page views, and handled exceptions) + * **Crash reporting** for both managed and unmanaged unhandled exceptions +* Support for plattform specific as well as shared projects +* Demo project added \ No newline at end of file diff --git a/README.md b/README.md index 0623c19..7149cf4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Application Insights for Xamarin (1.0-alpha.1) +# Application Insights for Xamarin (1.0-alpha.2) This project provides an Xamarin SDK for Application Insights. [Application Insights](http://azure.microsoft.com/en-us/services/application-insights/) is a service that allows developers to keep their applications available, performing, and succeeding. This SDK allows your Xamarin apps to send telemetry of various kinds (events, traces, exceptions, etc.) to the Application Insights service where your data can be visualized in the Azure Portal. Currently, we provide support for iOS and Android. @@ -12,8 +12,9 @@ This project provides an Xamarin SDK for Application Insights. [Application Insi 7. [Automatic Collection of Lifecycle Events](#7) 8. [Exception Handling (Crashes)](#8) 9. [Additional configuration](#9) -10. [Troubleshooting](#10) -11. [Contact](#11) +10. [Integrate plugin sources](#10) +11. [Troubleshooting](#11) +12. [Contact](#12) ## 1. Requirements @@ -29,121 +30,70 @@ Older versions might work, but haven't been tested. ## 2. Release Notes -* Android and iOS support - * **Auto collection** (sessions and page views) - * **Tracking of telemetry** data (events, metrics, traces, page views, and handled exceptions) - * **Crash reporting** for both managed and unmanaged unhandled exceptions -* Support for plattform specific as well as shared projects -* Demo project added +Also see changes in [older versions](NOTES.md). +* Add NuGet support +* Prevent linker from stripping SDK assemblies (release builds on iOS) +* Align public interface (remove additional parameters of setup()-method on Android) +* Add license and release notes -## 3. Breaking Changes & deprecations - -## 4. Setup -This is the recommended way to setup Application Insights for your Xamarin app. We're assuming you are using Xamarin Studio to create your apps. +## 3. Breaking Changes & deprecations -### 4.1 **Add SDK sources to your Xamarin solution** +* `Using` statement changed: `using AI.XamarinSDK.Abstractions;` +* `setup()`-method for Android changed: As on iOS this method only takes the instrumentation key as parameter -Clone the repository in order to get the SDK sources. It contains 3 subfolder, one for a demo project (*DemoApp*) as well as its Dependencies (*packages*) and one for the SDK (*ApplicationInsightsXamarin*). - -Copy *ApplicationInsightsXamarin* to your solution directory. Open Xamarin Studio and add its projects to your solution. This can be done by right clicking the solution name in the solution panel, then click *Add* - *Add Existing Project...*: - -1. **AI.XamarinSDK** -2. **AI.XamarinSDK.iOS** *(only needed for iOS support)* -3. **AI.XamarinSDK.Android** & **AI.XamarinSDK.AndroidBindings** *(only needed for Android support)* - -[**Note**] In order to successfully build the SDK, you may have to update all referenced packages. Simply right click on the *Packages* folder of each of those projects and click *Update*. +## 4. Setup -### 4.2 **Add references to your app projects** +We're assuming you are using Xamarin Studio to create your apps. -#### Android +### 4.1 **Add SDK to your Xamarin solution** -1. In the solution panel, select the Android app project. -2. In the main menu go to *Project* - *Edit References*. -3. Select the *All* tab and check *AI.XamarinSDK.Android* -4. Confirm the change by clicking the *OK* button +Clone the repository in order to get the SDK sources. It contains 2 subfolder, one for a demo project (*DemoApp*) and one for the SDK (*ApplicationInsightsXamarin*). -#### iOS +There are several ways to integrate the Application Insights Xamarin SDK into your app. The recommend way is to use the NuGet-package. However, you can also integrate the SDK by importing the sources. -1. In the solution panel, select the iOS app project. -2. In the main menu go to *Project* - *Edit References*. -3. Select the *All* tab and check *AI.XamarinSDK.iOS* -4. Confirm the change by clicking the *OK* button +1. Expand one of your platform projects inside the solution panel +2. Right click the **Packages** folder and select ***Add Packages...*** +3. [Configure a local package source](http://developer.xamarin.com/guides/cross-platform/application_fundamentals/nuget_walkthrough/) and let it point to +*ApplicationInsightsXamarin/NuGet* +4. Choose the local package source in the sources dropdown +4. Check the **Show pre-release packages** and select **ApplicationInsights SDK for Xamarin-Forms** +5. Click the **Add Package** button +6. Repeat those steps for all other platform projects -### 4.3 Configure the instrumentation key +### 4.2 Configure the instrumentation key Please see the "[Getting an Application Insights Instrumentation Key](https://github.com/Microsoft/ApplicationInsights-Home/wiki#getting-an-application-insights-instrumentation-key)" section of the wiki for more information on acquiring a key. -### 4.4 Add code to setup and start Application Insights - -You can setup and start the Application Insights Xamarin SDK in different ways. - -#### Option 1: Application class (Xamarin.Forms, shared project) - -1. Open the application class inside the shared app project (*project_name*.cs) -2. Add using statements - - ```csharp - using AI.XamarinSDK; - - #if __ANDROID__ - using Android; - #endif - ``` - -3. Add the following lines of code to the `OnStart ()` method to support both platforms. - - ```csharp - #if __IOS__ - - ApplicationInsights.Setup (""); - ApplicationInsights.Start (); - - #elif __ANDROID__ - - Android.App.Application app = ((Android.App.Activity)Forms.Context).Application; - ApplicationInsights.Setup (Android.App.Application.Context, app, ""); - ApplicationInsights.Start (); +### 4.3 Add code to setup and start Application Insights - #endif - ``` - -4. Replace ``with the instrumentation key of your app. - -#### Option 2: AppDelegate.cs (iOS project) - -1. Open *AppDelegate.cs* inside the iOS app project +1. Depending on the plattforms you want to support, you can setup and start the Application Insights Xamarin SDK in different files: + * **Xamarin.Forms** (Android & iOS): Application class (e.g. *project_name*.cs in the apps shared project + * **iOS only**: AppDelegate.cs in your iOS platform project + * **Android only**: Main Activity of your Android platform project 2. Add using statements ```csharp - using AI.XamarinSDK; + using AI.XamarinSDK.Abstractions; ``` -3. Add the following lines of code to the `FinishedLaunching ()` method +3. Add the following lines of code to on of the following methods + * **Xamarin.Forms** (Android & iOS): `OnStart ()` + * **iOS only**: `FinishedLaunching()` + * **Android only**: `OnStart ()` - ```csharp - ApplicationInsights.Setup (""); - ApplicationInsights.Start (); - ``` -4. Replace ``with the instrumentation key of your app. - -#### Option 3: MainActivity (Android project) - -1. Open your main activity (e.g. *MainActivity.cs*) inside the Android app project -2. Add using statements - - ```csharp - using AI.XamarinSDK; - ``` + ```csharp + ApplicationInsights.Setup (""); + ApplicationInsights.Start (); + ``` -3. Add the following lines of code to the `OnCreate ()` method right after `SetContentView (Resource.Layout.Main);` - - ```csharp - ApplicationInsights.Setup (this.ApplicationContext, this.Application, ""); - ApplicationInsights.Start (); - ``` + * **[NOTE]**: If you plan to support *iOS* you currently need to make a direct call to the iOS assembly so that it doesn't get stripped by the linker. Add the following line right after the Xamarin.Forms init()-call inside the `FinsihedLaunching()` of your **AppDelegate.cs** + ```csharp + AI.XamarinSDK.iOS.ApplicationInsights.Init(); + ``` + 4. Replace ``with the instrumentation key of your app. **Congratulation, now you're all set to use Application Insights! See [Usage](#6) on how to use Application Insights.** @@ -155,8 +105,7 @@ The **developer mode** is enabled automatically in case the debugger is attached You can explicitly enable/disable the developer mode like this: ```csharp -ApplicationInsights.SetDeveloperMode(false); - +ApplicationInsights.SetDebugLogEnabled(false); ``` ## 6. Basic Usage ## @@ -202,11 +151,7 @@ Auto collection is **enabled by default**. However, you can disable automatic pa ### Android -To support the auto collection feature make sure the min SDK of your app is at least API level 14. Also don't forget to provide an Application instance when setting up Application Insights (otherwise auto collection will be disabled): - -```csharp -ApplicationInsights.Setup(this.getApplicationContext(), this.getApplication()); -``` +To support the auto collection feature make sure the min SDK of your app is at least API level 14. [**NOTE**] Only 'Activity' instances will be recognized by auto collection. Note that using e.g. `Navigation.PushAsync()` within a Xamarin.Forms page will replace a `Fragment`. However, you can programmatically [track a page view](#6) in situations like this. @@ -269,8 +214,39 @@ ApplicationInsights.SetUserId("User371263"); ApplicationInsights.RenewSession("New session ID"); ``` [**NOTE**] If you want to manage sessions manually, please disable [Automatic Collection of Lifecycle Events](#7). - -## 10. Troubleshooting + +## 10. Integrate plugin sources + +There are several ways to integrate the Application Insights Xamarin SDK into your app. The recommend way is to use the NuGet-package. However, you can also integrate the SDK by importing the sources: + +1. Copy *ApplicationInsightsXamarin* to your solution directory. +2. Open Xamarin Studio and add its projects to your solution. This can be done by right clicking the solution name in the solution panel, then click *Add* - *Add Existing Project...*: + + * **AI.XamarinSDK** + * **AI.XamarinSDK.iOS** *(only needed for iOS support)* + * **AI.XamarinSDK.Android** & **AI.XamarinSDK.AndroidBindings** *(only needed for Android support)* + + [**Note**] In order to successfully build the SDK, you may have to update all referenced packages. Simply right click on the *Packages* folder of each of those projects and click *Update*. + +3. Add references to your app projects + + * **Android** + + 1. In the solution panel, select the Android app project. + 2. In the main menu go to *Project* - *Edit References*. + 3. Select the *All* tab and check *AI.XamarinSDK.Android*. + 4. Confirm the change by clicking the *OK* button. + + * **iOS** + + 1. In the solution panel, select the iOS app project. + 2. In the main menu go to *Project* - *Edit References*. + 3. Select the *All* tab and check *AI.XamarinSDK.iOS*. + 4. Confirm the change by clicking the *OK* button + + 4. Follow instructions in [4.2](#4).. + +## 11. Troubleshooting ### SDK references broken @@ -278,8 +254,11 @@ In order to successfully build the SDK, you may have to update all referenced pa ### iOS App crashes immediately after start -Please right click on the iOS project and select *Options*. Go to *Build* - *iOS Build* - *General*. Set the *Linker behaviour* to ` -Don't link`. -## 11. Contact +If you plan to support *iOS* you currently need to make a direct call to the iOS assembly so that it doesn't get stripped by the linker. Add the following line right after the Xamarin.Forms init()-call inside the `FinsihedLaunching()` of your **AppDelegate.cs** + +```csharp +AI.XamarinSDK.iOS.ApplicationInsights.Init(); +``` +## 12. Contact If you have further questions or are running into trouble that cannot be resolved by any of the steps here, feel free to contact us at [AppInsights-Xamarin@microsoft.com](mailto:AppInsights-Xamarin@microsoft.com)