private void RunTests(RudderClient client, int trials) { for (int i = 0; i < trials; i += 1) { Actions.Random(client); } }
/// <summary> /// Constructor. /// </summary> public RudderAnalyticsManager() { // to make it work along with AM or other SDK that uses SQLite RudderClient.SerializeSqlite(); //Get access to RudderClient singleton instance //The writeKey used here is a sample one generated by the Rudder Labs //development team. For Production, the Torpedo development team //can retrieve the writeKey from the management web interface and embed //in WynnAnalyticsDataConstants.cs RudderConfigBuilder configBuilder = new RudderConfigBuilder() .WithEndPointUrl(WynnAnalyticsDataConstants.RUDDER_END_POINT_URL) .WithFactory(RudderAdjustIntegrationFactory.getFactory()); rudder = RudderClient.GetInstance( WynnAnalyticsDataConstants.RUDDER_WRITE_KEY, configBuilder.Build() ); //rudder.enableLog(); //Logging is disabled by default //There is no requirement for specifying Amplitude key since same //is configured at Rudder server end //Since Rudder SDK supports multiple destinations with different user_id //connotations, hence Rudder does not set user_id at instance level //It can be included in individual event calls to pass on to Amplitude //Same has been incorporated in code below GameEngine.DebugMsg("RudderAnalyticsManager: Initialized"); }
public async Task PerformanceTestNetStandard20() { var client = new RudderClient(Constants.WRITE_KEY, new RudderConfig(), _mockRequestHandler.Object); RudderAnalytics.Initialize(client); RudderAnalytics.Client.Succeeded += Client_Succeeded; RudderAnalytics.Client.Failed += Client_Failed; int trials = 100; DateTime start = DateTime.Now; RunTests(RudderAnalytics.Client, trials); await RudderAnalytics.Client.FlushAsync(); TimeSpan duration = DateTime.Now.Subtract(start); Assert.AreEqual(trials, RudderAnalytics.Client.Statistics.Submitted); Assert.AreEqual(trials, RudderAnalytics.Client.Statistics.Succeeded); Assert.AreEqual(0, RudderAnalytics.Client.Statistics.Failed); Assert.IsTrue(duration.CompareTo(TimeSpan.FromSeconds(20)) < 0); }
public static void Random(RudderClient client) { switch (random.Next(0, 6)) { case 0: Identify(client); return; case 1: Track(client); return; case 2: Alias(client); return; case 3: Group(client); return; case 4: Page(client); return; case 5: Screen(client); return; } }
public void ClientUsesBlockingRequestHandlerWhenSendIsTrue() { var client = new RudderClient("writeKey", new RudderConfig(send: true)); var flushHandler = GetPrivateFieldValue <AsyncIntervalFlushHandler>(client, "_flushHandler"); var requestHandler = GetPrivateFieldValue <object>(flushHandler, "_requestHandler"); Assert.IsInstanceOf <BlockingRequestHandler>(requestHandler); }
/// <summary> /// Initialized the default RudderStack client with your API writeKey. /// </summary> /// <param name="writeKey"></param> public static void Initialize(string writeKey, RudderConfig config) { lock (padlock) { if (Client == null) { Client = new RudderClient(writeKey, config); } } }
internal static void Initialize(RudderClient client) { lock (padlock) { if (Client == null) { Client = client; } } }
internal BlockingRequestHandler(RudderClient client, TimeSpan timeout, HttpClient httpClient, Backo backo) #endif { this._client = client; _backo = backo; this.Timeout = timeout; if (httpClient != null) { _httpClient = httpClient; } // Create HttpClient instance in .Net 3.5 #if NET35 if (httpClient == null) { _httpClient = new HttpClient { Timeout = Timeout } } ; #else var handler = new HttpClientHandler(); #endif // Set proxy information if (!string.IsNullOrEmpty(_client.Config.Proxy)) { #if NET35 _httpClient.Proxy = new WebProxy(_client.Config.Proxy); #else handler.Proxy = new WebProxy(_client.Config.Proxy); handler.UseProxy = true; #endif } // Initialize HttpClient instance with given configuration #if !NET35 if (httpClient == null) { _httpClient = new HttpClient(handler) { Timeout = Timeout } } ; #endif // Send user agent in the form of {library_name}/{library_version} as per RFC 7231. var szUserAgent = _client.Config.UserAgent; #if NET35 _httpClient.Headers.Set("User-Agent", szUserAgent); #else _httpClient.DefaultRequestHeaders.Add("User-Agent", szUserAgent); #endif }
/// <summary> /// Disposes of the current client and allows the creation of a new one /// </summary> public static void Dispose() { lock (padlock) { if (Client != null) { Client.Dispose(); Client = null; } } }
private void RunTests(RudderClient client, int trials) { for (int i = 0; i < trials; i += 1) { Actions.Random(client); if (i % 100 == 0) { Thread.Sleep(500); } } }
public void Init() { _mockHttpClient = new Mock <IHttpClient>(MockBehavior.Strict); _mockHeaders = new Mock <WebHeaderCollection>(MockBehavior.Strict); _mockHeaders.Setup(x => x.Set(It.IsAny <string>(), It.IsAny <string>())).Verifiable(); _mockHttpClient.Setup(x => x.UploadData(It.IsAny <Uri>(), "POST", It.IsAny <byte[]>())).Returns(new byte[] { }); _mockHttpClient.Setup(x => x.Headers).Returns(() => _mockHeaders.Object); _client = new RudderClient("foo"); _handler = new BlockingRequestHandler(_client, new TimeSpan(0, 0, 10), _mockHttpClient.Object, new Backo(max: 500, jitter: 0)); }
/// <summary> /// Initialized the default RudderStack client with your API writeKey. /// </summary> /// <param name="writeKey"></param> public static void Initialize(string writeKey) { // avoiding double locking as recommended: // http://www.yoda.arachsys.com/csharp/singleton.html lock (padlock) { if (Client == null) { Client = new RudderClient(writeKey); } } }
void Awake() { #if !MOBILE_INPUT // Create a layer mask for the floor layer. floorMask = LayerMask.GetMask("Floor"); #endif // Set up references. anim = GetComponent <Animator>(); playerRigidbody = GetComponent <Rigidbody>(); rudderClient = RudderClient.GetInstance(RUDDER_WRITE_KEY, END_POINT_URL); }
public void GZipTestNet35() { // Set GZip/Deflate on request header var client = new RudderClient(Constants.WRITE_KEY, new RudderConfig().SetAsync(false), _mockRequestHandler.Object); RudderAnalytics.Initialize(client); Actions.Identify(RudderAnalytics.Client); Assert.AreEqual(1, RudderAnalytics.Client.Statistics.Submitted); Assert.AreEqual(1, RudderAnalytics.Client.Statistics.Succeeded); Assert.AreEqual(0, RudderAnalytics.Client.Statistics.Failed); }
public void GZipTestNetStanard20() { // Set proxy address, like as "http://localhost:8888" var client = new RudderClient(Constants.WRITE_KEY, new RudderConfig().SetAsync(false), _mockRequestHandler.Object); RudderAnalytics.Initialize(client); Actions.Identify(RudderAnalytics.Client); Assert.AreEqual(1, RudderAnalytics.Client.Statistics.Submitted); Assert.AreEqual(1, RudderAnalytics.Client.Statistics.Succeeded); Assert.AreEqual(0, RudderAnalytics.Client.Statistics.Failed); }
public void Init() { _mockRequestHandler = new Mock <IRequestHandler>(); _mockRequestHandler .Setup(x => x.MakeRequest(It.IsAny <Batch>())) .Returns(async(Batch b) => { b.batch.ForEach(_ => RudderAnalytics.Client.Statistics.IncrementSucceeded()); }); RudderAnalytics.Dispose(); var client = new RudderClient(Constants.WRITE_KEY, new RudderConfig().SetAsync(false), _mockRequestHandler.Object); RudderAnalytics.Initialize(client); }
public void SynchronousFlushTestNetStandard20() { var client = new RudderClient(Constants.WRITE_KEY, new RudderConfig().SetAsync(false), _mockRequestHandler.Object); RudderAnalytics.Initialize(client); RudderAnalytics.Client.Succeeded += Client_Succeeded; RudderAnalytics.Client.Failed += Client_Failed; int trials = 10; RunTests(RudderAnalytics.Client, trials); Assert.AreEqual(trials, RudderAnalytics.Client.Statistics.Submitted); Assert.AreEqual(trials, RudderAnalytics.Client.Statistics.Succeeded); Assert.AreEqual(0, RudderAnalytics.Client.Statistics.Failed); }
// Start is called before the first frame update void Start() { Debug.Log("Info Here"); RudderClient.SerializeSqlite(); RudderConfig config = new RudderConfigBuilder() .WithDataPlaneUrl("https://8452ddb9ed62.ngrok.io") .WithLogLevel(RudderLogLevel.VERBOSE) .Build(); rudderClient = RudderClient.GetInstance("1glg5JWDIVF1c90oLs6CDePrFy9", config); // create event properties Dictionary <string, object> eventProperties = new Dictionary <string, object>(); eventProperties.Add("test_key_1", "test_value_1"); eventProperties.Add("test_key_2", "test_value_2"); // create user properties Dictionary <string, object> userProperties = new Dictionary <string, object>(); userProperties.Add("test_u_key_1", "test_u_value_1"); userProperties.Add("test_u_key_2", "test_u_value_2"); // create message to track RudderMessageBuilder builder = new RudderMessageBuilder(); builder.WithEventName("test_event_name"); builder.WithEventProperties(eventProperties); builder.WithUserProperties(userProperties); rudderClient.Track(builder.Build()); // create message to track builder = new RudderMessageBuilder(); builder.WithEventName("test_event_name"); builder.WithEventProperty("foo", "bar"); builder.WithUserProperty("foo1", "bar1"); rudderClient.Track(builder.Build()); RudderMessage identifyMessage = new RudderMessageBuilder().Build(); RudderTraits traits = new RudderTraits().PutEmail("*****@*****.**"); rudderClient.Identify("some_user_id", traits, identifyMessage); }
public void Init() { _mockHttpMessageHandler = new Mock <HttpMessageHandler>(MockBehavior.Strict); _httpBehavior = SingleHttpResponseBehavior(HttpStatusCode.OK); _mockHttpMessageHandler.Protected().Setup <Task <HttpResponseMessage> >( "SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>() ) // prepare the expected response of the mocked http call .ReturnsAsync(() => _httpBehavior()) .Verifiable(); _client = new RudderClient("foo"); _handler = new BlockingRequestHandler(_client, new TimeSpan(0, 0, 10), new HttpClient(_mockHttpMessageHandler.Object), new Backo(max: 500, jitter: 0)); }
public static void AddAnalytics(this IServiceCollection services, string writeKey, RudderConfig config = null) { RudderConfig configuration; if (config == null) { configuration = new RudderConfig(); } else { configuration = config; } var client = new RudderClient(writeKey, configuration); services.AddSingleton <IRudderAnalyticsClient>(client); }
float camRayLength = 100f; // The length of the ray from the camera into the scene. #endif void Awake() { #if !MOBILE_INPUT // Create a layer mask for the floor layer. floorMask = LayerMask.GetMask("Floor"); #endif // Set up references. anim = GetComponent <Animator>(); playerRigidbody = GetComponent <Rigidbody>(); #if !UNITY_EDITOR Debug.Log("Initializing Rudder"); rudderInstance = RudderClient.GetInstance(RUDDER_WRITE_KEY, RUDDER_API_URL, RUDDER_FLUSH_QUEUE_SIZE); #endif // Debug.Log("Initializing Amplitude"); // Amplitude amplitude = Amplitude.Instance; // amplitude.logging = true; // amplitude.init(AMPLITUDE_API_KEY); // amplitude.setUserId(SystemInfo.deviceUniqueIdentifier.ToLower()); }
public static RudderClient GetInstance( string writeKey, string endPointUri, int flushQueueSize, int dbCountThreshold, int sleepTimeOut ) { if (instance == null) { // initialize the instance instance = new RudderClient( writeKey, endPointUri, flushQueueSize, dbCountThreshold, sleepTimeOut ); } return instance; }
public static void Screen(RudderClient client) { client.Screen("user", "name", "category", Properties(), Options()); }
public static void Identify(RudderClient client, Traits traits, RudderOptions options) { client.Identify("user", traits, options); RudderAnalytics.Client.Flush(); }
public static void Group(RudderClient client) { client.Group("user", "group", Traits(), Options()); RudderAnalytics.Client.Flush(); }
public static void Track(RudderClient client) { client.Track("user", "Ran .NET test", Properties(), Options()); }
public static void Alias(RudderClient client) { client.Alias("previousId", "to"); }
public void Init() { client = new RudderClient("foo"); }
public void Init() { _client = new RudderClient("foo", new RudderConfig(), Mock.Of <IRequestHandler>()); }
public static void Identify(RudderClient client) { client.Identify("user", Traits(), Options()); RudderAnalytics.Client.Flush(); }