public void LogViewModel(string viewModelName)
        {
            var appView = GAIDictionaryBuilder.CreateScreenView();

            appView.Set(viewModelName, GAIConstants.ScreenName);
            Trackers.ForEach(x => x.Send(appView.Build()));
        }
Beispiel #2
0
        async private void SaveItinerary()
        {
            UserTripDataManager userTripManager = new UserTripDataManager();
            iOSLoginManager     loginManager    = iOSLoginManager.Instance;

            string origin       = Criteria.GetStartLocationString();
            string destination  = Criteria.GetEndLocationString();
            string prioritycode = "1";
            bool   isWheelchair = false;
            bool   isBike       = false;

            int  travelerId = loginManager.GetTravelerId();
            bool didSave    = await userTripManager.SaveTripForUser(travelerId, ItineraryToShow, origin, destination, prioritycode, isWheelchair, isBike);

            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("ui_action", "save trip", "save trip", didSave).Build());

            if (didSave)
            {
                this.NavigationController.PopToRootViewController(false);
            }
            else
            {
                UIAlertView alert = new UIAlertView("Not Saved", "Error saving trip.  Please try again.", null, "OK", null);
                alert.Show();
            }
        }
Beispiel #3
0
        protected override void StartNewSession()
        {
            var builder = GAIDictionaryBuilder.CreateAppView();

            builder.Set("start", GAIConstants.SessionControl);
            SendHit(builder);
        }
        public override void TrackView(string viewName)
        {
            var tracker = TrackerService.Instance.GetTracker(Configuration);

            tracker.Set(GAIConstants.ScreenName, viewName);
            tracker.Send(GAIDictionaryBuilder.CreateScreenView().Build());
        }
        public void LogException(string className, string methodName, Exception e, bool isFatal = false)
        {
            var exception = GAIDictionaryBuilder.CreateException(
                className + ":" + methodName + ": " + e.Message,
                NSNumber.FromBoolean(isFatal));

            Trackers.ForEach(x => x.Send(exception.Build()));
        }
Beispiel #6
0
        /*public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
         * {
         *      ProcessNotification(userInfo, false);
         * }*/

        void ProcessNotification(NSDictionary options, bool fromFinishedLaunching, UIApplicationState appState)
        {
            // Check to see if the dictionary has the aps key.  This is the notification payload you would have sent
            if (null != options && options.ContainsKey(new NSString("aps")))
            {
                //Get the aps dictionary
                NSDictionary aps = options.ObjectForKey(new NSString("aps")) as NSDictionary;

                string alert = string.Empty;

                //Extract the alert text
                //NOTE: If you're using the simple alert by just specifying "  aps:{alert:"alert msg here"}  "
                //this will work fine.  But if you're using a complex alert with Localization keys, etc.,
                //your "alert" object from the aps dictionary will be another NSDictionary... Basically the
                //json gets dumped right into a NSDictionary, so keep that in mind
                if (aps.ContainsKey(new NSString("alert")))
                {
                    alert = (aps [new NSString("alert")] as NSString).ToString();

                    int tripid = -1;
                    if (aps.ContainsKey(new NSString("tripid")))
                    {
                        tripid = (aps [new NSString("tripid")] as NSNumber).IntValue;
                    }


                    //If this came from the ReceivedRemoteNotification while the app was running,
                    // we of course need to manually process things like the sound, badge, and alert.
                    if (!fromFinishedLaunching)
                    {
                        //Manually show an alert
                        if (!string.IsNullOrEmpty(alert))
                        {
                            if (NotificationAlertView != null)
                            {
                                NotificationAlertView.DismissWithClickedButtonIndex(0, false);
                            }

                            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("app_action", "notifications", "alert", null).Build());

                            NotificationAlertView = new UIAlertView("Notification", alert, null, "OK", null);
                            NotificationAlertView.Show();
                        }
                    }
                }

                if (aps.ContainsKey(new NSString("content-available")))
                {
                    GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("app_action", "notifications", "content-available", null).Build());
                    //TODO get list of times to send location
                    //backgroundTaskId = UIApplication.SharedApplication.BeginBackgroundTask( () => {});
                    DurationToSendLocation_Sec = (aps [new NSString("content-available")] as NSNumber).IntValue;
                    //NSTimer locationTimer = NSTimer.CreateScheduledTimer (TimeSpan.FromSeconds (60), delegate {
                    MonitorLocation(appState);
                    //});
                }
            }
        }
