/// <summary> /// Creates a new REST client with a specified API writeKey and default config /// </summary> /// <param name="writeKey"></param> /// <param name="config"></param> public RudderClient(string writeKey, RudderConfig config) : this(writeKey, config, null) { if (string.IsNullOrEmpty(writeKey)) { throw new InvalidOperationException("Please supply a valid writeKey to initialize."); } }
public RudderIntegrationManager(string writeKey, RudderConfig config) { this._writeKey = writeKey; this._config = config; ServicePointManager.ServerCertificateValidationCallback = Validator; DownloadIntegrations(); }
public static IServiceCollection AddAnalytics(this IServiceCollection services, string writeKey, Action <RudderConfig> configuration) { var config = new RudderConfig(); configuration?.Invoke(config); var client = new RudderClient(writeKey, config); services.AddSingleton <IRudderAnalyticsClient>(client); return(services); }
public static RudderClient GetInstance( string writeKey, RudderConfig config ) { if (_instance == null) { // initialize the cache RudderCache.Init(); RudderLogger.LogDebug("Instantiating RudderClient SDK"); // initialize the instance _instance = new RudderClient( writeKey, config.dataPlaneUrl, config.controlPlaneUrl, config.flushQueueSize, config.dbCountThreshold, config.sleepTimeOut, config.configRefreshInterval, config.trackLifecycleEvents, config.recordScreenViews, config.logLevel ); RudderLogger.LogDebug("Instantiating RudderIntegrationManager"); _integrationManager = new RudderIntegrationManager( writeKey, config ); } else { RudderLogger.LogDebug("RudderClient SDK is already initiated"); } return(_instance); }
internal RudderClient(string writeKey, RudderConfig config, IRequestHandler requestHandler) { this.Statistics = new Statistics(); this._writeKey = writeKey; this._config = config; if (requestHandler == null) { if (config.Send) { if (config.MaxRetryTime.HasValue) { requestHandler = new BlockingRequestHandler(this, config.Timeout, new Backo(max: (Convert.ToInt32(config.MaxRetryTime.Value.TotalSeconds) * 1000), jitter: 5000)); } else { requestHandler = new BlockingRequestHandler(this, config.Timeout); } } else { requestHandler = new FakeRequestHandler(this); } } IBatchFactory batchFactory = new SimpleBatchFactory(this._writeKey); if (config.Async) { _flushHandler = new AsyncIntervalFlushHandler(batchFactory, requestHandler, config.MaxQueueSize, config.FlushAt, config.FlushIntervalInMillis, config.Threads); } else { _flushHandler = new BlockingFlushHandler(batchFactory, requestHandler); } }
public RudderFirebaseIntegration(Dictionary <string, object> config, RudderClient client, RudderConfig rudderConfig) { RudderLogger.LogDebug("Instantiating RudderFirebaseIntegration"); RudderLogger.LogDebug("Starting Firebase native SDK"); }
public RudderAdjustIntegration(Dictionary <string, object> config, RudderClient client, RudderConfig rudderConfig) { RudderLogger.LogDebug("Instantiating RudderAdjustIntegration"); string appToken = null; if (config.ContainsKey("appToken")) { appToken = config["appToken"] as string; RudderLogger.LogDebug("Adjust: appToken: " + appToken); } List <object> eventTokens = new List <object>(); if (config.ContainsKey("customMappings")) { eventTokens = config["customMappings"] as List <object>; foreach (var eventConfig in eventTokens) { Dictionary <string, object> eventTokenDict = eventConfig as Dictionary <string, object>; string eventName = eventTokenDict["from"] as string; string eventToken = eventTokenDict["to"] as string; RudderLogger.LogDebug("Adjust: " + eventName + " : " + eventToken); this.eventTokenMap[eventName] = eventToken; } } string delayTime = null; if (config.ContainsKey("delay")) { delayTime = config["delay"] as string; RudderLogger.LogDebug("delayTime:" + delayTime); } if (appToken != null && !appToken.Equals("")) { RudderLogger.LogDebug("Initiating Adjust native SDK"); AdjustConfig adjustConfig = new AdjustConfig( appToken, rudderConfig.logLevel >= RudderLogLevel.DEBUG ? AdjustEnvironment.Sandbox : AdjustEnvironment.Production, true); adjustConfig.setLogLevel(rudderConfig.logLevel >= RudderLogLevel.DEBUG ? AdjustLogLevel.Verbose : AdjustLogLevel.Error); double delay = 0; try { if (delayTime != null) { delay = double.Parse(delayTime); } } catch (System.Exception ex) { RudderLogger.LogError("Invalid delay time" + ex.Message); } if (delay < 0) { delay = 0; } else if (delay > 10) { delay = 10; } if (delay > 0) { adjustConfig.setDelayStart(delay); } RudderLogger.LogDebug("Starting Adjust native SDK"); Adjust.start(adjustConfig); } else { RudderLogger.LogError("appToken was not set in Dashboard"); } }
public override RudderIntegration Create(Dictionary <string, object> config, RudderClient client, RudderConfig rudderConfig) { RudderLogger.LogDebug("Creating RudderAdjustIntegrationFactory"); return(new RudderAdjustIntegration(config, client, rudderConfig)); }