diff --git a/README.md b/README.md index 055c37f..7f1e299 100644 --- a/README.md +++ b/README.md @@ -205,10 +205,11 @@ Aside from "output" configuration, all fields in the configuration file are opti "unstruct": 1 "pageView": 1 "pagePing": 1 + "unstructEventFrequencyDefault": 1 "unstructEventFrequencies": { - "changeForm": 1 - "funnelInteraction": 1 - "linkClick": 1 + "change_form": 10 + "funnel_interaction": 100 + "link_click": 1000 } } diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/Body.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/Body.scala index e1e1d32..d5244eb 100644 --- a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/Body.scala +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/Body.scala @@ -90,7 +90,7 @@ object Body { u <- User.genOpt event <- e match { case EventType.Struct => StructEvent.gen - case EventType.Unstruct => UnstructEventWrapper.gen(now, frequencies.unstructEventFrequencies) + case EventType.Unstruct => UnstructEventWrapper.gen(now, frequencies) case EventType.PageView => PageView.gen case EventType.PagePing => PagePing.gen case EventType.Transaction => TransactionEvent.gen diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/event/EventType.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/event/EventType.scala index fb38f9b..db2d932 100644 --- a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/event/EventType.scala +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/event/EventType.scala @@ -21,7 +21,8 @@ case class EventFrequencies( pagePing: Int, transaction: Int, transactionItem: Int, - unstructEventFrequencies: UnstructEventFrequencies + unstructEventFrequencyDefault: Int, + unstructEventFrequencies: Map[String, Int] ) sealed trait EventType { diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/event/UnstructEventWrapper.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/event/UnstructEventWrapper.scala index 7fcdbc6..b06e936 100644 --- a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/event/UnstructEventWrapper.scala +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/event/UnstructEventWrapper.scala @@ -12,7 +12,7 @@ */ package com.snowplowanalytics.snowplow.eventgen.protocol.event -import com.snowplowanalytics.snowplow.eventgen.protocol.unstructs.{ChangeForm, FunnelInteraction, LinkClick} +import com.snowplowanalytics.snowplow.eventgen.protocol.unstructs.AllUnstructs import com.snowplowanalytics.iglu.core.SelfDescribingData import com.snowplowanalytics.snowplow.analytics.scalasdk.SnowplowEvent import com.snowplowanalytics.snowplow.eventgen.primitives.base64Encode @@ -22,8 +22,6 @@ import org.apache.http.message.BasicNameValuePair import org.scalacheck.Gen import java.time.Instant -case class UnstructEventFrequencies(changeForm: Int, funnelInteraction: Int, linkClick: Int) - final case class UnstructEventWrapper( event: SelfDescribingData[Json], b64: Boolean @@ -38,12 +36,17 @@ final case class UnstructEventWrapper( } object UnstructEventWrapper { - def gen(now: Instant, frequencies: UnstructEventFrequencies): Gen[UnstructEventWrapper] = - Gen - .frequency( - frequencies.linkClick -> LinkClick.gen(now), - frequencies.changeForm -> ChangeForm.gen(now), - frequencies.funnelInteraction -> FunnelInteraction.gen(now) - ) - .map(l => UnstructEventWrapper(l, b64 = true)) + + def gen(now: Instant, config: EventFrequencies): Gen[UnstructEventWrapper] = { + val freqToUnstruct = AllUnstructs.all.map { unstruct => + val frequency = + config + .unstructEventFrequencies + .getOrElse(unstruct.schemaKey.name, default = config.unstructEventFrequencyDefault) + + frequency -> unstruct.gen(now) + } + Gen.frequency(freqToUnstruct: _*).map(l => UnstructEventWrapper(l, b64 = true)) + } + } diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdBreakEndEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdBreakEndEvent.scala new file mode 100644 index 0000000..bea3a0d --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdBreakEndEvent.scala @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object AdBreakEndEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "ad_break_end_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map.empty + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdBreakStartEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdBreakStartEvent.scala new file mode 100644 index 0000000..ab2b1cf --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdBreakStartEvent.scala @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object AdBreakStartEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "ad_break_start_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map.empty + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdClickEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdClickEvent.scala new file mode 100644 index 0000000..a74b804 --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdClickEvent.scala @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object AdClickEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "ad_click_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map.empty + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdCompleteEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdCompleteEvent.scala new file mode 100644 index 0000000..62bf5c8 --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdCompleteEvent.scala @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object AdCompleteEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "ad_complete_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map.empty + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdPauseEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdPauseEvent.scala new file mode 100644 index 0000000..6afed75 --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdPauseEvent.scala @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import com.snowplowanalytics.snowplow.eventgen.protocol.implicits._ +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object AdPauseEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "ad_pause_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map( + "percentProgress" -> Gen.chooseNum(0, 100).optionalOrNull + ) + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdQuartileEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdQuartileEvent.scala new file mode 100644 index 0000000..2c6c1ad --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdQuartileEvent.scala @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import com.snowplowanalytics.snowplow.eventgen.protocol.implicits._ +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object AdQuartileEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "ad_quartile_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map( + "percentProgress" -> Gen.chooseNum(0, 100).required + ) + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdResumeEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdResumeEvent.scala new file mode 100644 index 0000000..d700330 --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdResumeEvent.scala @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import com.snowplowanalytics.snowplow.eventgen.protocol.implicits._ +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object AdResumeEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "ad_resume_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map( + "percentProgress" -> Gen.chooseNum(0, 100).optionalOrNull + ) + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdSkipEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdSkipEvent.scala new file mode 100644 index 0000000..e3241f9 --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdSkipEvent.scala @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import com.snowplowanalytics.snowplow.eventgen.protocol.implicits._ +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object AdSkipEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "ad_skip_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map( + "percentProgress" -> Gen.chooseNum(0, 100).optionalOrNull + ) + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdStartEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdStartEvent.scala new file mode 100644 index 0000000..eb068f6 --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AdStartEvent.scala @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object AdStartEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "ad_start_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map.empty + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/Alert.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/Alert.scala new file mode 100644 index 0000000..0dfa98a --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/Alert.scala @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import com.snowplowanalytics.snowplow.eventgen.protocol.implicits._ +import com.snowplowanalytics.snowplow.eventgen.primitives._ +import org.scalacheck.Gen +import io.circe.{Json, JsonObject} +import io.circe.syntax.EncoderOps +import java.time.Instant + +object Alert extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.monitoring.loader", "alert", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map( + "appName" -> strGen(1, 64).required, + "appVersion" -> strGen(1, 64).required, + "message" -> strGen(1, 200).required, + "tags" -> tagsGen.required + ) + + private def tagsGen: Gen[Json] = { + val tupleGen = for { + k <- strGen(1, 20) + v <- strGen(1, 20) + } yield k -> v.asJson + Gen.listOfN(5, tupleGen).map { fields => + JsonObject.fromIterable(fields).asJson + } + } +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AllUnstructs.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AllUnstructs.scala new file mode 100644 index 0000000..a36fa83 --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/AllUnstructs.scala @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen + +object AllUnstructs { + + val all: List[SelfDescribingJsonGen] = + List( + AdBreakEndEvent, + AdBreakStartEvent, + AdClickEvent, + AdCompleteEvent, + AdPauseEvent, + AdQuartileEvent, + AdResumeEvent, + AdSkipEvent, + AdStartEvent, + Alert, + BufferStartEvent, + BufferEndEvent, + ButtonClick, + ChangeForm, + Conversion, + FullscreenChangeEvent, + FunnelInteraction, + LinkClick, + LoadSucceeded, + PauseEvent, + PercentProgressEvent, + PictureInPictureChangeEvent, + PlayEvent, + PlaybackRateChangeEvent, + SnowplowEcommerceAction, + SeekStartEvent, + SeekEndEvent, + Spamreport, + QualityChangeEvent, + VolumeChangeEvent + ) + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/BufferEndEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/BufferEndEvent.scala new file mode 100644 index 0000000..a58c14e --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/BufferEndEvent.scala @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object BufferEndEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "buffer_end_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map.empty + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/BufferStartEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/BufferStartEvent.scala new file mode 100644 index 0000000..1585f42 --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/BufferStartEvent.scala @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object BufferStartEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "buffer_start_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map.empty + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/ButtonClick.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/ButtonClick.scala new file mode 100644 index 0000000..d9e9f6b --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/ButtonClick.scala @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import com.snowplowanalytics.snowplow.eventgen.protocol.implicits._ +import com.snowplowanalytics.snowplow.eventgen.primitives._ +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object ButtonClick extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow", "button_click", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map( + "label" -> strGen(1, 100).required, + "id" -> strGen(1, 100).optionalOrNull, + "classes" -> Gen.listOfN(5, strGen(1, 10)).optionalOrNull, + "name" -> strGen(1, 100).optionalOrNull + ) + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/Conversion.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/Conversion.scala new file mode 100644 index 0000000..eddbe60 --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/Conversion.scala @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import com.snowplowanalytics.snowplow.eventgen.protocol.implicits._ +import com.snowplowanalytics.snowplow.eventgen.primitives._ +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object Conversion extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("io.snowplow.foundation", "conversion", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map( + "name" -> strGen(1, 255).optional, + "value" -> Gen.choose(0, 100000).optional + ) + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/FullscreenChangeEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/FullscreenChangeEvent.scala new file mode 100644 index 0000000..f29e742 --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/FullscreenChangeEvent.scala @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import com.snowplowanalytics.snowplow.eventgen.protocol.implicits._ +import com.snowplowanalytics.snowplow.eventgen.primitives._ +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object FullscreenChangeEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "fullscreen_change_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map( + "fullscreen" -> genBool.required + ) + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/LoadSucceeded.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/LoadSucceeded.scala new file mode 100644 index 0000000..e59dbc1 --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/LoadSucceeded.scala @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import com.snowplowanalytics.snowplow.eventgen.protocol.implicits._ +import com.snowplowanalytics.snowplow.eventgen.primitives._ +import org.scalacheck.Gen +import io.circe.{Json, JsonObject} +import io.circe.syntax.EncoderOps +import java.time.Instant + +object LoadSucceeded extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.monitoring.batch", "load_succeeded", "jsonschema", SchemaVer.Full(3, 0, 1)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map( + "shredding" -> shreddingGen(now).required, + "application" -> strGen(1, 128).required, + "attempt" -> Gen.chooseNum(1, 100).required, + "loadingStarted" -> genInstant(now).map(_.toString).required, + "loadingCompleted" -> genInstant(now).map(_.toString).required, + "recoveryTableNames" -> Gen.listOfN(5, strGen(1, 5)).optional, + "tags" -> tagsGen.required + ) + + private def tagsGen: Gen[Json] = { + val tupleGen = for { + k <- strGen(1, 20) + v <- strGen(1, 20) + } yield k -> v.asJson + Gen.listOfN(5, tupleGen).map { fields => + JsonObject.fromIterable(fields).asJson + } + } + + private def shreddingGen(now: Instant): Gen[Json] = + Map( + "base" -> Url.gen.map(_.toString).required, + "compression" -> Gen.oneOf("GZIP", "NONE").required, + "typesInfo" -> typesInfoGen.required, + "timestamps" -> timestampsGen(now).required, + "processor" -> processorGen.required + ).genObject + + private def processorGen: Gen[Json] = + Map( + "artifact" -> strGen(1, 64).required, + "version" -> strGen(1, 16).required + ).genObject + + private def timestampsGen(now: Instant): Gen[Json] = + Map( + "jobStarted" -> genInstant(now).required, + "jobCompleted" -> genInstant(now).required, + "min" -> genInstant(now).orNull, + "max" -> genInstant(now).orNull + ).genObject + + private def typesInfoGen: Gen[Json] = + Map( + "transformation" -> Gen.const("WIDEROW").required, + "fileFormat" -> Gen.oneOf("JSON", "PARQUET").required, + "types" -> Gen.listOfN(5, typeGen).required + ).genObject + + private def typeGen: Gen[Json] = + Map( + "schemaKey" -> strGen(1, 256).required, + "snowplowEntity" -> Gen.oneOf("SELF_DESCRIBING_EVENT", "CONTEXT").required + ).genObject + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/PauseEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/PauseEvent.scala new file mode 100644 index 0000000..5185520 --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/PauseEvent.scala @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object PauseEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "pause_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map.empty + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/PercentProgressEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/PercentProgressEvent.scala new file mode 100644 index 0000000..3b014dd --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/PercentProgressEvent.scala @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import com.snowplowanalytics.snowplow.eventgen.protocol.implicits._ +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object PercentProgressEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "percent_progress_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map( + "percentProgress" -> Gen.chooseNum(0, 100).optionalOrNull + ) + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/PictureInPictureChangeEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/PictureInPictureChangeEvent.scala new file mode 100644 index 0000000..41d7d74 --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/PictureInPictureChangeEvent.scala @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import com.snowplowanalytics.snowplow.eventgen.protocol.implicits._ +import com.snowplowanalytics.snowplow.eventgen.primitives._ +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object PictureInPictureChangeEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey( + "com.snowplowanalytics.snowplow.media", + "picture_in_picture_change_event", + "jsonschema", + SchemaVer.Full(1, 0, 0) + ) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map( + "pictureInPicture" -> genBool.required + ) + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/PlayEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/PlayEvent.scala new file mode 100644 index 0000000..c62e307 --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/PlayEvent.scala @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object PlayEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "play_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map.empty + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/PlaybackRateChangeEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/PlaybackRateChangeEvent.scala new file mode 100644 index 0000000..bc44def --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/PlaybackRateChangeEvent.scala @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import com.snowplowanalytics.snowplow.eventgen.protocol.implicits._ +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object PlaybackRateChangeEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey( + "com.snowplowanalytics.snowplow.media", + "playback_rate_change_event", + "jsonschema", + SchemaVer.Full(1, 0, 0) + ) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map( + "previousRate" -> Gen.chooseNum(0, 100).optionalOrNull, + "newRate" -> Gen.chooseNum(0, 100).required + ) + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/QualityChangeEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/QualityChangeEvent.scala new file mode 100644 index 0000000..493c80f --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/QualityChangeEvent.scala @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import com.snowplowanalytics.snowplow.eventgen.protocol.implicits._ +import com.snowplowanalytics.snowplow.eventgen.primitives._ +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object QualityChangeEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "quality_change_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map( + "previousQuality" -> strGen(1, 100).optionalOrNull, + "newQuality" -> strGen(1, 100).optionalOrNull, + "bitrate" -> Gen.chooseNum(0L, 9007199254740991L).optionalOrNull, + "framesPerSecond" -> Gen.chooseNum(0, 65535).optionalOrNull, + "automatic" -> genBool.optionalOrNull + ) + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/SeekEndEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/SeekEndEvent.scala new file mode 100644 index 0000000..00b3e19 --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/SeekEndEvent.scala @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object SeekEndEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "seek_end_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map.empty + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/SeekStartEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/SeekStartEvent.scala new file mode 100644 index 0000000..9f3bb68 --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/SeekStartEvent.scala @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object SeekStartEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "seek_start_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map.empty + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/SnowplowEcommerceAction.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/SnowplowEcommerceAction.scala new file mode 100644 index 0000000..581ef9b --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/SnowplowEcommerceAction.scala @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import com.snowplowanalytics.snowplow.eventgen.protocol.implicits._ +import com.snowplowanalytics.snowplow.eventgen.primitives._ +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object SnowplowEcommerceAction extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey( + "com.snowplowanalytics.snowplow.ecommerce", + "snowplow_ecommerce_action", + "jsonschema", + SchemaVer.Full(1, 0, 2) + ) + + def typeGen: Gen[String] = + Gen.oneOf( + "add_to_cart", + "remove_from_cart", + "product_view", + "list_click", + "list_view", + "promo_click", + "promo_view", + "checkout_step", + "transaction", + "refund", + "trns_error" + ) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map( + "type" -> typeGen.required, + "name" -> strGen(1, 128).optionalOrNull + ) +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/Spamreport.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/Spamreport.scala new file mode 100644 index 0000000..6f4f8cb --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/Spamreport.scala @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import com.snowplowanalytics.snowplow.eventgen.protocol.implicits._ +import com.snowplowanalytics.snowplow.eventgen.primitives._ +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object Spamreport extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.sendgrid", "spamreport", "jsonschema", SchemaVer.Full(3, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map( + "timestamp" -> genInstant(now).map(_.toString).optional, + "email" -> strGen(1, 320).optional, + "sg_event_id" -> strGen(22, 100).optional, + "smtp-id" -> strGen(1, 100).optional, + "category" -> Gen.listOfN(5, strGen(1, 5)).optional, + "asm_group_id" -> Gen.chooseNum(BigInt(0), BigInt("9223372036854776000")).optional, + "sg_message_id" -> strGen(1, 100).optional, + "marketing_campaign_id" -> Gen.chooseNum(1, Int.MaxValue).optional, + "marketing_campaign_name" -> strGen(1, 100).optional, + "marketing_campaign_version" -> strGen(1, 100).optional, + "marketing_campaign_split_id" -> Gen.chooseNum(1, Int.MaxValue).optional + ) + +} diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/VolumeChangeEvent.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/VolumeChangeEvent.scala new file mode 100644 index 0000000..c928210 --- /dev/null +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/eventgen/protocol/unstructs/VolumeChangeEvent.scala @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved. + * + * This program is licensed to you under the Apache License Version 2.0, + * and you may not use this file except in compliance with the Apache License Version 2.0. + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the Apache License Version 2.0 is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. + */ +package com.snowplowanalytics.snowplow.eventgen.protocol.unstructs + +import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} +import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen +import com.snowplowanalytics.snowplow.eventgen.protocol.implicits._ +import org.scalacheck.Gen +import io.circe.Json +import java.time.Instant + +object VolumeChangeEvent extends SelfDescribingJsonGen { + + override def schemaKey: SchemaKey = + SchemaKey("com.snowplowanalytics.snowplow.media", "volume_change_event", "jsonschema", SchemaVer.Full(1, 0, 0)) + + override def fieldGens(now: Instant): Map[String, Gen[Option[Json]]] = + Map( + "previousVolume" -> Gen.chooseNum(0, 100).optionalOrNull, + "newVolume" -> Gen.chooseNum(0, 100).required + ) + +} diff --git a/sinks/src/main/resources/application.conf b/sinks/src/main/resources/application.conf index 7bdf869..cecaca4 100644 --- a/sinks/src/main/resources/application.conf +++ b/sinks/src/main/resources/application.conf @@ -26,10 +26,8 @@ "pagePing": 1 "transaction": 1 "transactionItem": 1 + "unstructEventFrequencyDefault": 1 "unstructEventFrequencies": { - "changeForm": 1 - "funnelInteraction": 1 - "linkClick": 1 } } "contexts": { diff --git a/sinks/src/main/scala/com.snowplowanalytics.snowplow.eventgen/Config.scala b/sinks/src/main/scala/com.snowplowanalytics.snowplow.eventgen/Config.scala index 4b11ca9..1b513fd 100644 --- a/sinks/src/main/scala/com.snowplowanalytics.snowplow.eventgen/Config.scala +++ b/sinks/src/main/scala/com.snowplowanalytics.snowplow.eventgen/Config.scala @@ -24,7 +24,7 @@ import io.circe.config.parser import io.circe.generic.extras.Configuration import io.circe.generic.extras.semiauto._ -import com.snowplowanalytics.snowplow.eventgen.protocol.event.{EventFrequencies, UnstructEventFrequencies} +import com.snowplowanalytics.snowplow.eventgen.protocol.event.EventFrequencies import com.snowplowanalytics.snowplow.eventgen.protocol.Context import com.snowplowanalytics.snowplow.eventgen.tracker.HttpRequest.MethodFrequencies @@ -96,9 +96,6 @@ object Config { implicit val methodFrequenciesDecoder: Decoder[MethodFrequencies] = deriveConfiguredDecoder[MethodFrequencies] - implicit val unstructEventFrequenciesDecoder: Decoder[UnstructEventFrequencies] = - deriveConfiguredDecoder[UnstructEventFrequencies] - implicit val mapDecoder: Decoder[Map[String, String]] = Decoder.decodeMap[String, String] implicit val uriDecoder: Decoder[URI] = Decoder[String].emap { str => diff --git a/sinks/src/main/scala/com.snowplowanalytics.snowplow.eventgen/Main.scala b/sinks/src/main/scala/com.snowplowanalytics.snowplow.eventgen/Main.scala index e9d8d26..1b0fc2b 100644 --- a/sinks/src/main/scala/com.snowplowanalytics.snowplow.eventgen/Main.scala +++ b/sinks/src/main/scala/com.snowplowanalytics.snowplow.eventgen/Main.scala @@ -20,7 +20,7 @@ import com.snowplowanalytics.snowplow.analytics.scalasdk.Event import com.snowplowanalytics.snowplow.eventgen.enrich.SdkEvent import com.snowplowanalytics.snowplow.eventgen.tracker.HttpRequest import com.snowplowanalytics.snowplow.eventgen.protocol.contexts.AllContexts -import com.snowplowanalytics.snowplow.eventgen.protocol.unstructs._ +import com.snowplowanalytics.snowplow.eventgen.protocol.unstructs.AllUnstructs import com.snowplowanalytics.snowplow.eventgen.protocol.SelfDescribingJsonGen import software.amazon.awssdk.core.SdkBytes import software.amazon.awssdk.services.kinesis.KinesisAsyncClient @@ -38,11 +38,13 @@ object Main extends IOApp { def run(args: List[String]): IO[ExitCode] = Config.parse(args) match { case Right(Config.Cli(config)) => + val unstructCounts = printCounts(AllUnstructs.all) + val contextCounts = printCounts(AllContexts.all) sink[IO](config) >> IO.println(s"""Contexts: - |${printCounts(AllContexts.all)} + |$contextCounts |Unstruct Events: - |${printCounts(List(ChangeForm, FunnelInteraction, LinkClick))} + |$unstructCounts |""".stripMargin) .as(ExitCode.Success) case Left(error) =>