Beispiel #7
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            var tracker = ServiceContainer.Resolve <IGAITracker> ();

            tracker.Set(GAIConstants.ScreenName, "Welcome View");
            tracker.Send(GAIDictionaryBuilder.CreateAppView().Build());
        }
Beispiel #8
0
        public async override void ViewDidAppear(bool animated)
        {
            String className = this.GetType().Name;

            GAI.SharedInstance.DefaultTracker.Set(GAIConstants.ScreenName, className);
            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateAppView().Build());

            base.ViewDidAppear(animated);
        }
Beispiel #9
0
 public void LogEvent(string category, string action, string label)
 {
                 #if !DEBUG
     if (GAI.SharedInstance.DefaultTracker == null)
     {
         return;
     }
     GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent(category, action, label, null).Build());
                 #endif
 }
Beispiel #10
0
 protected override void SendTiming(long elapsedMilliseconds, string category, string variable, string label)
 {
     SendHit(GAIDictionaryBuilder.CreateTiming(category, elapsedMilliseconds, variable, label));
     if (Insights.IsInitialized)
     {
         Insights.Track("AppStartupTime", new Dictionary <string, string>  {
             { "ElapsedTime", elapsedMilliseconds.ToString() + "ms" }
         });
     }
 }
Beispiel #11
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);
            nameTextField.BecomeFirstResponder();

            var tracker = ServiceContainer.Resolve <IGAITracker> ();

            tracker.Set(GAIConstants.ScreenName, "New Client View");
            tracker.Send(GAIDictionaryBuilder.CreateAppView().Build());
        }
Beispiel #12
0
        private void SendHit (GAIDictionaryBuilder builder)
        {
            // Inject custom dimensions, if any have been set:
            foreach (var kvp in customDimensions) {
                builder.Set (kvp.Value, GAIFields.CustomDimension ((uint)kvp.Key));
            }
            customDimensions.Clear ();

            tracker.Send (builder.Build ());
        }
Beispiel #13
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            // This screen name value will remain set on the tracker and sent with
            // hits until it is set to a new value or to null.
            GAI.SharedInstance.DefaultTracker.Set(GAIConstants.ScreenName, Category + " Category View");

            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateAppView().Build());
        }
Beispiel #14
0
        private void SendHit(GAIDictionaryBuilder builder)
        {
            // Inject custom dimensions, if any have been set:
            foreach (var kvp in customDimensions)
            {
                builder.Set(kvp.Value, GAIFields.CustomDimension((uint)kvp.Key));
            }
            customDimensions.Clear();

            tracker.Send(builder.Build());
        }
Beispiel #15
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            if (model == null)
            {
                newModel();
            }

            GAI.SharedInstance.DefaultTracker.Set(GAIConstants.ScreenName, "Main View");

            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateAppView().Build());
        }
