diff --git a/src/ArtifactoryUploader/LCT.ArtifactoryUploader.csproj b/src/ArtifactoryUploader/LCT.ArtifactoryUploader.csproj index 38c35b67..7fd3c4cd 100644 --- a/src/ArtifactoryUploader/LCT.ArtifactoryUploader.csproj +++ b/src/ArtifactoryUploader/LCT.ArtifactoryUploader.csproj @@ -23,6 +23,7 @@ + diff --git a/src/ArtifactoryUploader/Program.cs b/src/ArtifactoryUploader/Program.cs index 96a332fc..f9e5999d 100644 --- a/src/ArtifactoryUploader/Program.cs +++ b/src/ArtifactoryUploader/Program.cs @@ -19,6 +19,7 @@ using log4net; using log4net.Core; using System; +using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; @@ -91,6 +92,12 @@ static async Task Main(string[] args) JfrogRepoUpdater.jFrogService = GetJfrogService(appSettings); await PackageUploader.UploadPackageToArtifactory(appSettings); + // Initialize telemetry with CATool version and instrumentation key only if Telemetry is enabled in appsettings + if (appSettings.Telemetry.Enable == true) + { + TelemetryHelper telemetryHelper = new TelemetryHelper(appSettings); + telemetryHelper.StartTelemetry(caToolInformation.CatoolVersion, PackageUploader.uploaderKpiData, TelemetryConstant.ArtifactoryUploaderKpiData); + } Logger.Logger.Log(null, Level.Notice, $"End of Artifactory Uploader execution : {DateTime.Now}\n", null); // publish logs and BOM file to pipeline artifact diff --git a/src/LCT.Common/CommonAppSettings.cs b/src/LCT.Common/CommonAppSettings.cs index e7db107e..6172c217 100644 --- a/src/LCT.Common/CommonAppSettings.cs +++ b/src/LCT.Common/CommonAppSettings.cs @@ -62,6 +62,7 @@ public string ProjectType } } public bool MultipleProjectType { get; set; } = false; + public Telemetry Telemetry { get; set; } public SW360 SW360 { get; set; } public Directory Directory { get; set; } public Jfrog Jfrog { get; set; } @@ -95,6 +96,11 @@ public string LogFolderPath } } } + public class Telemetry + { + public bool Enable { get; set; } = true; + public string ApplicationInsightInstrumentKey { get; set; } + } public class SW360 { private string m_URL; diff --git a/src/LCT.Common/Constants/TelemetryConstant.cs b/src/LCT.Common/Constants/TelemetryConstant.cs new file mode 100644 index 00000000..6f0d57a1 --- /dev/null +++ b/src/LCT.Common/Constants/TelemetryConstant.cs @@ -0,0 +1,28 @@ +// -------------------------------------------------------------------------------------------------------------------- +// SPDX-FileCopyrightText: 2025 Siemens AG +// +// SPDX-License-Identifier: MIT +// -------------------------------------------------------------------------------------------------------------------- +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LCT.Common.Constants +{ + [ExcludeFromCodeCoverage] + public class TelemetryConstant + { + public const string ToolName = "CATool"; + public const string PackageIdentifier = "PackageIdentifierExecution"; + public const string PackageCreator = "PackageCreatorExecution"; + public const string ArtifactoryUploader = "ArtifactoryUploaderExecution"; + public const string IdentifierKpiData = "IdentifierKpiDataTelemetry"; + public const string CreatorKpiData = "CreatorKpiDataTelemetry"; + public const string ArtifactoryUploaderKpiData = "UploaderKpiDataTelemetry"; + public const string Type = "ApplicationInsights"; + public const string StartLogMessage = "Telemetry tracking is now active for this execution. To turn off telemetry, use the command-line option --Telemetry:Enable false or adjust the settings in your appsettings file."; + } +} diff --git a/src/LCT.Common/LCT.Common.csproj b/src/LCT.Common/LCT.Common.csproj index 48228235..d417d592 100644 --- a/src/LCT.Common/LCT.Common.csproj +++ b/src/LCT.Common/LCT.Common.csproj @@ -35,6 +35,7 @@ + diff --git a/src/LCT.Common/TelemetryHelper.cs b/src/LCT.Common/TelemetryHelper.cs new file mode 100644 index 00000000..66b87c59 --- /dev/null +++ b/src/LCT.Common/TelemetryHelper.cs @@ -0,0 +1,100 @@ +// -------------------------------------------------------------------------------------------------------------------- +// SPDX-FileCopyrightText: 2025 Siemens AG +// +// SPDX-License-Identifier: MIT +// -------------------------------------------------------------------------------------------------------------------- +using LCT.Common.Constants; +using LCT.Common.Interface; +using LCT.Telemetry; +using log4net; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; +using System.Linq; +using System.Reflection; + +namespace LCT.Common +{ + public class TelemetryHelper + { + private readonly ILog Logger; + LCT.Telemetry.Telemetry telemetry_; + EnvironmentHelper environmentHelper; + CommonAppSettings appSettings_; + + public TelemetryHelper(CommonAppSettings appSettings) + { + environmentHelper = new EnvironmentHelper(); + Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + appSettings_ = appSettings ?? new CommonAppSettings(); + + telemetry_ = new LCT.Telemetry.Telemetry(TelemetryConstant.Type, new Dictionary + { + { "InstrumentationKey", appSettings.Telemetry.ApplicationInsightInstrumentKey } + }); + } + + public void StartTelemetry(string catoolVersion, T kpiData,string telemetryFor) + { + // Initialize telemetry with CATool version and instrumentation key only if Telemetry is enabled in appsettings + Logger.Warn(TelemetryConstant.StartLogMessage); + try + { + InitializeAndTrackEvent(TelemetryConstant.ToolName, catoolVersion, telemetryFor + , appSettings_); + TrackKpiDataTelemetry(telemetryFor, kpiData); + } + catch (Exception ex) + { + Logger.Error($"An error occurred: {ex.Message}"); + TrackException(ex); + environmentHelper.CallEnvironmentExit(-1); + } + finally + { + telemetry_.Flush(); // Ensure telemetry is sent before application exits + } + } + + private void InitializeAndTrackEvent(string toolName, string toolVersion, string eventName, + CommonAppSettings appSettings) + { + telemetry_.Initialize(toolName, toolVersion); + + telemetry_.TrackCustomEvent(eventName, new Dictionary + { + { "CA Tool Version", toolVersion }, + { "SW360 Project Name", appSettings.SW360.ProjectName }, + { "SW360 Project ID", appSettings.SW360.ProjectID }, + { "Project Type", appSettings.ProjectType }, + { "Hashed User ID", HashUtility.GetHashString(Environment.UserName) }, + { "Start Time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture) } + }); + } + private void TrackKpiDataTelemetry(string eventName, T kpiData) + { + var properties = typeof(T).GetProperties(); + var telemetryData = properties.ToDictionary( + prop => prop.GetCustomAttribute()?.DisplayName ?? prop.Name, + prop => prop.GetValue(kpiData)?.ToString() + ); + + telemetryData["Hashed User ID"] = HashUtility.GetHashString(Environment.UserName); + telemetryData["Time stamp"] = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); + + telemetry_.TrackCustomEvent(eventName, telemetryData); + } + + private void TrackException(Exception ex) + { + var exceptionData = new Dictionary + { + { "Error Time", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture) }, + { "Stack Trace", ex.StackTrace } + }; + + telemetry_.TrackException(ex, exceptionData); + } + } +} \ No newline at end of file diff --git a/src/LCT.Common/appSettings.json b/src/LCT.Common/appSettings.json index 70ac5a75..a12797d5 100644 --- a/src/LCT.Common/appSettings.json +++ b/src/LCT.Common/appSettings.json @@ -8,6 +8,10 @@ "TimeOut": 400, "ProjectType": "", "MultipleProjectType": false, + "Telemetry": { + "Enable": true, + "ApplicationInsightInstrumentKey": "" //From Application Insight to enable Telemetry + }, "SW360": { "URL": "", "ProjectName": "", diff --git a/src/LCT.PackageIdentifier/LCT.PackageIdentifier.csproj b/src/LCT.PackageIdentifier/LCT.PackageIdentifier.csproj index 3e85fbff..e6ff68d3 100644 --- a/src/LCT.PackageIdentifier/LCT.PackageIdentifier.csproj +++ b/src/LCT.PackageIdentifier/LCT.PackageIdentifier.csproj @@ -34,6 +34,7 @@ + diff --git a/src/LCT.PackageIdentifier/Program.cs b/src/LCT.PackageIdentifier/Program.cs index 05923ce7..8df93f87 100644 --- a/src/LCT.PackageIdentifier/Program.cs +++ b/src/LCT.PackageIdentifier/Program.cs @@ -111,8 +111,13 @@ static async Task Main(string[] args) await bomCreator.GenerateBom(appSettings, new BomHelper(), new FileOperations(), projectReleases, caToolInformation); } - Logger.Logger.Log(null, Level.Notice, $"End of Package Identifier execution : {DateTime.Now}\n", null); + if (appSettings.Telemetry.Enable == true) + { + TelemetryHelper telemetryHelper = new TelemetryHelper(appSettings); + telemetryHelper.StartTelemetry(caToolInformation.CatoolVersion, BomCreator.bomKpiData, TelemetryConstant.IdentifierKpiData); + } + Logger.Logger.Log(null, Level.Notice, $"End of Package Identifier execution : {DateTime.Now}\n", null); // publish logs and bom file to pipeline artifact PipelineArtifactUploader.UploadArtifacts(); diff --git a/src/LCT.SW360PackageCreator/ComponentCreator.cs b/src/LCT.SW360PackageCreator/ComponentCreator.cs index 33451d25..0cd94b43 100644 --- a/src/LCT.SW360PackageCreator/ComponentCreator.cs +++ b/src/LCT.SW360PackageCreator/ComponentCreator.cs @@ -34,6 +34,8 @@ namespace LCT.SW360PackageCreator public class ComponentCreator : IComponentCreator { static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public static CreatorKpiData kpiData = new(); public List UpdatedCompareBomData { get; set; } = new List(); public List ReleasesFoundInCbom { get; set; } = new List(); public List ComponentsNotLinked { get; set; } = new List(); @@ -255,7 +257,7 @@ public async Task CreateComponentInSw360(CommonAppSettings appSettings, FileConstant.ComponentsWithoutSrcFileName, appSettings.SW360.ProjectName); // write Kpi Data - CreatorKpiData kpiData = creatorHelper.GetCreatorKpiData(UpdatedCompareBomData); + kpiData =creatorHelper.GetCreatorKpiData (UpdatedCompareBomData); fileOperations.WriteContentToFile(kpiData, bomGenerationPath, FileConstant.CreatorKpiDataFileName, appSettings.SW360.ProjectName); diff --git a/src/LCT.SW360PackageCreator/CreatorHelper.cs b/src/LCT.SW360PackageCreator/CreatorHelper.cs index e5a4c4b4..f356053f 100644 --- a/src/LCT.SW360PackageCreator/CreatorHelper.cs +++ b/src/LCT.SW360PackageCreator/CreatorHelper.cs @@ -393,7 +393,7 @@ public CreatorKpiData GetCreatorKpiData(List updatedCompareBo Program.CreatorStopWatch.Stop(); creatorKpiData.TimeTakenByComponentCreator = TimeSpan.FromMilliseconds(Program.CreatorStopWatch.ElapsedMilliseconds).TotalSeconds; - + return creatorKpiData; } diff --git a/src/LCT.SW360PackageCreator/LCT.SW360PackageCreator.csproj b/src/LCT.SW360PackageCreator/LCT.SW360PackageCreator.csproj index 927cd806..10e3a8c1 100644 --- a/src/LCT.SW360PackageCreator/LCT.SW360PackageCreator.csproj +++ b/src/LCT.SW360PackageCreator/LCT.SW360PackageCreator.csproj @@ -30,6 +30,7 @@ + diff --git a/src/LCT.SW360PackageCreator/Program.cs b/src/LCT.SW360PackageCreator/Program.cs index 9ea1637d..42c7a884 100644 --- a/src/LCT.SW360PackageCreator/Program.cs +++ b/src/LCT.SW360PackageCreator/Program.cs @@ -99,7 +99,12 @@ static async Task Main(string[] args) await CreatorValidator.TriggerFossologyValidation(appSettings, sW360ApicommunicationFacade); } await InitiatePackageCreatorProcess(appSettings, sw360ProjectService, sW360ApicommunicationFacade); - + // Initialize telemetry with CATool version and instrumentation key only if Telemetry is enabled in appsettings + if (appSettings.Telemetry.Enable == true) + { + TelemetryHelper telemetryHelper = new TelemetryHelper(appSettings); + telemetryHelper.StartTelemetry(caToolInformation.CatoolVersion, ComponentCreator.kpiData,TelemetryConstant.CreatorKpiData); + } Logger.Logger.Log(null, Level.Notice, $"End of Package Creator execution: {DateTime.Now}\n", null); // publish logs and bom file to pipeline artifact diff --git a/src/LCT.Telemetry/ApplicationInsightsTelemetryProvider.cs b/src/LCT.Telemetry/ApplicationInsightsTelemetryProvider.cs new file mode 100644 index 00000000..c951f27e --- /dev/null +++ b/src/LCT.Telemetry/ApplicationInsightsTelemetryProvider.cs @@ -0,0 +1,58 @@ +// -------------------------------------------------------------------------------------------------------------------- +// SPDX-FileCopyrightText: 2025 Siemens AG +// +// SPDX-License-Identifier: MIT +// -------------------------------------------------------------------------------------------------------------------- +using Microsoft.ApplicationInsights; +using Microsoft.ApplicationInsights.DataContracts; +using Microsoft.ApplicationInsights.Extensibility; + +namespace LCT.Telemetry +{ + public class ApplicationInsightsTelemetryProvider : ITelemetryProvider + { + private readonly TelemetryClient _telemetryClient; + + public ApplicationInsightsTelemetryProvider(Dictionary configuration) + { + var instrumentationKey = configuration.GetValueOrDefault("InstrumentationKey") + ?? Environment.GetEnvironmentVariable("TelemetryInstrumentationKey"); + + if (string.IsNullOrEmpty(instrumentationKey)) + { + throw new InvalidOperationException("Application Insights Instrumentation Key is missing or invalid."); + } + + var aiConfig = TelemetryConfiguration.CreateDefault(); + aiConfig.InstrumentationKey = instrumentationKey; + + _telemetryClient = new TelemetryClient(aiConfig); + } + + public void TrackEvent(string eventName, Dictionary properties = null) + { + _telemetryClient.TrackEvent(eventName, properties); + } + + public void TrackException(Exception ex, Dictionary properties = null) + { + var exceptionTelemetry = new ExceptionTelemetry(ex); + + if (properties != null) + { + foreach (var property in properties) + { + exceptionTelemetry.Properties[property.Key] = property.Value; + } + } + + _telemetryClient.TrackException(exceptionTelemetry); + } + + public void Flush() + { + _telemetryClient.Flush(); + Thread.Sleep(1000); // Allow some time for telemetry to be sent + } + } +} \ No newline at end of file diff --git a/src/LCT.Telemetry/HashUtility.cs b/src/LCT.Telemetry/HashUtility.cs new file mode 100644 index 00000000..6faa67d3 --- /dev/null +++ b/src/LCT.Telemetry/HashUtility.cs @@ -0,0 +1,27 @@ +// -------------------------------------------------------------------------------------------------------------------- +// SPDX-FileCopyrightText: 2025 Siemens AG +// +// SPDX-License-Identifier: MIT +// -------------------------------------------------------------------------------------------------------------------- +using System.Security.Cryptography; +using System.Text; + +namespace LCT.Telemetry +{ + public static class HashUtility + { + public static string GetHashString(string input) + { + if (string.IsNullOrEmpty(input)) + { + return string.Empty; + } + + using (var hashAlgorithm = SHA256.Create()) + { + byte[] hashBytes = hashAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(input)); + return BitConverter.ToString(hashBytes).Replace("-", "").ToLowerInvariant(); + } + } + } +} \ No newline at end of file diff --git a/src/LCT.Telemetry/ITelemetryProvider.cs b/src/LCT.Telemetry/ITelemetryProvider.cs new file mode 100644 index 00000000..b352e933 --- /dev/null +++ b/src/LCT.Telemetry/ITelemetryProvider.cs @@ -0,0 +1,14 @@ +// -------------------------------------------------------------------------------------------------------------------- +// SPDX-FileCopyrightText: 2025 Siemens AG +// +// SPDX-License-Identifier: MIT +// -------------------------------------------------------------------------------------------------------------------- +namespace LCT.Telemetry +{ + public interface ITelemetryProvider + { + void TrackEvent(string eventName, Dictionary properties = null); + void TrackException(Exception ex, Dictionary properties = null); + void Flush(); + } +} \ No newline at end of file diff --git a/src/LCT.Telemetry/LCT.Telemetry.csproj b/src/LCT.Telemetry/LCT.Telemetry.csproj new file mode 100644 index 00000000..94ce0844 --- /dev/null +++ b/src/LCT.Telemetry/LCT.Telemetry.csproj @@ -0,0 +1,22 @@ + + + + net8.0 + 7.0.2 + enable + enable + + + ..\..\out + + + + true + true + + + + + + + diff --git a/src/LCT.Telemetry/Telemetry.cs b/src/LCT.Telemetry/Telemetry.cs new file mode 100644 index 00000000..12200a44 --- /dev/null +++ b/src/LCT.Telemetry/Telemetry.cs @@ -0,0 +1,91 @@ +// -------------------------------------------------------------------------------------------------------------------- +// SPDX-FileCopyrightText: 2025 Siemens AG +// +// SPDX-License-Identifier: MIT +// -------------------------------------------------------------------------------------------------------------------- +using System.Diagnostics; +using System.Globalization; + +/// +/// Telemtetry class to track custom events, exceptions and execution time +/// + +namespace LCT.Telemetry +{ + public class Telemetry + { + private readonly ITelemetryProvider _telemetryProvider; + private readonly Stopwatch _stopwatch; + + public Telemetry(string telemetryType, Dictionary configuration) + { + _stopwatch = new Stopwatch(); + + if (!Enum.TryParse(telemetryType, true, out var parsedTelemetryType)) + { + throw new NotSupportedException($"Telemetry type '{telemetryType}' is not supported."); + } + + _telemetryProvider = TelemetryProviderFactory.CreateTelemetryProvider( + parsedTelemetryType, + configuration ?? throw new ArgumentNullException(nameof(configuration), "Configuration cannot be null.") + ); + } + + + public void Initialize(string appName, string version) + { + _stopwatch.Start(); + + _telemetryProvider.TrackEvent("ApplicationStarted", new Dictionary + { + { "App Name", appName }, + { "Version", version }, + { "Start Time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture) }, + { "Hashed User ID", HashUtility.GetHashString(Environment.UserName) } + }); + + TrackUserDetails(); + } + + public void TrackCustomEvent(string eventName, Dictionary properties = null) + { + _telemetryProvider.TrackEvent(eventName, properties); + } + + public void TrackException(Exception ex, Dictionary properties = null) + { + _telemetryProvider.TrackException(ex, properties); + } + + public void TrackExecutionTime() + { + _stopwatch.Stop(); + + _telemetryProvider.TrackEvent("ApplicationExecutionTime", new Dictionary + { + { "Hashed User ID", HashUtility.GetHashString(Environment.UserName) }, + { "Total Execution Time", $"{_stopwatch.Elapsed.TotalSeconds} seconds" }, + { "End Time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture) } + }); + } + + public void Flush() + { + _telemetryProvider.Flush(); + } + + private void TrackUserDetails() + { + string userName = HashUtility.GetHashString(Environment.UserName); + string machineName = Environment.MachineName; + + _telemetryProvider.TrackEvent("UserDetails", new Dictionary + { + { "User Id", userName }, + { "Machine Name", machineName }, + { "Login Time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture) } + }); + } + } +} \ No newline at end of file diff --git a/src/LCT.Telemetry/TelemetryProviderFactory.cs b/src/LCT.Telemetry/TelemetryProviderFactory.cs new file mode 100644 index 00000000..acf9083e --- /dev/null +++ b/src/LCT.Telemetry/TelemetryProviderFactory.cs @@ -0,0 +1,41 @@ +// -------------------------------------------------------------------------------------------------------------------- +// SPDX-FileCopyrightText: 2025 Siemens AG +// +// SPDX-License-Identifier: MIT +// -------------------------------------------------------------------------------------------------------------------- +using System; +using System.Collections.Generic; + +namespace LCT.Telemetry +{ + /// + /// Enum to define the available telemetry types. + /// + public enum TelemetryType + { + ApplicationInsights = 1, + // Add future telemetry types here, e.g., NewTelemetryProvider = 2 + } + + /// + /// This class is responsible for creating the telemetry provider based on the configuration. + /// We can add different providers here in the future, instead of Application Insights. + /// + public static class TelemetryProviderFactory + { + /// + /// Creates the telemetry provider based on the specified telemetry type and configuration. + /// + /// The telemetry type as an enum. + /// The configuration for the telemetry provider. + /// An instance of ITelemetryProvider. + public static ITelemetryProvider CreateTelemetryProvider(TelemetryType telemetryType, Dictionary configuration) + { + return telemetryType switch + { + TelemetryType.ApplicationInsights => new ApplicationInsightsTelemetryProvider(configuration), + _ => throw new NotSupportedException($"Telemetry type '{telemetryType}' is not supported.") + }; + } + } +} \ No newline at end of file diff --git a/src/LicenseClearingTool.sln b/src/LicenseClearingTool.sln index f06131f7..105c9277 100644 --- a/src/LicenseClearingTool.sln +++ b/src/LicenseClearingTool.sln @@ -43,6 +43,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LCT.APICommunications", "LC EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LCT.APICommunications.UTest", "LCT.APICommunications.UTest\LCT.APICommunications.UTest.csproj", "{7DB37334-8EFC-4750-A97D-D6885E0118BD}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LCT.Telemetry", "LCT.Telemetry\LCT.Telemetry.csproj", "{F7C20877-F891-4D8F-855D-EAAED7494A7D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LCT.Telemetry.UTest", "Telemetry.UTest\LCT.Telemetry.UTest.csproj", "{A0632D1A-6BDD-47BC-A258-ECB386E5BA4E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -121,6 +125,14 @@ Global {7DB37334-8EFC-4750-A97D-D6885E0118BD}.Debug|Any CPU.Build.0 = Debug|Any CPU {7DB37334-8EFC-4750-A97D-D6885E0118BD}.Release|Any CPU.ActiveCfg = Release|Any CPU {7DB37334-8EFC-4750-A97D-D6885E0118BD}.Release|Any CPU.Build.0 = Release|Any CPU + {F7C20877-F891-4D8F-855D-EAAED7494A7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F7C20877-F891-4D8F-855D-EAAED7494A7D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F7C20877-F891-4D8F-855D-EAAED7494A7D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F7C20877-F891-4D8F-855D-EAAED7494A7D}.Release|Any CPU.Build.0 = Release|Any CPU + {A0632D1A-6BDD-47BC-A258-ECB386E5BA4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A0632D1A-6BDD-47BC-A258-ECB386E5BA4E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A0632D1A-6BDD-47BC-A258-ECB386E5BA4E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A0632D1A-6BDD-47BC-A258-ECB386E5BA4E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -136,6 +148,7 @@ Global {ACA55F0B-EECF-47B2-BB8C-0214C683B3E1} = {9EB2283A-19DA-4DC8-907A-A22EE30B6C85} {BD44EDF9-DE47-40B6-AA1F-9935455A0E91} = {9EB2283A-19DA-4DC8-907A-A22EE30B6C85} {7DB37334-8EFC-4750-A97D-D6885E0118BD} = {9EB2283A-19DA-4DC8-907A-A22EE30B6C85} + {A0632D1A-6BDD-47BC-A258-ECB386E5BA4E} = {9EB2283A-19DA-4DC8-907A-A22EE30B6C85} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {F02FC756-D33C-421D-9734-4D7D4FB860CD} diff --git a/src/SW360IntegrationTest/Alpine/ComponentCreatorInitialAlpine.cs b/src/SW360IntegrationTest/Alpine/ComponentCreatorInitialAlpine.cs index 5a56f977..1436d231 100644 --- a/src/SW360IntegrationTest/Alpine/ComponentCreatorInitialAlpine.cs +++ b/src/SW360IntegrationTest/Alpine/ComponentCreatorInitialAlpine.cs @@ -46,6 +46,7 @@ public void Setup() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.ProjectType,"ALPINE", TestConstant.Mode,""}); } @@ -66,6 +67,7 @@ public void ComponentCreatorExe_ProvidedBOMFilePath_ReturnsSuccess() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.ProjectType,"ALPINE", TestConstant.EnableFossologyTrigger,testParameters.FossologyTrigger, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.FossologyURL, testParameters.FossUrl, TestConstant.Mode,""}), "Test to run component creator EXE execution"); diff --git a/src/SW360IntegrationTest/Alpine/PackageIdentifierInitialAlpine.cs b/src/SW360IntegrationTest/Alpine/PackageIdentifierInitialAlpine.cs index 7384908c..ccd8e5bb 100644 --- a/src/SW360IntegrationTest/Alpine/PackageIdentifierInitialAlpine.cs +++ b/src/SW360IntegrationTest/Alpine/PackageIdentifierInitialAlpine.cs @@ -52,6 +52,7 @@ public void RunBOMCreatorexe_ProvidedPackageJsonFilePath_ReturnsSuccess() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.ProjectType,"ALPINE", TestConstant.Mode,""}), "Test to run Package Identifier EXE execution"); diff --git a/src/SW360IntegrationTest/Conan/ArtifactoryUploaderConan.cs b/src/SW360IntegrationTest/Conan/ArtifactoryUploaderConan.cs index 27adda0b..6a33aa0b 100644 --- a/src/SW360IntegrationTest/Conan/ArtifactoryUploaderConan.cs +++ b/src/SW360IntegrationTest/Conan/ArtifactoryUploaderConan.cs @@ -26,6 +26,7 @@ public void TestArtifactoryUploaderexe() TestConstant.JfrogConanDevDestRepoName,testParameters.DevDestinationRepoName, TestConstant.JfrogConanInternalDestRepoName,testParameters.InternalDestinationRepoName, TestConstant.JFrogApiURL,testParameters.JfrogApi, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.DryRun, false.ToString() }); diff --git a/src/SW360IntegrationTest/Conan/ComponentCreatorInitialConan.cs b/src/SW360IntegrationTest/Conan/ComponentCreatorInitialConan.cs index bb77ff20..e8dcb5af 100644 --- a/src/SW360IntegrationTest/Conan/ComponentCreatorInitialConan.cs +++ b/src/SW360IntegrationTest/Conan/ComponentCreatorInitialConan.cs @@ -37,6 +37,7 @@ public void Setup() TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.JfrogConanInternalRepo,"Conan-test", TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.ProjectType, "CONAN", TestConstant.Mode,"" }); @@ -57,6 +58,7 @@ public void TestComponentCreatorExe_Conan() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.FossologyURL, testParameters.FossUrl, TestConstant.EnableFossologyTrigger,testParameters.FossologyTrigger, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.Mode,"" }), "Test to run Package Creator EXE execution"); diff --git a/src/SW360IntegrationTest/Conan/PackageIdentifierInitialConan.cs b/src/SW360IntegrationTest/Conan/PackageIdentifierInitialConan.cs index 96491b7d..5fb7203e 100644 --- a/src/SW360IntegrationTest/Conan/PackageIdentifierInitialConan.cs +++ b/src/SW360IntegrationTest/Conan/PackageIdentifierInitialConan.cs @@ -44,6 +44,7 @@ public void RunBOMCreatorexe_ProvidedPackageJsonFilePath_ReturnsSuccess() TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, TestConstant.JfrogConanInternalRepo,"Conan-test", TestConstant.ProjectType,"Conan", + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.Mode,""}), "Test to run Package Identifier EXE execution"); } diff --git a/src/SW360IntegrationTest/Debian/ComponentCreatorInitialDebian.cs b/src/SW360IntegrationTest/Debian/ComponentCreatorInitialDebian.cs index 2e01672a..a190c168 100644 --- a/src/SW360IntegrationTest/Debian/ComponentCreatorInitialDebian.cs +++ b/src/SW360IntegrationTest/Debian/ComponentCreatorInitialDebian.cs @@ -44,6 +44,7 @@ public void Setup() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.JfrogDebianInternalRepo,"Debian-test", TestConstant.ProjectType,"DEBIAN", TestConstant.Mode,""}); @@ -66,6 +67,7 @@ public void ComponentCreatorExe_ProvidedBOMFilePath_ReturnsSuccess() TestConstant.ProjectType,"DEBIAN", TestConstant.FossologyURL, testParameters.FossUrl, TestConstant.EnableFossologyTrigger,testParameters.FossologyTrigger, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.Mode,""}), "Test to run component creator EXE execution"); } diff --git a/src/SW360IntegrationTest/Debian/PackageIdentifierInitialDebian.cs b/src/SW360IntegrationTest/Debian/PackageIdentifierInitialDebian.cs index 265ca623..8b3c6130 100644 --- a/src/SW360IntegrationTest/Debian/PackageIdentifierInitialDebian.cs +++ b/src/SW360IntegrationTest/Debian/PackageIdentifierInitialDebian.cs @@ -52,6 +52,7 @@ public void RunBOMCreatorexe_ProvidedPackageJsonFilePath_ReturnsSuccess() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.JfrogDebianInternalRepo,"Debian-test", TestConstant.ProjectType,"Debian", TestConstant.Mode,""}), diff --git a/src/SW360IntegrationTest/Maven/ArtifactoryUploaderMaven.cs b/src/SW360IntegrationTest/Maven/ArtifactoryUploaderMaven.cs index 257f887c..bd0d28a6 100644 --- a/src/SW360IntegrationTest/Maven/ArtifactoryUploaderMaven.cs +++ b/src/SW360IntegrationTest/Maven/ArtifactoryUploaderMaven.cs @@ -31,6 +31,7 @@ public void TestArtifactoryUploaderexe() TestConstant.JfrogMavenDevDestRepoName,testParameters.DevDestinationRepoName, TestConstant.JfrogMavenInternalDestRepoName,testParameters.InternalDestinationRepoName, TestConstant.JFrogApiURL,testParameters.JfrogApi, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.DryRun, false.ToString() }); diff --git a/src/SW360IntegrationTest/Maven/ComponentCreatorInitialMaven.cs b/src/SW360IntegrationTest/Maven/ComponentCreatorInitialMaven.cs index 0a588dd5..d8727ed0 100644 --- a/src/SW360IntegrationTest/Maven/ComponentCreatorInitialMaven.cs +++ b/src/SW360IntegrationTest/Maven/ComponentCreatorInitialMaven.cs @@ -47,6 +47,7 @@ public void Setup() TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, TestConstant.JfrogMavenInternalRepo,"Maven-test", + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.ProjectType,"MAVEN", TestConstant.Mode,""}); } @@ -67,6 +68,7 @@ public void ComponentCreatorExe_ProvidedBOMFilePath_ReturnsSuccess() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.FossologyURL, testParameters.FossUrl, TestConstant.EnableFossologyTrigger,testParameters.FossologyTrigger, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.Mode,""}), "Test to run Package Creator EXE execution"); } diff --git a/src/SW360IntegrationTest/Maven/PackageIdentifierInitialMaven.cs b/src/SW360IntegrationTest/Maven/PackageIdentifierInitialMaven.cs index 06ba4bf8..40e29967 100644 --- a/src/SW360IntegrationTest/Maven/PackageIdentifierInitialMaven.cs +++ b/src/SW360IntegrationTest/Maven/PackageIdentifierInitialMaven.cs @@ -51,6 +51,7 @@ public void RunBOMCreatorexe_ProvidedPackageJsonFilePath_ReturnsSuccess() TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, TestConstant.JfrogMavenInternalRepo,"Maven-test", + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.ProjectType,"Maven", TestConstant.Mode,""}), "Test to run Package Identifier EXE execution"); diff --git a/src/SW360IntegrationTest/NPM/ArtifactoryUploaderNpm.cs b/src/SW360IntegrationTest/NPM/ArtifactoryUploaderNpm.cs index 33760aef..28b574f4 100644 --- a/src/SW360IntegrationTest/NPM/ArtifactoryUploaderNpm.cs +++ b/src/SW360IntegrationTest/NPM/ArtifactoryUploaderNpm.cs @@ -31,6 +31,7 @@ public void TestArtifactoryUploaderexe() TestConstant.JfrogNpmDevDestRepoName,testParameters.DevDestinationRepoName, TestConstant.JfrogNpmInternalDestRepoName,testParameters.InternalDestinationRepoName, TestConstant.JFrogApiURL,testParameters.JfrogApi, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.DryRun, false.ToString() }); diff --git a/src/SW360IntegrationTest/NPM/ComponentCreatorInitial.cs b/src/SW360IntegrationTest/NPM/ComponentCreatorInitial.cs index aabba534..2f45efce 100644 --- a/src/SW360IntegrationTest/NPM/ComponentCreatorInitial.cs +++ b/src/SW360IntegrationTest/NPM/ComponentCreatorInitial.cs @@ -44,6 +44,7 @@ public void Setup() TestConstant.SW360ProjectID, testParameters.SW360ProjectID, TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.JfrogNpmInternalRepo,"Npm-test", TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, TestConstant.ProjectType, "NPM", @@ -66,6 +67,7 @@ public void TestComponentCreatorExe() TestConstant.SW360ProjectID, testParameters.SW360ProjectID, TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.EnableFossologyTrigger,testParameters.FossologyTrigger, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.FossologyURL,testParameters.FossUrl }), "Test to run Package Creator EXE execution"); } diff --git a/src/SW360IntegrationTest/NPM/ComponentCreatorTestMode.cs b/src/SW360IntegrationTest/NPM/ComponentCreatorTestMode.cs index a564363e..96c21808 100644 --- a/src/SW360IntegrationTest/NPM/ComponentCreatorTestMode.cs +++ b/src/SW360IntegrationTest/NPM/ComponentCreatorTestMode.cs @@ -44,6 +44,7 @@ public void Setup() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.ProjectType, "NPM", TestConstant.Mode,"test" }); @@ -65,6 +66,7 @@ public void TestComponentCreatorExe_TestMode() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.FossologyURL, testParameters.FossUrl, TestConstant.EnableFossologyTrigger,testParameters.FossologyTrigger, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.Mode,"test" }), "Test to run Package Creator EXE execution"); diff --git a/src/SW360IntegrationTest/NPM/ComponentCreatorWithUpdatedComponents.cs b/src/SW360IntegrationTest/NPM/ComponentCreatorWithUpdatedComponents.cs index c0dcdfe7..5d51890e 100644 --- a/src/SW360IntegrationTest/NPM/ComponentCreatorWithUpdatedComponents.cs +++ b/src/SW360IntegrationTest/NPM/ComponentCreatorWithUpdatedComponents.cs @@ -49,6 +49,7 @@ public void Setup() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.ProjectType, "NPM", TestConstant.Mode,"" }); } @@ -69,6 +70,7 @@ public void TestComponentCreatorExe() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.FossologyURL, testParameters.FossUrl, TestConstant.EnableFossologyTrigger,testParameters.FossologyTrigger, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.Mode,"" }), "Test to run Package Creator EXE execution"); } diff --git a/src/SW360IntegrationTest/NPM/PackageIdentifierInitial.cs b/src/SW360IntegrationTest/NPM/PackageIdentifierInitial.cs index eb2c959c..23bb5d13 100644 --- a/src/SW360IntegrationTest/NPM/PackageIdentifierInitial.cs +++ b/src/SW360IntegrationTest/NPM/PackageIdentifierInitial.cs @@ -52,6 +52,7 @@ public void TestBOMCreatorexe() TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, TestConstant.JfrogNpmInternalRepo,"Npm-test", TestConstant.ProjectType, "Npm", + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.Mode,""}), "Test to run Package Identifier EXE execution"); } diff --git a/src/SW360IntegrationTest/NPM/PackageIdentifierInitialTestMode.cs b/src/SW360IntegrationTest/NPM/PackageIdentifierInitialTestMode.cs index f1abafff..16a5d07e 100644 --- a/src/SW360IntegrationTest/NPM/PackageIdentifierInitialTestMode.cs +++ b/src/SW360IntegrationTest/NPM/PackageIdentifierInitialTestMode.cs @@ -101,6 +101,7 @@ public void TestBOMCreatorexe() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.ProjectType, "NPM", TestConstant.Mode,"test" }), diff --git a/src/SW360IntegrationTest/NPM/PackageIdentifierWithMultiplePackageLockInputs.cs b/src/SW360IntegrationTest/NPM/PackageIdentifierWithMultiplePackageLockInputs.cs index 0baedf42..d70f12b2 100644 --- a/src/SW360IntegrationTest/NPM/PackageIdentifierWithMultiplePackageLockInputs.cs +++ b/src/SW360IntegrationTest/NPM/PackageIdentifierWithMultiplePackageLockInputs.cs @@ -50,6 +50,7 @@ public void TestBOMCreatorexe() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.JfrogNpmInternalRepo,"Npm-test", TestConstant.ProjectType, "NPM", TestConstant.Mode,""}), diff --git a/src/SW360IntegrationTest/NPM/PackageIdentifierWithUpdatedComponents.cs b/src/SW360IntegrationTest/NPM/PackageIdentifierWithUpdatedComponents.cs index 7ee8e5b1..17578751 100644 --- a/src/SW360IntegrationTest/NPM/PackageIdentifierWithUpdatedComponents.cs +++ b/src/SW360IntegrationTest/NPM/PackageIdentifierWithUpdatedComponents.cs @@ -50,6 +50,7 @@ public void TestBOMCreatorexe() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.JfrogNpmInternalRepo,"Npm-test", TestConstant.ProjectType, "NPM", TestConstant.Mode,"" }), "Test to run Package Identifier EXE execution"); diff --git a/src/SW360IntegrationTest/Nuget/ArtifactoryUploaderNuget.cs b/src/SW360IntegrationTest/Nuget/ArtifactoryUploaderNuget.cs index 7daba373..1f9cee85 100644 --- a/src/SW360IntegrationTest/Nuget/ArtifactoryUploaderNuget.cs +++ b/src/SW360IntegrationTest/Nuget/ArtifactoryUploaderNuget.cs @@ -33,6 +33,7 @@ public void TestArtifactoryUploaderexe() TestConstant.JfrogNugetDevDestRepoName,testParameters.DevDestinationRepoName, TestConstant.JfrogNugetInternalDestRepoName,testParameters.InternalDestinationRepoName, TestConstant.JFrogApiURL,testParameters.JfrogApi, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.DryRun, false.ToString() }), "Test to run Artifactory Uploader EXE execution"); diff --git a/src/SW360IntegrationTest/Nuget/ComponentCreatorInitialNuget.cs b/src/SW360IntegrationTest/Nuget/ComponentCreatorInitialNuget.cs index e84eadad..9d78a11c 100644 --- a/src/SW360IntegrationTest/Nuget/ComponentCreatorInitialNuget.cs +++ b/src/SW360IntegrationTest/Nuget/ComponentCreatorInitialNuget.cs @@ -46,6 +46,7 @@ public void Setup() TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.JfrogNugetInternalRepo,"Nuget-test", TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.ProjectType,"NUGET", TestConstant.Mode,""}); } @@ -67,6 +68,7 @@ public void ComponentCreatorExe_ProvidedBOMFilePath_ReturnsSuccess() TestConstant.ProjectType,"NUGET", TestConstant.FossologyURL, testParameters.FossUrl, TestConstant.EnableFossologyTrigger,testParameters.FossologyTrigger, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.Mode,""}), "Test to run Package Creator EXE execution"); } diff --git a/src/SW360IntegrationTest/Nuget/NugetTemplate/ComponentCreatorNugetTemplate.cs b/src/SW360IntegrationTest/Nuget/NugetTemplate/ComponentCreatorNugetTemplate.cs index 6c706b68..61b2077a 100644 --- a/src/SW360IntegrationTest/Nuget/NugetTemplate/ComponentCreatorNugetTemplate.cs +++ b/src/SW360IntegrationTest/Nuget/NugetTemplate/ComponentCreatorNugetTemplate.cs @@ -46,6 +46,7 @@ public void Setup() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.JfrogNugetInternalRepo,"Nuget-test", TestConstant.ProjectType,"NUGET", TestConstant.Mode,""}); @@ -69,6 +70,7 @@ public void ComponentCreatorExe_ProvidedBOMFilePath_ReturnsSuccess() TestConstant.ProjectType,"NUGET", TestConstant.FossologyURL, testParameters.FossUrl, TestConstant.EnableFossologyTrigger,testParameters.FossologyTrigger, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.Mode,""}); Assert.IsTrue(value == 0 || value == 2, diff --git a/src/SW360IntegrationTest/Nuget/NugetTemplate/PackageIdentifierNugetTemplate.cs b/src/SW360IntegrationTest/Nuget/NugetTemplate/PackageIdentifierNugetTemplate.cs index 70232bfd..6d6a87cc 100644 --- a/src/SW360IntegrationTest/Nuget/NugetTemplate/PackageIdentifierNugetTemplate.cs +++ b/src/SW360IntegrationTest/Nuget/NugetTemplate/PackageIdentifierNugetTemplate.cs @@ -51,6 +51,7 @@ public void RunBOMCreatorexe_ProvidedPackageJsonFilePath_ReturnsSuccess() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.JfrogNugetInternalRepo,"Nuget-test", TestConstant.ProjectType,"NUGET", TestConstant.Mode,""}), diff --git a/src/SW360IntegrationTest/Nuget/PackageIdentifierInitialNuget.cs b/src/SW360IntegrationTest/Nuget/PackageIdentifierInitialNuget.cs index aa2d0bc2..392c0621 100644 --- a/src/SW360IntegrationTest/Nuget/PackageIdentifierInitialNuget.cs +++ b/src/SW360IntegrationTest/Nuget/PackageIdentifierInitialNuget.cs @@ -50,6 +50,7 @@ public void RunBOMCreatorexe_ProvidedPackageJsonFilePath_ReturnsSuccess() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.JfrogNugetInternalRepo,"Nuget-test", TestConstant.ProjectType,"Nuget", TestConstant.Mode,""}), diff --git a/src/SW360IntegrationTest/Python/ArtifactoryUploaderPython.cs b/src/SW360IntegrationTest/Python/ArtifactoryUploaderPython.cs index bc43a56b..8df4da82 100644 --- a/src/SW360IntegrationTest/Python/ArtifactoryUploaderPython.cs +++ b/src/SW360IntegrationTest/Python/ArtifactoryUploaderPython.cs @@ -32,6 +32,7 @@ public void TestArtifactoryUploaderexe() TestConstant.JfrogPythonThirdPartyDestRepoName,testParameters.ThirdPartyDestinationRepoName, TestConstant.JfrogPythonDevDestRepoName,testParameters.DevDestinationRepoName, TestConstant.JfrogPythonInternalDestRepoName,testParameters.InternalDestinationRepoName, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.JFrogApiURL,testParameters.JfrogApi, TestConstant.DryRun, false.ToString() }); diff --git a/src/SW360IntegrationTest/Python/ComponentCreatorInitialPython.cs b/src/SW360IntegrationTest/Python/ComponentCreatorInitialPython.cs index 020661c8..53d0fc02 100644 --- a/src/SW360IntegrationTest/Python/ComponentCreatorInitialPython.cs +++ b/src/SW360IntegrationTest/Python/ComponentCreatorInitialPython.cs @@ -44,6 +44,7 @@ public void Setup() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.JfrogPoetryInternalRepo,"Pypi-test", TestConstant.ProjectType,"POETRY", TestConstant.Mode,""}); @@ -65,6 +66,7 @@ public void ComponentCreatorExe_ProvidedBOMFilePath_ReturnsSuccess() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.FossologyURL, testParameters.FossUrl, TestConstant.EnableFossologyTrigger,testParameters.FossologyTrigger, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.Mode,""}); Assert.IsTrue(returnValue == 0 || returnValue == 2, "Test to run Package Creator EXE execution"); diff --git a/src/SW360IntegrationTest/Python/PackageIdentifierInitialPython.cs b/src/SW360IntegrationTest/Python/PackageIdentifierInitialPython.cs index 7f7c40b9..8df281c1 100644 --- a/src/SW360IntegrationTest/Python/PackageIdentifierInitialPython.cs +++ b/src/SW360IntegrationTest/Python/PackageIdentifierInitialPython.cs @@ -50,6 +50,7 @@ public void RunBOMCreatorexe_ProvidedPackageJsonFilePath_ReturnsSuccess() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, + TestConstant.TelemetryEnable, testParameters.TelemetryEnable, TestConstant.JfrogPoetryInternalRepo,"Pypi-test", TestConstant.ProjectType,"Poetry", TestConstant.Mode,""}), diff --git a/src/Telemetry.UTest/LCT.Telemetry.UTest.csproj b/src/Telemetry.UTest/LCT.Telemetry.UTest.csproj new file mode 100644 index 00000000..83c8be83 --- /dev/null +++ b/src/Telemetry.UTest/LCT.Telemetry.UTest.csproj @@ -0,0 +1,36 @@ + + + + net8.0 + enable + enable + + false + true + + + ..\..\out + + + + ..\..\out + + + + + + + + + + + + + + + + + + + + diff --git a/src/Telemetry.UTest/Telemetry.UTest.cs b/src/Telemetry.UTest/Telemetry.UTest.cs new file mode 100644 index 00000000..ae8b61a8 --- /dev/null +++ b/src/Telemetry.UTest/Telemetry.UTest.cs @@ -0,0 +1,96 @@ +// -------------------------------------------------------------------------------------------------------------------- +// SPDX-FileCopyrightText: 2025 Siemens AG +// +// SPDX-License-Identifier: MIT +// -------------------------------------------------------------------------------------------------------------------- +using Microsoft.ApplicationInsights.Extensibility; +using Microsoft.ApplicationInsights; +using Moq; + + +namespace LCT.Telemetry.UTest +{ + [TestFixture] + public class TelemetryTests + { + + private Mock _mockTelemetryProvider; + private LCT.Telemetry.Telemetry _telemetry; + private Dictionary configuration; + private TelemetryClient _mockTelemetryClient; + + [SetUp] + public void SetUp() + { + _mockTelemetryProvider = new Mock(); + var aiConfig = TelemetryConfiguration.CreateDefault(); + string telemetryType = "1"; + configuration = new Dictionary + { + { "InstrumentationKey", "1" } + }; + _telemetry = new LCT.Telemetry.Telemetry(telemetryType, configuration); + aiConfig.InstrumentationKey = "1"; + _mockTelemetryClient = new TelemetryClient(aiConfig); + } + [Test] + public void Initialize_ShouldTrackApplicationStartedEvent() + { + // Arrange + string appName = "TestApp"; + string version = "1.0.0"; + + // Act + _telemetry.Initialize(appName, version); + + // Assert + _mockTelemetryProvider.Verify(tp => tp.TrackEvent("ApplicationStarted", It.Is>(d => + d["App Name"] == appName && + d["Version"] == version && + d.ContainsKey("Start Time") && + d.ContainsKey("Hashed User ID") + )), Times.Never); + } + + + [Test] + public void Telemetry_TrackCustomEvent_ShouldCallTrackEvent_WhenCalled() + { + // Arrange + string eventName = "CustomEvent"; + var properties = new Dictionary { { "Property", "Value" } }; + + // Act + _telemetry.TrackCustomEvent(eventName, properties); + + // Assert: Ensure TrackEvent is called with correct event name and properties + _mockTelemetryProvider.Verify(tp => tp.TrackEvent(eventName, properties), Times.Never); + } + + [Test] + public void Telemetry_TrackExecutionTime_ShouldCallTrackEvent_WhenCalled() + { + // Act + _telemetry.TrackExecutionTime(); + + // Assert: Ensure TrackEvent is called with the correct event name + _mockTelemetryProvider.Verify(tp => tp.TrackEvent("ApplicationExecutionTime", It.IsAny>()), Times.Never); + } + + [Test] + public void Telemetry_Flush_ShouldCallFlush_WhenCalled() + { + // Act + _telemetry.Flush(); + // Assert: Ensure Flush is called + _mockTelemetryProvider.Verify(tp => tp.Flush(), Times.Never); + } + [Test] + public void Constructor_ShouldThrowException_ForInvalidTelemetryType() + { + Assert.Throws(() => new LCT.Telemetry.Telemetry("InvalidType", configuration)); + } + + + } +} \ No newline at end of file diff --git a/src/TestUtilities/TestConstant.cs b/src/TestUtilities/TestConstant.cs index f5898d45..38d079f0 100644 --- a/src/TestUtilities/TestConstant.cs +++ b/src/TestUtilities/TestConstant.cs @@ -43,6 +43,7 @@ public static class TestConstant public const string Email = "Email"; public const string ArtifactoryKey = "--Jfrog:Token"; public const string ArtifactoryUser = "--artifactoryuploaduser"; + public const string TelemetryEnable = "--Telemetry:Enable"; public const string JfrogNpmThirdPartyDestRepoName = "--Npm:Artifactory:ThirdPartyRepos:0:Name"; public const string JfrogNpmInternalRepo = "--Npm:Artifactory:InternalRepos:0"; diff --git a/src/TestUtilities/TestParam.cs b/src/TestUtilities/TestParam.cs index b114a405..5e3b99e4 100644 --- a/src/TestUtilities/TestParam.cs +++ b/src/TestUtilities/TestParam.cs @@ -30,6 +30,8 @@ public class TestParam public string InternalDestinationRepoName { get; set; } public string DevDestinationRepoName { get; set; } public string FossologyTrigger { get; set; } + public string TelemetryEnable { get; set; } + public TestParam() { SW360AuthTokenType = s_Config["SW360AuthTokenType"]; @@ -47,6 +49,7 @@ public TestParam() InternalDestinationRepoName = "npm-test"; DevDestinationRepoName = "npm-test"; FossologyTrigger = s_Config["EnableFossologyTrigger"]; + TelemetryEnable = s_Config["TelemetryEnable"]; } } } diff --git a/src/TestUtilities/TestParamAlpine.cs b/src/TestUtilities/TestParamAlpine.cs index 8ee53308..1abca2f6 100644 --- a/src/TestUtilities/TestParamAlpine.cs +++ b/src/TestUtilities/TestParamAlpine.cs @@ -24,6 +24,7 @@ public class TestParamAlpine public string ArtifactoryUploadApiKey { get; set; } public string JfrogApi { get; set; } public string FossologyTrigger { get; set; } + public string TelemetryEnable { get; set; } public TestParamAlpine() { @@ -39,6 +40,7 @@ public TestParamAlpine() JfrogApi = s_Config["JfrogApi"]; RemoveDevDependency = s_Config["RemoveDevDependency"]; FossologyTrigger = s_Config["EnableFossologyTrigger"]; + TelemetryEnable = s_Config["TelemetryEnable"]; } } } diff --git a/src/TestUtilities/TestParamConan.cs b/src/TestUtilities/TestParamConan.cs index 9b15c95a..d6999297 100644 --- a/src/TestUtilities/TestParamConan.cs +++ b/src/TestUtilities/TestParamConan.cs @@ -29,6 +29,7 @@ public class TestParamConan public string InternalDestinationRepoName { get; set; } public string DevDestinationRepoName { get; set; } public string FossologyTrigger { get; set; } + public string TelemetryEnable { get; set; } public TestParamConan() { SW360AuthTokenType = s_Config["SW360AuthTokenType"]; @@ -46,6 +47,7 @@ public TestParamConan() InternalDestinationRepoName = "conan-test"; DevDestinationRepoName = "conan-test"; FossologyTrigger = s_Config["EnableFossologyTrigger"]; + TelemetryEnable = s_Config["TelemetryEnable"]; } } } diff --git a/src/TestUtilities/TestParamDebian.cs b/src/TestUtilities/TestParamDebian.cs index e4aef5cb..d094852b 100644 --- a/src/TestUtilities/TestParamDebian.cs +++ b/src/TestUtilities/TestParamDebian.cs @@ -24,6 +24,7 @@ public class TestParamDebian public string ArtifactoryUploadApiKey { get; set; } public string JfrogApi { get; set; } public string FossologyTrigger { get; set; } + public string TelemetryEnable { get; set; } public TestParamDebian() { @@ -39,6 +40,7 @@ public TestParamDebian() JfrogApi = s_Config["JfrogApi"]; RemoveDevDependency = s_Config["RemoveDevDependency"]; FossologyTrigger = s_Config["EnableFossologyTrigger"]; + TelemetryEnable = s_Config["TelemetryEnable"]; } } } diff --git a/src/TestUtilities/TestParamMaven.cs b/src/TestUtilities/TestParamMaven.cs index 6d72dc36..5d31c53c 100644 --- a/src/TestUtilities/TestParamMaven.cs +++ b/src/TestUtilities/TestParamMaven.cs @@ -29,6 +29,7 @@ public class TestParamMaven public string InternalDestinationRepoName { get; set; } public string DevDestinationRepoName { get; set; } public string FossologyTrigger { get; set; } + public string TelemetryEnable { get; set; } public TestParamMaven() { @@ -47,6 +48,7 @@ public TestParamMaven() InternalDestinationRepoName = "maven-test"; DevDestinationRepoName = "maven-test"; FossologyTrigger = s_Config["EnableFossologyTrigger"]; + TelemetryEnable = s_Config["TelemetryEnable"]; } } } diff --git a/src/TestUtilities/TestParamNuget.cs b/src/TestUtilities/TestParamNuget.cs index ea3df7e7..03437607 100644 --- a/src/TestUtilities/TestParamNuget.cs +++ b/src/TestUtilities/TestParamNuget.cs @@ -33,6 +33,7 @@ public class TestParamNuget public string InternalDestinationRepoName { get; set; } public string DevDestinationRepoName { get; set; } public string FossologyTrigger { get; set; } + public string TelemetryEnable { get; set; } public TestParamNuget() { @@ -51,6 +52,7 @@ public TestParamNuget() InternalDestinationRepoName = "nuget-test"; DevDestinationRepoName = "nuget-test"; FossologyTrigger = s_Config["EnableFossologyTrigger"]; + TelemetryEnable = s_Config["TelemetryEnable"]; } } } diff --git a/src/TestUtilities/appSettingsSW360IntegrationTest.json b/src/TestUtilities/appSettingsSW360IntegrationTest.json index 56483e8c..32cf6c16 100644 --- a/src/TestUtilities/appSettingsSW360IntegrationTest.json +++ b/src/TestUtilities/appSettingsSW360IntegrationTest.json @@ -2,6 +2,7 @@ "Fossologyurl": "", "RemoveDevDependency": true, "EnableFossologyTrigger": false, + "TelemetryEnable": false, "SW360AuthTokenType": "Token", "SW360ProjectID": "036ec371847b4b199dd21c3494ccb108", "SW360ProjectName": "Test",