Skip to content

Commit e22c8e3

Browse files
authored
Release 0.4.0
2 parents a930a7f + d2344fb commit e22c8e3

File tree

14 files changed

+756
-721
lines changed

14 files changed

+756
-721
lines changed

CHANGELOG

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
Version 0.4.0 (2019-09-18)
2+
--------------------------
3+
Fix typo in user ID field name for mobile events (#57)
4+
Add option to configure Indicative's API URI via environment variable (#58)
5+
Exclude null values from being included in Indicative event payload (#63)
6+
Refactor unit tests to use mutable Specification (#59)
7+
Make testing for a user identifier a separate function that can be unit-tested (#62)
8+
Bump sbt to 1.3.0 (#64)
9+
Bump sbt-tpolecat to 0.1.8 (#65)
10+
Bump amazon-kinesis-client to 1.11.2 (#66)
11+
Bump aws-lambda-java-events to 2.2.7 (#67)
12+
Bump cats-effect to 1.4.0 (#68)
13+
Bump version to 0.4.0 (#75)
14+
115
Version 0.3.0 (2019-05-13)
216
--------------------------
317
Limit fields and contexts (#23)

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![License][license-image]][license]
55

66
Snowplow Indicative Relay is an AWS Lambda function that reads Snowplow enriched events
7-
from a Kinesis Stream and transfers them to Indicative. It processes events in batches, which
7+
from a Kinesis Stream and transfers them to Indicative. It processes events in batches, whose
88
size depends on your AWS Lambda configuration.
99

1010
Detailed setup instructions, as well as more technical information, are provided on the [wiki page][wiki-page].
@@ -20,7 +20,7 @@ Unless required by applicable law or agreed to in writing, software distributed
2020
[travis-image]: https://travis-ci.org/snowplow-incubator/snowplow-indicative-relay.svg?branch=master
2121
[travis]: https://travis-ci.org/snowplow-incubator/snowplow-indicative-relay
2222

23-
[release-image]: https://img.shields.io/badge/release-0.3.0-orange.svg?style=flat
23+
[release-image]: https://img.shields.io/badge/release-0.4.0-orange.svg?style=flat
2424
[release]: https://github.com/snowplow-incubator/snowplow-indicative-relay/releases
2525

2626
[license-image]: http://img.shields.io/badge/license-Apache--2-blue.svg?style=flat

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ lazy val root = project
1515
.settings(
1616
name := "indicative-relay",
1717
organization := "com.snowplowanalytics",
18-
version := "0.3.0",
18+
version := "0.4.0",
1919
description := "A relay transforming Snowplow enriched events into Indicative format",
2020
scalaVersion := "2.11.12",
2121
javacOptions := BuildSettings.javaCompilerOptions

project/Dependencies.scala

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ object Dependencies {
1616

1717
object V {
1818
val awsLambdaCore = "1.2.0"
19-
val awsLambdaEvents = "2.2.2"
20-
val kinesisClient = "1.9.1"
21-
val analyticsSdk = "0.3.0"
22-
val circe = "0.10.0"
23-
val catsEffect = "1.2.0"
24-
val scalaj = "2.4.1"
25-
val specs2 = "4.2.0"
19+
val awsLambdaEvents = "2.2.7"
20+
val kinesisClient = "1.11.2"
21+
val analyticsSdk = "0.3.2"
22+
val circe = "0.11.1"
23+
val catsEffect = "1.4.0"
24+
val scalaj = "2.4.2"
25+
val specs2 = "4.5.1"
2626
val scalacheckSchema = "0.1.0"
2727
}
2828

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version = 1.1.6
1+
sbt.version = 1.3.0

project/plugins.sbt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.15")
2-
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.7")
1+
addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.16")
2+
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
33
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
4-
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.5")
4+
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.8")

src/main/scala/com/snowplowanalytics/indicative/FieldsExtraction.scala

+4-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ object FieldsExtraction {
6565
json.asArray
6666
.map(vector => if (vector.isEmpty) accumulator else iterate(key, vector.head, accumulator))
6767
.orElse(json.asObject.map(obj => iterateObject(key, obj.toList, accumulator)))
68-
.getOrElse(accumulator.updated(key, json))
68+
.getOrElse(
69+
json.asNull
70+
.map(_ => accumulator)
71+
.getOrElse(accumulator.updated(key, json)))
6972

7073
iterate("", json, Map.empty)
7174
}

src/main/scala/com/snowplowanalytics/indicative/LambdaHandler.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import Transformer.TransformationError
2626
class LambdaHandler {
2727
import LambdaHandler._
2828

29-
val apiKey: String = getConfig[String]("INDICATIVE_API_KEY")(s => s)
29+
val indicativeUri: String = getConfig[String]("INDICATIVE_URI", Some(Relay.defaultIndicativeUri))(s => s)
30+
val apiKey: String = getConfig[String]("INDICATIVE_API_KEY")(s => s)
3031
val unusedEvents
3132
: List[String] = getConfig[List[String]]("UNUSED_EVENTS", Some(Filters.unusedEvents))(strToList(_)) // eg, `UNUSED_EVENTS=page_ping,app_heartbeat`
3233
val unusedAtomicFields: List[String] = getConfig[List[String]](
@@ -62,7 +63,7 @@ class LambdaHandler {
6263
}
6364

6465
val sendEvents = toSend
65-
.traverse(Relay.postEventBatch)
66+
.traverse(Relay.postEventBatch(indicativeUri))
6667

6768
(tooBigDebugging >>
6869
sendEvents

src/main/scala/com/snowplowanalytics/indicative/Relay.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@ import io.circe.Json
2121

2222
object Relay {
2323

24-
private val indicativeUri = "https://api.indicative.com/service/event"
24+
val defaultIndicativeUri = "https://api.indicative.com/service/event"
2525
private val relayHeaders = NonEmptyList.of(
2626
("Indicative-Client", "Snowplow-Relay-" + BuildInfo.version),
2727
("Content-Type", "application/json; charset=utf-8")
2828
)
2929

30-
def postSingleEvent(event: Json): IO[HttpResponse[String]] =
30+
def postSingleEvent(indicativeUri: String)(event: Json): IO[HttpResponse[String]] =
3131
IO {
3232
Http(indicativeUri)
3333
.postData(event.noSpaces)
3434
.headers(relayHeaders.head, relayHeaders.tail: _*)
3535
.asString
3636
}
3737

38-
def postEventBatch(batchEvent: Json)(
38+
def postEventBatch(indicativeUri: String)(batchEvent: Json)(
3939
implicit c: Clock[IO]
4040
): IO[(HttpResponse[String], Long)] =
4141
for {

src/main/scala/com/snowplowanalytics/indicative/Transformer.scala

+7-4
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ object Transformer {
7979
case _ => Some(eventName)
8080
}
8181

82-
val userId = extractField(flattenedEvent, "user_id")
83-
.leftFlatMap(_ => extractField(flattenedEvent, "client_session_user_id"))
84-
.leftFlatMap(_ => extractField(flattenedEvent, "domain_userid"))
85-
.toOption
82+
val userId = getUserId(flattenedEvent)
8683

8784
val eventTime = extractField(flattenedEvent, "derived_tstamp").flatMap(timestampToMillis)
8885

@@ -105,6 +102,12 @@ object Transformer {
105102
}
106103
}
107104

105+
def getUserId(flattenedEvent: Map[String, Json]): Option[String] =
106+
extractField(flattenedEvent, "user_id")
107+
.leftFlatMap(_ => extractField(flattenedEvent, "client_session_userId"))
108+
.leftFlatMap(_ => extractField(flattenedEvent, "domain_userid"))
109+
.toOption
110+
108111
private def constructIndicativeJson(eventName: String,
109112
uniqueId: String,
110113
properties: Map[String, Json],

0 commit comments

Comments
 (0)