Skip to content

Commit

Permalink
send version metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
stuqdog committed Aug 1, 2024
1 parent 7598b27 commit dd41cdb
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ jobs:
uses: andymckay/[email protected]
if: steps.release_exists.outputs.id != ''

- name: Bump Version Metadata
run: sed -i -e "s/sdkVersion = 'v[0-9]*\.[0-9]*\.[0-9]*'/sdkVersion = 'v${{ steps.which_version.outputs.version }}'" > lib/src/utils.dart

- name: "Generate release changelog"
uses: heinrichreimer/[email protected]
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/update_protos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
- name: Format
run: make format

- name: Update Proto Tag
run: sed -i -e "s/apiTag = 'v[0-9]*\.[0-9]*\.[0-9]*'/api_tag = '${{ github.event.client_payload.tag }}'" > lib/src/utils.dart

- name: Add + Commit + Open PR
uses: peter-evans/create-pull-request@v5
with:
Expand Down
1 change: 1 addition & 0 deletions lib/src/rpc/dial.dart
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ class AuthenticatedChannel extends ViamGrpcOrGrpcWebChannel {
}

options = options.mergedWith(CallOptions(metadata: {'Authorization': 'Bearer $accessToken'}));
options = options.mergedWith(CallOptions(metadata: {'viam_client': getVersionMetadata()}));
return super.createCall(method, requests, options);
}
}
Expand Down
2 changes: 2 additions & 0 deletions lib/src/rpc/web_rtc/web_rtc_client.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter_webrtc/flutter_webrtc.dart';
import 'package:grpc/grpc.dart';
import 'package:grpc/grpc_connection_interface.dart';
import 'package:viam_sdk/src/utils.dart';

import '../../robot/sessions_client.dart';
import 'web_rtc_client_connection.dart';
Expand Down Expand Up @@ -31,6 +32,7 @@ class WebRtcClientChannel extends ClientChannelBase {
if (!SessionsClient.unallowedMethods.contains(method.path)) {
options = options.mergedWith(CallOptions(metadata: {SessionsClient.sessionMetadataKey: _sessionId()}));
}
options = options.mergedWith(CallOptions(metadata: {'viam_client': getVersionMetadata()}));
return super.createCall(method, requests, options);
}
}
7 changes: 7 additions & 0 deletions lib/src/utils.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:format/format.dart';
import 'package:grpc/grpc.dart';
import 'package:logger/logger.dart';

Expand Down Expand Up @@ -82,3 +83,9 @@ extension MapStructUtils on Map<String, dynamic> {
return Value()..structValue = toStruct();
}
}

String getVersionMetadata() {
const String sdkVersion = 'v0.0.18';
const String apiTag = 'v0.1.328';
return format('flutter;{};{}', sdkVersion, apiTag);
}
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies:
collection: ^1.17.1
async: ^2.11.0
bonsoir: ^5.1.8
format: ^1.5.2

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit dd41cdb

Please sign in to comment.