diff --git a/packages/plugins/plugin_adjust/README.md b/packages/plugins/plugin_adjust/README.md index b9dfee2..bb9d875 100644 --- a/packages/plugins/plugin_adjust/README.md +++ b/packages/plugins/plugin_adjust/README.md @@ -41,6 +41,16 @@ class _MyAppState extends State { } ``` +### Settings + +#### Partner Parameters + +As Adjust `partnerParameters` cannot directly be extracted from the Segment payload, as its properties are forwarded as `callbackProperties` you can specify a specific key to extract the `partnerParameters` from instead of passing it to the `callbackParameters`. +if a value is passed behind `partnerParametersKey` it has to be a map. + +```dart + + ## Support Please use Github issues, Pull Requests, or feel free to reach out to our [support team](https://segment.com/help/). @@ -52,6 +62,7 @@ Interested in integrating your service with us? Check out our [Partners page](ht ## License ``` + MIT License Copyright (c) 2023 Segment @@ -73,4 +84,5 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ``` diff --git a/packages/plugins/plugin_adjust/lib/plugin_adjust.dart b/packages/plugins/plugin_adjust/lib/plugin_adjust.dart index 540439a..6bfbd29 100644 --- a/packages/plugins/plugin_adjust/lib/plugin_adjust.dart +++ b/packages/plugins/plugin_adjust/lib/plugin_adjust.dart @@ -57,32 +57,19 @@ class AdjustDestination extends DestinationPlugin { hasRegisteredCallback = true; } - final bufferingEnabled = adjustSettings!.setEventBufferingEnabled; - if (bufferingEnabled == true) { - adjustConfig.eventBufferingEnabled = bufferingEnabled; - } - - final useDelay = adjustSettings!.setDelay; - if (useDelay == true) { - final delayTime = adjustSettings!.delayTime; - if (delayTime != null) { - adjustConfig.delayStart = delayTime.toDouble(); - } - } - - Adjust.start(adjustConfig); + Adjust.initSdk(adjustConfig); } @override identify(event) async { final userId = event.userId; if (userId != null && userId.isNotEmpty) { - Adjust.addSessionPartnerParameter('user_id', userId); + Adjust.addGlobalPartnerParameter('user_id', userId); } final anonId = event.anonymousId; if (anonId != null && anonId.isNotEmpty) { - Adjust.addSessionPartnerParameter('anonymous_id', anonId); + Adjust.addGlobalPartnerParameter('anonymous_id', anonId); } return event; } @@ -91,7 +78,7 @@ class AdjustDestination extends DestinationPlugin { track(event) async { final anonId = event.anonymousId; if (anonId != null && anonId.isNotEmpty) { - Adjust.addSessionPartnerParameter('anonymous_id', anonId); + Adjust.addGlobalPartnerParameter('anonymous_id', anonId); } if (adjustSettings == null) { @@ -104,6 +91,17 @@ class AdjustDestination extends DestinationPlugin { final properties = event.properties; if (properties != null) { + final partnerParameterKey = adjustSettings!.partnerParameterKey; + if (partnerParameterKey != null) { + final partnerParameters = properties[partnerParameterKey]; + properties.remove(partnerParameterKey); + if (partnerParameters is Map) { + for (final entry in partnerParameters.entries) { + adjEvent.addPartnerParameter(entry.key, entry.value); + } + } + } + for (final entry in properties.entries) { adjEvent.addCallbackParameter(entry.key, entry.value.toString()); } @@ -129,6 +127,6 @@ class AdjustDestination extends DestinationPlugin { @override reset() { - Adjust.resetSessionPartnerParameters(); + Adjust.removeGlobalPartnerParameters(); } } diff --git a/packages/plugins/plugin_adjust/lib/types.dart b/packages/plugins/plugin_adjust/lib/types.dart index 796c10c..caf43f5 100644 --- a/packages/plugins/plugin_adjust/lib/types.dart +++ b/packages/plugins/plugin_adjust/lib/types.dart @@ -6,20 +6,38 @@ class AdjustSettings { final bool disabled; final String appToken; final bool? setEnvironmentProduction; + @Deprecated(""" + this setting has been removed in the adjust sdk + it will be removed in the next version of the plugin + and has currently no effect + """) final bool? setEventBufferingEnabled; final bool? trackAttributionData; + @Deprecated(""" + this setting has been removed in the adjust sdk + it will be removed in the next version of the plugin + and has currently no effect + """) final bool? setDelay; final Map? customEvents; final int? delayTime; - AdjustSettings(this.appToken, - {this.disabled = false, - this.customEvents, - this.delayTime, - this.setDelay, - this.setEnvironmentProduction, - this.setEventBufferingEnabled, - this.trackAttributionData}); + /// under which property key the partner parameters are stored + /// the map behind that key will then be forwarded to the adjust sdk + /// as partner parameters + final String? partnerParameterKey; + + AdjustSettings( + this.appToken, { + this.disabled = false, + this.customEvents, + this.delayTime, + this.setDelay, + this.setEnvironmentProduction, + this.setEventBufferingEnabled, + this.trackAttributionData, + this.partnerParameterKey, + }); factory AdjustSettings.fromJson(Map json) => _$AdjustSettingsFromJson(json); diff --git a/packages/plugins/plugin_adjust/pubspec.yaml b/packages/plugins/plugin_adjust/pubspec.yaml index 6b7fdb8..bf8479a 100644 --- a/packages/plugins/plugin_adjust/pubspec.yaml +++ b/packages/plugins/plugin_adjust/pubspec.yaml @@ -1,6 +1,6 @@ name: segment_analytics_plugin_adjust description: The hassle-free way to add Segment analytics to your Flutter app. -version: 1.0.1 +version: 1.0.2 homepage: https://github.com/segmentio/analytics_flutter#readme repository: https://github.com/segmentio/analytics_flutter/tree/main/packages/plugins/plugin_adjust#readme issue_tracker: https://github.com/segmentio/analytics_flutter/issues @@ -14,7 +14,7 @@ dependencies: sdk: flutter segment_analytics: ^1.1.1 json_annotation: ^4.9.0 - adjust_sdk: ^4.38.2 + adjust_sdk: ^5.0.2 dev_dependencies: build_runner: ^2.4.7