C# Класс CSharpAnalytics.AutoMeasurement

Helper class to get up and running with CSharpAnalytics in WindowsStore applications. Either use as-is by calling StartAsync, Attach and StopAsync from your App.xaml.cs or use as a starting point to wire up your own way.
Показать файл Открыть проект

Private Properties

Свойство Тип Описание
Add void
AddUserAgent void
ApplicationOnResuming void
ApplicationOnSuspending void
DebugRequest void
FrameNavigated void
GetScreenName string
HookEvents void
IsInternetAvailable bool
LoadSessionState Task
PreprocessHttpRequest void
RejoinPayload Task
SaveSessionState System.Threading.Tasks.Task
StartRequesterAsync System.Threading.Tasks.Task
SuspendRequesterAsync System.Threading.Tasks.Task
TrackFrameNavigate void
UnhookEvents void

Открытые методы

Метод Описание
Attach ( Frame frame ) : void

Attach to the root frame, hook into the navigation event and track initial page appview. Call this just before Window.Current.Activate() in your App.OnLaunched method.

SetOptOut ( bool optOut ) : void

Opt the user in or out of analytics for this application install.

This option persists automatically. You should call this only when the user changes their decision.

StartAsync ( MeasurementConfiguration configuration, IActivatedEventArgs launchArgs, TimeSpan uploadInterval = null ) : System.Threading.Tasks.Task

Initialize CSharpAnalytics by restoring the session state and starting the background sender and tracking the application lifecycle start event.

Приватные методы

Метод Описание
Add ( Uri uri ) : void

Send the Uri request to the current background requester safely.

AddUserAgent ( ICollection userAgents ) : void

Figure out the user agent and add it to the header collection.

ApplicationOnResuming ( object sender, object o ) : void

Handle application resuming from suspend without shutdown.

ApplicationOnSuspending ( object sender, SuspendingEventArgs suspendingEventArgs ) : void

Handle application suspending.

DebugRequest ( HttpRequestMessage requestMessage ) : void

Send the HttpRequestMessage with the protocol debugger for examination.

FrameNavigated ( object sender, NavigationEventArgs e ) : void

Receive navigation events to translate them into analytics page views.

Implement IAnalyticsPageView if your pages look up content so you can track better detail from the end of your LoadState method.

GetScreenName ( Type page ) : string

Determine the screen name of a page to track.

HookEvents ( ) : void

Hook into various events to automatically track suspend, resume, page navigation, social sharing etc.

IsInternetAvailable ( ) : bool

Determine if the Internet is available at this point in time.

LoadSessionState ( ) : Task

Load the session state from storage if it exists, null if it does not.

PreprocessHttpRequest ( HttpRequestMessage requestMessage ) : void

Pre-process the HttpRequestMessage before it is sent. This includes adding the user agent for tracking and for debug builds writing out the debug information to the console log.

Because user agent is not persisted unsent URIs that are saved and then sent after an upgrade will have the new user agent string not the actual one that generated them.

RejoinPayload ( HttpRequestMessage requestMessage ) : Task

Rejoin the POST body payload with the Uri parameter if necessary so it can be sent to the protocol debugger.

SaveSessionState ( SessionState sessionState ) : System.Threading.Tasks.Task

Save the session state to preserve state between application launches.

StartRequesterAsync ( ) : System.Threading.Tasks.Task

Start the requester with any unsent URIs from the last application run.

SuspendRequesterAsync ( ) : System.Threading.Tasks.Task

Suspend the requester and preserve any unsent URIs.

TrackFrameNavigate ( Type page ) : void

Track an app view if it does not track itself.

UnhookEvents ( ) : void

Unhook events that were wired up in HookEvents.

Not actually used in AutoMeasurement but here to show you what to do if you wanted to.

Описание методов

Attach() публичный статический Метод

Attach to the root frame, hook into the navigation event and track initial page appview. Call this just before Window.Current.Activate() in your App.OnLaunched method.
public static Attach ( Frame frame ) : void
frame Windows.UI.Xaml.Controls.Frame
Результат void

SetOptOut() публичный статический Метод

Opt the user in or out of analytics for this application install.
This option persists automatically. You should call this only when the user changes their decision.
public static SetOptOut ( bool optOut ) : void
optOut bool True if the user is opting out, false if they are opting back in.
Результат void

StartAsync() публичный статический Метод

Initialize CSharpAnalytics by restoring the session state and starting the background sender and tracking the application lifecycle start event.
public static StartAsync ( MeasurementConfiguration configuration, IActivatedEventArgs launchArgs, TimeSpan uploadInterval = null ) : System.Threading.Tasks.Task
configuration MeasurementConfiguration Configuration to use, must at a minimum specify your Google Analytics ID and app name.
launchArgs IActivatedEventArgs Launch arguments from your Application OnLaunched to determine how the app was launched.
uploadInterval TimeSpan How often to upload to the server. Lower times = more traffic but realtime. Defaults to 5 seconds.
Результат System.Threading.Tasks.Task