SimplyticsEvent class abstract
An interface that allows you to create type safe analytics events.
For example, you can create an event to send a game score:
class PostScoreEvent extends SimplyticsEvent {
final int score;
final int level;
final String? character;
PostScoreEvent({required this.score, this.level = 1, this.character});
@override
SimplyticsEventData getEventData(SimplyticsAnalyticsInterface service) => SimplyticsEventData(
name: 'post_score',
parameters: {
'score': score,
'level': level,
'character': character,
},
);
}
...and then use it in your code:
Simplytics.analytics.log(PostScoreEvent(score: 7));
It is possible to send different events for different analytics services
with a different set of parameters by checking the type of the service
parameter:
@override
SimplyticsEventData getEventData(SimplyticsAnalyticsInterface service) {
if (service is SimplyticsFirebaseAnalyticsService) {
return SimplyticsEventData(
name: 'post_score',
parameters: {
'score': score,
'level': level,
'character': character,
},
);
} else {
return SimplyticsEventData(
name: 'game_score',
parameters: {
'scoreValue': score,
'gameLevel': level,
'characterName': character,
},
);
}
);
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getEventData(
SimplyticsAnalyticsInterface service) → SimplyticsEventData - Return the description of the event to send to the analytics service.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited