Пример #1
0
 public override void SetUser(string username)
 {
     if (!string.IsNullOrWhiteSpace(username))
     {
         _tracker.Send(HitBuilder.CreateCustomEvent("User", username).Build());
     }
 }
Пример #2
0
        private void GooglePlayNoticeNotNow_Tapped(object sender, TappedRoutedEventArgs e)
        {
            OKButton_Tapped(this, e);
#if !DEBUG
            App.Tracker.Send(HitBuilder.CreateCustomEvent("GooglePlayImportantNotice", "NotNow", "").Build());
#endif
        }
Пример #3
0
        internal static async Task <StorePurchaseStatus> TryPurchaseConsumable(PurchaseItem item)
        {
            if (context == null)
            {
                context = StoreContext.GetDefault();
            }

            Guid trackingId = Guid.NewGuid();

            try
            {
                StorePurchaseResult result = await context.RequestPurchaseAsync(item.StoreID);

                var fulfillResult = await context.ReportConsumableFulfillmentAsync(item.StoreID, 1, trackingId);

                Debug.WriteLine($"In app purchase of consumable {item.Token} finished with status: Purchase={result.Status}, Fulfill={fulfillResult.Status}");

#if !DEBUG
                App.Tracker.Send(HitBuilder.CreateCustomEvent("TryDonate" + item.Token, "Done", $"Purchase={result.Status}, Fulfill={fulfillResult.Status}").Build());
#endif

                return(result.Status);
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"In app purchase of consumable {item.Token} failed: {ex.Message}");
#if !DEBUG
                App.Tracker.Send(HitBuilder.CreateCustomEvent("TryDonate" + item.Token, "Failed", ex.Message).Build());
#endif
                return(StorePurchaseStatus.NotPurchased);
            }
        }
Пример #4
0
 public void _setCustomMetricOnTracker <T>(HitBuilder <T> builder)
 {
     foreach (KeyValuePair <int, string> entry in builder.GetCustomMetrics())
     {
         setCustomMetricOnTracker(entry.Key, entry.Value);
     }
 }
    private string AddCustomVariables <T>(HitBuilder <T> builder)
    {
        if (!trackingCodeSet)
        {
            return("");
        }
        String url = "";

        foreach (KeyValuePair <int, string> entry in builder.GetCustomDimensions())
        {
            if (entry.Value != null)
            {
                url += Fields.CUSTOM_DIMENSION.ToString() + entry.Key + "=" +
                       WWW.EscapeURL(entry.Value.ToString());
            }
        }
        foreach (KeyValuePair <int, float> entry in builder.GetCustomMetrics())
        {
            if (entry.Value != null)
            {
                url += Fields.CUSTOM_METRIC.ToString() + entry.Key + "=" +
                       WWW.EscapeURL(entry.Value.ToString());
            }
        }

        if (!String.IsNullOrEmpty(url))
        {
            if (GoogleAnalyticsV4.belowThreshold(logLevel, GoogleAnalyticsV4.DebugMode.VERBOSE))
            {
                Debug.Log("Added custom variables to hit.");
            }
        }
        return(url);
    }
    private string AddCampaignParameters <T>(HitBuilder <T> builder)
    {
        if (!trackingCodeSet)
        {
            return("");
        }
        String url = "";

        url += AddOptionalMPParameter(Fields.CAMPAIGN_NAME, builder.GetCampaignName());
        url += AddOptionalMPParameter(Fields.CAMPAIGN_SOURCE, builder.GetCampaignSource());
        url += AddOptionalMPParameter(Fields.CAMPAIGN_MEDIUM, builder.GetCampaignMedium());
        url += AddOptionalMPParameter(Fields.CAMPAIGN_KEYWORD, builder.GetCampaignKeyword());
        url += AddOptionalMPParameter(Fields.CAMPAIGN_CONTENT, builder.GetCampaignContent());
        url += AddOptionalMPParameter(Fields.CAMPAIGN_ID, builder.GetCampaignID());
        url += AddOptionalMPParameter(Fields.GCLID, builder.GetGclid());
        url += AddOptionalMPParameter(Fields.DCLID, builder.GetDclid());

        if (!String.IsNullOrEmpty(url))
        {
            if (GoogleAnalyticsV4.belowThreshold(logLevel, GoogleAnalyticsV4.DebugMode.VERBOSE))
            {
                Debug.Log("Added campaign parameters to hit. url:" + url);
            }
        }
        return(url);
    }
        public async Task TrackDependencyAsync(string dependencyType, string dependencyName, DateTimeOffset startTime, TimeSpan duration, bool success, int resultCode = 0, Exception exception = null)
        {
            try
            {
                var builder = HitBuilder.CreateTiming(dependencyType, dependencyName, duration, success.ToString());
                //  builder.set

                var dependencyToTrack = builder.Build();

                dependencyToTrack.Add("ResultCode", resultCode.ToString());

                if (exception != null)
                {
                    dependencyToTrack.Add("Exception message", exception.Message);
                    dependencyToTrack.Add("StackTrace", exception.StackTrace);

                    if (exception.InnerException != null)
                    {
                        dependencyToTrack.Add("Inner exception message", exception.InnerException.Message);
                        dependencyToTrack.Add("Inner exception stackTrace", exception.InnerException.StackTrace);
                    }
                }

                Tracker.Send(dependencyToTrack);
            }
            catch (Exception ex)
            {
                _ = TinyInsights.TrackErrorAsync(ex);
            }
        }