Beispiel #16
0
        public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
        {
            base.PrepareForSegue(segue, sender);

            if (segue.Identifier == "PlanTripDetailsSegue")
            {
                GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("ui_action", "trip details", "trip details", null).Build());
                TripDetailsViewController vc = (TripDetailsViewController)segue.DestinationViewController;
                vc.ItineraryToShow = mSelectedItinerary;
                vc.Criteria        = SearchResults.searchCriteria;
            }
        }
        public override bool TrackPageView(string relativeUrl)
        {
            SystemLogger.Log(SystemLogger.Module.PLATFORM, "Tracking Page View: " + relativeUrl);
            if (this._tracker != null)
            {
                try {
                    UIApplication.SharedApplication.InvokeOnMainThread(delegate {
                        try {
                            /* deprecated - changes to compile with iOS 7
                             * NSError error;
                             * bool success = this._tracker.TrackPageView(relativeUrl, out error);
                             * this._tracker.Dispatch();
                             * if(!success){
                             *      SystemLogger.Log(SystemLogger.Module.PLATFORM, "error:" + error.ToString());
                             * } else {
                             *      SystemLogger.Log(SystemLogger.Module.PLATFORM, "Page View: " + relativeUrl);
                             * }
                             *
                             * bool success = SharedTracker().TrackView(relativeUrl);
                             * if(success){
                             *      SystemLogger.Log(SystemLogger.Module.PLATFORM, "Page View TRACKED: " + relativeUrl);
                             * } else {
                             *      SystemLogger.Log(SystemLogger.Module.PLATFORM, "Error tracking page view (without further error information)");
                             * }*/
                            // changes for ios 8 and new version 3.0.7
                            // v2 this._tracker.Set(GAIFields.ScreenName,relativeUrl);
                            //v3
                            this._tracker.Set(GAIConstants.ScreenName, relativeUrl);

                            this._tracker.Send(GAIDictionaryBuilder.CreateAppView().Build());
                        } catch (Exception e) {
                            SystemLogger.Log(SystemLogger.Module.PLATFORM, "Error tracking page view", e);
                        }
                    });
                    return(true);
                } catch (Exception e) {
                    SystemLogger.Log(SystemLogger.Module.PLATFORM, "Couldn't track analytics pageview [" + relativeUrl + "]", e);
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Beispiel #18
0
        async partial void SubmitRegistration(MonoTouch.Foundation.NSObject sender)
        {
            iOSLoginManager loginManager = iOSLoginManager.Instance;

            String username       = txtEmailAddress.Text;
            String password       = txtPassword.Text;
            String verifyPassword = txtVerifyPassword.Text;
            String firstName      = txtFirstName.Text;
            String lastName       = txtLastName.Text;



            if (String.IsNullOrEmpty(firstName) || String.IsNullOrEmpty(lastName) ||
                String.IsNullOrEmpty(verifyPassword) || String.IsNullOrEmpty(password) || String.IsNullOrEmpty(username))
            {
                UIAlertView alert = new UIAlertView("Error", "All fields are required", null, "OK", null);
                alert.Show();
            }
            else if (password != verifyPassword)
            {
                UIAlertView alert = new UIAlertView("Error", "Passwords don't match", null, "OK", null);
                alert.Show();
            }
            else
            {
                RegistrationApplicant regApp = new RegistrationApplicant(username, password, verifyPassword, firstName, lastName);

                LoginResult loginResult = await regApp.Register(loginManager);                 //await loginManager.Register(username, password, firstName, lastName);

                GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("ui_action", "register user", "register result", loginResult.Success).Build());

                if (loginResult.Success)
                {
                    if (RegisteredEvent != null)
                    {
                        RegisteredEvent();
                    }
                }
                else
                {
                    UIAlertView alert = new UIAlertView("Error", loginResult.ErrorString, null, "OK", null);
                    alert.Show();
                }
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Create a GA event and dispatch it to GA.
            NavigationItem.LeftBarButtonItem = new UIBarButtonItem("Dispatch", UIBarButtonItemStyle.Bordered, (s, e) => {
                var gaEvent = GAIDictionaryBuilder.CreateEvent("UI", "buttonPress", "dispatch", null).Build();
                GAI.SharedInstance.DefaultTracker.Send(gaEvent);
                GAI.SharedInstance.Dispatch();
                Console.WriteLine("Event Sent, Check Google's GA Event Console");
            });

            // Create a Crash
            NavigationItem.RightBarButtonItem = new UIBarButtonItem("Crash", UIBarButtonItemStyle.Bordered, (s, e) => {
                var obj = new NSObject();
                obj.PerformSelector(new Selector("doesNotRecognizeSelector"), obj, 0);
            });
        }
Beispiel #20
0
        public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
        {
            // NOTE: Don't call the base implementation on a Model class
            // see http://docs.xamarin.com/guides/ios/application_fundamentals/delegates,_protocols,_and_events

            Hub = new SBNotificationHub(Constants.ConnectionString, Constants.NotificationHubPath);
            this.DeviceToken = deviceToken;

            try{
                Hub.UnregisterAllAsync(deviceToken, (error) => {
                    if (error != null)
                    {
                        Console.WriteLine("Error calling Unregister: {0}", error.ToString());
                        return;
                    }


                    iOSLoginManager loginManager = iOSLoginManager.Instance;

                    string username   = loginManager.GetUsername();
                    string travelerId = loginManager.GetTravelerId().ToString();

                    string[] tagsArray = new string[2];
                    tagsArray[0]       = username;
                    tagsArray[1]       = travelerId;

                    NSSet tags = new NSSet(tagsArray);

                    Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => {
                        if (errorCallback != null)
                        {
                            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("app_action", "notifications", "notifications registration error", null).Build());
                            Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString());
                        }
                        else
                        {
                            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("app_action", "notifications launched", "notifications registration complete", null).Build());
                        }
                    });
                });
            }catch (Exception ex) {
                Console.WriteLine("Error" + ex.ToString());
            }
        }
