Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ jobs:
- name: Create zip
run: |
cd ${{ env.PUBLISH_PATH }}
zip -r ../telemetry-server-${{ steps.vars.outputs.version }}.zip .
zip -r ../b4e-telemetry-${{ steps.vars.outputs.version }}.zip .

- name: Generate checksum
run: |
sha256sum telemetry-server-${{ steps.vars.outputs.version }}.zip > checksums.txt
sha256sum b4e-telemetry-${{ steps.vars.outputs.version }}.zip > checksums.txt

- name: Generate metadata
run: |
Expand All @@ -132,7 +132,7 @@ jobs:
prerelease: false
generate_release_notes: true
files: |
telemetry-server-${{ steps.vars.outputs.version }}.zip
b4e-telemetry-${{ steps.vars.outputs.version }}.zip
checksums.txt
build-info.json

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The project follows a Clean Architecture approach:
To build the project locally, run the following command from the root directory:

```bash
dotnet build telemetry-server.slnx
dotnet build b4e-telemetry.slnx
```

To run the application:
Expand All @@ -47,7 +47,7 @@ The project provides several Docker Compose configurations to support different
To start the API using the pre-built image, you can pull the latest version:

```bash
docker pull ghcr.io/pyrevitlabs/telemetry-server:latest
docker pull ghcr.io/Bim4Everyone/b4e-telemetry:latest
```

To start the API with a specific database, use the following command structure:
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
telemetry-api:
container_name: telemetry-api
image: ghcr.io/pyrevitlabs/telemetry-server:2.0.14-alpha
image: ghcr.io/Bim4Everyone/b4e-telemetry:2.0.0
ports:
- "8080:8080"
environment:
Expand Down
147 changes: 147 additions & 0 deletions src/Telemetry.Api/Application/DTOs/LogRecordDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
using System.Text.Json.Serialization;
using System.ComponentModel.DataAnnotations;
using Telemetry.Api.Domain.Constants;
using Telemetry.Api.JsonConverters;