Пример #8
0
        private async void RateAndReviewButton_Tapped(object sender, TappedRoutedEventArgs e)
        {
#if !DEBUG
            App.Tracker.Send(HitBuilder.CreateCustomEvent("Settings", "RateAndReview").Build());
#endif
            await Launcher.LaunchUriAsync(new Uri(string.Format("ms-windows-store:REVIEW?PFN={0}", Windows.ApplicationModel.Package.Current.Id.FamilyName)));
        }
Пример #9
0
 public void _buildCustomMetricsDictionary <T>(HitBuilder <T> builder)
 {
     foreach (KeyValuePair <int, string> entry in builder.GetCustomMetrics())
     {
         addCustomMetricToDictionary(entry.Key, entry.Value);
     }
 }
Пример #10
0
        private async void PrivacyPolicyButton_Tapped(object sender, TappedRoutedEventArgs e)
        {
#if !DEBUG
            App.Tracker.Send(HitBuilder.CreateScreenView("PrivacyPolicy").Build());
#endif
            await Launcher.LaunchUriAsync(new Uri("https://roamit.ghiasi.net/privacy/"));
        }
Пример #11
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            shareDetails = e.Parameter as ShareTargetDetails;

            if (shareDetails.Type == StandardDataFormats.StorageItems)
            {
                string s = "???";

                if (SendDataTemporaryStorage.Files != null)
                {
                    s = SendDataTemporaryStorage.Files.Count.ToString() +
                        " file" + (SendDataTemporaryStorage.Files.Count > 1 ? "s" : "");
                }

                ViewModel.PreviewText = s;
                ViewModel.ShowShareStorageItem();
            }
            else if ((shareDetails.Type == StandardDataFormats.WebLink) || (shareDetails.Type == StandardDataFormats.ApplicationLink))
            {
                ViewModel.PreviewText = SendDataTemporaryStorage.LaunchUri.OriginalString;
                ViewModel.ShowShareUrl();
            }
            else if (shareDetails.Type == StandardDataFormats.Text)
            {
                ViewModel.PreviewText = SendDataTemporaryStorage.Text;
                ViewModel.ShowShareText();
            }

            base.OnNavigatedTo(e);

#if !DEBUG
            App.Tracker.Send(HitBuilder.CreateScreenView("ShareTarget").Build());
#endif
        }
Пример #12
0
        public static async Task TryUpgrade()
        {
            if (context == null)
            {
                context = StoreContext.GetDefault();
            }

            try
            {
                StorePurchaseResult result = await context.RequestPurchaseAsync(RemoveAdsAndSizeLimit_StoreID);

                Debug.WriteLine($"In app purchase of {RemoveAdsAndSizeLimit_Token} finished with status: {result.Status}");

                CheckIfFullVersion();

#if !DEBUG
                App.Tracker.Send(HitBuilder.CreateCustomEvent("TryUpgrade", "Upgraded", result.Status.ToString()).Build());
#endif
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"In app purchase of {RemoveAdsAndSizeLimit_Token} failed: {ex.Message}");
#if !DEBUG
                App.Tracker.Send(HitBuilder.CreateCustomEvent("TryUpgrade", "Failed", ex.Message).Build());
#endif
            }
        }
        public async Task SendCommercePageView()
        {
            var product = MockConfig.MakeProduct();
            var hit     = HitBuilder.CreateScreenView();

            hit.AddProduct(product);
            await SendHitAsync(hit);
        }
        public async Task SendCommerceImpressionPageView()
        {
            var product = MockConfig.MakeProduct();
            var hit     = HitBuilder.CreateScreenView();

            hit.AddImpression(product, "Impression List");
            await SendHitAsync(hit);
        }
