AnalyticsEvent constructor

AnalyticsEvent({
  1. required String eventId,
  2. required String name,
  3. required DateTime occurredAt,
  4. int schemaVersion = 1,
  5. String? surface = AnalyticsSurface.paywall,
  6. String? surfaceId,
  7. String? surfaceVersion,
  8. String? placementId,
  9. String? anonymousId,
  10. String? sessionId,
  11. String? surfaceSessionId,
  12. String? userId,
  13. AnalyticsAppContext? appContext,
  14. String? productId,
  15. String? offerId,
  16. Map<String, Object?> properties = const <String, Object?>{},
})

Creates an event envelope.

surface defaults to AnalyticsSurface.paywall; pass null for an app-wide / server event.

Implementation

AnalyticsEvent({
  required this.eventId,
  required this.name,
  required this.occurredAt,
  this.schemaVersion = 1,
  this.surface = AnalyticsSurface.paywall,
  this.surfaceId,
  this.surfaceVersion,
  this.placementId,
  this.anonymousId,
  this.sessionId,
  this.surfaceSessionId,
  this.userId,
  this.appContext,
  this.productId,
  this.offerId,
  Map<String, Object?> properties = const <String, Object?>{},
  // Deep defensive copy: the envelope is `@immutable`, so a caller can
  // neither mutate `properties` (or any nested map/list) after construction
  // nor leak in a later mutation of the source structure.
}) : properties = _deepUnmodifiableMap(scrubReservedKeys(properties));