-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
806 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key" | ||
ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv" | ||
ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR} | ||
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR} | ||
|
||
git config --global user.name "$USER" | ||
git config --global user.email "$TRAVIS_BUILD_NUMBER@$TRAVIS_COMMIT" | ||
|
||
openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in project/travis-deploy-key.enc -out project/travis-deploy-key -d | ||
chmod 600 project/travis-deploy-key | ||
|
||
eval "$(ssh-agent -s)" | ||
ssh-add project/travis-deploy-key | ||
|
||
sbt ghpagesPushSite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2016-2018 Snowplow Analytics Ltd. All rights reserved. | ||
* 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. | ||
|
@@ -19,6 +19,19 @@ import Keys._ | |
import bintray.BintrayPlugin._ | ||
import bintray.BintrayKeys._ | ||
|
||
// Mima plugin | ||
import com.typesafe.tools.mima.plugin.MimaKeys._ | ||
import com.typesafe.tools.mima.plugin.MimaPlugin | ||
|
||
// Scoverage plugin | ||
import scoverage.ScoverageKeys._ | ||
|
||
import com.typesafe.sbt.sbtghpages.GhpagesPlugin.autoImport._ | ||
import com.typesafe.sbt.site.SitePlugin.autoImport._ | ||
import com.typesafe.sbt.site.SiteScaladocPlugin.autoImport._ | ||
import com.typesafe.sbt.SbtGit.GitKeys.{gitBranch, gitRemoteRepo} | ||
import com.typesafe.sbt.site.preprocess.PreprocessPlugin.autoImport._ | ||
|
||
object BuildSettings { | ||
|
||
// Basic settings for our app | ||
|
@@ -59,4 +72,40 @@ object BuildSettings { | |
</developer> | ||
</developers>) | ||
) | ||
|
||
// If new version introduces breaking changes, | ||
// clear-out mimaBinaryIssueFilters and mimaPreviousVersions. | ||
// Otherwise, add previous version to set without | ||
// removing other versions. | ||
val mimaPreviousVersions = Set() | ||
|
||
val mimaSettings = MimaPlugin.mimaDefaultSettings ++ Seq( | ||
mimaPreviousArtifacts := mimaPreviousVersions.map { organization.value %% name.value % _ }, | ||
mimaBinaryIssueFilters ++= Seq(), | ||
test in Test := { | ||
mimaReportBinaryIssues.value | ||
(test in Test).value | ||
} | ||
) | ||
|
||
val scoverageSettings = Seq( | ||
coverageMinimum := 50, | ||
coverageFailOnMinimum := true, | ||
coverageHighlighting := false, | ||
(test in Test) := { | ||
(coverageReport dependsOn (test in Test)).value | ||
} | ||
) | ||
|
||
val ghPagesSettings = Seq( | ||
ghpagesPushSite := (ghpagesPushSite dependsOn makeSite).value, | ||
ghpagesNoJekyll := false, | ||
gitRemoteRepo := "[email protected]:snowplow/snowplow-scala-analytics-sdk.git", | ||
gitBranch := Some("gh-pages"), | ||
siteSubdirName in SiteScaladoc := s"${version.value}", | ||
preprocessVars in Preprocess := Map("VERSION" -> version.value), | ||
excludeFilter in ghpagesCleanSite := new FileFilter { | ||
def accept(f: File) = true | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.3") | ||
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.5.0") | ||
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0") | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.0") | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0") | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 149 additions & 0 deletions
149
src/main/scala/com.snowplowanalytics.snowplow.analytics.scalasdk/ParsingError.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
/* | ||
* 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 cats.data.NonEmptyList | ||
import cats.syntax.either._ | ||
import io.circe._ | ||
import io.circe.syntax._ | ||
import com.snowplowanalytics.snowplow.analytics.scalasdk.decode.Key | ||
import com.snowplowanalytics.snowplow.analytics.scalasdk.decode.Key._ | ||
|
||
/** | ||
* Represents an error raised when parsing a TSV line. | ||
*/ | ||
sealed trait ParsingError extends Product with Serializable | ||
|
||
object ParsingError { | ||
|
||
/** | ||
* Represents an error indicating a non-TSV line. | ||
*/ | ||
final case object NotTSV extends ParsingError | ||
|
||
/** | ||
* Represents an error indicating the number of actual fields is not equal | ||
* to the number of expected fields. | ||
* @param fieldCount The number of fields in the TSV line. | ||
*/ | ||
final case class FieldNumberMismatch(fieldCount: Int) extends ParsingError | ||
|
||
/** | ||
* Represents an error raised when trying to decode the values in a line. | ||
* @param errors A non-empty list of errors encountered when trying to decode the values. | ||
*/ | ||
final case class RowDecodingError(errors: NonEmptyList[RowDecodingErrorInfo]) extends ParsingError | ||
|
||
/** | ||
* Contains information about the reasons behind errors raised when trying to decode the values in a line. | ||
*/ | ||
sealed trait RowDecodingErrorInfo extends Product with Serializable | ||
|
||
object RowDecodingErrorInfo { | ||
/** | ||
* Represents cases where tha value in a field is not valid, | ||
* e.g. an invalid timestamp, an invalid UUID, etc. | ||
* @param key The name of the field. | ||
* @param value The value of field. | ||
* @param message The error message. | ||
*/ | ||
final case class InvalidValue(key: Key, value: String, message: String) extends RowDecodingErrorInfo | ||
|
||
/** | ||
* Represents unhandled errors raised when trying to decode a line. | ||
* For example, while parsing a list of tuples to [[HList]] in | ||
* [[RowDecoder]], type checking should make it impossible to get more or less values | ||
* than expected. | ||
* @param message The error message. | ||
*/ | ||
final case class UnhandledRowDecodingError(message: String) extends RowDecodingErrorInfo | ||
|
||
implicit val analyticsSdkRowDecodingErrorInfoCirceEncoder: Encoder[RowDecodingErrorInfo] = | ||
Encoder.instance { | ||
case InvalidValue(key, value, message) => | ||
Json.obj( | ||
"type" := "InvalidValue", | ||
"key" := key, | ||
"value" := value, | ||
"message" := message | ||
) | ||
case UnhandledRowDecodingError(message: String) => | ||
Json.obj( | ||
"type" := "UnhandledRowDecodingError", | ||
"message" := message | ||
) | ||
} | ||
|
||
implicit val analyticsSdkRowDecodingErrorInfoCirceDecoder: Decoder[RowDecodingErrorInfo] = | ||
Decoder.instance { cursor => | ||
for { | ||
errorType <- cursor.downField("type").as[String] | ||
result <- errorType match { | ||
case "InvalidValue" => | ||
for { | ||
key <- cursor.downField("key").as[Key] | ||
value <- cursor.downField("value").as[String] | ||
message <- cursor.downField("message").as[String] | ||
} yield InvalidValue(key, value, message) | ||
|
||
case "UnhandledRowDecodingError" => | ||
cursor | ||
.downField("message") | ||
.as[String] | ||
.map(UnhandledRowDecodingError) | ||
} | ||
} yield result | ||
} | ||
} | ||
|
||
implicit val analyticsSdkParsingErrorCirceEncoder: Encoder[ParsingError] = | ||
Encoder.instance { | ||
case NotTSV => | ||
Json.obj("type" := "NotTSV") | ||
case FieldNumberMismatch(fieldCount) => | ||
Json.obj( | ||
"type" := "FieldNumberMismatch", | ||
"fieldCount" := fieldCount | ||
) | ||
case RowDecodingError(errors) => | ||
Json.obj( | ||
"type" := "RowDecodingError", | ||
"errors" := errors.asJson | ||
) | ||
} | ||
|
||
implicit val analyticsSdkParsingErrorCirceDecoder: Decoder[ParsingError] = | ||
Decoder.instance { cursor => | ||
for { | ||
error <- cursor.downField("type").as[String] | ||
result <- error match { | ||
case "NotTSV" => | ||
NotTSV.asRight | ||
case "FieldNumberMismatch" => | ||
cursor | ||
.downField("fieldCount") | ||
.as[Int] | ||
.map(FieldNumberMismatch) | ||
case "RowDecodingError" => | ||
cursor | ||
.downField("errors") | ||
.as[NonEmptyList[RowDecodingErrorInfo]] | ||
.map(RowDecodingError) | ||
case _ => | ||
DecodingFailure( | ||
s"Error type $error is not an Analytics SDK Parsing Error.", | ||
cursor.history).asLeft | ||
} | ||
} yield result | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.