namespace Telemetry.Api.Application.DTOs
{
/// <summary>
/// Log event record class.
/// </summary>
public sealed class LogRecordDto
{
/// <summary>
/// The time at which the event occurred.
/// </summary>
[JsonPropertyName(PropertyNames.Timestamp)]
public DateTimeOffset Timestamp { get; init; }

/// <summary>
/// The level of the event.
/// </summary>
[MaxLength(100)]
[JsonPropertyName(PropertyNames.LogLevel)]
public required string Level { get; init; }

/// <summary>
/// The message template describing the event.
/// </summary>
[MaxLength(8000)]
[JsonPropertyName(PropertyNames.MessageTemplate)]
public required string MessageTemplate { get; init; }

/// <summary>
/// The render message describing the event.
/// </summary>
[MaxLength(8000)]
[JsonPropertyName(PropertyNames.RenderedMessage)]
public required string RenderedMessage { get; init; }

/// <summary>
/// An exception associated with the event, or null.
/// </summary>
[MaxLength(8000)]
[JsonPropertyName(PropertyNames.Exception)]
[JsonConverter(typeof(DynamicDataJsonConverter))]
public string? Exception { get; init; }

/// <summary>
/// Revit Session Id (unique revit start instance)
/// </summary>
[JsonPropertyName(PropertyNames.LogSessionId)]
public Guid SessionId { get; init; }

/// <summary>
/// Revit plugin name.
/// </summary>
[MaxLength(100)]
[JsonPropertyName(PropertyNames.PluginName)]
public required string PluginName { get; init; }

/// <summary>
/// Revit Plugin Session Id (unique revit plugin start instance)
/// </summary>
[JsonPropertyName(PropertyNames.PluginSessionId)]
public Guid PluginSessionId { get; init; }

/// <summary>
/// Environment UserName
/// </summary>
[MaxLength(100)]
[JsonPropertyName(PropertyNames.EnvironmentUserName)]
public required string EnvironmentUserName { get; init; }

/// <summary>
/// Environment MachineName
/// </summary>
[MaxLength(100)]
[JsonPropertyName(PropertyNames.EnvironmentMachineName)]
public required string EnvironmentMachineName { get; init; }

/// <summary>
/// Revit <a href="https://www.revitapidocs.com/2017.1/04ef312a-e25a-cbcd-40c4-43fe6311e677.htm">VersionBuild</a>
/// property.
/// </summary>
[MaxLength(100)]
[JsonPropertyName(PropertyNames.LogRevitBuild)]
public required string RevitBuild { get; init; }

/// <summary>
/// Revit <a href="https://www.revitapidocs.com/2017.1/320391bf-2c21-98ca-192c-da1d9becff11.htm">VersionNumber</a>
/// property.
/// </summary>
[JsonPropertyName(PropertyNames.LogRevitVersion)]
public int RevitVersion { get; init; }

/// <summary>
/// Revit <a href="https://www.revitapidocs.com/2017.1/2b1d8b80-a11c-2a57-63bd-6c0d67691879.htm">Language</a> property.
/// </summary>
[MaxLength(100)]
[JsonPropertyName(PropertyNames.RevitLanguage)]
public required string RevitLanguage { get; init; }

/// <summary>
/// Revit <a href="https://www.revitapidocs.com/2017.1/2a7c8664-de0d-7a43-e670-2e733e579609.htm">Username</a> property.
/// </summary>
[MaxLength(100)]
[JsonPropertyName(PropertyNames.RevitUserName)]
public string? RevitUserName { get; init; }

/// <summary>
/// Revit <a href="https://www.revitapidocs.com/2017.1/4cee7916-d799-fc83-daf3-97cb03900b72.htm">Document.Title</a>
/// property.
/// </summary>
[MaxLength(250)]
[JsonPropertyName(PropertyNames.RevitDocumentTitle)]
public string? RevitDocumentTitle { get; init; }

/// <summary>
/// Revit <a href="https://www.revitapidocs.com/2022/8a92a6fd-ce25-cd86-2068-f9dcb24d72d6.htm">Document.PathName</a>
/// property.
/// </summary>
[MaxLength(1024)]
[JsonPropertyName(PropertyNames.RevitDocumentPathName)]
public string? RevitDocumentPathName { get; init; }

/// <summary>
/// Revit ModelPath property.
/// <br />If
/// <a href="https://www.revitapidocs.com/2020/e12f7980-ba6c-2e72-6687-f0bf807ff014.htm">Document.IsModelInCloud</a> is true
/// <a href="https://www.revitapidocs.com/2020/087a7c14-1a6e-7022-c47b-923e90f4c5be.htm">Document.GetCloudModelPath()</a>.
/// <br />If
/// <a href="https://www.revitapidocs.com/2017.1/7f368167-6543-9be9-67a3-c6e1696ae060.htm">Document.IsWorkshared</a> is true
/// <a href="https://www.revitapidocs.com/2017.1/6d42ee05-5738-8685-2165-57f9809f3161.htm">Document.GetWorksharingCentralModelPath()</a>.
/// </summary>
[MaxLength(1024)]
[JsonPropertyName(PropertyNames.RevitDocumentModelPath)]
public string? RevitDocumentModelPath { get; init; }

/// <summary>
/// Dynamic properties data.
/// </summary>
[MaxLength(8000)]
[JsonPropertyName(PropertyNames.LogEvent)]
[JsonConverter(typeof(DynamicDataJsonConverter))]
public string? LogEvent { get; init; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public interface IApplicationDbContext
/// <returns>A task that represents the asynchronous add operation.</returns>
Task AddScriptRecord(ScriptRecord scriptRecord, CancellationToken cancellationToken);

/// <summary>
/// Asynchronously adds a new log record to the database context.
/// </summary>
/// <returns>A task that represents the asynchronous add operation.</returns>
Task AddLogRecord(LogRecord logRecord, CancellationToken cancellationToken);

/// <summary>
/// Asynchronously saves all changes made in the current context to the database.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,5 +208,66 @@ public static EventRecordDto ToDto(this EventRecord model)
EventArgs = model.EventArgs
};
}

/// <summary>
/// Transforms the provided DTO into its corresponding model representation.
/// </summary>
/// <param name="dto">The data transfer object to be transformed.</param>
/// <returns>An instance of the model derived from the given DTO.</returns>
public static LogRecord ToModel(this LogRecordDto dto)
{
return new LogRecord
{
Id = Guid.CreateVersion7(),
Timestamp = dto.Timestamp,
Level = dto.Level,
MessageTemplate = dto.MessageTemplate,
RenderedMessage = dto.RenderedMessage,
Exception = dto.Exception,
SessionId = dto.SessionId,
PluginName = dto.PluginName,
PluginSessionId = dto.PluginSessionId,
EnvironmentUserName = dto.EnvironmentUserName,
EnvironmentMachineName = dto.EnvironmentMachineName,
RevitBuild = dto.RevitBuild,
RevitVersion = dto.RevitVersion,
RevitLanguage = dto.RevitLanguage,
RevitUserName = dto.RevitUserName,
RevitDocumentTitle = dto.RevitDocumentTitle,
RevitDocumentPathName = dto.RevitDocumentPathName,
RevitDocumentModelPath = dto.RevitDocumentModelPath,
LogEvent = dto.LogEvent
};
}

/// <summary>
/// Converts the specified model object to a data transfer object representation.
/// </summary>
/// <param name="model">The model object to be converted.</param>
/// <returns>A new instance of the data transfer object created from the source.</returns>
public static LogRecordDto ToDto(this LogRecord model)
{
return new LogRecordDto
{
Timestamp = model.Timestamp,
Level = model.Level,
MessageTemplate = model.MessageTemplate,
RenderedMessage = model.RenderedMessage,
Exception = model.Exception,
SessionId = model.SessionId,
PluginName = model.PluginName,
PluginSessionId = model.PluginSessionId,
EnvironmentUserName = model.EnvironmentUserName,
EnvironmentMachineName = model.EnvironmentMachineName,
RevitBuild = model.RevitBuild,
RevitVersion = model.RevitVersion,
RevitLanguage = model.RevitLanguage,
RevitUserName = model.RevitUserName,
RevitDocumentTitle = model.RevitDocumentTitle,
RevitDocumentPathName = model.RevitDocumentPathName,
RevitDocumentModelPath = model.RevitDocumentModelPath,
LogEvent = model.LogEvent
};
}
}
}
54 changes: 54 additions & 0 deletions src/Telemetry.Api/Domain/Constants/PropertyNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public static class PropertyNames
/// <summary>Session identifier.</summary>
public const string SessionId = "sessionid";

