Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom partnerParameters #129

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/plugins/plugin_adjust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ class _MyAppState extends State<MyApp> {
}
```

### 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/).
Expand All @@ -52,6 +62,7 @@ Interested in integrating your service with us? Check out our [Partners page](ht
## License

```

MIT License

Copyright (c) 2023 Segment
Expand All @@ -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.

```
34 changes: 16 additions & 18 deletions packages/plugins/plugin_adjust/lib/plugin_adjust.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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) {
Expand All @@ -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<String, dynamic>) {
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());
}
Expand All @@ -129,6 +127,6 @@ class AdjustDestination extends DestinationPlugin {

@override
reset() {
Adjust.resetSessionPartnerParameters();
Adjust.removeGlobalPartnerParameters();
}
}
34 changes: 26 additions & 8 deletions packages/plugins/plugin_adjust/lib/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String>? 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<String, dynamic> json) =>
_$AdjustSettingsFromJson(json);
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/plugin_adjust/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down