toJson method

Map<String, Object?> toJson()

Encodes to the SDK→ingest wire map. Non-null fields only; tier/source are never emitted (not envelope fields).

Implementation

Map<String, Object?> toJson() => <String, Object?>{
      'schemaVersion': schemaVersion,
      'eventId': eventId,
      'name': name,
      if (surface != null) 'surface': surface,
      if (surfaceId != null) 'surfaceId': surfaceId,
      if (surfaceVersion != null) 'surfaceVersion': surfaceVersion,
      if (placementId != null) 'placementId': placementId,
      'occurredAt': occurredAt.toUtc().toIso8601String(),
      if (anonymousId != null) 'anonymousId': anonymousId,
      if (sessionId != null) 'sessionId': sessionId,
      if (surfaceSessionId != null) 'surfaceSessionId': surfaceSessionId,
      if (userId != null) 'userId': userId,
      if (appContext != null) 'appContext': appContext!.toJson(),
      if (productId != null) 'productId': productId,
      if (offerId != null) 'offerId': offerId,
      if (properties.isNotEmpty) 'properties': properties,
    };