Skip to content

Commit

Permalink
Remove deprecated EventTransformer API (close #68)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzats committed Feb 13, 2019
1 parent 3b5e1a1 commit c6269dc
Show file tree
Hide file tree
Showing 14 changed files with 549 additions and 2,937 deletions.
5 changes: 1 addition & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ lazy val root = project.in(file("."))
Dependencies.circeParser,
Dependencies.circeGeneric,
Dependencies.circeJava,
Dependencies.json4sJackson,
Dependencies.s3,
Dependencies.dynamodb,
// Scala (test only)
Dependencies.scalaCheck,
Dependencies.specs2,
Dependencies.specs2Scalacheck
Dependencies.specs2
)
)
5 changes: 0 additions & 5 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,17 @@ object Dependencies {
val cats = "1.6.0"
val circe = "0.11.1"
val aws = "1.11.490"
val json4s = "3.2.11"
// Scala (test only)
val specs2 = "4.4.1"
val scalaCheck = "1.14.0"
}

val igluCore = "com.snowplowanalytics" %% "iglu-core-circe" % V.igluCore
val cats = "org.typelevel" %% "cats-core" % V.cats
val circeParser = "io.circe" %% "circe-parser" % V.circe
val circeGeneric = "io.circe" %% "circe-generic" % V.circe
val circeJava = "io.circe" %% "circe-java8" % V.circe
val json4sJackson = "org.json4s" %% "json4s-jackson" % V.json4s
val s3 = "com.amazonaws" % "aws-java-sdk-s3" % V.aws
val dynamodb = "com.amazonaws" % "aws-java-sdk-dynamodb" % V.aws
// Scala (test only)
val specs2 = "org.specs2" %% "specs2-core" % V.specs2 % "test"
val specs2Scalacheck = "org.specs2" %% "specs2-scalacheck" % V.specs2 % "test"
val scalaCheck = "org.scalacheck" %% "scalacheck" % V.scalaCheck % "test"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2016-2019 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.analytics.scalasdk

import com.snowplowanalytics.iglu.core.SchemaKey

/**
* Common data types for enriched event
*/
object Data {

/**
* The type (contexts/derived_contexts/unstruct_event) and Iglu URI of a shredded type
*/
case class ShreddedType(shredProperty: ShredProperty, schemaKey: SchemaKey)

/**
* Known contexts types of enriched event
*/
sealed trait ContextsType {
def field: String
}

case object DerivedContexts extends ContextsType {
def field = "derived_contexts"
}

case object CustomContexts extends ContextsType {
def field = "contexts"
}

/**
* Field types of enriched event that can be shredded (self-describing JSONs)
*/
sealed trait ShredProperty {
/**
* Canonical field name
*/
def name: String

/**
* Result output prefix
*/
def prefix: String
}

case class Contexts(contextType: ContextsType) extends ShredProperty {
def name = contextType.field
def prefix = "contexts_"
}

case object UnstructEvent extends ShredProperty {
def name = "unstruct_event"
def prefix = name + "_"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import com.snowplowanalytics.iglu.core.SelfDescribingData
import com.snowplowanalytics.iglu.core.circe.instances._

// This library
import com.snowplowanalytics.snowplow.analytics.scalasdk.json.Data
import com.snowplowanalytics.snowplow.analytics.scalasdk.decode.{Parser, DecodeResult}
import com.snowplowanalytics.snowplow.analytics.scalasdk.SnowplowEvent.{Contexts, UnstructEvent}
import com.snowplowanalytics.snowplow.analytics.scalasdk.SnowplowEvent._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ import io.circe.{Encoder, Json, JsonObject}
import com.snowplowanalytics.iglu.core.circe.CirceIgluCodecs._
import com.snowplowanalytics.iglu.core.{SchemaKey, SelfDescribingData}

// This library
import com.snowplowanalytics.snowplow.analytics.scalasdk.json.Data
import com.snowplowanalytics.snowplow.analytics.scalasdk.json.Data.ShredProperty

object SnowplowEvent {

/**
Expand Down Expand Up @@ -81,7 +77,7 @@ object SnowplowEvent {
* @param model Iglu schema model
* @return the schema, transformed into an Elasticsearch-compatible column name
*/
def transformSchema(shredProperty: ShredProperty, vendor: String, name: String, model: Int): String = {
def transformSchema(shredProperty: Data.ShredProperty, vendor: String, name: String, model: Int): String = {
// Convert dots & dashes in schema vendor to underscore
val snakeCaseVendor = vendor.replaceAll("""[\.\-]""", "_").toLowerCase

Expand All @@ -91,5 +87,5 @@ object SnowplowEvent {
s"${shredProperty.prefix}${snakeCaseVendor}_${snakeCaseName}_$model"
}

def transformSchema(shredProperty: ShredProperty, schema: SchemaKey): String = transformSchema(shredProperty, schema.vendor, schema.name, schema.version.model)
def transformSchema(shredProperty: Data.ShredProperty, schema: SchemaKey): String = transformSchema(shredProperty, schema.vendor, schema.name, schema.version.model)
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit c6269dc

Please sign in to comment.