Beispiel #21
0
        async partial void SubmitLogin(NSObject sender)
        {
            showLoading();


            iOSLoginManager loginManager = iOSLoginManager.Instance;

            String username = txtEmailAddress.Text;
            String password = txtPassword.Text;

            LoginResult loginResult = await loginManager.Login(username, password);

            dismissLoading();


            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("ui_action", "user login", "login result", Convert.ToInt32(loginResult.Success)).Build());

            if (loginResult.Success)
            {
                //check for terms acceptance
                AccountManager acm = new AccountManager();

                TravelerModel traveler = await acm.GetTravelerByEmail(username);

                if (!traveler.InformedConsent)
                {
                    PerformSegue("LoginTermsSegue", this);
                }
                else
                {
                    if (LoginEvent != null)
                    {
                        LoginEvent();
                    }
                }
            }
            else
            {
                UIAlertView alert = new UIAlertView("Error", loginResult.ErrorString, null, "OK", null);
                alert.Show();
            }
        }
        public override bool TrackEvent(string sGroup, string action, string label, int iValue)
        {
            SystemLogger.Log(SystemLogger.Module.PLATFORM, "Tracking event [" + sGroup + "-" + action + "-" + label + "-" + iValue);
            if (this._tracker != null)
            {
                try {
                    UIApplication.SharedApplication.InvokeOnMainThread(delegate {
                        try {
                            /* deprecated - changes to compile with iOS 7
                             * NSError error;
                             * this._tracker.TrackEvent(sGroup, action, label, iValue, out error);
                             * this._tracker.Dispatch();
                             */
                            // changes for ios 8 and new version 3.0.7
                            // v2 this._tracker.Send(GAIDictionaryBuilder.CreateEventWithCategory(sGroup,action,label,iValue).Build());
                            //v3
                            this._tracker.Send(GAIDictionaryBuilder.CreateEvent(sGroup, action, label, iValue).Build());

                            GAI.SharedInstance.Dispatch();

                            /*bool success = SharedTracker().TrackEvent(sGroup,action, label, iValue);
                             * if(success)  {
                             *      SystemLogger.Log(SystemLogger.Module.PLATFORM, "Event TRACKED [" + sGroup + "-" + action + "-" + label + "-" + iValue);
                             * } else {
                             *      SystemLogger.Log(SystemLogger.Module.PLATFORM, "Error tracking event (without further error information)");
                             * }*/
                        } catch (Exception e) {
                            SystemLogger.Log(SystemLogger.Module.PLATFORM, "Error tracking event", e);
                        }
                    });
                    return(true);
                } catch (Exception e) {
                    SystemLogger.Log(SystemLogger.Module.PLATFORM, "Couldn't track analytics event", e);
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Beispiel #23
0
        async private void CancelTrip()
        {
            UserTripDataManager userTripManager = new UserTripDataManager();
            iOSLoginManager     loginManager    = iOSLoginManager.Instance;

            int  travelerId = loginManager.GetTravelerId();
            bool didSave    = await userTripManager.CancelTripForUser(travelerId, TripToShow);

            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("ui_action", "cancel trip", "cancel trip", didSave).Build());

            if (didSave)
            {
                UIAlertView alert = new UIAlertView("Canceled", "Trip Canceled", null, "OK", null);
                alert.Show();
                btnSaveCancel.Hidden = true;
            }
            else
            {
                UIAlertView alert = new UIAlertView("Not Canceled", "Error canceling trip.  Please try again.", null, "OK", null);
                alert.Show();
            }
        }
Beispiel #24
0
        private void MonitorLocation(UIApplicationState appState)
        {
            if (CLLocationManager.LocationServicesEnabled)
            {
                LastSentLocationTime  = new DateTime(0);
                FirstSentLocationTime = new DateTime(0);
                Console.WriteLine("MONITOR LOCATION");

                GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("app_action", "location", "monitor location", null).Build());

                LocationManager = new CLLocationManager();
                LocationManager.DesiredAccuracy = 10;
                LocationManager.PausesLocationUpdatesAutomatically = false;

                LocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {
                    CLLocation currentLocation  = e.Locations[e.Locations.Length - 1];
                    DateTime   locationDateTime = DateTime.SpecifyKind(currentLocation.Timestamp, DateTimeKind.Utc);

                    double timeremaining = UIApplication.SharedApplication.BackgroundTimeRemaining;

                    Console.WriteLine("LOCATION UPDATE - Time Remaining: " + timeremaining.ToString());

                    if (LastSentLocationTime.Ticks == 0)
                    {
                        Console.WriteLine("FIRST LOCATION SENT");
                        sendLocation(currentLocation);
                        FirstSentLocationTime = locationDateTime;
                        LastSentLocationTime  = locationDateTime;
                    }
                    else
                    {
                        var diffInSeconds = (locationDateTime - LastSentLocationTime).TotalSeconds;
                        if (diffInSeconds >= 10.0)
                        {
                            Console.WriteLine("LOCATION SENT");
                            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("app_action", "location", "location sent", null).Build());
                            sendLocation(currentLocation);
                            LastSentLocationTime = locationDateTime;
                        }

                        var diffInSecondsFromFirst = (locationDateTime - FirstSentLocationTime).TotalSeconds;
                        if (diffInSecondsFromFirst >= 120)
                        {
                            Console.WriteLine("STOP MONITOR LOCATION");
                            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("app_action", "location", "stop monitor location", null).Build());
                            if (LocationManager != null)
                            {
                                LocationManager.StopUpdatingLocation();
                                LocationManager.StopMonitoringSignificantLocationChanges();
                            }

                            LocationManager = null;
                        }
                    }
                };


                if (appState == UIApplicationState.Active)
                {
                    LocationManager.StartUpdatingLocation();
                }
                else
                {
                    LocationManager.StartMonitoringSignificantLocationChanges();
                }
            }
            else
            {
                Console.WriteLine("Location services not enabled");
            }
        }
        public void LogEvent(string @event)
        {
            var eventGA = GAIDictionaryBuilder.CreateEvent("Interaction", "Event", @event, 0);

            Trackers.ForEach(x => x.Send(eventGA.Build()));
        }
        public override void TrackEvent(string category, string action, string label)
        {
            var tracker = TrackerService.Instance.GetTracker(Configuration);

            tracker.Send(GAIDictionaryBuilder.CreateEvent(category, action, label, 1).Build());
        }
