Skip to content

Commit

Permalink
lib: renamed trackEvent parameter data to attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-roland committed Jul 25, 2024
1 parent 25d5ffd commit 6eb6e5e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions example/lib/batch_store/event_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import 'data/model/article.dart';

class EventManager {
static void trackArticleVisit(Article article) {
BatchProfile.instance.trackEvent(name: "ARTICLE_VIEW", data: BatchEventAttributes().putString("\$label", article.name));
BatchProfile.instance.trackEvent(name: "ARTICLE_VIEW", attributes: BatchEventAttributes().putString("\$label", article.name));
}

static void trackAddArticleToCart(Article article) {
BatchProfile.instance.trackEvent(name: "ADD_TO_CART", data: BatchEventAttributes().putString("\$label", article.name));
BatchProfile.instance.trackEvent(name: "ADD_TO_CART", attributes: BatchEventAttributes().putString("\$label", article.name));
}

static void trackCheckout(double amount) {
BatchProfile.instance.trackEvent(name: "CHECKOUT", data: BatchEventAttributes().putDouble("amount", amount));
BatchProfile.instance.trackEvent(name: "CHECKOUT", attributes: BatchEventAttributes().putDouble("amount", amount));
}
}
2 changes: 1 addition & 1 deletion example/lib/plugin_test_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class _PluginTestMenuState extends State<PluginTestMenu> {
.putStringList('metadata', ['first_purchase', 'apple_pay'])
.putString('\$label', 'legacy_label')
.putStringList('\$tags', ['first_purchase', 'in_promo']);
BatchProfile.instance.trackEvent(name: "test_event", data: eventData);
BatchProfile.instance.trackEvent(name: "test_event", attributes: eventData);
BatchProfile.instance.trackLocation(latitude: 0.4, longitude: 0.523232);
}

Expand Down
8 changes: 4 additions & 4 deletions lib/batch_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ class BatchProfile {
/// The event name is required and must not be empty. It should be composed of letters,
/// numbers or underscores (\[a-z0-9_\]) and can’t be longer than 30 characters.
///
/// The event attributes are an optional object holding attributes related
/// The event [attributes] are an optional object holding attributes related
/// to the event. See [BatchEventAttributes]'s documentation for more info.
void trackEvent({required String name, BatchEventAttributes? data}) {
void trackEvent({required String name, BatchEventAttributes? attributes}) {
Map eventArgs = {"name": name};
if (data != null) {
eventArgs["event_data"] = data.internalGetBridgeRepresentation();
if (attributes != null) {
eventArgs["event_data"] = attributes.internalGetBridgeRepresentation();
}
_channel.invokeMethod("profile.track.event", eventArgs).catchError((error) => {
BatchLogger.public("Tracking event '"+ name +"' failed with error: " + error.toString())
Expand Down

0 comments on commit 6eb6e5e

Please sign in to comment.