Skip to content

Commit 869e32e

Browse files
committed
feat: option to provide a custom salt
1 parent aa8aaf8 commit 869e32e

File tree

8 files changed

+47
-20
lines changed

8 files changed

+47
-20
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
## 2.0.0
22

33
- https://github.com/TelemetryDeck/FlutterSDK/releases/tag/2.0.0
4-
- The KotlinSDK has been updated to [version 4.0.0](https://github.com/TelemetryDeck/KotlinSDK/releases/tag/4.0.0) introducing automatic generation of random user identifiers ([link](https://github.com/TelemetryDeck/KotlinSDK/issues/14))
4+
- The KotlinSDK has been updated to [version 4.0.2](https://github.com/TelemetryDeck/KotlinSDK/releases/tag/4.0.2) introducing automatic generation of random user identifiers ([link](https://github.com/TelemetryDeck/KotlinSDK/issues/14)) and other improvements.
5+
- Added the option to provide a custom salt for consistent user identifiers.
56

67
## 1.0.0
78

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ void main() {
2525
}
2626
```
2727

28-
## Permission for internet access
28+
### Permission for internet access
2929

3030
Sending signals requires access to the internet so the following permissions should be granted. For more information, you can check [Flutter Cross-platform HTTP networking ](https://docs.flutter.dev/data-and-backend/networking).
3131

32-
### Android
32+
#### Android
3333

3434
Change the app's `AndroidManifest.xml` to include:
3535

3636
```xml
3737
<uses-permission android:name="android.permission.INTERNET" />
3838
```
3939

40-
### macOS
40+
#### macOS
4141

4242
Set the `com.apple.security.network.client` entitlement to `true` in the `macos/Runner/DebugProfile.entitlements` and `macos/Runner/Release.entitlements` files. You can also do this in Xcode by selecting the `macos` target, then the `Signing & Capabilities` tab, and checking `Outgoing connections (Client)` for both the Release and Debug targets of your app.
4343

@@ -64,7 +64,7 @@ Telemetrydecksdk.send(
6464

6565
The Flutter SDK uses the native SDKs for Android and iOS which offer a number of built-in attributes which are submitted with every signal.
6666

67-
You can overwrite these attributes by providing a custom value with the same key. For more information on how each value is calcualted, check the corresponding platform library.
67+
For more information on how each value is calcualted, check the corresponding platform library.
6868

6969
The Flutter SDK adds the following additional attributes:
7070

@@ -118,6 +118,23 @@ Telemetrydecksdk.start(
118118

119119
[Getting started with Test Mode](https://telemetrydeck.com/docs/articles/test-mode/)
120120

121+
## Custom Salt
122+
123+
By default, user identifiers are hashed by the TelemetryDeck SDK, and then sent to the Ingestion API, where we'll add a salt to the received identifier and hash it again.
124+
125+
This is enough for most use cases, but if you want to extra privacy conscious, you can add in you own salt on the client side. The TelemetryDeck SDK will append the salt to all user identifers before hashing them and sending them to us.
126+
127+
If you'd like to use a custom salt, you can do so by passing it on to the starting `TelemetryManagerConfiguration`:
128+
129+
```dart
130+
Telemetrydecksdk.start(
131+
TelemetryManagerConfiguration(
132+
appID: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
133+
salt: "<A RANDOM STRING>",
134+
),
135+
);
136+
```
137+
121138
## Custom Server
122139

123140
A very small subset of our customers will want to use a custom signal ingestion server or a custom proxy server. To do so, you can pass the URL of the custom server to the `TelemetryManagerConfiguration`:

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ android {
5050
}
5151

5252
dependencies {
53-
implementation 'com.telemetrydeck:kotlin-sdk:4.0.0'
53+
implementation 'com.telemetrydeck:kotlin-sdk:4.0.2'
5454
testImplementation 'org.jetbrains.kotlin:kotlin-test'
5555
testImplementation 'org.mockito:mockito-core:5.0.0'
5656
}

android/src/main/kotlin/com/telemetrydeck/telemetrydecksdk/TelemetrydecksdkPlugin.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ class TelemetrydecksdkPlugin : FlutterPlugin, MethodCallHandler {
169169
val defaultUser = arguments["defaultUser"] as? String?
170170
val debug = arguments["debug"] as? Boolean
171171
val testMode = arguments["testMode"] as? Boolean
172+
val salt = arguments["salt"] as? String?
172173

173174

174175
// Initialize the client
@@ -188,6 +189,9 @@ class TelemetrydecksdkPlugin : FlutterPlugin, MethodCallHandler {
188189
testMode?.let {
189190
builder.testMode(it)
190191
}
192+
salt?.let {
193+
builder.salt(it)
194+
}
191195

192196
val application = applicationContext as Application
193197
TelemetryDeck.start(application, builder)

example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#Mon Dec 16 15:22:49 CET 2024
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip

example/lib/main.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ void main() {
77
WidgetsFlutterBinding.ensureInitialized();
88
Telemetrydecksdk.start(
99
const TelemetryManagerConfiguration(
10-
appID: "22385F1C-3699-4F04-9D63-24CC0B2E62D8",
11-
debug: true,
12-
testMode: true,
13-
),
10+
appID: "22385F1C-3699-4F04-9D63-24CC0B2E62D8",
11+
debug: true,
12+
testMode: true),
1413
);
1514
runApp(const MyApp());
1615
}

ios/Classes/TelemetrydecksdkPlugin.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@ public class TelemetrydecksdkPlugin: NSObject, FlutterPlugin {
113113
baseURL = url
114114
}
115115

116+
117+
let salt = arguments["salt"] as? String
116118
let configuration = TelemetryManagerConfiguration.init(
117-
appID: appID, salt: nil, baseURL: baseURL)
119+
appID: appID, salt: salt, baseURL: baseURL)
118120

119121
// other optional params
120122
if arguments.keys.contains("defaultUser") {

lib/src/telemetry_manager_configuration.dart

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ class TelemetryManagerConfiguration {
2020
/// If `testMode` is not set explicitly, the corresponding native SDK will automatically determine the value based on whether this is a debug or release build of the app.
2121
final bool? testMode;
2222

23-
const TelemetryManagerConfiguration({
24-
required this.appID,
25-
this.apiBaseURL,
26-
this.defaultUser,
27-
this.debug,
28-
this.testMode,
29-
});
23+
final String? salt;
24+
25+
const TelemetryManagerConfiguration(
26+
{required this.appID,
27+
this.apiBaseURL,
28+
this.defaultUser,
29+
this.debug,
30+
this.testMode,
31+
this.salt});
3032

3133
/// to map
3234
Map<String, dynamic> toMap() {
@@ -36,6 +38,7 @@ class TelemetryManagerConfiguration {
3638
'defaultUser': defaultUser,
3739
'debug': debug,
3840
'testMode': testMode,
41+
'salt': salt
3942
};
4043
}
4144
}

0 commit comments

Comments
 (0)