Beispiel #27
0
        async private Task search()
        {
            //Save Date Time

            var userPrefs = NSUserDefaults.StandardUserDefaults;

            userPrefs.SetString(txtMaxWalk.Text, MAX_WALK_DIST_USER_PREF);
            userPrefs.Synchronize();

            String maxWalkString = txtMaxWalk.Text.Replace("Mile", "").Trim();

            double maxWalkDistMeters = 500;

            if (maxWalkString.Equals("1/4"))
            {
                maxWalkDistMeters = 403;
            }
            else if (maxWalkString.Equals("1/2"))
            {
                maxWalkDistMeters = 805;
            }
            else if (maxWalkString.Equals("3/4"))
            {
                maxWalkDistMeters = 1207;
            }
            else if (maxWalkString.Equals("1"))
            {
                maxWalkDistMeters = 1610;
            }


            bool isDeparture = true;

            DateTime tripDate = DateTime.Parse(txtDate.Text);

            int selectedIndex = segmentDateType.SelectedSegment;

            string selectedValue = segmentDateType.TitleAt(selectedIndex);

            if (selectedValue.Equals("Departure"))
            {
                isDeparture = true;
            }
            else
            {
                isDeparture = false;
            }

            string startLocation = txtStartLocation.Text;
            string endLocation   = txtEndLocation.Text;

            if (startLocation.Equals(CURRENT_LOCATION_STRING))
            {
                startLocation = mCurrentLocation.Latitude.ToString() + "," + mCurrentLocation.Longitude.ToString();
            }

            if (endLocation.Equals(CURRENT_LOCATION_STRING))
            {
                endLocation = mCurrentLocation.Latitude.ToString() + "," + mCurrentLocation.Longitude.ToString();
            }

            mSearchResults = await mUserTripDataManager.SearchForTrips(startLocation, endLocation, maxWalkDistMeters, tripDate, isDeparture, mCityString, mStateString);

            if (mSearchResults != null)
            {
                GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("ui_action", "search trips", "search results", mSearchResults.itineraries.Count).Build());

                this.PerformSegue("SearchResultsSegue", this);
            }
            else
            {
                GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("ui_action", "search trips", "search results", -1).Build());
                UIAlertView alert = new UIAlertView("No Results", "No trips found.  Please check your start and end location.  Location can be either current location or an address.", null, "OK", null);
                alert.Show();
            }
        }
Beispiel #28
0
 protected override void SendTiming(long elapsedMilliseconds, string category, string variable, string label)
 {
     SendHit(GAIDictionaryBuilder.CreateTiming(category, elapsedMilliseconds, variable, label));
 }
Beispiel #29
0
 protected override void SendEvent(string category, string action, string label, long value)
 {
     SendHit(GAIDictionaryBuilder.CreateEvent(category, action, label, value));
 }