Пример #15
0
        internal static void PageView(string pageName)
        {
#if !DEBUG
            GoogleAnalyticsTracker.Send(HitBuilder.CreateScreenView(pageName).Build());

            logger.Info($"PageView '{pageName}' fired.");
#endif
        }
Пример #16
0
        private async void ContactButton_Tapped(object sender, TappedRoutedEventArgs e)
        {
            await Launcher.LaunchUriAsync(new Uri($"mailto:[email protected]?subject={Model.PackageName}%20v{Model.PackageVersion}"));

#if !DEBUG
            App.Tracker.Send(HitBuilder.CreateCustomEvent("Settings", "Link", "Contact").Build());
#endif
        }
Пример #17
0
        private async void GetChromeFirefoxExtension_Tapped(object sender, TappedRoutedEventArgs e)
        {
            await Launcher.LaunchUriAsync(new Uri($"https://roamit.ghiasi.net/#browserExtensions"));

#if !DEBUG
            App.Tracker.Send(HitBuilder.CreateCustomEvent("Settings", "Link", "GetBrowserExtensions").Build());
#endif
        }
Пример #18
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            VisualChildFinder.FindVisualChild <ContentControl>(pivot, "HeaderClipper").MaxWidth = 720;

#if !DEBUG
            App.Tracker.Send(HitBuilder.CreateScreenView("Settings").Build());
#endif
        }
Пример #19
0
        public static void Log(string eventName, string action, string label)
        {
#if !DEBUG
            StoreCustomEventLogger.Log(eventName + " : " + action + " : " + label);
            GoogleAnalyticsTracker.Send(HitBuilder.CreateCustomEvent(eventName, action, label).Build());
#endif
            logger.Info($"Analytics event '{eventName} : {action} : {label}' fired.");
        }
Пример #20
0
        private async void GitHubIssueButton_Tapped(object sender, TappedRoutedEventArgs e)
        {
            await Launcher.LaunchUriAsync(new Uri(Common.Constants.GitHubIssuesUrl));

#if !DEBUG
            App.Tracker.Send(HitBuilder.CreateCustomEvent("Settings", "Link", "GitHubIssues").Build());
#endif
        }
Пример #21
0
        public void TrackError(Exception exception)
        {
            Regex patFun = new Regex("KiwiGui\\.[a-zA-Z0-9().?]+");
            Match m      = patFun.Match(exception.StackTrace);
            var   data   = HitBuilder.CreateException(exception.GetType().ToString() + ":" + exception.Message + " : " + m?.Groups[0], true).Build();

            tracker.Send(data);
        }
        public async Task SendCommerceEvent()
        {
            var product = MockConfig.MakeProduct();
            var hit     = HitBuilder.CreateCustomEvent("commerce", "purchase", product.Name, 0);

            hit.AddProduct(product);
            hit.SetProductAction(MockConfig.MakePurchaseAction());
            await SendHitAsync(hit);
        }
Пример #23
0
        private async void UpgradeButton_Tapped(object sender, TappedRoutedEventArgs e)
        {
#if !DEBUG
            App.Tracker.Send(HitBuilder.CreateCustomEvent("Settings", "TryUpgrade", "Windows").Build());
#endif
            await TrialHelper.AskForUpgrade();

            Model.CheckTrialStatus();
        }
