示例#1
0
        /// <summary>
        /// Tracks the browser window.performance events.
        /// </summary>
        /// <param name="type">The type of window.performance timings you want to track.</param>
        /// <param name="additionalProperties">The additional properties you want to track in telemetry. These values will show up in the customDimensions of the customEvents</param>
        /// <param name="clearTimings">if set to <c>true</c> clears the resource timings.</param>
        public void TrackBrowserEvents(BrowserEventType type, Dictionary <string, string> additionalProperties = null, bool clearTimings = false)
        {
            var properties = GetBrowserTimings(type);

            if (additionalProperties != null)
            {
                properties = properties.Merge(additionalProperties);
            }

            if (properties.Count > 0)
            {
                TrackEvents(type.ToString(), properties, null);
            }
        }
示例#2
0
        internal Dictionary <string, string> GetBrowserTimings(BrowserEventType type, bool clearTimings = false)
        {
            var entries = (IEnumerable <object>)_client.Browser.Driver.ExecuteScript("return window.performance.getEntriesByType('" + type.ToString("g").ToLowerString() + "')");

            var results = new Dictionary <string, string>();

            foreach (var entry in entries)
            {
                var dict   = (Dictionary <string, object>)entry;
                var todict = dict.ToDictionary(x => x.Key, x => x.Value.ToString());
                results = results.Merge(todict);
            }

            if (clearTimings)
            {
                ClearResourceTimings();
            }

            return(results);
        }