Skip to content

Commit

Permalink
Include additional metadata in enrichment payload (closes #16)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenFradet committed Jul 31, 2019
1 parent 52029b5 commit 8137859
Show file tree
Hide file tree
Showing 2 changed files with 327 additions and 266 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ object Payload {
implicit val payloadEncoder: Encoder[Payload] = Encoder.instance {
case p: RawPayload => deriveEncoder[RawPayload].apply(p)
case p: CollectorPayload => deriveEncoder[CollectorPayload].apply(p)
case p: PartiallyEnrichedEvent => deriveEncoder[PartiallyEnrichedEvent].apply(p)
case p: EnrichmentPayload => deriveEncoder[EnrichmentPayload].apply(p)
}
implicit val payloadDecoder: Decoder[Payload] = List[Decoder[Payload]](
deriveDecoder[RawPayload].widen,
deriveDecoder[CollectorPayload].widen,
deriveDecoder[PartiallyEnrichedEvent].widen
deriveDecoder[EnrichmentPayload].widen
).reduceLeft(_ or _)

final case class RawPayload(line: String) extends Payload
Expand All @@ -49,6 +49,31 @@ object Payload {
networkUserId: Option[String] // User ID generated by collector-set third-party cookie
) extends Payload

final case class EnrichmentPayload(
partiallyEnrichedEvent: PartiallyEnrichedEvent,
rawEvent: RawEvent
) extends Payload

final case class RawEvent(
vendor: String,
version: String,
parameters: Map[String, String],
contentType: Option[String],
loaderName: String,
encoding: String,
hostname: Option[String],
timestamp: Option[String],
ipAddress: Option[String],
useragent: Option[String],
refererUri: Option[String],
headers: List[String],
userId: Option[String]
)
object RawEvent {
implicit val rawEventEncoder: Encoder[RawEvent] = deriveEncoder
implicit val rawEventDecoder: Decoder[RawEvent] = deriveDecoder
}

final case class PartiallyEnrichedEvent(
app_id: Option[String],
platform: Option[String],
Expand Down Expand Up @@ -181,7 +206,11 @@ object Payload {
event_version: Option[String],
event_fingerprint: Option[String],
true_tstamp: Option[String]
) extends Payload
)
object PartiallyEnrichedEvent {
implicit val partiallyEnrichedEventEncoder: Encoder[PartiallyEnrichedEvent] = deriveEncoder
implicit val partiallyEnrichedEventDecoder: Decoder[PartiallyEnrichedEvent] = deriveDecoder
}
}

final case class NVP(name: String, value: Option[String])
Expand Down
Loading

0 comments on commit 8137859

Please sign in to comment.