Пример #24
0
        void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
        {
            var ex = e.Exception.InnerException ?? e.Exception; // inner exception contains better info for unobserved tasks

            foreach (var tracker in Trackers)
            {
                tracker.Send(HitBuilder.CreateException(ex.ToString(), false).Build());
            }
        }
    private Dictionary<AndroidJavaObject, string> AddCustomVariablesAndCampaignParameters(HitBuilder builder)
    {
        Dictionary<AndroidJavaObject, string> parameters =
        new Dictionary<AndroidJavaObject, string>();
        AndroidJavaObject fieldName;
        foreach (var entry in builder.GetCustomDimensions()) {
          fieldName = analyticsTrackingFields.CallStatic<AndroidJavaObject>(
          "customDimension", entry.Key);
          parameters.Add(fieldName, entry.Value);
        }
        foreach (var entry in builder.GetCustomMetrics()) {
          fieldName = analyticsTrackingFields.CallStatic<AndroidJavaObject>(
          "customMetric", entry.Key);
          parameters.Add(fieldName, entry.Value);
        }

        if (parameters.Keys.Count > 0) {
          if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.VERBOSE)) {
        Debug.Log("Added custom variables to hit.");
          }
        }

        if (!String.IsNullOrEmpty(builder.GetCampaignSource())) {
          fieldName = analyticsTrackingFields.
          GetStatic<AndroidJavaObject>("CAMPAIGN_SOURCE");
          parameters.Add(fieldName, builder.GetCampaignSource());
          fieldName = analyticsTrackingFields.
          GetStatic<AndroidJavaObject>("CAMPAIGN_MEDIUM");
          parameters.Add(fieldName, builder.GetCampaignMedium());
          fieldName = analyticsTrackingFields.
          GetStatic<AndroidJavaObject>("CAMPAIGN_NAME");
          parameters.Add(fieldName, builder.GetCampaignName());
          fieldName = analyticsTrackingFields.
          GetStatic<AndroidJavaObject>("CAMPAIGN_CONTENT");
          parameters.Add(fieldName, builder.GetCampaignContent());
          fieldName = analyticsTrackingFields.
          GetStatic<AndroidJavaObject>("CAMPAIGN_KEYWORD");
          parameters.Add(fieldName, builder.GetCampaignKeyword());
          fieldName = analyticsTrackingFields.
          GetStatic<AndroidJavaObject>("CAMPAIGN_ID");
          parameters.Add(fieldName, builder.GetCampaignID());
          fieldName = analyticsTrackingFields.
          GetStatic<AndroidJavaObject>("GCLID");
          parameters.Add(fieldName, builder.GetGclid());
          fieldName = analyticsTrackingFields.
          GetStatic<AndroidJavaObject>("DCLID");
          parameters.Add(fieldName, builder.GetDclid());
          if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.VERBOSE)) {
        Debug.Log("Added campaign parameters to hit.");
          }
        }

        if (parameters.Keys.Count > 0) {
          return parameters;
        }
        return null;
    }
Пример #26
0
        private async void GooglePlayNoticeGetIt_Tapped(object sender, TappedRoutedEventArgs e)
        {
            await Launcher.LaunchUriAsync(new Uri("https://play.google.com/store/apps/details?id=com.ghiasi.roamitapp"));

            OKButton_Tapped(this, e);
#if !DEBUG
            App.Tracker.Send(HitBuilder.CreateCustomEvent("GooglePlayImportantNotice", "GetIt", "").Build());
#endif
        }
        public void TrackAtomicFeature(string feature)
        {
            string category;
            string eventAction;

            this.SplitFeatureName(feature, out category, out eventAction);
            var data = HitBuilder.CreateCustomEvent(category, eventAction + " event", feature.ToString(), 1).Build();

            tracker.Send(data);
        }
Пример #28
0
        public void GenerateHitWithOverrides()
        {
            var hit  = HitBuilder.CreateCustomEvent("category", "action", "", 0).Set("ec", "new");
            var data = hit.Build();

            Assert.IsTrue(data[ParameterNames.EventCategory] == "new");
            hit  = hit.Set(ParameterNames.EventCategory, "newer");
            data = hit.Build();
            Assert.IsTrue(data[ParameterNames.EventCategory] == "newer");
        }
        private async Task SendHitAsync(HitBuilder hit)
        {
#if RUN_SYNCHRONOUS
            lock (syncObject)
            {
#endif
            HitSentEventArgs args = null;

            var serviceManager = new AnalyticsManager(MockConfig.Current.PlatformInfoProvider)
            {
                IsDebug = true
            };
            serviceManager.HitSent      += (s, e) => { args = e;    Assert.IsFalse(args == null); };
            serviceManager.HitMalformed += (s, e) => { Assert.Fail("Malformed: " + e.Hit.Parse()); };
            serviceManager.HitFailed    += (s, e) => { Assert.Fail("Failed:" + e.Error); };

#if !NATIVESDK_TEST
            var tracker =
                new SimpleTracker(MockConfig.Current.PropertyId, serviceManager)
            {
                AppName    = MockConfig.Current.AppName,
                ClientId   = MockConfig.Current.ClientId,
                ScreenName = MockConfig.Current.ScreenName
            };
#else
            var tracker = new Tracker(MockConfig.Current.PropertyId,
                                      MockConfig.Current.PlatformInfoProvider, serviceManager);
            serviceManager.IsDebug = true;
#endif
            tracker.Send(hit.Build());


#if RUN_SYNCHRONOUS
            serviceManager.DispatchAsync().AsTask().Wait();
#else
            await serviceManager.DispatchAsync();

            await Task.Delay(200);         //HitSent processing is async.. since we need args, let it replicate
#endif


            Assert.IsTrue(args != null, "args != null (" + hit.BuildToString() + ")");
            using (var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(args.Response)))
            {
                if (serviceManager.IsDebug)
                {
                    var serializer    = new DataContractJsonSerializer(typeof(DebugResponse));
                    var debugResponse = (DebugResponse)serializer.ReadObject(stream);
                    Assert.IsTrue(debugResponse.HitParsingResult.All(r => r.Valid), "Invalid Request: (" + args.Response + ")");
                }
            }
#if RUN_SYNCHRONOUS
        }       // lock
