Skip to content

Commit d32b1af

Browse files
committed
Merge branch 'add-context-to-logevent-handler' into 'master'
Add optional context to logEvent request See merge request pace/mobile/android/pace-cloud-sdk!363
2 parents 7980e6c + 29b7807 commit d32b1af

File tree

6 files changed

+18
-9
lines changed

6 files changed

+18
-9
lines changed

docs/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This framework combines multipe functionalities provided by PACE i.e. authorizin
2323
+ [20.x.x -> 21.x.x](#from-20xx-to-21xx)
2424
+ [21.x.x -> 22.x.x](#from-21xx-to-22xx)
2525
+ [22.x.x -> 23.x.x](#from-22xx-to-23xx)
26+
+ [23.x.x -> 24.x.x](#from-23xx-to-24xx)
2627

2728
## Documentation
2829
The full documentation and instructions on how to integrate PACE Cloud SDK can be found [here](https://docs.pace.cloud/en/integrating/mobile-app)
@@ -182,6 +183,9 @@ The `GasStations` properties `paymentMethods`, `amenities`, `foods`, `loyaltyPro
182183
- If you use the `appDrawer` modifier in your custom `AppDrawer` UI, you need to move the `onClick` function to its content, e.g. to the `AppDrawerContent`.
183184
- You can use the newly introduced `AppDrawerColumn` as a wrapper around your content so that the swipe gestures are handled for you.
184185

186+
### From 23.x.x to 24.x.x
187+
- The `logEvent` SDK handler now includes an optional `context`. This context is to be used to provide a context in which the event is logged and must not be forwarded to the analytics backend.
188+
185189
## SDK API Docs
186190

187191
Here is a complete list of all our SDK API documentations:

library/src/main/java/cloud/pace/sdk/appkit/app/webview/AppWebViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ class AppWebViewModelImpl(
640640
LogEventResult(LogEventResult.Failure(LogEventResult.Failure.StatusCode.InternalServerError, LogEventError("An error occurred")))
641641

642642
) {
643-
appModel.logEvent(logEventRequest.key, logEventRequest.parameters ?: emptyMap())
643+
appModel.logEvent(logEventRequest.key, logEventRequest.parameters ?: emptyMap(), logEventRequest.context)
644644
LogEventResult(LogEventResult.Success())
645645
}
646646
}

library/src/main/java/cloud/pace/sdk/appkit/communication/AppCallback.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,9 @@ interface AppCallback {
132132
*
133133
* @param key The event key
134134
* @param parameters Optional parameters to be logged
135+
* @param context Optional context in which the event is logged. These must not be logged.
135136
*/
136-
fun logEvent(key: String, parameters: Map<String, Any>)
137+
fun logEvent(key: String, parameters: Map<String, Any>, context: Map<String, Any>?)
137138

138139
/**
139140
* Is called when the app requests a configuration.
@@ -232,7 +233,7 @@ abstract class AppCallbackImpl : AppCallback, CloudSDKKoinComponent {
232233
}
233234

234235
override fun setUserProperty(key: String, value: String, update: Boolean) {}
235-
override fun logEvent(key: String, parameters: Map<String, Any>) {}
236+
override fun logEvent(key: String, parameters: Map<String, Any>, context: Map<String, Any>?) {}
236237
override fun getConfig(key: String, config: (String?) -> Unit) {
237238
config(null)
238239
}

library/src/main/java/cloud/pace/sdk/appkit/communication/AppModel.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ interface AppModel {
6666
fun onFileDataReceived(fileData: ByteArray)
6767
fun onShareTextReceived(text: String, title: String)
6868
fun setUserProperty(key: String, value: String, update: Boolean)
69-
fun logEvent(key: String, parameters: Map<String, Any>)
69+
fun logEvent(key: String, parameters: Map<String, Any>, context: Map<String, Any>?)
7070
fun getConfig(key: String, config: (String?) -> Unit)
7171
fun isAppRedirectAllowed(app: String, isAllowed: (Boolean) -> Unit)
7272
fun isSignedIn(isSignedIn: (Boolean) -> Unit)
@@ -340,9 +340,9 @@ class AppModelImpl(
340340
}
341341
}
342342

343-
override fun logEvent(key: String, parameters: Map<String, Any>) {
343+
override fun logEvent(key: String, parameters: Map<String, Any>, context: Map<String, Any>?) {
344344
coroutineScope.launch {
345-
callback?.logEvent(key, parameters)
345+
callback?.logEvent(key, parameters, context)
346346
}
347347
}
348348

library/src/main/java/cloud/pace/sdk/appkit/communication/generated/model/request/LogEventRequest.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@ public data class LogEventRequest(
1414
/**
1515
* Dictionary of additional event parameters
1616
*/
17-
public val parameters: Map<String, Any>?
17+
public val parameters: Map<String, Any>?,
18+
/**
19+
* Provide additional context for the SDK which will not be logged
20+
*/
21+
public val context: Map<String, Any>?
1822
)

library/src/test/java/cloud/pace/sdk/appkit/AppWebViewModelTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,9 @@ class AppWebViewModelTest {
328328
val key = "foo"
329329
val parameters = mapOf("string" to "value", "number" to 1.0, "boolean" to true, "list" to listOf("element1", 3.0, false))
330330

331-
val result = viewModel.logEvent(5000, LogEventRequest(key, parameters))
331+
val result = viewModel.logEvent(5000, LogEventRequest(key, parameters, null))
332332

333-
verify(appCallback, times(1)).logEvent(key, parameters)
333+
verify(appCallback, times(1)).logEvent(key, parameters, null)
334334
assertEquals(204, result.status)
335335
assertNull(result.body)
336336
}

0 commit comments

Comments
 (0)