Skip to content
Open
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
16 changes: 16 additions & 0 deletions PowerSync/PowerSync.Common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# PowerSync.Common Changelog

## 0.0.6-alpha.1
- Added ability to specify `AppMetadata` for sync/stream requests.

Note: This requires a PowerSync service version `>=1.17.0` in order for logs to display metadata.

```csharp
db.Connect(connector, new PowerSync.Common.Client.Sync.Stream.PowerSyncConnectionOptions
{
// This will be included in PowerSync service logs
AppMetadata = new Dictionary<string, string>
{
{ "app_version", myAppVersion },
}
});
```

## 0.0.5-alpha.1
- Using the latest (0.4.9) version of the core extension, it introduces support for the Rust Sync implementation and also makes it the default - users can still opt out and use the legacy C# sync implementation as option when calling `connect()`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ public class StreamingSyncImplementationOptions : AdditionalConnectionOptions
public ILogger? Logger { get; init; }
}

public class BaseConnectionOptions(Dictionary<string, object>? parameters = null, SyncClientImplementation? clientImplementation = null)
public class BaseConnectionOptions(Dictionary<string, object>? parameters = null, SyncClientImplementation? clientImplementation = null, Dictionary<string, string>? appMetadata = null)
{
/// <summary>
/// A set of metadata to be included in service logs.
/// </summary>
public Dictionary<string, string>? AppMetadata { get; set; } = appMetadata;

/// <summary>
/// These parameters are passed to the sync rules and will be available under the `user_parameters` object.
/// </summary>
Expand All @@ -89,6 +94,9 @@ public class BaseConnectionOptions(Dictionary<string, object>? parameters = null

public class RequiredPowerSyncConnectionOptions : BaseConnectionOptions
{

public new Dictionary<string, string> AppMetadata { get; set; } = new();

public new Dictionary<string, object> Params { get; set; } = new();

public new SyncClientImplementation ClientImplementation { get; set; } = new();
Expand Down Expand Up @@ -128,6 +136,7 @@ public class StreamingSyncImplementation : EventStream<StreamingSyncImplementati
{
public static RequiredPowerSyncConnectionOptions DEFAULT_STREAM_CONNECTION_OPTIONS = new()
{
AppMetadata = [],
Params = [],
ClientImplementation = SyncClientImplementation.RUST
};
Expand Down Expand Up @@ -413,6 +422,7 @@ protected async Task<StreamingSyncIterationResult> StreamingSyncIteration(Cancel
{
var resolvedOptions = new RequiredPowerSyncConnectionOptions
{
AppMetadata = options?.AppMetadata ?? DEFAULT_STREAM_CONNECTION_OPTIONS.AppMetadata,
Params = options?.Params ?? DEFAULT_STREAM_CONNECTION_OPTIONS.Params,
ClientImplementation = options?.ClientImplementation ?? DEFAULT_STREAM_CONNECTION_OPTIONS.ClientImplementation
};
Expand Down Expand Up @@ -611,7 +621,7 @@ async Task HandleInstruction(Instruction instruction)

try
{
await Control(PowerSyncControlCommand.START, JsonConvert.SerializeObject(new { parameters = resolvedOptions.Params }));
await Control(PowerSyncControlCommand.START, JsonConvert.SerializeObject(new { parameters = resolvedOptions.Params, app_metadata = resolvedOptions.AppMetadata }));

notifyCompletedUploads = () =>
{
Expand Down Expand Up @@ -682,6 +692,7 @@ protected async Task<StreamingSyncIterationResult> LegacyStreamingSyncIteration(
IncludeChecksum = true,
RawData = true,
Parameters = resolvedOptions.Params,
AppMetadata = resolvedOptions.AppMetadata,
ClientId = clientId
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public class StreamingSyncRequest
[JsonProperty("raw_data")]
public bool RawData { get; set; }

[JsonProperty("app_metadata")]
public Dictionary<string, string>? AppMetadata { get; set; }

[JsonProperty("parameters")]
public Dictionary<string, object>? Parameters { get; set; }

Expand Down
4 changes: 4 additions & 0 deletions PowerSync/PowerSync.Maui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# PowerSync.Maui Changelog

## 0.0.4-alpha.1
- Upstream PowerSync.Common version bump
- Added ability to specify `AppMetadata` sync/stream requests (see Common changelog).

## 0.0.3-alpha.1
- Upstream PowerSync.Common version bump
- Using the latest (0.4.9) version of the core extension, it introduces support for the Rust Sync implementation and also makes it the default - users can still opt out and use the legacy C# sync implementation as option when calling `connect()`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public async Task InitializeAsync()
await db.Connect(connector, new PowerSyncConnectionOptions
{
ClientImplementation = SyncClientImplementation.RUST,
AppMetadata = new Dictionary<string, string>
{
{ "app_version", "1.0.0-integration-tests" },
{ "environment", "integration-tests" }
}
});
await db.WaitForFirstSync();
}
Expand Down
1 change: 1 addition & 0 deletions demos/CommandLine/CommandLine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<Version>0.0.1</Version>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
16 changes: 15 additions & 1 deletion demos/CommandLine/Demo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace CommandLine;

using System.Reflection;
using CommandLine.Utils;
using PowerSync.Common.Client;
using PowerSync.Common.Client.Connection;
Expand Down Expand Up @@ -96,7 +97,14 @@ static async Task Main()
}
});

await db.Connect(connector);
await db.Connect(connector, new PowerSync.Common.Client.Sync.Stream.PowerSyncConnectionOptions
{
ClientImplementation = PowerSync.Common.Client.Sync.Stream.SyncClientImplementation.RUST,
AppMetadata = new Dictionary<string, string>
{
{ "app_version", GetAppVersion() },
}
});
await db.WaitForFirstSync();

var panel = new Panel(table)
Expand Down Expand Up @@ -128,4 +136,10 @@ await AnsiConsole.Live(panel)

Console.WriteLine("\nExited live table. Press any key to exit.");
}

private static string GetAppVersion()
{
var version = Assembly.GetExecutingAssembly().GetName().Version;
return version?.ToString() ?? "unknown";
}
}