-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Labels
featureRequesting a new feature.Requesting a new feature.package: flutter_client_sdkIssues that affect the flutter client SDK.Issues that affect the flutter client SDK.
Description
Currently, the LaunchDarkly Flutter SDK stores a device-level unique identifier (the ld_device
context) using SharedPreferences
, but this value is not accessible through the public API. I have resorted to manually reading shared preferences to retrieve it, which is brittle and relies on internal key formats that may change.
💡 Motivation
- The device ID is essential for correlating evaluations or analytics across devices and backend systems.
- There’s currently no safe, stable alternative to manually parsing shared preferences, which risks breaking in future versions.
- Offering official access would improve developer experience and support valid use cases like debugging, analytics, or correlating logs.
❌ Actual implementation
/// Encoder method
String _encodePersistenceKey(String input) {
final bytes = utf8.encode(input);
final digest = sha256.convert(bytes);
// This will be the hex encoded digest.
return digest.toString();
}
final _preferences = await SharedPreferences.getInstance();
final _deviceIdLaunchy = _preferences.getString(
'LaunchDarkly_AutoEnvContextKey.${_encodePersistenceKey('ld_device')}',
);
debugPrint('deviceId: $_deviceIdLaunchy');
✅ Desired API
Expose a new asynchronous method on LDClient
, such as:
Future<String?> getDeviceId();
That returns the same ld_device
UUID stored internally. It could be available once the client has been started.
🛠️ Proposed Implementation
- Dart-side: add
getDeviceId()
toLDClient
inlaunchdarkly_flutter_client_sdk.dart
, exposing the value. - Testing: Add unit tests that confirm the device ID matches across calls and persists across restarts.
- Documentation: Include usage in
README
andCHANGELOG
.
I’d be happy to draft a PR implementing this feature, including all necessary code, tests, and documentation.
Please let me know if this aligns with the project’s goals, I can begin right away 🙏
HofmannZ and Aleksandar-ArgeadHofmannZ
Metadata
Metadata
Assignees
Labels
featureRequesting a new feature.Requesting a new feature.package: flutter_client_sdkIssues that affect the flutter client SDK.Issues that affect the flutter client SDK.