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
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ private void AuthenticationStateChanged(Task<AuthenticationState> task)
//#if (signalR == true)
private void SubscribeToSignalREventsMessages()
{
hubConnection.Remove(SignalREvents.SHOW_MESSAGE);
signalROnDisposables.Add(hubConnection.On<string, Dictionary<string, string?>?, bool>(SignalREvents.SHOW_MESSAGE, async (message, data) =>
{
logger.LogInformation("SignalR Message {Message} received from server to show.", message);
Expand Down Expand Up @@ -209,17 +210,20 @@ private void SubscribeToSignalREventsMessages()
// You can also leverage IPubSubService to notify other components in the application.
}));

hubConnection.Remove(SignalREvents.PUBLISH_MESSAGE);
signalROnDisposables.Add(hubConnection.On<string, object?>(SignalREvents.PUBLISH_MESSAGE, async (message, payload) =>
{
logger.LogInformation("SignalR Message {Message} received from server to publish.", message);
PubSubService.Publish(message, payload);
}));

hubConnection.Remove(SignalREvents.EXCEPTION_THROWN);
signalROnDisposables.Add(hubConnection.On<AppProblemDetails>(SignalREvents.EXCEPTION_THROWN, async (appProblemDetails) =>
{
ExceptionHandler.Handle(appProblemDetails, displayKind: ExceptionDisplayKind.NonInterrupting);
}));

hubConnection.Remove(SignalRMethods.UPLOAD_DIAGNOSTIC_LOGGER_STORE);
signalROnDisposables.Add(hubConnection.On(SignalRMethods.UPLOAD_DIAGNOSTIC_LOGGER_STORE, async () =>
{
return DiagnosticLogger.Store.ToArray();
Expand Down Expand Up @@ -308,8 +312,6 @@ await storageService.GetItem("Culture") ?? // 2- User settings
private List<IDisposable> signalROnDisposables = [];
protected override async ValueTask DisposeAsync(bool disposing)
{
await base.DisposeAsync(disposing);

unsubscribe?.Invoke();

NavigationManager.LocationChanged -= NavigationManager_LocationChanged;
Expand All @@ -320,6 +322,9 @@ protected override async ValueTask DisposeAsync(bool disposing)
hubConnection.Reconnected -= HubConnectionConnected;
hubConnection.Reconnecting -= HubConnectionStateChange;
signalROnDisposables.ForEach(d => d.Dispose());
signalROnDisposables = [];
//#endif

await base.DisposeAsync(disposing);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@ public static IServiceCollection AddClientCoreProjectServices(this IServiceColle
.WithAutomaticReconnect(sp.GetRequiredService<IRetryPolicy>())
.WithUrl(new Uri(absoluteServerAddressProvider.GetAddress(), "app-hub"), options =>
{
var telemetryContext = sp.GetRequiredService<ITelemetryContext>();

options.Headers.Add("X-App-Version", telemetryContext.AppVersion!);
options.Headers.Add("X-App-Platform", AppPlatform.Type.ToString());

options.SkipNegotiation = false; // Required for Azure SignalR.
options.Transports = HttpTransportType.WebSockets;
// Avoid enabling long polling or Server-Sent Events. Focus on resolving the issue with WebSockets instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@
<AndroidAotProfile Condition="Exists('custom.aprof')" Include="custom.aprof" />
<!--/+:msbuild-conditional:noEmit -->
<PackageReference Condition=" '$(notification)' == 'true' OR '$(notification)' == ''" Include="Xamarin.Firebase.Messaging" />
<PackageReference Condition=" '$(notification)' == 'true' OR '$(notification)' == ''" Include="Xamarin.AndroidX.SavedState" />
<PackageReference Condition=" '$(notification)' == 'true' OR '$(notification)' == ''" Include="Xamarin.AndroidX.SavedState.SavedState.Ktx" />
<!--/-:msbuild-conditional:noEmit -->
<!-- Run the following commands to create custom.aprof file which improves the Android app performance -->
<!-- dotnet add package Mono.AotProfiler.Android -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<BlazorWebAssemblyLoadAllGlobalizationData Condition="'$(InvariantGlobalization)' == 'false'">true</BlazorWebAssemblyLoadAllGlobalizationData>
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
<StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode>
<WasmEnableSIMD Condition="'$(Environment)' != 'Development'">true</WasmEnableSIMD>
<!--/+:msbuild-conditional:noEmit -->
<WasmEnableSIMD>false</WasmEnableSIMD>
<WasmStripILAfterAOT Condition=" '$(offlineDb)' == 'false'">true</WasmStripILAfterAOT>
<WasmBuildNative Condition=" '$(offlineDb)' == 'true' OR '$(offlineDb)' == ''">true</WasmBuildNative>
<!--/-:msbuild-conditional:noEmit -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@
<PackageVersion Condition=" '$(sentry)' == 'true' OR '$(sentry)' == '' " Include="Sentry.Extensions.Logging" Version="6.0.0-preview.1-prerelease" />
<PackageVersion Condition=" '$(sentry)' == 'true' OR '$(sentry)' == '' " Include="Sentry.Maui" Version="6.0.0-preview.1-prerelease" />
<PackageVersion Condition=" '$(notification)' == 'true' OR '$(notification)' == ''" Include="Xamarin.Firebase.Messaging" Version="125.0.0.1" />
<PackageVersion Condition=" '$(notification)' == 'true' OR '$(notification)' == ''" Include="Xamarin.AndroidX.SavedState" Version="1.3.2" />
<PackageVersion Condition=" '$(notification)' == 'true' OR '$(notification)' == ''" Include="Xamarin.AndroidX.SavedState.SavedState.Ktx" Version="1.3.2" />
<PackageVersion Condition=" '$(notification)' == 'true' OR '$(notification)' == ''" Include="Plugin.LocalNotification" Version="12.0.2" />
<PackageVersion Condition=" '$(notification)' == 'true' OR '$(notification)' == ''" Include="AdsPush" Version="2.0.0" />
<PackageVersion Condition=" '$(offlineDb)' == 'true' OR '$(offlineDb)' == ''" Include="Bit.Besql" Version="10.0.0-pre-05" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void Configure(EntityTypeBuilder<Product> builder)
//#if (database == "PostgreSQL" || database == "SqlServer")
if (AppDbContext.IsEmbeddingEnabled)
{
builder.Property(p => p.Embedding).HasColumnType("vector(768)"); // Checkout appsettings.json's AI:EmbeddingOptions:Dimensions
builder.Property(p => p.Embedding).HasColumnType("vector(384)"); // Dimensions depends on the model used, here assuming 384 because of LocalTextEmbeddingGenerationService.
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,6 @@ void AddDbContext(DbContextOptionsBuilder options)
Endpoint = appSettings.AI.OpenAI.EmbeddingEndpoint,
Transport = new HttpClientPipelineTransport(sp.GetRequiredService<IHttpClientFactory>().CreateClient("AI"))
}).AsIEmbeddingGenerator())
.ConfigureOptions(options =>
{
configuration.GetRequiredSection("AI:EmbeddingOptions").Bind(options);
})
.UseLogging()
.UseOpenTelemetry();
// .UseDistributedCache()
Expand All @@ -428,10 +424,6 @@ void AddDbContext(DbContextOptionsBuilder options)
{
Transport = new Azure.Core.Pipeline.HttpClientTransport(sp.GetRequiredService<IHttpClientFactory>().CreateClient("AI"))
}).AsIEmbeddingGenerator(appSettings.AI.AzureOpenAI.EmbeddingModel))
.ConfigureOptions(options =>
{
configuration.GetRequiredSection("AI:EmbeddingOptions").Bind(options);
})
.UseLogging()
.UseOpenTelemetry();
// .UseDistributedCache()
Expand All @@ -442,10 +434,6 @@ void AddDbContext(DbContextOptionsBuilder options)
new Uri(appSettings.AI.HuggingFace.EmbeddingEndpoint),
apiKey: appSettings.AI.HuggingFace.EmbeddingApiKey,
httpClient: sp.GetRequiredService<IHttpClientFactory>().CreateClient("AI"), loggerFactory: sp.GetRequiredService<ILoggerFactory>()))
.ConfigureOptions(options =>
{
configuration.GetRequiredSection("AI:EmbeddingOptions").Bind(options);
})
.UseLogging()
.UseOpenTelemetry();
// .UseDistributedCache()
Expand All @@ -454,10 +442,6 @@ void AddDbContext(DbContextOptionsBuilder options)
{
services.AddEmbeddingGenerator(sp => new LocalTextEmbeddingGenerationService()
.AsEmbeddingGenerator())
.ConfigureOptions(options =>
{
configuration.GetRequiredSection("AI:EmbeddingOptions").Bind(options);
})
.UseLogging()
.UseOpenTelemetry();
// .UseDistributedCache()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public partial class AppHub : Hub

public override async Task OnConnectedAsync()
{
CheckClientAppVersion();

if (Context.GetHttpContext()?.ContainsExpiredAccessToken() is true)
throw new HubException(nameof(AppStrings.UnauthorizedException)).WithData("ConnectionId", Context.ConnectionId);

Expand Down Expand Up @@ -97,18 +95,4 @@ private async Task ChangeAuthenticationStateImplementation(ClaimsPrincipal? user
await dbContext.UserSessions.Where(us => us.SignalRConnectionId == Context.ConnectionId).ExecuteUpdateAsync(us => us.SetProperty(x => x.SignalRConnectionId, (string?)null));
}
}

private void CheckClientAppVersion()
{
if (Context.GetHttpContext()?.Request?.Headers?.TryGetValue("X-App-Version", out var appVersionHeaderValue) is true && appVersionHeaderValue.Any())
{
var appVersion = appVersionHeaderValue.Single()!;
var appPlatformType = Enum.Parse<AppPlatformType>(Context.GetHttpContext()!.Request.Headers["X-App-Platform"].Single()!);
var minimumSupportedVersion = settings.SupportedAppVersions!.GetMinimumSupportedAppVersion(appPlatformType);
if (minimumSupportedVersion != null && Version.Parse(appVersion) < minimumSupportedVersion)
throw new HubException(nameof(AppStrings.ForceUpdateTitle))
.WithData("ClientAppVersion", appVersion)
.WithData("ConnectionId", Context.ConnectionId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
"ChatOptions": {
"Temperature": 0
},
"EmbeddingOptions": {
"Dimensions": 768
},
"ChatOptions_Comment": "Configures Temperature, TopP, TopK and the rest of the properties of Microsoft.Extensions.AI.ChatOptions",
"OpenAI": {
"ChatModel": "gpt-4.1-mini",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@
//#endif
//#endif

// Blazor WebAssembly Standalone project.
builder.AddProject("clientwebwasm", "../../Client/Boilerplate.Client.Web/Boilerplate.Client.Web.csproj");

if (builder.ExecutionContext.IsRunMode) // The following project is only added for testing purposes.
{
// Blazor WebAssembly Standalone project.
builder.AddProject("clientwebwasm", "../../Client/Boilerplate.Client.Web/Boilerplate.Client.Web.csproj")
.WithExplicitStart();

var mailpit = builder.AddMailPit("smtp") // For testing purposes only, in production, you would use a real SMTP server.
.WithDataVolume("mailpit");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"mysqlserver__Comment": "The username is `root` by default",
//#endif
//#if (filesStorage == "S3")
"minio-rootPassword": "P@ssw0rd",
"minio__Comment": "The username is `minioadmin` by default",
"s3-rootPassword": "P@ssw0rd",
"s3__Comment": "The username is `minioadmin` by default",
//#endif
"Comment": "You might need to delete the docker volumes to apply changes to the passwords"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,21 @@ private static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder)
.AddProcessor<AppOpenTelemetryProcessor>()
.AddAspNetCoreInstrumentation(options =>
{
// Filter out Blazor static file requests
// Filter out Blazor static files and health checks requests.
string[] toBeIgnoredSegments = ["/health",
"/alive",
"/_content",
"/_framework"];

options.Filter = context =>
{
if (context.Request.Path.HasValue is false)
return true;
var path = context.Request.Path.Value;
return path.StartsWith("/_framework", StringComparison.OrdinalIgnoreCase) is false &&
path.StartsWith("/_content", StringComparison.OrdinalIgnoreCase) is false;
foreach (var segment in toBeIgnoredSegments)
{
if (context.Request.Path.StartsWithSegments(segment, StringComparison.OrdinalIgnoreCase))
return false;
}

return true;
};
})
.AddHttpClientInstrumentation()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using OpenTelemetry;

namespace Boilerplate.Server.Shared.Services;

public class AppOpenTelemetryProcessor : BaseProcessor<Activity>
{
public override void OnStart(Activity activity)
Expand All @@ -9,5 +10,9 @@ public override void OnStart(Activity activity)
{
activity.IsAllDataRequested = false; // Prevents Blazor Server's SignalR from being exported
}
else if (activity.OperationName is "Microsoft.AspNetCore.Components.HandleEvent")
{
activity.IsAllDataRequested = false; // Prevents Blazor's events from being exported.
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
"ChatOptions": {
"Temperature": 0
},
"EmbeddingOptions": {
"Dimensions": 768
},
"OpenAI": {
"ChatModel": "gpt-4.1-mini",
"ChatApiKey": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,7 @@ private static async Task InitializeDatabase(AppTestServer testServer)
}
//#endif
//#endif
if ((await dbContext.Database.GetPendingMigrationsAsync()).Any())
{
await dbContext.Database.MigrateAsync();
}
else if ((await dbContext.Database.GetAppliedMigrationsAsync()).Any() is false)
{
throw new InvalidOperationException("No migrations have been added. Please ensure that migrations are added before running tests.");
}
await dbContext.Database.EnsureCreatedAsync(); // It's recommended to start using ef-core migrations.
}
}

Expand Down
Loading