Skip to content

Application Backgrounded events send properties as null, but properties should always be an object #60

Closed
@niallzato

Description

@niallzato

The automatically collected Application Backgrounded event should send an empty properties as an empty object, and not as null.

 "event": "Application Backgrounded",
  "integrations": {},
  "messageId": "d7ee8923-280f-4224-86b7-117ae34771c3",
  "originalTimestamp": "2024-02-22T03:34:17.882927",
  "properties": null,
  "receivedAt": "2024-02-22T08:34:24.593Z",
  "sentAt": "2024-02-22T03:34:23.476Z",
  "timestamp": "2024-02-22T08:34:18.999Z",
  "type": "track",

The Segment spec specifies this should be an object: https://segment.com/docs/connections/spec/track/

As an interim workaround, a plugin can be used to change the format:

class PropertyFixPlugin extends Plugin {
  PropertyFixPlugin() : super(PluginType.enrichment);

  @override
  void configure(Analytics analytics) {
    super.configure(analytics);

    if (kIsWeb) {
      return;
    }
  }

  @override
  Future<RawEvent?> execute(RawEvent event) async {
    var local = event.type.toString();
    if (local == 'track') {
      var track = event as TrackEvent;
      final properties = track.properties;
      
      if (properties == null) {
        track.properties = {};
      }
    }

    return event;
  }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions