mapp-intelligence-reactnative-plugin 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +31 -0
- package/android/build.gradle +118 -0
- package/android/gradle.properties +7 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/mappinteligenceplugin/ConfigAdapter.kt +25 -0
- package/android/src/main/java/com/mappinteligenceplugin/MappinteligencePluginModule.kt +489 -0
- package/android/src/main/java/com/mappinteligenceplugin/MappinteligencePluginPackage.kt +23 -0
- package/android/src/main/java/com/mappinteligenceplugin/mapper/ActionEventMapper.kt +26 -0
- package/android/src/main/java/com/mappinteligenceplugin/mapper/CampaignActionMapper.kt +17 -0
- package/android/src/main/java/com/mappinteligenceplugin/mapper/CampaignParametersMapper.kt +28 -0
- package/android/src/main/java/com/mappinteligenceplugin/mapper/ECommerceParametersMapper.kt +59 -0
- package/android/src/main/java/com/mappinteligenceplugin/mapper/EventParametersMapper.kt +17 -0
- package/android/src/main/java/com/mappinteligenceplugin/mapper/ExceptionTypeMapper.kt +13 -0
- package/android/src/main/java/com/mappinteligenceplugin/mapper/Mapper.kt +5 -0
- package/android/src/main/java/com/mappinteligenceplugin/mapper/MediaEventMapper.kt +43 -0
- package/android/src/main/java/com/mappinteligenceplugin/mapper/MediaParametersMapper.kt +29 -0
- package/android/src/main/java/com/mappinteligenceplugin/mapper/PageParametersMapper.kt +23 -0
- package/android/src/main/java/com/mappinteligenceplugin/mapper/ProductMapper.kt +29 -0
- package/android/src/main/java/com/mappinteligenceplugin/mapper/SessionParametersMapper.kt +16 -0
- package/android/src/main/java/com/mappinteligenceplugin/mapper/UserCategoriesMapper.kt +49 -0
- package/android/src/main/java/com/mappinteligenceplugin/mapper/Util.kt +75 -0
- package/ios/MappinteligencePlugin.h +11 -0
- package/ios/MappinteligencePlugin.mm +533 -0
- package/lib/commonjs/Converters.js +168 -0
- package/lib/commonjs/Converters.js.map +1 -0
- package/lib/commonjs/DataTypes.js +71 -0
- package/lib/commonjs/DataTypes.js.map +1 -0
- package/lib/commonjs/GlobalErrorHandler.js +51 -0
- package/lib/commonjs/GlobalErrorHandler.js.map +1 -0
- package/lib/commonjs/UseWebTracking.js +114 -0
- package/lib/commonjs/UseWebTracking.js.map +1 -0
- package/lib/commonjs/global.d.js +6 -0
- package/lib/commonjs/global.d.js.map +1 -0
- package/lib/commonjs/index.js +401 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/promiseRejectionHandler.js +50 -0
- package/lib/commonjs/promiseRejectionHandler.js.map +1 -0
- package/lib/module/Converters.js +155 -0
- package/lib/module/Converters.js.map +1 -0
- package/lib/module/DataTypes.js +65 -0
- package/lib/module/DataTypes.js.map +1 -0
- package/lib/module/GlobalErrorHandler.js +44 -0
- package/lib/module/GlobalErrorHandler.js.map +1 -0
- package/lib/module/UseWebTracking.js +107 -0
- package/lib/module/UseWebTracking.js.map +1 -0
- package/lib/module/global.d.js +4 -0
- package/lib/module/global.d.js.map +1 -0
- package/lib/module/index.js +321 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/promiseRejectionHandler.js +44 -0
- package/lib/module/promiseRejectionHandler.js.map +1 -0
- package/lib/typescript/src/Converters.d.ts +10 -0
- package/lib/typescript/src/Converters.d.ts.map +1 -0
- package/lib/typescript/src/DataTypes.d.ts +151 -0
- package/lib/typescript/src/DataTypes.d.ts.map +1 -0
- package/lib/typescript/src/GlobalErrorHandler.d.ts +3 -0
- package/lib/typescript/src/GlobalErrorHandler.d.ts.map +1 -0
- package/lib/typescript/src/UseWebTracking.d.ts +13 -0
- package/lib/typescript/src/UseWebTracking.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +201 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/promiseRejectionHandler.d.ts +3 -0
- package/lib/typescript/src/promiseRejectionHandler.d.ts.map +1 -0
- package/mapp-intelligence-reactnative-plugin.podspec +25 -0
- package/package.json +163 -0
- package/src/Converters.tsx +219 -0
- package/src/DataTypes.tsx +168 -0
- package/src/GlobalErrorHandler.tsx +58 -0
- package/src/UseWebTracking.tsx +135 -0
- package/src/global.d.ts +24 -0
- package/src/index.tsx +410 -0
- package/src/promiseRejectionHandler.tsx +54 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package com.mappinteligenceplugin
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.JavaScriptModule
|
|
5
|
+
import com.facebook.react.bridge.NativeModule
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.uimanager.ViewManager
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class MappinteligencePluginPackage : ReactPackage {
|
|
11
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
12
|
+
return listOf(MappinteligencePluginModule(reactContext))
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@Suppress("unused")
|
|
16
|
+
fun createJSModules(): MutableList<Class<out JavaScriptModule>> {
|
|
17
|
+
return mutableListOf()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
21
|
+
return emptyList()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package com.mappinteligenceplugin.mapper
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.mappinteligenceplugin.mapper.Util.optMap
|
|
5
|
+
import com.mappinteligenceplugin.mapper.Util.optString
|
|
6
|
+
import webtrekk.android.sdk.events.ActionEvent
|
|
7
|
+
|
|
8
|
+
class ActionEventMapper(val readableMap: ReadableMap?) : Mapper<ActionEvent> {
|
|
9
|
+
override fun getData(): ActionEvent? {
|
|
10
|
+
val map = readableMap ?: return null
|
|
11
|
+
val name = map.optString("name") ?: ""
|
|
12
|
+
val eventParameters = EventParametersMapper(map.optMap("eventParameters"))
|
|
13
|
+
val campaignParameters = CampaignParametersMapper(map.optMap("campaignParameters"))
|
|
14
|
+
val ecommerceParameters = ECommerceParametersMapper(map.optMap("ecommerceParameters"))
|
|
15
|
+
val sessionParameters = SessionParametersMapper(map.optMap("sessionParameters"))
|
|
16
|
+
val userCategories = UserCategoriesMapper(map.optMap("userCategories"))
|
|
17
|
+
|
|
18
|
+
return ActionEvent(name).apply {
|
|
19
|
+
this.eventParameters = eventParameters.getData()
|
|
20
|
+
this.campaignParameters = campaignParameters.getData()
|
|
21
|
+
this.eCommerceParameters = ecommerceParameters.getData()
|
|
22
|
+
this.sessionParameters = sessionParameters.getData()
|
|
23
|
+
this.userCategories = userCategories.getData()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.mappinteligenceplugin.mapper
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.mappinteligenceplugin.mapper.Util.optInt
|
|
5
|
+
import webtrekk.android.sdk.events.eventParams.CampaignParameters
|
|
6
|
+
|
|
7
|
+
class CampaignActionMapper(private val readableMap: ReadableMap?) :
|
|
8
|
+
Mapper<CampaignParameters.CampaignAction> {
|
|
9
|
+
override fun getData(): CampaignParameters.CampaignAction {
|
|
10
|
+
val map = readableMap ?: return CampaignParameters.CampaignAction.CLICK
|
|
11
|
+
val action = map.optInt("action")
|
|
12
|
+
return if (action == 1)
|
|
13
|
+
CampaignParameters.CampaignAction.CLICK
|
|
14
|
+
else
|
|
15
|
+
CampaignParameters.CampaignAction.VIEW
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package com.mappinteligenceplugin.mapper
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.mappinteligenceplugin.mapper.Util.optBoolean
|
|
5
|
+
import com.mappinteligenceplugin.mapper.Util.optString
|
|
6
|
+
import com.mappinteligenceplugin.mapper.Util.toMap
|
|
7
|
+
import webtrekk.android.sdk.events.eventParams.CampaignParameters
|
|
8
|
+
|
|
9
|
+
class CampaignParametersMapper(private val readableMap: ReadableMap?) : Mapper<CampaignParameters> {
|
|
10
|
+
override fun getData(): CampaignParameters? {
|
|
11
|
+
val map = readableMap ?: return null
|
|
12
|
+
|
|
13
|
+
val campaignId = map.optString("campaignId") ?: ""
|
|
14
|
+
val mediaCode = map.optString("mediaCode") ?: ""
|
|
15
|
+
val oncePerSession = map.optBoolean("oncePerSession") ?: false
|
|
16
|
+
val action = CampaignActionMapper(map).getData()
|
|
17
|
+
|
|
18
|
+
return CampaignParameters().apply {
|
|
19
|
+
this.campaignId = campaignId
|
|
20
|
+
this.action = action
|
|
21
|
+
this.mediaCode = mediaCode
|
|
22
|
+
this.oncePerSession = oncePerSession
|
|
23
|
+
this.customParameters = map.getMap("customParameters").toMap(keyTransform = {
|
|
24
|
+
it.toString().toInt()
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
package com.mappinteligenceplugin.mapper
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.mappinteligenceplugin.mapper.Util.optArray
|
|
5
|
+
import com.mappinteligenceplugin.mapper.Util.optDouble
|
|
6
|
+
import com.mappinteligenceplugin.mapper.Util.optInt
|
|
7
|
+
import com.mappinteligenceplugin.mapper.Util.optMap
|
|
8
|
+
import com.mappinteligenceplugin.mapper.Util.optString
|
|
9
|
+
import com.mappinteligenceplugin.mapper.Util.toMap
|
|
10
|
+
import webtrekk.android.sdk.events.eventParams.ECommerceParameters
|
|
11
|
+
import webtrekk.android.sdk.events.eventParams.ProductParameters
|
|
12
|
+
|
|
13
|
+
class ECommerceParametersMapper(private val readableMap: ReadableMap?) :
|
|
14
|
+
Mapper<ECommerceParameters> {
|
|
15
|
+
override fun getData(): ECommerceParameters? {
|
|
16
|
+
val map = readableMap ?: return null
|
|
17
|
+
|
|
18
|
+
val prodArray=map.optArray("products")
|
|
19
|
+
val products = mutableListOf<ProductParameters>()
|
|
20
|
+
for(i in 0 until (prodArray?.size() ?: 0)){
|
|
21
|
+
val prod=prodArray?.getMap(i)?.let { ProductMapper(it).getData() }
|
|
22
|
+
prod?.let {
|
|
23
|
+
products.add(it)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
val status = map.optInt("status").let {
|
|
27
|
+
when (it) {
|
|
28
|
+
1 -> ECommerceParameters.Status.ADDED_TO_BASKET
|
|
29
|
+
2 -> ECommerceParameters.Status.PURCHASED
|
|
30
|
+
3 -> ECommerceParameters.Status.VIEWED
|
|
31
|
+
4 -> ECommerceParameters.Status.DELETED_FROM_BASKET
|
|
32
|
+
5 -> ECommerceParameters.Status.ADDED_TO_WISHLIST
|
|
33
|
+
6 -> ECommerceParameters.Status.DELETED_FROM_WISHLIST
|
|
34
|
+
7 -> ECommerceParameters.Status.CHECKOUT
|
|
35
|
+
else -> ECommerceParameters.Status.NONE_STATUS
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return ECommerceParameters().apply {
|
|
39
|
+
this.products = products
|
|
40
|
+
this.status = status
|
|
41
|
+
this.currency = map.optString("currency")
|
|
42
|
+
this.orderID = map.optString("orderID")
|
|
43
|
+
this.orderValue = map.optDouble("orderValue")
|
|
44
|
+
this.returningOrNewCustomer = map.optString("returningOrNewCustomer")
|
|
45
|
+
this.returnValue = map.optDouble("returnValue")
|
|
46
|
+
this.cancellationValue = map.optDouble("cancellationValue")
|
|
47
|
+
this.couponValue = map.optDouble("couponValue")
|
|
48
|
+
this.paymentMethod = map.optString("paymentMethod")
|
|
49
|
+
this.shippingServiceProvider = map.optString("shippingServiceProvider")
|
|
50
|
+
this.shippingSpeed = map.optString("shippingSpeed")
|
|
51
|
+
this.shippingCost = map.optDouble("shippingCost")
|
|
52
|
+
this.markUp = map.optDouble("markUp")
|
|
53
|
+
this.orderStatus = map.optString("orderStatus")
|
|
54
|
+
this.customParameters = map.optMap("customParameters").toMap(keyTransform = {
|
|
55
|
+
it.toString().toInt()
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.mappinteligenceplugin.mapper
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.mappinteligenceplugin.mapper.Util.optMap
|
|
5
|
+
import com.mappinteligenceplugin.mapper.Util.toMap
|
|
6
|
+
import webtrekk.android.sdk.events.eventParams.EventParameters
|
|
7
|
+
|
|
8
|
+
class EventParametersMapper(private val readableMap: ReadableMap?) : Mapper<EventParameters> {
|
|
9
|
+
override fun getData(): EventParameters? {
|
|
10
|
+
val map = readableMap ?: return null
|
|
11
|
+
return EventParameters().apply {
|
|
12
|
+
this.customParameters = map.optMap("customParameters").toMap(keyTransform = {
|
|
13
|
+
it.toString().toInt()
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
package com.mappinteligenceplugin.mapper
|
|
2
|
+
|
|
3
|
+
import webtrekk.android.sdk.ExceptionType
|
|
4
|
+
|
|
5
|
+
class ExceptionTypeMapper(private val level: Double) : Mapper<ExceptionType> {
|
|
6
|
+
override fun getData(): ExceptionType {
|
|
7
|
+
return try {
|
|
8
|
+
ExceptionType.values()[level.toBigDecimal().toInt()]
|
|
9
|
+
} catch (e: Exception) {
|
|
10
|
+
ExceptionType.NONE
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
package com.mappinteligenceplugin.mapper
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.mappinteligenceplugin.mapper.Util.optMap
|
|
5
|
+
import com.mappinteligenceplugin.mapper.Util.optString
|
|
6
|
+
import com.mappinteligenceplugin.mapper.Util.toMap
|
|
7
|
+
import webtrekk.android.sdk.events.MediaEvent
|
|
8
|
+
import webtrekk.android.sdk.events.eventParams.ECommerceParameters
|
|
9
|
+
import webtrekk.android.sdk.events.eventParams.EventParameters
|
|
10
|
+
import webtrekk.android.sdk.events.eventParams.MediaParameters
|
|
11
|
+
import webtrekk.android.sdk.events.eventParams.SessionParameters
|
|
12
|
+
|
|
13
|
+
class MediaEventMapper(private val readableMap: ReadableMap?) : Mapper<MediaEvent> {
|
|
14
|
+
|
|
15
|
+
private var eventParameters: EventParameters? = null
|
|
16
|
+
private var eCommerceParameters: ECommerceParameters? = null
|
|
17
|
+
private var sessionParameters: SessionParameters? = null
|
|
18
|
+
private var customParameters: Map<String, String> = emptyMap()
|
|
19
|
+
private var mediaParameters: MediaParameters? = null
|
|
20
|
+
private var pageName: String? = null
|
|
21
|
+
|
|
22
|
+
override fun getData(): MediaEvent? {
|
|
23
|
+
val map = readableMap ?: return null
|
|
24
|
+
|
|
25
|
+
val params = map.optMap("parameters")
|
|
26
|
+
|
|
27
|
+
pageName = map.optString("pageName") ?: ""
|
|
28
|
+
eventParameters = EventParametersMapper(map.optMap("eventParameters")).getData()
|
|
29
|
+
eCommerceParameters = ECommerceParametersMapper(map.optMap("eCommerceParameters")).getData()
|
|
30
|
+
sessionParameters = SessionParametersMapper(map.optMap("sessionParameters")).getData()
|
|
31
|
+
customParameters = map.optMap("customParameters").toMap(keyTransform = { it.toString() })
|
|
32
|
+
mediaParameters = MediaParametersMapper(params).getData()
|
|
33
|
+
|
|
34
|
+
val media = mediaParameters ?: return null
|
|
35
|
+
val name = pageName ?: return null
|
|
36
|
+
return MediaEvent(name, media).also {
|
|
37
|
+
it.eventParameters = eventParameters
|
|
38
|
+
it.eCommerceParameters = eCommerceParameters
|
|
39
|
+
it.sessionParameters = sessionParameters
|
|
40
|
+
it.customParameters.putAll(customParameters)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package com.mappinteligenceplugin.mapper
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.mappinteligenceplugin.mapper.Util.optBoolean
|
|
5
|
+
import com.mappinteligenceplugin.mapper.Util.optDouble
|
|
6
|
+
import com.mappinteligenceplugin.mapper.Util.optMap
|
|
7
|
+
import com.mappinteligenceplugin.mapper.Util.optString
|
|
8
|
+
import com.mappinteligenceplugin.mapper.Util.toMap
|
|
9
|
+
import webtrekk.android.sdk.events.eventParams.MediaParameters
|
|
10
|
+
|
|
11
|
+
class MediaParametersMapper(private val readableMap: ReadableMap?) : Mapper<MediaParameters> {
|
|
12
|
+
override fun getData(): MediaParameters? {
|
|
13
|
+
val map = readableMap ?: return null
|
|
14
|
+
|
|
15
|
+
return MediaParameters(
|
|
16
|
+
map.optString("name") ?: "",
|
|
17
|
+
map.optString("action") ?: "",
|
|
18
|
+
map.optDouble("position")?.toLong() ?: 0,
|
|
19
|
+
map.optDouble("duration")?.toLong() ?: 0,
|
|
20
|
+
).apply {
|
|
21
|
+
this.bandwith = map.optDouble("bandwith")
|
|
22
|
+
this.soundIsMuted = map.optBoolean("soundIsMuted")
|
|
23
|
+
this.soundVolume = map.optDouble("soundVolume")?.toInt()
|
|
24
|
+
this.customCategories = map.optMap("customCategories").toMap(keyTransform = {
|
|
25
|
+
it.toString().toInt()
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package com.mappinteligenceplugin.mapper
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.mappinteligenceplugin.mapper.Util.optMap
|
|
5
|
+
import com.mappinteligenceplugin.mapper.Util.optString
|
|
6
|
+
import com.mappinteligenceplugin.mapper.Util.toMap
|
|
7
|
+
import webtrekk.android.sdk.events.eventParams.PageParameters
|
|
8
|
+
|
|
9
|
+
class PageParametersMapper(private val readableMap: ReadableMap?) : Mapper<PageParameters> {
|
|
10
|
+
override fun getData(): PageParameters? {
|
|
11
|
+
val map = readableMap ?: return null
|
|
12
|
+
|
|
13
|
+
return PageParameters().apply {
|
|
14
|
+
this.search = map.optString("searchTerm") ?: ""
|
|
15
|
+
this.parameters = map.optMap("params").toMap(keyTransform = {
|
|
16
|
+
it.toString().toInt()
|
|
17
|
+
})
|
|
18
|
+
this.pageCategory = map.optMap("categories").toMap(keyTransform = {
|
|
19
|
+
it.toString().toInt()
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package com.mappinteligenceplugin.mapper
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.mappinteligenceplugin.mapper.Util.optBoolean
|
|
5
|
+
import com.mappinteligenceplugin.mapper.Util.optDouble
|
|
6
|
+
import com.mappinteligenceplugin.mapper.Util.optMap
|
|
7
|
+
import com.mappinteligenceplugin.mapper.Util.optString
|
|
8
|
+
import com.mappinteligenceplugin.mapper.Util.toMap
|
|
9
|
+
import webtrekk.android.sdk.events.eventParams.ProductParameters
|
|
10
|
+
|
|
11
|
+
class ProductMapper(private val readableMap: ReadableMap?) : Mapper<ProductParameters> {
|
|
12
|
+
override fun getData(): ProductParameters? {
|
|
13
|
+
val map=readableMap ?: return null
|
|
14
|
+
val name=map.optString("name") ?: ""
|
|
15
|
+
return ProductParameters(name = name).apply {
|
|
16
|
+
this.cost=map.optDouble("cost") ?: 0.0
|
|
17
|
+
this.quantity=map.optDouble("quantity")
|
|
18
|
+
this.productAdvertiseID=map.optDouble("productAdvertiseID")
|
|
19
|
+
this.productSoldOut=map.optBoolean("productSoldOut")
|
|
20
|
+
this.productVariant=map.optString("productVariant")
|
|
21
|
+
this.categories=map.optMap("categories").toMap(keyTransform = {
|
|
22
|
+
it.toString().toInt()
|
|
23
|
+
})
|
|
24
|
+
this.ecommerceParameters=map.optMap("ecommerceParameters").toMap(keyTransform = {
|
|
25
|
+
it.toString().toInt()
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package com.mappinteligenceplugin.mapper
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.mappinteligenceplugin.mapper.Util.toMap
|
|
5
|
+
import webtrekk.android.sdk.events.eventParams.SessionParameters
|
|
6
|
+
|
|
7
|
+
class SessionParametersMapper(private val readableMap: ReadableMap?) : Mapper<SessionParameters> {
|
|
8
|
+
override fun getData(): SessionParameters? {
|
|
9
|
+
val map = readableMap ?: return null
|
|
10
|
+
return SessionParameters().apply {
|
|
11
|
+
this.parameters = map.toMap(keyTransform = {
|
|
12
|
+
it.toString().toInt()
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
package com.mappinteligenceplugin.mapper
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.mappinteligenceplugin.mapper.Util.optBoolean
|
|
5
|
+
import com.mappinteligenceplugin.mapper.Util.optInt
|
|
6
|
+
import com.mappinteligenceplugin.mapper.Util.optMap
|
|
7
|
+
import com.mappinteligenceplugin.mapper.Util.optString
|
|
8
|
+
import com.mappinteligenceplugin.mapper.Util.toMap
|
|
9
|
+
import webtrekk.android.sdk.events.eventParams.UserCategories
|
|
10
|
+
|
|
11
|
+
class UserCategoriesMapper(private val readableMap: ReadableMap?) : Mapper<UserCategories> {
|
|
12
|
+
override fun getData(): UserCategories? {
|
|
13
|
+
val map = readableMap ?: return null
|
|
14
|
+
|
|
15
|
+
val birthday = map.optMap("birthday")?.let {
|
|
16
|
+
val d = it.optInt("day")
|
|
17
|
+
val m = it.optInt("month")
|
|
18
|
+
val y = it.optInt("year")
|
|
19
|
+
UserCategories.Birthday(d, m, y)
|
|
20
|
+
}
|
|
21
|
+
val gender = map.optInt("gender").let {
|
|
22
|
+
return@let when (it) {
|
|
23
|
+
2 -> UserCategories.Gender.MALE
|
|
24
|
+
3 -> UserCategories.Gender.FEMALE
|
|
25
|
+
else -> UserCategories.Gender.UNKNOWN
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return UserCategories().apply {
|
|
30
|
+
this.birthday = birthday
|
|
31
|
+
this.city = map.optString("city")
|
|
32
|
+
this.country = map.optString("country")
|
|
33
|
+
this.emailAddress = map.optString("emailAddress")
|
|
34
|
+
this.emailReceiverId = map.optString("emailReceiverId")
|
|
35
|
+
this.firstName = map.optString("firstName")
|
|
36
|
+
this.gender = gender
|
|
37
|
+
this.customerId = map.optString("customerId")
|
|
38
|
+
this.lastName = map.optString("lastName")
|
|
39
|
+
this.newsletterSubscribed = map.optBoolean("newsletterSubscribed")
|
|
40
|
+
this.phoneNumber = map.optString("phoneNumber")
|
|
41
|
+
this.street = map.optString("street")
|
|
42
|
+
this.streetNumber = map.optString("streetNumber")
|
|
43
|
+
this.zipCode = map.optString("zipCode")
|
|
44
|
+
this.customCategories = map.optMap("customCategories").toMap(keyTransform = {
|
|
45
|
+
it.toString().toInt()
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
package com.mappinteligenceplugin.mapper
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableArray
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap
|
|
5
|
+
|
|
6
|
+
object Util {
|
|
7
|
+
// inline fun <reified K, reified V> ReadableMap?.toMap(): Map<K, V> {
|
|
8
|
+
// val map = mutableMapOf<K, V>()
|
|
9
|
+
// this?.entryIterator?.forEach {
|
|
10
|
+
// val key = it.key as K
|
|
11
|
+
// val value = it.value as? V
|
|
12
|
+
//
|
|
13
|
+
// if (key is K && value is V) {
|
|
14
|
+
// map[key] = value
|
|
15
|
+
// }
|
|
16
|
+
// }
|
|
17
|
+
// return map
|
|
18
|
+
// }
|
|
19
|
+
|
|
20
|
+
inline fun <K, V> ReadableMap?.toMap(
|
|
21
|
+
keyTransform: (k: Any) -> K, valueTransform: (v: String?) -> V? = { (it as V) }
|
|
22
|
+
): Map<K, V> {
|
|
23
|
+
val map = mutableMapOf<K, V>()
|
|
24
|
+
val iterator = this?.keySetIterator() ?: return map
|
|
25
|
+
|
|
26
|
+
while (iterator.hasNextKey()) {
|
|
27
|
+
val key = iterator.nextKey()
|
|
28
|
+
val keyItem = keyTransform(key)
|
|
29
|
+
val valueItem = valueTransform(this.getString(key))
|
|
30
|
+
valueItem?.let {
|
|
31
|
+
map[keyItem] = it
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return map
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
fun ReadableMap?.optDouble(key: String?): Double? {
|
|
39
|
+
if (this == null || key == null || !this.hasKey(key)) return null
|
|
40
|
+
return try {
|
|
41
|
+
this.getDouble(key)
|
|
42
|
+
} catch (ignored: Exception) {
|
|
43
|
+
null
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
fun ReadableMap?.optString(key: String?): String? {
|
|
48
|
+
if (this == null || key == null || !this.hasKey(key)) return null
|
|
49
|
+
return this.getString(key)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fun ReadableMap?.optBoolean(key: String?): Boolean {
|
|
53
|
+
if (this == null || key == null || !this.hasKey(key)) return false
|
|
54
|
+
return this.getBoolean(key)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
fun ReadableMap?.optInt(key: String?): Int {
|
|
58
|
+
if (this == null || key == null || !this.hasKey(key)) return 0
|
|
59
|
+
return try {
|
|
60
|
+
this.getDouble(key).toBigDecimal().toInt()
|
|
61
|
+
} catch (ignored: Exception) {
|
|
62
|
+
0
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
fun ReadableMap?.optMap(key: String?): ReadableMap? {
|
|
67
|
+
if (this == null || key == null || !this.hasKey(key)) return null
|
|
68
|
+
return this.getMap(key)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
fun ReadableMap?.optArray(key: String?): ReadableArray? {
|
|
72
|
+
if (this == null || key == null || !this.hasKey(key)) return null
|
|
73
|
+
return this.getArray(key)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
3
|
+
#import "RNMappinteligencePluginSpec.h"
|
|
4
|
+
|
|
5
|
+
@interface MappinteligencePlugin : NSObject <NativeMappinteligencePluginSpec>
|
|
6
|
+
#else
|
|
7
|
+
#import <React/RCTBridgeModule.h>
|
|
8
|
+
|
|
9
|
+
@interface MappinteligencePlugin : NSObject <RCTBridgeModule>
|
|
10
|
+
#endif
|
|
11
|
+
@end
|