コード例 #1
0
ファイル: Helpers.cs プロジェクト: bartosz-jarmuz/Telimena
        public static ITelimena GetCrackedTelimena(ICollection <ITelemetry> sentTelemetry, Guid telemetryKey, string userName, bool excludeStartingEvent = false)
        {
            var startupInfo = new TelimenaStartupInfo(telemetryKey, Helpers.TeliUri)
            {
                UserInfo = new TelimenaClient.Model.UserInfo()
                {
                    UserIdentifier = userName
                }
            };
            var telimena = TelimenaFactory.Construct(startupInfo);
            StubTelemetryChannel channel = new StubTelemetryChannel
            {
                OnSend = t =>
                {
                    EventTelemetry ev = t as EventTelemetry;
                    if (excludeStartingEvent && ev?.Name == "TelimenaSessionStarted")
                    {
                        return;
                    }
                    sentTelemetry.Add(t);
                }
            };
            TelemetryModule module = telimena.GetFieldValue <TelemetryModule>("telemetryModule");

            SetStaticFieldValue(module, "isSessionStartedEventSent", false);

            TelemetryClient client = module.GetPropertyValue <TelemetryClient>("TelemetryClient");
            var             config = client.GetPropertyValue <TelemetryConfiguration>("TelemetryConfiguration");

            config.SetPropertyValue("TelemetryChannel", channel);


            return(telimena);
        }