diff --git a/EpsonPrintService/PrintServerBootstrapper.cs b/EpsonPrintService/PrintServerBootstrapper.cs index 40f5906..8b1fa54 100644 --- a/EpsonPrintService/PrintServerBootstrapper.cs +++ b/EpsonPrintService/PrintServerBootstrapper.cs @@ -8,9 +8,11 @@ using Inspectron.Epson.PrintServer.PrinterAssinment; using Inspectron.Epson.PrintServer.Printers; using Inspectron.Epson.PrintServer.Printers.Utils; using Inspectron.Epson.PrintServer.PrintServices; +using Inspectron.Epson.PrintServer.Telemetry; using Inspectron.Epson.Queue; using Microsoft.Extensions.Logging; using Ninject; +using System.Reflection; namespace EpsonPrintService; @@ -45,6 +47,10 @@ public class PrintServerBootstrapper _kernel = new StandardKernel(); _kernel.Bind().ToConstant(new HttpClient { Timeout = TimeSpan.FromSeconds(30) }).InSingletonScope(); + if (_config.EmulationMode) + _kernel.Bind().To().InSingletonScope(); + else + _kernel.Bind().To().InSingletonScope(); _kernel.Bind().ToConstant(_config); if (_config.EmulationMode) @@ -97,7 +103,12 @@ public class PrintServerBootstrapper { _kernel.Bind().ToConstant(handler); } - _kernel.Bind().To().InSingletonScope(); + _kernel.Bind().ToSelf().InSingletonScope(); + _kernel.Bind().ToMethod(ctx => + new InsinTelemetryDiscoveredPrintersReceiver( + ctx.Kernel.Get(), + ctx.Kernel.Get())) + .InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); @@ -120,5 +131,15 @@ public class PrintServerBootstrapper IsRunning = true; Console.WriteLine("Print server started."); + + var version = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "unknown"; + var telemetry = _kernel.Get(); + try + { + telemetry.Emit(InsinEventKinds.ServiceStarted, InsinMessageFormatter.Format( + ("version", version), + ("restaurantId", _config.RestaurantId))); + } + catch { /* telemetry must never fail startup */ } } }