From 3bea3716314b01331686bb3460cbb8c522f62cd5 Mon Sep 17 00:00:00 2001 From: pavel-kuznetsov-hypertrack <78730314+pavel-kuznetsov-hypertrack@users.noreply.github.com> Date: Tue, 25 Jun 2024 18:11:01 +0300 Subject: [PATCH] Add worker handle support (#57) --- CHANGELOG.md | 14 ++++++++ android/build.gradle | 2 +- .../sdk/flutter/HyperTrackPlugin.kt | 10 ++++++ .../flutter/common/HyperTrackSdkWrapper.kt | 15 ++++++++ .../sdk/flutter/common/SdkMethod.kt | 2 ++ .../sdk/flutter/common/Serialization.kt | 21 ++++++++++-- docs/__404error.html | 2 +- .../HyperTrackError.html | 2 +- .../HyperTrackError/HyperTrackError.html | 2 +- .../HyperTrackError/values-constant.html | 2 +- .../data_types_hypertrack_error-library.html | 2 +- docs/data_types_json/JSON-class.html | 2 +- docs/data_types_json/JSON/JSON.html | 2 +- docs/data_types_json/JSON/fromMap.html | 2 +- docs/data_types_json/JSON/fromString.html | 2 +- docs/data_types_json/JSON/serialize.html | 2 +- docs/data_types_json/JSONArray-class.html | 2 +- docs/data_types_json/JSONArray/JSONArray.html | 2 +- docs/data_types_json/JSONArray/items.html | 2 +- docs/data_types_json/JSONArray/serialize.html | 2 +- docs/data_types_json/JSONBool-class.html | 2 +- docs/data_types_json/JSONBool/JSONBool.html | 2 +- docs/data_types_json/JSONBool/serialize.html | 2 +- docs/data_types_json/JSONBool/value.html | 2 +- docs/data_types_json/JSONNull-class.html | 2 +- docs/data_types_json/JSONNull/JSONNull.html | 2 +- docs/data_types_json/JSONNull/serialize.html | 2 +- docs/data_types_json/JSONNumber-class.html | 2 +- .../JSONNumber/JSONNumber.html | 2 +- .../data_types_json/JSONNumber/serialize.html | 2 +- docs/data_types_json/JSONNumber/value.html | 2 +- docs/data_types_json/JSONObject-class.html | 2 +- .../JSONObject/JSONObject.html | 2 +- docs/data_types_json/JSONObject/fields.html | 2 +- .../data_types_json/JSONObject/serialize.html | 2 +- docs/data_types_json/JSONString-class.html | 2 +- .../JSONString/JSONString.html | 2 +- .../data_types_json/JSONString/serialize.html | 2 +- docs/data_types_json/JSONString/value.html | 2 +- .../data_types_json-library.html | 2 +- docs/data_types_json/fromMap.html | 2 +- docs/data_types_location/Location-class.html | 2 +- .../Location/Location.html | 2 +- .../Location/latitude.html | 2 +- .../Location/longitude.html | 2 +- .../data_types_location-library.html | 2 +- .../Errors-class.html | 2 +- .../Errors/Errors.html | 2 +- .../LocationError-class.html | 2 +- .../LocationError/LocationError.errors.html | 2 +- .../LocationError.notRunning.html | 2 +- .../LocationError/LocationError.starting.html | 2 +- .../NotRunning-class.html | 2 +- .../NotRunning/NotRunning.html | 2 +- .../Starting-class.html | 2 +- .../Starting/Starting.html | 2 +- .../data_types_location_error-library.html | 2 +- .../LocationWithDeviation-class.html | 2 +- .../LocationWithDeviation.html | 2 +- .../LocationWithDeviation/deviation.html | 2 +- .../LocationWithDeviation/location.html | 2 +- ...types_location_with_deviation-library.html | 2 +- .../ClockIn-class.html | 2 +- .../ClockIn/ClockIn.html | 2 +- .../ClockOut-class.html | 2 +- .../ClockOut/ClockOut.html | 2 +- .../data_types_order_status/Custom-class.html | 2 +- .../Custom/Custom.html | 2 +- .../data_types_order_status/Custom/value.html | 2 +- .../OrderStatus-class.html | 2 +- .../OrderStatus/OrderStatus.clockIn.html | 2 +- .../OrderStatus/OrderStatus.clockOut.html | 2 +- .../OrderStatus/OrderStatus.custom.html | 2 +- .../OrderStatus/OrderStatus.html | 2 +- .../data_types_order_status-library.html | 2 +- docs/data_types_result/Failure-class.html | 2 +- docs/data_types_result/Failure/Failure.html | 2 +- docs/data_types_result/Result-class.html | 2 +- .../Result/Result.error.html | 2 +- .../Result/Result.success.html | 2 +- docs/data_types_result/Success-class.html | 2 +- docs/data_types_result/Success/Success.html | 2 +- docs/data_types_result/Success/value.html | 2 +- .../data_types_result-library.html | 2 +- docs/hypertrack/HyperTrack-class.html | 2 +- docs/hypertrack/HyperTrack/HyperTrack.html | 2 +- docs/hypertrack/HyperTrack/addGeotag.html | 2 +- .../HyperTrack/addGeotagDeprecated.html | 2 +- .../addGeotagWithExpectedLocation.html | 2 +- ...dGeotagWithExpectedLocationDeprecated.html | 2 +- docs/hypertrack/HyperTrack/deviceId.html | 2 +- docs/hypertrack/HyperTrack/errors.html | 2 +- .../HyperTrack/errorsSubscription.html | 2 +- docs/hypertrack/HyperTrack/isAvailable.html | 2 +- .../HyperTrack/isAvailableSubscription.html | 2 +- docs/hypertrack/HyperTrack/isTracking.html | 2 +- .../HyperTrack/isTrackingSubscription.html | 2 +- docs/hypertrack/HyperTrack/locate.html | 2 +- docs/hypertrack/HyperTrack/location.html | 2 +- .../HyperTrack/locationSubscription.html | 2 +- docs/hypertrack/HyperTrack/metadata.html | 2 +- docs/hypertrack/HyperTrack/name.html | 2 +- .../hypertrack/HyperTrack/setIsAvailable.html | 2 +- docs/hypertrack/HyperTrack/setIsTracking.html | 2 +- docs/hypertrack/HyperTrack/setMetadata.html | 2 +- docs/hypertrack/HyperTrack/setName.html | 2 +- docs/hypertrack/hypertrack-library.html | 2 +- docs/index.html | 2 +- docs/search.html | 2 +- ios/Classes/HyperTrackPluginSwift.swift | 4 +++ ios/Classes/common/HyperTrackSDKWrapper.swift | 30 ++++++++++------ ios/Classes/common/SDKMethod.swift | 2 ++ ios/Classes/common/Serialization.swift | 26 +++++++++++--- ios/hypertrack_plugin.podspec | 4 +-- lib/hypertrack.dart | 22 ++++++++++++ lib/src/sdk_method.dart | 2 ++ lib/src/serialization.dart | 34 +++++++++++++------ pubspec.yaml | 4 +-- 118 files changed, 263 insertions(+), 135 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a49b8b..5e95d8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/android/build.gradle b/android/build.gradle index 5a68e29..6944181 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -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}" diff --git a/android/src/main/kotlin/com/hypertrack/sdk/flutter/HyperTrackPlugin.kt b/android/src/main/kotlin/com/hypertrack/sdk/flutter/HyperTrackPlugin.kt index 458be06..048d356 100644 --- a/android/src/main/kotlin/com/hypertrack/sdk/flutter/HyperTrackPlugin.kt +++ b/android/src/main/kotlin/com/hypertrack/sdk/flutter/HyperTrackPlugin.kt @@ -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) @@ -156,6 +160,12 @@ public class HyperTrackPlugin : FlutterPlugin, MethodCallHandler { HyperTrackSdkWrapper.setName(args) } } + + SdkMethod.setWorkerHandle -> { + withArgs(call) { args -> + HyperTrackSdkWrapper.setWorkerHandle(args) + } + } } } diff --git a/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/HyperTrackSdkWrapper.kt b/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/HyperTrackSdkWrapper.kt index 7002d70..40b6e59 100644 --- a/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/HyperTrackSdkWrapper.kt +++ b/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/HyperTrackSdkWrapper.kt @@ -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 @@ -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 @@ -137,6 +139,12 @@ internal object HyperTrackSdkWrapper { ) } + fun getWorkerHandle(): WrapperResult { + return Success( + serializeWorkerHandle(HyperTrack.workerHandle), + ) + } + fun setDynamicPublishableKey(args: Serialized): WrapperResult { return deserializeDynamicPublishableKey(args) .mapSuccess { publishableKey -> @@ -174,4 +182,11 @@ internal object HyperTrackSdkWrapper { HyperTrack.name = name } } + + fun setWorkerHandle(args: Serialized): WrapperResult { + return deserializeWorkerHandle(args) + .mapSuccess { workerHandle -> + HyperTrack.workerHandle = workerHandle + } + } } diff --git a/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/SdkMethod.kt b/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/SdkMethod.kt index 37c7710..784e5ef 100644 --- a/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/SdkMethod.kt +++ b/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/SdkMethod.kt @@ -16,10 +16,12 @@ internal enum class SdkMethod { getLocation, getMetadata, getName, + getWorkerHandle, locate, setDynamicPublishableKey, setIsAvailable, setIsTracking, setMetadata, setName, + setWorkerHandle, } diff --git a/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/Serialization.kt b/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/Serialization.kt index c56a15b..ff25d33 100644 --- a/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/Serialization.kt +++ b/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/Serialization.kt @@ -87,6 +87,15 @@ internal object Serialization { } } + fun deserializeWorkerHandle(map: Map): WrapperResult { + return parse(map) { + it.assertValue(key = KEY_TYPE, value = TYPE_WORKER_HANDLE) + it + .get(KEY_VALUE) + .getOrThrow() + } + } + fun serializeDeviceId(deviceId: String): Map { return mapOf( KEY_TYPE to TYPE_DEVICE_ID, @@ -206,6 +215,13 @@ internal object Serialization { ) } + fun serializeWorkerHandle(workerHandle: String): Map { + return mapOf( + KEY_TYPE to TYPE_WORKER_HANDLE, + KEY_VALUE to workerHandle, + ) + } + private fun deserializeLocation(map: Map): WrapperResult { return parse(map) { it.assertValue(key = KEY_TYPE, value = TYPE_LOCATION) @@ -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" diff --git a/docs/__404error.html b/docs/__404error.html index c01925b..d0e6b9f 100644 --- a/docs/__404error.html +++ b/docs/__404error.html @@ -96,7 +96,7 @@
hypertrack_plugin hypertrack_plugin - 2.2.3 + 2.3.0 diff --git a/docs/data_types_hypertrack_error/HyperTrackError.html b/docs/data_types_hypertrack_error/HyperTrackError.html index 90c3445..b5224de 100644 --- a/docs/data_types_hypertrack_error/HyperTrackError.html +++ b/docs/data_types_hypertrack_error/HyperTrackError.html @@ -430,7 +430,7 @@
hypertrack_error library