コード例 #1
0
        /// <summary>
        /// Initializes the instance.
        /// </summary>
        /// <param name="propertyId">The property ID to use, string with the format US-XXXX. Must not be null.</param>
        /// <param name="appName">The name of the app for which this reporter is reporting. Must not be null.</param>
        /// <param name="clientId">The client id to use when reporting, if null a new random Guid will be generated.</param>
        /// <param name="appVersion">Optional, the app version. Defaults to null.</param>
        /// <param name="debug">Optional, whether this reporter is in debug mode. Defaults to false.</param>
        /// <param name="userAgent">Optiona, the user agent to use for all HTTP requests.</param>
        /// <param name="sender">The instance of <seealso cref="IHitSender"/> to use to send the this.</param>
        public AnalyticsReporter(
            string propertyId,
            string appName,
            string clientId   = null,
            string appVersion = null,
            bool debug        = false,
            string userAgent  = null,
            IHitSender sender = null)
        {
            PropertyId         = Preconditions.CheckNotNull(propertyId, nameof(propertyId));
            ApplicationName    = Preconditions.CheckNotNull(appName, nameof(appName));
            ClientId           = clientId ?? Guid.NewGuid().ToString();
            ApplicationVersion = appVersion;

            _baseHitData = MakeBaseHitData();
            _hitSender   = sender ?? new HitSender(debug, userAgent);
        }
        /// <summary>
        /// Initializes the instance.
        /// </summary>
        /// <param name="propertyId">The property ID to use, string with the format US-XXXX. Must not be null.</param>
        /// <param name="appName">The name of the app for which this reporter is reporting. Must not be null.</param>
        /// <param name="clientId">The client id to use when reporting, if null a new random Guid will be generated.</param>
        /// <param name="appVersion">Optional, the app version. Defaults to null.</param>
        /// <param name="debug">Optional, whether this reporter is in debug mode. Defaults to false.</param>
        /// <param name="userAgent">Optiona, the user agent to use for all HTTP requests.</param>
        /// <param name="sender">The instance of <seealso cref="IHitSender"/> to use to send the this.</param>
        public AnalyticsReporter(
            string propertyId,
            string appName,
            string clientId = null,
            string appVersion = null,
            bool debug = false,
            string userAgent = null,
            IHitSender sender = null)
        {
            PropertyId = Preconditions.CheckNotNull(propertyId, nameof(propertyId));
            ApplicationName = Preconditions.CheckNotNull(appName, nameof(appName));
            ClientId = clientId ?? Guid.NewGuid().ToString();
            ApplicationVersion = appVersion;

            _baseHitData = MakeBaseHitData();
            _hitSender = sender ?? new HitSender(debug, userAgent);
        }