Skip to content

Instantly share code, notes, and snippets.

@colbylwilliams
Created November 28, 2016 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colbylwilliams/574e7c49b37491c16d5a763466340e23 to your computer and use it in GitHub Desktop.
Save colbylwilliams/574e7c49b37491c16d5a763466340e23 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using UIKit;
using HockeyApp.iOS;
namespace AppToTrack.iOS
{
[Register ("AppDelegate")]
public class AppDelegate : UIApplicationDelegate
{
public override UIWindow Window { get; set; }
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{
var startTicks = Environment.TickCount;
var manager = BITHockeyManager.SharedHockeyManager;
manager.Configure (PrivateKeys.HockeyApp.iOS);
manager.DisableCrashManager = false;
manager.DisableUpdateManager = false;
manager.DisableMetricsManager = false;
manager.DisableInstallTracking = false;
manager.StartManager ();
// stuff
trackEvent ("LaunchTime", null, new Dictionary<string, double> { { "ticks", Environment.TickCount - startTicks } });
return true;
}
void trackEvent (string eventName, Dictionary<string, string> properties, Dictionary<string, double> measurements)
{
NSMutableDictionary<NSString, NSString> nsProperties = null;
if (properties != null)
nsProperties = new NSMutableDictionary<NSString, NSString> (
properties.Keys.Select (k => new NSString (k)).ToArray (),
properties.Values.Select (v => new NSString (v)).ToArray ());
NSMutableDictionary<NSString, NSNumber> nsMeasurements = null;
if (measurements != null)
nsMeasurements = new NSMutableDictionary<NSString, NSNumber> (
measurements.Keys.Select (k => new NSString (k)).ToArray (),
measurements.Values.Select (v => new NSNumber (v)).ToArray ());
BITHockeyManager.SharedHockeyManager.MetricsManager.MetricsManager.TrackEvent (eventName, nsProperties, nsMeasurements);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment