Skip to content

Commit

Permalink
Add worker handle support (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-kuznetsov-hypertrack authored Jun 25, 2024
1 parent f56c107 commit 3bea371
Show file tree
Hide file tree
Showing 118 changed files with 263 additions and 135 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.3.0] - 2024-06-22

### Added

- New `setWorkerHandle` and `getWorkerHandle` can be used to identify workers
- We observed our customers identify worker devices via `HyperTrack.metadata`, so we decided to make it a first class citizen in our API.
- If you previously used `metadata` to identify workers, we suggest using `workerHandle` for this purpose instead.

### Changed

- Updated HyperTrack SDK iOS to [5.6.0](https://github.com/hypertrack/sdk-ios/releases/tag/5.6.0)
- Updated HyperTrack SDK Android to [7.6.0](https://github.com/hypertrack/sdk-android/releases/tag/7.6.0)

## [2.2.3] - 2024-05-24

### Changed
Expand Down Expand Up @@ -359,3 +372,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[2.2.1]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.2.1
[2.2.2]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.2.2
[2.2.3]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.2.3
[2.3.0]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.3.0
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ android {
disable 'InvalidPackage'
}
dependencies {
def hyperTrackVersion = "7.5.5"
def hyperTrackVersion = "7.6.0"
implementation "com.hypertrack:sdk-android:${hyperTrackVersion}"
implementation "com.hypertrack:location-services-google:${hyperTrackVersion}"
implementation "com.hypertrack:push-service-firebase:${hyperTrackVersion}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ public class HyperTrackPlugin : FlutterPlugin, MethodCallHandler {
HyperTrackSdkWrapper.getName()
}

SdkMethod.getWorkerHandle -> {
HyperTrackSdkWrapper.getWorkerHandle()
}

SdkMethod.locate -> {
// locate is implemented as a EventChannel
Success(NotImplemented)
Expand Down Expand Up @@ -156,6 +160,12 @@ public class HyperTrackPlugin : FlutterPlugin, MethodCallHandler {
HyperTrackSdkWrapper.setName(args)
}
}

SdkMethod.setWorkerHandle -> {
withArgs<Unit>(call) { args ->
HyperTrackSdkWrapper.setWorkerHandle(args)
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.hypertrack.sdk.flutter.common.Serialization.deserializeIsAvailable
import com.hypertrack.sdk.flutter.common.Serialization.deserializeIsTracking
import com.hypertrack.sdk.flutter.common.Serialization.deserializeMetadata
import com.hypertrack.sdk.flutter.common.Serialization.deserializeName
import com.hypertrack.sdk.flutter.common.Serialization.deserializeWorkerHandle
import com.hypertrack.sdk.flutter.common.Serialization.serializeDeviceId
import com.hypertrack.sdk.flutter.common.Serialization.serializeDynamicPublishableKey
import com.hypertrack.sdk.flutter.common.Serialization.serializeErrors
Expand All @@ -20,6 +21,7 @@ import com.hypertrack.sdk.flutter.common.Serialization.serializeLocationSuccess
import com.hypertrack.sdk.flutter.common.Serialization.serializeLocationWithDeviationSuccess
import com.hypertrack.sdk.flutter.common.Serialization.serializeMetadata
import com.hypertrack.sdk.flutter.common.Serialization.serializeName
import com.hypertrack.sdk.flutter.common.Serialization.serializeWorkerHandle

typealias Serialized = Map<String, Any?>

Expand Down Expand Up @@ -137,6 +139,12 @@ internal object HyperTrackSdkWrapper {
)
}

fun getWorkerHandle(): WrapperResult<Serialized> {
return Success(
serializeWorkerHandle(HyperTrack.workerHandle),
)
}

fun setDynamicPublishableKey(args: Serialized): WrapperResult<Unit> {
return deserializeDynamicPublishableKey(args)
.mapSuccess { publishableKey ->
Expand Down Expand Up @@ -174,4 +182,11 @@ internal object HyperTrackSdkWrapper {
HyperTrack.name = name
}
}

fun setWorkerHandle(args: Serialized): WrapperResult<Unit> {
return deserializeWorkerHandle(args)
.mapSuccess { workerHandle ->
HyperTrack.workerHandle = workerHandle
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ internal enum class SdkMethod {
getLocation,
getMetadata,
getName,
getWorkerHandle,
locate,
setDynamicPublishableKey,
setIsAvailable,
setIsTracking,
setMetadata,
setName,
setWorkerHandle,
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ internal object Serialization {
}
}

fun deserializeWorkerHandle(map: Map<String, Any?>): WrapperResult<String> {
return parse(map) {
it.assertValue<String>(key = KEY_TYPE, value = TYPE_WORKER_HANDLE)
it
.get<String>(KEY_VALUE)
.getOrThrow()
}
}

fun serializeDeviceId(deviceId: String): Map<String, Any?> {
return mapOf(
KEY_TYPE to TYPE_DEVICE_ID,
Expand Down Expand Up @@ -206,6 +215,13 @@ internal object Serialization {
)
}

fun serializeWorkerHandle(workerHandle: String): Map<String, Any?> {
return mapOf(
KEY_TYPE to TYPE_WORKER_HANDLE,
KEY_VALUE to workerHandle,
)
}

private fun deserializeLocation(map: Map<String, Any?>): WrapperResult<Location> {
return parse(map) {
it.assertValue<String>(key = KEY_TYPE, value = TYPE_LOCATION)
Expand Down Expand Up @@ -397,10 +413,11 @@ internal object Serialization {
private const val TYPE_ERROR = "error"
private const val TYPE_IS_AVAILABLE = "isAvailable"
private const val TYPE_IS_TRACKING = "isTracking"
private const val TYPE_METADATA = "metadata"
private const val TYPE_NAME = "name"
private const val TYPE_LOCATION = "location"
private const val TYPE_LOCATION_WITH_DEVIATION = "locationWithDeviation"
private const val TYPE_METADATA = "metadata"
private const val TYPE_NAME = "name"
private const val TYPE_WORKER_HANDLE = "workerHandle"

private const val TYPE_LOCATION_ERROR_ERRORS = "errors"
private const val TYPE_LOCATION_ERROR_NOT_RUNNING = "notRunning"
Expand Down
2 changes: 1 addition & 1 deletion docs/__404error.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ <h5><span class="package-name">hypertrack_plugin</span> <span class="package-kin
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_hypertrack_error/HyperTrackError.html
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ <h5>hypertrack_error library</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ <h5>HyperTrackError enum</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ <h5>HyperTrackError enum</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ <h5>hypertrack_error library</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSON-class.html
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ <h5>json library</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSON/JSON.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ <h5>JSON class</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSON/fromMap.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ <h5>JSON class</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSON/fromString.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ <h5>JSON class</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSON/serialize.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ <h5>JSON class</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSONArray-class.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ <h5>json library</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSONArray/JSONArray.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ <h5>JSONArray class</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSONArray/items.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ <h5>JSONArray class</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSONArray/serialize.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ <h5>JSONArray class</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSONBool-class.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ <h5>json library</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSONBool/JSONBool.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ <h5>JSONBool class</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSONBool/serialize.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ <h5>JSONBool class</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSONBool/value.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ <h5>JSONBool class</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSONNull-class.html
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ <h5>json library</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSONNull/JSONNull.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h5>JSONNull class</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSONNull/serialize.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ <h5>JSONNull class</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSONNumber-class.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ <h5>json library</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSONNumber/JSONNumber.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ <h5>JSONNumber class</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSONNumber/serialize.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ <h5>JSONNumber class</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSONNumber/value.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ <h5>JSONNumber class</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSONObject-class.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ <h5>json library</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion docs/data_types_json/JSONObject/JSONObject.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ <h5>JSONObject class</h5>
<footer>
<span class="no-break">
hypertrack_plugin
2.2.3
2.3.0
</span>


Expand Down
Loading

0 comments on commit 3bea371

Please sign in to comment.