#endif
        }
Пример #30
0
 public static void TrackEvent(string category, string action, string label = "", long value = 0)
 {
     try
     {
         Tracker.Send(HitBuilder.CreateCustomEvent(category, action, label, value).Build());
     }
     catch
     {
         // Ignore error
     }
 }
Пример #31
0
 public static void TrackException(Exception ex)
 {
     try
     {
         Tracker.Send(HitBuilder.CreateException("Exception: " + ex.Message + "->" + ex.StackTrace, false).Build());
     }
     catch
     {
         // Ignore error
     }
 }
 public void _buildCustomDimensionsDictionary(HitBuilder builder)
 {
     foreach(var entry in builder.GetCustomDimensions())
     {
       addCustomDimensionToDictionary(entry.Key, entry.Value);
     }
 }
 public void _buildCustomMetricsDictionary(HitBuilder builder)
 {
     foreach(var entry in builder.GetCustomMetrics())
     {
       addCustomMetricToDictionary(entry.Key, entry.Value);
     }
 }
    private string AddCustomVariables(HitBuilder builder)
    {
        if(!trackingCodeSet)
        {
            return "";
        }

        string url	= "";
        foreach(var entry in builder.CustomDimensions)
        {
            if(entry.Value != null)
                url += Fields.CUSTOM_DIMENSION.ToString() + entry.Key + "=" + WWW.EscapeURL(entry.Value.ToString());
        }

        foreach(var entry in builder.CustomMetrics)
        {
            if(entry.Value != null)
                url += Fields.CUSTOM_METRIC.ToString() + entry.Key + "=" + WWW.EscapeURL(entry.Value.ToString());
        }

        if(!string.IsNullOrEmpty(url))
        {
            if(GoogleAnalyticsV3.belowThreshold(logLevel,GoogleAnalyticsV3.DebugMode.VERBOSE))
                Debug.Log("Added custom variables to hit.");
        }

        return url;
    }
    private string AddCampaignParameters(HitBuilder builder)
    {
        if(!trackingCodeSet)
        {
            return "";
        }
        String url = "";
        url += AddOptionalMPParameter(Fields.CAMPAIGN_NAME,builder.GetCampaignName());
        url += AddOptionalMPParameter(Fields.CAMPAIGN_SOURCE,builder.GetCampaignSource());
        url += AddOptionalMPParameter(Fields.CAMPAIGN_MEDIUM,builder.GetCampaignMedium());
        url += AddOptionalMPParameter(Fields.CAMPAIGN_KEYWORD,builder.GetCampaignKeyword());
        url += AddOptionalMPParameter(Fields.CAMPAIGN_CONTENT,builder.GetCampaignContent());
        url += AddOptionalMPParameter(Fields.CAMPAIGN_ID,builder.GetCampaignID());
        url += AddOptionalMPParameter(Fields.GCLID,builder.GetGclid());
        url += AddOptionalMPParameter(Fields.DCLID,builder.GetDclid());

        if(!String.IsNullOrEmpty(url))
        {
            if(GoogleAnalyticsV3.belowThreshold(logLevel,GoogleAnalyticsV3.DebugMode.VERBOSE))
                Debug.Log("Added campaign parameters to hit. url:" + url);
        }

        return url;
    }
 public void _buildCampaignParametersDictionary(HitBuilder builder)
 {
     if(!String.IsNullOrEmpty(builder.GetCampaignSource())){
       buildCampaignParametersDictionary(builder.GetCampaignSource(),
       builder.GetCampaignMedium() != null ? builder.GetCampaignMedium() : "",
       builder.GetCampaignName() != null? builder.GetCampaignName() : "",
       builder.GetCampaignContent() != null? builder.GetCampaignContent() : "",
       builder.GetCampaignKeyword() != null? builder.GetCampaignKeyword() : "");
     } else if(!String.IsNullOrEmpty(builder.GetCampaignMedium()) ||
     !String.IsNullOrEmpty(builder.GetCampaignName()) ||
     !String.IsNullOrEmpty(builder.GetCampaignMedium()) ||
     !String.IsNullOrEmpty(builder.GetCampaignContent()) ||
     !String.IsNullOrEmpty(builder.GetCampaignKeyword())) {
       Debug.Log("A required parameter (campaign source) is null or empty. No campaign parameters will be added to hit.");
     }
 }