Windows integration
Prerequisites
- UWP apps
- WinUI apps
- Make sure that your UWP or WinUI app targets version is not less than Windows 10 Build 16299 (Fall Creators Update, version 1709)
Add the SDK to your app
- Before you can add Zoho Apptics to your UWP app, you need to create a Project and add your app.
- Download the apptics-config.json, and add it to your root project.
- Change the build action property of JSON file into an embedded resource.
- Right-click on the apptics-config.json file and select Properties.
- Change the build action to an embedded Resource.
- Add a class file named "AppticsInterface.cs" in the project root.
- Download the Apptics windows library from this link, you will get a zip file. Extract the files.
For UWP apps
- Add reference to "AppticsUwpBase.dll" , "AppticsWindowsBase.dll",and "AppticsAnalytics.dll".
- Add more references like "AppticsAppUpdate.dll", if you want to use the in-app update feature.
For WinUI apps
- Add reference to "WinUISDKBase.dll", "AppticsWindowsBase.dll", and "WinUIAppticsAnalytics.dll".
- Add more references like "WinUIAppticsInAppUpdate.dll", if you want to use the in-app update feature.
- Add the following packages from NuGet.
- "System.Json" 4.4 or latest
- "JWT" 8.2.3 or latest
- Build the project, then go for the next step to add a build event.
For UWP apps
For WinUI apps
Post Build event to complete integration
For UWP apps
- Copy the "AppticsCommand.exe" file to any folder ("C:\TempReferences" ), here "TempReferences" is a folder in "C" drive. This can be in any folder on your computer.
- Open the project properties > Build Events > Post build event > add the following command.
- "C:\TempReferences\AppticsCommand $(ProjectDir) $(ProjectPath) $(TargetDir)"
- Build your project.
- After a successful build, apptics-config.json, and AppticsInterface.cs should be updated with the latest values from the server. This indicates that your project is almost ready.
For WinUI apps
- Keep the "AppticsCommandForWinUI" file along with the "System.json.dll" to any folder ("C:\TempReferences" ), here "TempReferences" is a folder in "C" drive. This can be in any folder on your computer.
- Open the project properties > Build Events > Post build event > add the following command.
- "C:\TempReferences\AppticsCommandForWinUI $(TargetDir) D:\Test\Demo\DemoWindowsAppSdk\Package.appxmanifest apptics-config.json $(ProjectDir) $(ProjectPath) 10.0.16299.0".
// $(TargetDir)-output dir -"D:\Test\Demo\DemoWindowsAppSdk\DemoWindowsApp\bin\x86\Debug\"
// manifest path with name - "D:\Test\Demo\DemoWindowsAppSdk\DemoWindowsApp\Package.appxmanifest"
// config file name - "apptics-config.json"
// $(ProjectDir) - "D:\Test\Demo\DemoWindowsAppSdk\DemoWindowsApp\"
// $(ProjectPath) -"D:\Test\Demo\DemoWindowsAppSdk\DemoWindowsApp\DemoWindowsApp.csproj"
// min os version(optional)- "10.0.16299.0"
- Build your project.
- After a successful build, apptics-config.json and AppticsInterface.cs should be updated with the latest values from the server. This indicates that the project is ready.
Integrate Apptics with your code
For UWP apps
- Open your app App.xaml.cs file and go to OnLaunched event (create if not), and add the following line of code, below your frame register.
CopiedAppticsUwpBase.Initializer.Instance.Init(this, (int)AppticsMode.Development, AnonymityType.PseudoAnonymous, true);
Params:
- application: The UWP application instance
- mode: Supported modes i.e. 0 - Development, 1 - Production, and 2 - Testing
- anonymity type: None - Will only track with the user identity; Pseudoanonymous - Will be tracked with or without user identity
- defaultTrackingState: True - To track before getting user consent; False - To track after getting user consent
Copied SessionDurationOption sessionDurationOption = new SessionDurationOption();
sessionDurationOption.MinimumSessionDuration = AppticsWindowsBase.Enum.MinimumSessionDuration.FifteenSeconds;
sessionDurationOption.MaxSessionDuration = AppticsWindowsBase.Enum.MaxSessionDuration.Ten;
await AppticsUwpBase.Initializer.Instance.Init(this, AnonymityType.PseudoAnonymous, true, sessionDurationOption, UseCustomLifeCyclEventsForApptics);
For WinUI apps
- Open your app's MainWindow.xaml.cs > MainWindow_Activated event (create this if not available). Add the below code.
Copiedprivate async void MainWindow_Activated(object sender, Microsoft.UI.Xaml.WindowActivatedEventArgs args)
{
SessionDurationOption sessionDurationOption = new SessionDurationOption();
await WinUISdkBase.Initializer.Instance.Init(App.Current, this, AppticsWindowsBase.Enum.AnonymityType.PseudoAnonymous, true, sessionDurationOption, false);
}
Params:
- application instance
- Windows - MainWindows
- defaultTrackingState: True - to track before getting user consent; False - to track after getting user consent.
- Add the below code to your MainWindows.xaml.cs constructor to enable screen tracking by default. This will track all the page navigation inside the given frame.
Copiedpublic MainWindow()
{
this.InitializeComponent();
Activated += MainWindow_Activated;
this.Content = mainFrame = frameMain;
WinUIAppticsAnalytics.Tracker.OnNewFrameLaunch(frameMain); // code need to be added
frameMain.Navigate(typeof(BlankPage1));
}