/// <summary>Session identifier.</summary>
public const string LogSessionId = "session_id";

/// <summary>Timestamp.</summary>
public const string Timestamp = "timestamp";

Expand All @@ -23,9 +26,15 @@ public static class PropertyNames
/// <summary>Revit build version.</summary>
public const string RevitBuild = "revitbuild";

/// <summary>Revit build version.</summary>
public const string LogRevitBuild = "revit_build";

/// <summary>Revit version.</summary>
public const string RevitVersion = "revit";

/// <summary>Revit version.</summary>
public const string LogRevitVersion = "revit_version";

/// <summary>pyRevit version.</summary>
public const string PyRevitVersion = "pyrevit";

Expand Down Expand Up @@ -127,5 +136,50 @@ public static class PropertyNames

/// <summary>Event arguments.</summary>
public const string EventArgs = "args";

/// <summary> Specifies the level of logging detail.</summary>
public const string LogLevel = "log_level";

/// <summary>Message template.</summary>
public const string MessageTemplate = "message_template";

/// <summary>Rendered message.</summary>
public const string RenderedMessage = "rendered_message";

/// <summary>Exception.</summary>
public const string Exception = "exception";

/// <summary>Plugin name.</summary>
public const string PluginName = "plugin_name";

/// <summary>Plugin session identifier.</summary>
public const string PluginSessionId = "plugin_session_id";

/// <summary>Environment username.</summary>
public const string EnvironmentUserName = "env_username";

/// <summary>Environment machine name.</summary>
public const string EnvironmentMachineName = "env_machinename";

/// <summary>Revit language.</summary>
public const string RevitLanguage = "revit_language";

/// <summary>Revit username.</summary>
public const string RevitUserName = "revit_username";

/// <summary>Document title.</summary>
public const string RevitDocumentTitle = "doc_title";

/// <summary>Document path name.</summary>
public const string RevitDocumentPathName = "doc_pathname";

/// <summary>Document model path.</summary>
public const string RevitDocumentModelPath = "doc_modelpath";

/// <summary>Log event.</summary>
public const string LogEvent = "log_event";

/// <summary>Meta information.</summary>
public const string Meta = "meta";
}
}
Loading
Loading