Files
speckle-sharp-connectors/Sdk/Speckle.Connectors.Common/HostApplications.cs
T
Oğuzhan Koral 68a0ed3334 Feat(gh): add tracking for metrics (#833)
* add MixPanel manager like v2

* add mixpanel to send and receive

* fix tests

* Delete old events

* Don't track receive and send operation

They are already tracked by UI - we shouldn't track them on low level, they always need to be tracked with UI clicks etc

* Pass account from outside

* Add email if available

* Add mixpanel to GH

* Add ui dui3 prop as default

* Remove mixpanel object from tests

* renames categories

* TODO notes for NodeRun later

* Add note for account id nullability

* Grasshopper specific send and receive info for workspace ids

* Auto property

* isMultiplayer prop for mixpanel

* fix mismatch in account id and user id

* Helper function for convertion source app name to slug

---------

Co-authored-by: Adam Hathcock <adam@hathcock.uk>
Co-authored-by: Claire Kuang <kuang.claire@gmail.com>
2025-05-14 21:35:20 +03:00

105 lines
2.8 KiB
C#

using System.Text.RegularExpressions;
using Speckle.Sdk;
namespace Speckle.Connectors.Common;
public static class HostApplications
{
public static string GetVersion(HostAppVersion version) => version.ToString().TrimStart('v');
public static readonly Application Rhino = new("Rhino", "rhino"),
Grasshopper = new("Grasshopper", "grasshopper"),
Revit = new("Revit", "revit"),
Dynamo = new("Dynamo", "dynamo"),
Unity = new("Unity", "unity"),
GSA = new("GSA", "gsa"),
Civil = new("Civil 3D", "civil3d"),
Civil3D = new("Civil 3D", "civil3d"),
AutoCAD = new("AutoCAD", "autocad"),
MicroStation = new("MicroStation", "microstation"),
OpenRoads = new("OpenRoads", "openroads"),
OpenRail = new("OpenRail", "openrail"),
OpenBuildings = new("OpenBuildings", "openbuildings"),
ETABS = new("ETABS", "etabs"),
SAP2000 = new("SAP2000", "sap2000"),
CSiBridge = new("CSiBridge", "csibridge"),
SAFE = new("SAFE", "safe"),
TeklaStructures = new("Tekla Structures", "teklastructures"),
Dxf = new("DXF Converter", "dxf"),
Excel = new("Excel", "excel"),
Unreal = new("Unreal", "unreal"),
PowerBI = new("Power BI", "powerbi"),
Blender = new("Blender", "blender"),
QGIS = new("QGIS", "qgis"),
ArcGIS = new("ArcGIS", "arcgis"),
SketchUp = new("SketchUp", "sketchup"),
Archicad = new("Archicad", "archicad"),
TopSolid = new("TopSolid", "topsolid"),
Python = new("Python", "python"),
NET = new(".NET", "net"),
Navisworks = new("Navisworks", "navisworks"),
AdvanceSteel = new("Advance Steel", "advancesteel"),
Other = new("Other", "other");
/// <summary>
/// Gets a slug from a host application name and version.
/// </summary>
/// <param name="appName">Application name with its version, e.g., "Rhino 7", "Revit 2024".</param>
/// <returns>Slug string.</returns>
public static string GetSlugFromHostAppNameAndVersion(string appName)
{
if (string.IsNullOrWhiteSpace(appName))
{
return "other";
}
// Remove whitespace and convert to lowercase
appName = Regex.Replace(appName.ToLowerInvariant(), @"\s+", "");
var keywords = new List<string>
{
"dynamo",
"revit",
"autocad",
"civil",
"rhino",
"grasshopper",
"unity",
"gsa",
"microstation",
"openroads",
"openrail",
"openbuildings",
"etabs",
"sap",
"csibridge",
"safe",
"teklastructures",
"dxf",
"excel",
"unreal",
"powerbi",
"blender",
"qgis",
"arcgis",
"sketchup",
"archicad",
"topsolid",
"python",
"net",
"navisworks",
"advancesteel"
};
foreach (var keyword in keywords)
{
if (appName.Contains(keyword))
{
return keyword;
}
}
return appName;
}
}