-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.0.0 #83
Closed
Closed
1.0.0 #83
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
84fb81d
Make parsing errors type-safe (closes #75)
aldemirenes 74476ad
Add function for creating empty event (closes #81)
aldemirenes fb7c576
Remove Vagrant setup (closes #84)
aldemirenes c9b6fac
Extend copyright notice to 2019 (closes #85)
aldemirenes 8238fd2
Deprecate run manifest (closes #86)
aldemirenes f5a2cf7
Integrate MiMa (closes #87)
aldemirenes fe43aaf
Prepared for release
aldemirenes fe42bf8
M1
aldemirenes 0378a73
Integrate scoverage
aldemirenes 752f4a4
Integrate sbt-gh-pages to create GH Pages from Scaladoc
aldemirenes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,17 @@ 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.makeSite | ||
import com.typesafe.sbt.SbtGit.GitKeys.{gitBranch, gitRemoteRepo} | ||
|
||
object BuildSettings { | ||
|
||
// Basic settings for our app | ||
|
@@ -59,4 +70,37 @@ 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( | ||
coverageEnabled := true, | ||
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"), | ||
excludeFilter in ghpagesCleanSite := "index.html" | ||
) | ||
} |
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,51 @@ | ||
#!/bin/bash | ||
|
||
# This script is used for initializing the gh-pages branch | ||
|
||
PROJECT_NAME=snowplow-scala-analytics-sdk | ||
[email protected]:snowplow/snowplow-scala-analytics-sdk.git | ||
|
||
# Using a fresh, temporary clone is safest for this procedure | ||
pushd /tmp | ||
git clone $PROJECT_REPO | ||
cd $PROJECT_NAME | ||
|
||
# Create branch with no history or content | ||
git checkout --orphan gh-pages | ||
git rm -rf . | ||
|
||
# Create index.html file in order to redirect main page | ||
# to /latest/api | ||
cat > index.html <<- EOM | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Project Documentation</title> | ||
<script language="JavaScript"> | ||
<!-- | ||
function doRedirect() | ||
{ | ||
window.location.replace("latest/api"); | ||
} | ||
|
||
doRedirect(); | ||
//--> | ||
</script> | ||
</head> | ||
<body> | ||
<a href="latest/api">Go to the project documentation | ||
</a> | ||
</body> | ||
</html> | ||
EOM | ||
|
||
git add index.html | ||
|
||
# Establish the branch existence | ||
git commit --allow-empty -m "Initialize gh-pages branch" | ||
git push origin gh-pages | ||
|
||
# Return to original working copy clone, we're finished with the /tmp one | ||
popd | ||
rm -rf /tmp/$PROJECT_NAME |
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
156 changes: 156 additions & 0 deletions
156
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,156 @@ | ||
/* | ||
* 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 | ||
|
||
/** | ||
* Represents error during parsing TSV event | ||
*/ | ||
sealed trait ParsingError | ||
|
||
object ParsingError { | ||
|
||
/** | ||
* Represents error which given line is not a TSV | ||
*/ | ||
final case object NonTSVPayload extends ParsingError | ||
|
||
/** | ||
* Represents error which number of given columns is not equal | ||
* to number of expected columns | ||
* @param columnCount mismatched column count in the event | ||
*/ | ||
final case class ColumnNumberMismatch(columnCount: Int) extends ParsingError | ||
|
||
/** | ||
* Represents error which encountered while decoding values in row | ||
* @param errors Infos of errors which encountered during decoding | ||
*/ | ||
final case class RowDecodingError(errors: NonEmptyList[RowDecodingErrorInfo]) extends ParsingError | ||
|
||
/** | ||
* Gives info about the reasons of the errors during decoding value in row | ||
*/ | ||
sealed trait RowDecodingErrorInfo | ||
|
||
object RowDecodingErrorInfo { | ||
/** | ||
* Represents cases where value in a field is not valid | ||
* e.g invalid timestamp, invalid UUID | ||
* @param key key of field | ||
* @param value value of field | ||
* @param message error message | ||
*/ | ||
final case class InvalidValue(key: Key, value: String, message: String) extends RowDecodingErrorInfo | ||
|
||
/** | ||
* Represents cases which getting error is not expected while decoding row | ||
* For example, while parsing the list of tuples to HList in the | ||
* RowDecoder, getting more or less values than expected is impossible | ||
* due to type check. Therefore 'UnexpectedRowDecodingError' is returned for | ||
* these cases. These errors can be ignored since they are not possible to get | ||
* @param error error message | ||
*/ | ||
final case class UnexpectedRowDecodingError(error: 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 UnexpectedRowDecodingError(error: String) => | ||
Json.obj( | ||
"type" := "UnexpectedRowDecodingError", | ||
"error" := error | ||
) | ||
} | ||
|
||
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 "UnexpectedRowDecodingError" => | ||
cursor | ||
.downField("error") | ||
.as[String] | ||
.map(UnexpectedRowDecodingError) | ||
} | ||
} yield result | ||
} | ||
|
||
implicit val analyticsSdkKeyCirceEncoder: Encoder[Key] = | ||
Encoder.instance(_.toString.stripPrefix("'").asJson) | ||
|
||
implicit val analyticsSdkKeyCirceDecoder: Decoder[Key] = | ||
Decoder.instance(_.as[String].map(Symbol(_))) | ||
|
||
} | ||
|
||
implicit val analyticsSdkParsingErrorCirceEncoder: Encoder[ParsingError] = | ||
Encoder.instance { | ||
case NonTSVPayload => | ||
Json.obj("type" := "NonTSVPayload") | ||
case ColumnNumberMismatch(columnCount) => | ||
Json.obj( | ||
"type" := "ColumnNumberMismatch", | ||
"columnCount" := columnCount | ||
) | ||
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 "NonTSVPayload" => | ||
NonTSVPayload.asRight | ||
case "ColumnNumberMismatch" => | ||
cursor | ||
.downField("columnCount") | ||
.as[Int] | ||
.map(ColumnNumberMismatch) | ||
case "RowDecodingError" => | ||
cursor | ||
.downField("errors") | ||
.as[NonEmptyList[RowDecodingErrorInfo]] | ||
.map(RowDecodingError) | ||
case _ => | ||
DecodingFailure( | ||
s"Error type $error cannot be recognized as Analytics SDK Parsing Error", | ||
cursor.history).asLeft | ||
} | ||
} yield result | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codecs are missing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will add them. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
License header.