-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release 7.0.0
- Loading branch information
Showing
20 changed files
with
301 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import 'package:collection/collection.dart' show IterableExtension; | ||
import 'package:json_annotation/json_annotation.dart'; | ||
import 'package:qonversion_flutter/qonversion_flutter.dart'; | ||
|
||
part 'user_properties.g.dart'; | ||
|
||
@JsonSerializable(createToJson: false) | ||
class QUserProperties { | ||
/// List of all user properties. | ||
@JsonKey(name: "properties") | ||
final List<QUserProperty> properties; | ||
|
||
/// List of user properties, set for the Qonversion defined keys. | ||
/// This is a subset of all [properties] list. | ||
/// See [Qonversion.setUserProperty]. | ||
final List<QUserProperty> definedProperties; | ||
|
||
/// List of user properties, set for custom keys. | ||
/// This is a subset of all [properties] list. | ||
/// See [Qonversion.setCustomUserProperty]. | ||
final List<QUserProperty> customProperties; | ||
|
||
/// Map of all user properties. | ||
/// This is a flattened version of the [properties] list as a key-value map. | ||
final Map<String, String> flatPropertiesMap; | ||
|
||
/// Map of user properties, set for the Qonversion defined keys. | ||
/// This is a flattened version of the [definedProperties] list as a key-value map. | ||
/// See [Qonversion.setUserProperty]. | ||
final Map<QUserPropertyKey, String> flatDefinedPropertiesMap; | ||
|
||
/// Map of user properties, set for custom keys. | ||
/// This is a flattened version of the [customProperties] list as a key-value map. | ||
/// See [Qonversion.setCustomUserProperty]. | ||
final Map<String, String> flatCustomPropertiesMap; | ||
|
||
QUserProperties._( | ||
this.properties, | ||
this.definedProperties, | ||
this.customProperties, | ||
this.flatPropertiesMap, | ||
this.flatDefinedPropertiesMap, | ||
this.flatCustomPropertiesMap, | ||
); | ||
|
||
factory QUserProperties(List<QUserProperty> properties) { | ||
final List<QUserProperty> definedProperties = properties.whereNot( | ||
(userProperty) => userProperty.definedKey == QUserPropertyKey.custom | ||
).toList(); | ||
final List<QUserProperty> customProperties = properties.where( | ||
(userProperty) => userProperty.definedKey == QUserPropertyKey.custom | ||
).toList(); | ||
|
||
final Map<String, String> flatPropertiesMap = Map.fromIterable( | ||
properties, | ||
key: (userProperty) => userProperty.key, | ||
value: (userProperty) => userProperty.value, | ||
); | ||
|
||
final Map<QUserPropertyKey, String> flatDefinedPropertiesMap = Map.fromIterable( | ||
definedProperties, | ||
key: (userProperty) => userProperty.definedKey, | ||
value: (userProperty) => userProperty.value, | ||
); | ||
|
||
final Map<String, String> flatCustomPropertiesMap = Map.fromIterable( | ||
customProperties, | ||
key: (userProperty) => userProperty.key, | ||
value: (userProperty) => userProperty.value, | ||
); | ||
|
||
return QUserProperties._( | ||
properties, | ||
definedProperties, | ||
customProperties, | ||
flatPropertiesMap, | ||
flatDefinedPropertiesMap, | ||
flatCustomPropertiesMap, | ||
); | ||
} | ||
|
||
factory QUserProperties.fromJson(Map<String, dynamic> json) => | ||
_$QUserPropertiesFromJson(json); | ||
|
||
/// Searches for a property with the given property [key] in all properties list. | ||
QUserProperty? getProperty(String key) { | ||
return properties.firstWhereOrNull((userProperty) => userProperty.key == key); | ||
} | ||
|
||
/// Searches for a property with the given Qonversion defined property [key] | ||
/// in defined properties list. | ||
QUserProperty? getDefinedProperty(QUserPropertyKey key) { | ||
return definedProperties.firstWhereOrNull((userProperty) => userProperty.definedKey == key); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
enum QUserProperty { | ||
email, | ||
name, | ||
kochavaDeviceId, | ||
appsFlyerUserId, | ||
adjustAdId, | ||
customUserId, | ||
facebookAttribution, | ||
firebaseAppInstanceId, | ||
appSetId, // Android only | ||
advertisingId, // iOS only | ||
import 'package:json_annotation/json_annotation.dart'; | ||
import 'package:qonversion_flutter/src/dto/user_property_key.dart'; | ||
import 'package:qonversion_flutter/src/internal/mapper.dart'; | ||
|
||
part 'user_property.g.dart'; | ||
|
||
@JsonSerializable(createToJson: false) | ||
class QUserProperty { | ||
@JsonKey(name: "key") | ||
final String key; | ||
|
||
@JsonKey(name: "value") | ||
final String value; | ||
|
||
final QUserPropertyKey definedKey; | ||
|
||
QUserProperty._(this.key, this.value, this.definedKey); | ||
|
||
factory QUserProperty(String key, String value) { | ||
final calculatedKey = QMapper.userPropertyKeyFromString(key); | ||
return QUserProperty._(key, value, calculatedKey); | ||
} | ||
|
||
factory QUserProperty.fromJson(Map<String, dynamic> json) => | ||
_$QUserPropertyFromJson(json); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
enum QUserPropertyKey { | ||
email, | ||
name, | ||
kochavaDeviceId, | ||
appsFlyerUserId, | ||
adjustAdId, | ||
customUserId, | ||
facebookAttribution, // Android only | ||
firebaseAppInstanceId, | ||
appSetId, // Android only | ||
advertisingId, // iOS only | ||
custom, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.