-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from ringpublishing/feature/client-type
Add client platform identifier RDLC
- Loading branch information
Showing
11 changed files
with
132 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
1.2.2 Release notes (2022-04-12) | ||
============================================================= | ||
|
||
Improvements to the 'RingPublishingTracking' module. | ||
|
||
### Changes | ||
|
||
* Added additional field to each request, 'RDLC' containing information that events come from native mobile app |
33 changes: 33 additions & 0 deletions
33
...rc/androidTest/java/com/ringpublishing/tracking/internal/decorator/ClientDecoratorTest.kt
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,33 @@ | ||
/* | ||
* Created by Grzegorz Małopolski on 4/12/22, 10:23 AM | ||
* Copyright © 2021 Ringier Axel Springer Tech. All rights reserved. | ||
* | ||
*/ | ||
|
||
package com.ringpublishing.tracking.internal.decorator | ||
|
||
import android.util.Base64 | ||
import com.google.gson.GsonBuilder | ||
import com.ringpublishing.tracking.data.Event | ||
import org.junit.Assert | ||
import org.junit.Test | ||
|
||
internal class ClientDecoratorTest | ||
{ | ||
|
||
@Test | ||
fun decorate_When_Correct_Client_Then_Decoded_Result() | ||
{ | ||
val gson = GsonBuilder().create() | ||
val clientDecorator = ClientDecorator(gson) | ||
|
||
val event = Event() | ||
clientDecorator.decorate(event) | ||
|
||
val result = event.parameters[EventParam.CLIENT_ID.text] as String? | ||
|
||
val decodedResult = String(Base64.decode(result, Base64.NO_WRAP)) | ||
|
||
Assert.assertTrue(decodedResult.contains("{\"client\":{\"type\":\"native_app\"}}")) | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
RingPublishingTracking/src/main/java/com/ringpublishing/tracking/internal/data/Client.kt
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,9 @@ | ||
/* | ||
* Created by Grzegorz Małopolski on 4/12/22, 9:55 AM | ||
* Copyright © 2021 Ringier Axel Springer Tech. All rights reserved. | ||
* | ||
*/ | ||
|
||
package com.ringpublishing.tracking.internal.data | ||
|
||
class Client(val client: ClientType) |
12 changes: 12 additions & 0 deletions
12
...lishingTracking/src/main/java/com/ringpublishing/tracking/internal/data/ClientPlatform.kt
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,12 @@ | ||
/* | ||
* Created by Grzegorz Małopolski on 4/12/22, 9:56 AM | ||
* Copyright © 2021 Ringier Axel Springer Tech. All rights reserved. | ||
* | ||
*/ | ||
|
||
package com.ringpublishing.tracking.internal.data | ||
|
||
enum class ClientPlatform | ||
{ | ||
native_app | ||
} |
9 changes: 9 additions & 0 deletions
9
RingPublishingTracking/src/main/java/com/ringpublishing/tracking/internal/data/ClientType.kt
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,9 @@ | ||
/* | ||
* Created by Grzegorz Małopolski on 4/12/22, 9:55 AM | ||
* Copyright © 2021 Ringier Axel Springer Tech. All rights reserved. | ||
* | ||
*/ | ||
|
||
package com.ringpublishing.tracking.internal.data | ||
|
||
class ClientType(val type: ClientPlatform) |
44 changes: 44 additions & 0 deletions
44
...gTracking/src/main/java/com/ringpublishing/tracking/internal/decorator/ClientDecorator.kt
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,44 @@ | ||
/* | ||
* Created by Grzegorz Małopolski on 10/6/21, 11:28 AM | ||
* Copyright © 2021 Ringier Axel Springer Tech. All rights reserved. | ||
* | ||
*/ | ||
|
||
package com.ringpublishing.tracking.internal.decorator | ||
|
||
import android.util.Base64 | ||
import com.google.gson.Gson | ||
import com.ringpublishing.tracking.data.Event | ||
import com.ringpublishing.tracking.internal.data.Client | ||
import com.ringpublishing.tracking.internal.data.ClientPlatform | ||
import com.ringpublishing.tracking.internal.data.ClientType | ||
import com.ringpublishing.tracking.internal.log.Logger | ||
import java.io.UnsupportedEncodingException | ||
|
||
internal class ClientDecorator(private val gson: Gson) : BaseDecorator() | ||
{ | ||
private val client = Client(ClientType(ClientPlatform.native_app)) | ||
|
||
override fun decorate(event: Event) | ||
{ | ||
val clientId = encodeClientId(client) | ||
clientId.let { event.add(EventParam.CLIENT_ID, it) } | ||
} | ||
|
||
private fun encodeClientId(client: Client): String? | ||
{ | ||
val jsonClient = gson.toJson(client) | ||
|
||
val data: ByteArray? | ||
|
||
try | ||
{ | ||
data = jsonClient.toByteArray(Charsets.UTF_8) | ||
} catch (e: UnsupportedEncodingException) | ||
{ | ||
Logger.warn("Parse jsonClient UnsupportedEncodingException $e") | ||
return null | ||
} | ||
return Base64.encodeToString(data, Base64.NO_WRAP) | ||
} | ||
} |
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
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