Skip to content

Commit 6e2081e

Browse files
robert-northmindrobert.magnusson
andauthored
Flutter SDK meta properties (#135)
> [!IMPORTANT] > **This PR cannot be merged until [grafana/app-o11y-kwl-endpoint#987](grafana/app-o11y-kwl-endpoint#987) is merged and deployed.** > > Without that backend fix, all telemetry from this SDK would be rejected because this SDK currently has version `0.9.0`, and the old backend requires versions of at least `1.3.5`. ## Description This PR aligns the Faro Flutter SDK's metadata (`meta.sdk.version` and `meta.sdk.name`) with the patterns established in the Faro Web SDK. The changes ensure: * Consistent SDK naming (`faro-mobile-flutter`) across Faro mobile implementations. * Accurate reporting of the SDK version, moving from a hardcoded value to `FaroConstants.sdkVersion`. * Removal of the `integrations` field from the `Sdk` model, as it provided no actionable insights and aligns with the web SDK's simplified model. These updates enable better SDK version analytics, distribution tracking, and proper version checking by the backend endpoint service. ## Related Issue(s) Closes grafana/faro-flutter-sdk#7403 ## Type of Change - [ ] 🛠️ Bug fix (non-breaking change which fixes an issue) - [x] 🚀 New feature (non-breaking change which adds functionality) - [ ] 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 📝 Documentation - [ ] 📈 Performance improvement - [x] 🏗️ Code refactoring - [ ] 🧹 Chore / Housekeeping ## Checklist - [x] I have made corresponding changes to the documentation - [x] I have added tests that prove my fix is effective or that my feature works - [x] I have updated the CHANGELOG.md under the "Unreleased" section ## Screenshots (if applicable) N/A ## Additional Notes This PR directly addresses the discussion regarding `meta.sdk.version` and `meta.sdk.name` alignment with the Faro Web SDK, as well as the simplification of the `Sdk` model by removing the `integrations` field. All tests pass with these changes. --- [Slack Thread](https://raintank-corp.slack.com/archives/C04LHN01GN7/p1769688028990529?thread_ts=1769688028.990529&cid=C04LHN01GN7) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes the shape and values of emitted metadata (`meta.sdk`, session attributes), which can affect backend validation/analytics and downstream dashboards even though the code changes are small. > > **Overview** > Updates telemetry `meta.sdk` to match Faro Web SDK conventions: renames the SDK identifier to `faro-mobile-flutter` and reports the real SDK version via `FaroConstants.sdkVersion` (removing the previous hardcoded `1.3.5` workaround). > > Simplifies SDK metadata by removing the `integrations` field (and the `Integration` model/export), and stops emitting `faro_sdk_version` as a session attribute; docs/changelog and affected tests are updated accordingly. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a223839. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: robert.magnusson <robert.magnusson@grafana.com>
1 parent e6053d8 commit 6e2081e

File tree

12 files changed

+27
-45
lines changed

12 files changed

+27
-45
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
129129

130130
- **Span.noParent sentinel**: New `Span.noParent` static constant allows explicitly starting a span with no parent, ignoring the active span in zone context. Useful for timer callbacks or event-driven scenarios where you want to start a fresh, independent trace. (Resolves #105)
131131

132+
### Changed
133+
134+
- **SDK metadata improvements**: Updated SDK identification to align with Faro Web SDK patterns and improve backend analytics
135+
- Changed SDK name from `'faro-flutter-sdk'` to `'faro-mobile-flutter'` to match naming convention discussed with Faro team
136+
- Removed hardcoded version `'1.3.5'` workaround and now sends actual SDK version (`0.9.0`) in `meta.sdk.version`
137+
- Removed `integrations` field from SDK metadata (following Faro Web SDK pattern - this field provided no actionable insights)
138+
- Removed unused `Integration` model class and its export from models barrel file
139+
- Backend endpoint service now properly handles Flutter SDK payloads with correct version checking
140+
- Enables better SDK version analytics and distribution tracking across different Faro implementations
141+
132142
### Fixed
133143

134144
- **SDK-internal span attributes now use typed values**: HTTP span attributes (`http.status_code`, `http.request_size`, `http.response_size`) are now sent as integers instead of strings, enabling proper numeric queries in Tempo (e.g., `status_code > 400`)

doc/Reference.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ Every telemetry event automatically includes these session attributes:
123123

124124
| Attribute | Description | iOS Example | Android Example |
125125
| --------------------- | --------------------------- | -------------------- | --------------------- |
126-
| `faro_sdk_version` | SDK version | `0.10.0` | `0.10.0` |
127126
| `dart_version` | Dart runtime version | `3.10.1 (stable)...` | `3.10.1 (stable)...` |
128127
| `device_os` | Operating system | `iOS` | `Android` |
129128
| `device_os_version` | OS version | `17.0` | `15` |
@@ -137,6 +136,17 @@ Every telemetry event automatically includes these session attributes:
137136

138137
> \*Android does not provide a mapping from model codes to marketing names, so `device_model_name` equals `device_model`.
139138

139+
### SDK Metadata
140+
141+
In addition to session attributes, every telemetry payload includes SDK identification via the `meta.sdk` object. These values are set automatically and cannot be changed by the user.
142+
143+
| Field | Description | Example |
144+
| ------------------ | ----------------- | -------------------- |
145+
| `meta.sdk.name` | SDK identifier | `faro-mobile-flutter`|
146+
| `meta.sdk.version` | SDK version | `0.12.0` |
147+
148+
In Grafana Cloud Frontend Observability, these appear as `sdk_name` and `sdk_version` in the structured metadata of each telemetry event.
149+
140150
---
141151

142152
## Performance Monitoring
@@ -948,7 +958,7 @@ Faro().runApp(
948958

949959
**Notes:**
950960

951-
- Custom attributes are merged with default attributes (like `faro_sdk_version`, `device_os`, `device_model`, etc.)
961+
- Custom attributes are merged with default attributes (like `device_os`, `device_model`, etc.)
952962
- Default attributes take precedence if there are naming conflicts
953963
- Session attributes are included in all telemetry data (logs, events, exceptions, traces)
954964
- **Type handling**: Session attributes support typed values (String, int, double, bool):

lib/src/device_info/session_attributes_provider.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:faro/src/device_info/device_id_provider.dart';
22
import 'package:faro/src/device_info/device_info_provider.dart';
3-
import 'package:faro/src/util/constants.dart';
43

54
class SessionAttributesProvider {
65
SessionAttributesProvider({
@@ -17,7 +16,6 @@ class SessionAttributesProvider {
1716
final deviceInfo = await _deviceInfoProvider.getDeviceInfo();
1817

1918
final attributes = <String, Object>{
20-
'faro_sdk_version': FaroConstants.sdkVersion,
2119
'dart_version': deviceInfo.dartVersion,
2220
'device_os': deviceInfo.deviceOs,
2321
'device_os_version': deviceInfo.deviceOsVersion,

lib/src/faro.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class Faro {
9393
SessionIdProviderFactory().create().sessionId,
9494
attributes: {},
9595
),
96-
sdk: Sdk(FaroConstants.sdkName, '1.3.5', []),
96+
sdk: Sdk(FaroConstants.sdkName, FaroConstants.sdkVersion),
9797
app: App(name: '', environment: '', version: ''),
9898
view: ViewMeta('default'),
9999
);

lib/src/models/integrations.dart

Lines changed: 0 additions & 19 deletions
This file was deleted.

lib/src/models/models.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export './device_info.dart';
55
export './event.dart';
66
export './exception.dart';
77
export './faro_user.dart';
8-
export './integrations.dart';
98
export './log.dart';
109
export './log_level.dart';
1110
export './measurement.dart';

lib/src/models/sdk.dart

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
1-
import 'package:faro/src/models/integrations.dart';
2-
31
class Sdk {
4-
Sdk(this.name, this.version, this.integrations);
2+
Sdk(this.name, this.version);
53

64
Sdk.fromJson(dynamic json) {
75
name = json['name'];
86
version = json['version'];
9-
if (json['integrations'] != null) {
10-
integrations = [];
11-
json['integrations'].forEach((dynamic v) {
12-
integrations.add(Integration.fromJson(v));
13-
});
14-
}
157
}
168
String name = '';
179
String version = '';
18-
List<Integration> integrations = [];
1910

2011
Map<String, dynamic> toJson() {
2112
final map = <String, dynamic>{};
2213
map['name'] = name;
2314
map['version'] = version;
24-
map['integrations'] = integrations.map((v) => v.toJson()).toList();
2515
return map;
2616
}
2717
}

lib/src/util/constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ class FaroConstants {
44
static const String sdkVersion = '0.13.0';
55

66
/// The name of the Faro Flutter SDK
7-
static const String sdkName = 'faro-flutter-sdk';
7+
static const String sdkName = 'faro-mobile-flutter';
88
}

test/src/device_info/session_attributes_provider_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'package:faro/src/device_info/device_id_provider.dart';
22
import 'package:faro/src/device_info/device_info_provider.dart';
33
import 'package:faro/src/device_info/session_attributes_provider.dart';
44
import 'package:faro/src/models/models.dart';
5-
import 'package:faro/src/util/constants.dart';
65
import 'package:flutter_test/flutter_test.dart';
76
import 'package:mocktail/mocktail.dart';
87

@@ -46,7 +45,6 @@ void main() {
4645
final attributes = await sut.getAttributes();
4746

4847
expect(attributes, {
49-
'faro_sdk_version': FaroConstants.sdkVersion,
5048
'dart_version': 'Some-dart-version',
5149
'device_os': 'Some-OS',
5250
'device_os_version': 'Some-OS-version',

test/src/faro_session_attributes_test.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ void main() {
129129
expect(sessionAttributes?['custom_label'], 'test_value');
130130

131131
// Default attributes should also be present
132-
expect(sessionAttributes?['faro_sdk_version'], isNotNull);
133132
expect(sessionAttributes?['device_os'], isNotNull);
134133
expect(sessionAttributes?['device_model'], isNotNull);
135134
},
@@ -152,7 +151,6 @@ void main() {
152151
expect(sessionAttributes, isNotNull);
153152

154153
// Only default attributes should be present
155-
expect(sessionAttributes?['faro_sdk_version'], isNotNull);
156154
expect(sessionAttributes?['device_os'], isNotNull);
157155
expect(sessionAttributes?['device_model'], isNotNull);
158156
});
@@ -174,7 +172,6 @@ void main() {
174172
expect(sessionAttributes, isNotNull);
175173

176174
// Only default attributes should be present
177-
expect(sessionAttributes?['faro_sdk_version'], isNotNull);
178175
expect(sessionAttributes?['device_os'], isNotNull);
179176
expect(sessionAttributes?['device_model'], isNotNull);
180177
});
@@ -286,7 +283,6 @@ void main() {
286283
}
287284

288285
// Default attributes should still be present
289-
expect(sessionAttributes?['faro_sdk_version'], isNotNull);
290286
expect(sessionAttributes?['device_os'], isNotNull);
291287
});
292288
});

0 commit comments

Comments
 (0)