mapp-intelligence-reactnative-plugin 1.0.3 → 1.1.1

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.
Files changed (156) hide show
  1. package/android/build.gradle +46 -63
  2. package/android/gradle.properties +7 -6
  3. package/android/settings.gradle +24 -0
  4. package/android/specs/MappinteligencePluginSpec.js +8 -0
  5. package/android/src/main/AndroidManifest.xml +3 -2
  6. package/android/src/main/java/com/mappinteligenceplugin/MappinteligencePluginModule.kt +296 -262
  7. package/android/src/main/java/com/mappinteligenceplugin/MappinteligencePluginPackage.kt +18 -7
  8. package/android/src/main/java/com/mappinteligenceplugin/MappintelligencePluginSpec.kt +59 -0
  9. package/ios/Frameworks/MappIntelligenceiOS.xcframework/Info.plist +48 -0
  10. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MIActionEvent.h +33 -0
  11. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MICampaignParameters.h +32 -0
  12. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MIDefaultTracker.h +49 -0
  13. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MIEcommerceParameters.h +52 -0
  14. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MIEventParameters.h +23 -0
  15. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MIFormField.h +28 -0
  16. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MIFormParameters.h +48 -0
  17. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MIFormSubmitEvent.h +22 -0
  18. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MIMediaEvent.h +30 -0
  19. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MIMediaParameters.h +31 -0
  20. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MIPageParameters.h +27 -0
  21. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MIPageViewEvent.h +34 -0
  22. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MIParamType.h +28 -0
  23. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MIParams.h +28 -0
  24. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MIProduct.h +28 -0
  25. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MIProperties.h +49 -0
  26. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MISessionParameters.h +20 -0
  27. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MITrackerRequest.h +39 -0
  28. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MITrackingEvent.h +23 -0
  29. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MIUsageStatistics.h +32 -0
  30. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MIUserCategories.h +49 -0
  31. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MappIntelligence.h +260 -0
  32. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceSDK/MappIntelligenceSDK.h +9 -0
  33. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MIActionEvent.h +33 -0
  34. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MICampaignParameters.h +32 -0
  35. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MIDefaultTracker.h +49 -0
  36. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MIEcommerceParameters.h +52 -0
  37. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MIEventParameters.h +23 -0
  38. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MIFormField.h +28 -0
  39. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MIFormParameters.h +48 -0
  40. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MIFormSubmitEvent.h +22 -0
  41. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MIMediaEvent.h +30 -0
  42. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MIMediaParameters.h +31 -0
  43. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MIPageParameters.h +27 -0
  44. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MIPageViewEvent.h +34 -0
  45. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MIParamType.h +28 -0
  46. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MIParams.h +28 -0
  47. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MIProduct.h +28 -0
  48. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MISessionParameters.h +20 -0
  49. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MITrackingEvent.h +23 -0
  50. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MIUsageStatistics.h +32 -0
  51. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MIUserCategories.h +49 -0
  52. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MIWebViewTracker.h +21 -0
  53. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MappIntelligence.h +260 -0
  54. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MappIntelligenceLogger.h +47 -0
  55. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/Headers/MappIntelligenceiOS/MappIntelligenceiOS.h +13 -0
  56. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64/libMappIntelligenceiOS.a +0 -0
  57. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MIActionEvent.h +33 -0
  58. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MICampaignParameters.h +32 -0
  59. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MIDefaultTracker.h +49 -0
  60. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MIEcommerceParameters.h +52 -0
  61. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MIEventParameters.h +23 -0
  62. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MIFormField.h +28 -0
  63. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MIFormParameters.h +48 -0
  64. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MIFormSubmitEvent.h +22 -0
  65. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MIMediaEvent.h +30 -0
  66. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MIMediaParameters.h +31 -0
  67. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MIPageParameters.h +27 -0
  68. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MIPageViewEvent.h +34 -0
  69. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MIParamType.h +28 -0
  70. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MIParams.h +28 -0
  71. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MIProduct.h +28 -0
  72. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MIProperties.h +49 -0
  73. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MISessionParameters.h +20 -0
  74. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MITrackerRequest.h +39 -0
  75. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MITrackingEvent.h +23 -0
  76. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MIUsageStatistics.h +32 -0
  77. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MIUserCategories.h +49 -0
  78. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MappIntelligence.h +260 -0
  79. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceSDK/MappIntelligenceSDK.h +9 -0
  80. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MIActionEvent.h +33 -0
  81. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MICampaignParameters.h +32 -0
  82. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MIDefaultTracker.h +49 -0
  83. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MIEcommerceParameters.h +52 -0
  84. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MIEventParameters.h +23 -0
  85. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MIFormField.h +28 -0
  86. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MIFormParameters.h +48 -0
  87. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MIFormSubmitEvent.h +22 -0
  88. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MIMediaEvent.h +30 -0
  89. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MIMediaParameters.h +31 -0
  90. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MIPageParameters.h +27 -0
  91. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MIPageViewEvent.h +34 -0
  92. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MIParamType.h +28 -0
  93. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MIParams.h +28 -0
  94. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MIProduct.h +28 -0
  95. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MISessionParameters.h +20 -0
  96. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MITrackingEvent.h +23 -0
  97. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MIUsageStatistics.h +32 -0
  98. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MIUserCategories.h +49 -0
  99. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MIWebViewTracker.h +21 -0
  100. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MappIntelligence.h +260 -0
  101. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MappIntelligenceLogger.h +47 -0
  102. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/Headers/MappIntelligenceiOS/MappIntelligenceiOS.h +13 -0
  103. package/ios/Frameworks/MappIntelligenceiOS.xcframework/ios-arm64_x86_64-simulator/libMappIntelligenceiOS.a +0 -0
  104. package/ios/MappinteligencePlugin.mm +50 -24
  105. package/lib/module/Converters.js +2 -0
  106. package/lib/module/Converters.js.map +1 -1
  107. package/lib/module/DataTypes.js +2 -0
  108. package/lib/module/DataTypes.js.map +1 -1
  109. package/lib/module/GlobalErrorHandler.js +9 -12
  110. package/lib/module/GlobalErrorHandler.js.map +1 -1
  111. package/lib/module/MappIntelligencePlugin.js +19 -4
  112. package/lib/module/MappIntelligencePlugin.js.map +1 -1
  113. package/lib/module/NativeMappintelligencePlugin.js +5 -0
  114. package/lib/module/NativeMappintelligencePlugin.js.map +1 -0
  115. package/lib/module/UseWebTracking.js +23 -21
  116. package/lib/module/UseWebTracking.js.map +1 -1
  117. package/lib/module/global.d.js +2 -0
  118. package/lib/module/global.d.js.map +1 -1
  119. package/lib/module/index.js +8 -6
  120. package/lib/module/index.js.map +1 -1
  121. package/lib/module/promiseRejectionHandler.js +4 -9
  122. package/lib/module/promiseRejectionHandler.js.map +1 -1
  123. package/lib/typescript/src/DataTypes.d.ts +6 -6
  124. package/lib/typescript/src/DataTypes.d.ts.map +1 -1
  125. package/lib/typescript/src/GlobalErrorHandler.d.ts +1 -1
  126. package/lib/typescript/src/GlobalErrorHandler.d.ts.map +1 -1
  127. package/lib/typescript/src/MappIntelligencePlugin.d.ts +6 -0
  128. package/lib/typescript/src/MappIntelligencePlugin.d.ts.map +1 -1
  129. package/lib/typescript/src/NativeMappintelligencePlugin.d.ts +39 -0
  130. package/lib/typescript/src/NativeMappintelligencePlugin.d.ts.map +1 -0
  131. package/lib/typescript/src/UseWebTracking.d.ts +1 -2
  132. package/lib/typescript/src/UseWebTracking.d.ts.map +1 -1
  133. package/lib/typescript/src/promiseRejectionHandler.d.ts.map +1 -1
  134. package/mapp-intelligence-reactnative-plugin.podspec +4 -1
  135. package/package.json +39 -40
  136. package/src/GlobalErrorHandler.tsx +8 -13
  137. package/src/MappIntelligencePlugin.tsx +27 -12
  138. package/src/NativeMappintelligencePlugin.ts +55 -0
  139. package/src/UseWebTracking.tsx +29 -27
  140. package/src/promiseRejectionHandler.tsx +5 -10
  141. package/lib/commonjs/Converters.js +0 -168
  142. package/lib/commonjs/Converters.js.map +0 -1
  143. package/lib/commonjs/DataTypes.js +0 -79
  144. package/lib/commonjs/DataTypes.js.map +0 -1
  145. package/lib/commonjs/GlobalErrorHandler.js +0 -47
  146. package/lib/commonjs/GlobalErrorHandler.js.map +0 -1
  147. package/lib/commonjs/MappIntelligencePlugin.js +0 -296
  148. package/lib/commonjs/MappIntelligencePlugin.js.map +0 -1
  149. package/lib/commonjs/UseWebTracking.js +0 -96
  150. package/lib/commonjs/UseWebTracking.js.map +0 -1
  151. package/lib/commonjs/global.d.js +0 -6
  152. package/lib/commonjs/global.d.js.map +0 -1
  153. package/lib/commonjs/index.js +0 -72
  154. package/lib/commonjs/index.js.map +0 -1
  155. package/lib/commonjs/promiseRejectionHandler.js +0 -50
  156. package/lib/commonjs/promiseRejectionHandler.js.map +0 -1
@@ -1,14 +1,14 @@
1
1
  package com.mappinteligenceplugin
2
2
 
3
- import android.net.Uri
4
3
  import android.util.Log
5
4
  import androidx.annotation.IntRange
5
+ import androidx.core.net.toUri
6
6
  import com.facebook.react.bridge.Promise
7
7
  import com.facebook.react.bridge.ReactApplicationContext
8
- import com.facebook.react.bridge.ReactContextBaseJavaModule
9
8
  import com.facebook.react.bridge.ReactMethod
10
9
  import com.facebook.react.bridge.ReadableArray
11
10
  import com.facebook.react.bridge.ReadableMap
11
+ import com.facebook.react.module.annotations.ReactModule
12
12
  import com.mappinteligenceplugin.mapper.CampaignParametersMapper
13
13
  import com.mappinteligenceplugin.mapper.ECommerceParametersMapper
14
14
  import com.mappinteligenceplugin.mapper.EventParametersMapper
@@ -18,266 +18,256 @@ import com.mappinteligenceplugin.mapper.PageParametersMapper
18
18
  import com.mappinteligenceplugin.mapper.SessionParametersMapper
19
19
  import com.mappinteligenceplugin.mapper.UserCategoriesMapper
20
20
  import com.mappinteligenceplugin.mapper.Util.toMap
21
+ import java.util.concurrent.TimeUnit
21
22
  import webtrekk.android.sdk.Logger
22
23
  import webtrekk.android.sdk.Webtrekk
23
24
  import webtrekk.android.sdk.WebtrekkConfiguration
24
25
  import webtrekk.android.sdk.events.ActionEvent
25
26
  import webtrekk.android.sdk.events.PageViewEvent
26
- import java.util.concurrent.TimeUnit
27
27
 
28
+ @ReactModule(name = MappinteligencePluginModule.NAME)
28
29
  class MappinteligencePluginModule(private val reactContext: ReactApplicationContext) :
29
- ReactContextBaseJavaModule(reactContext) {
30
+ NativeMappintelligencePluginSpec(reactContext) {
31
+
32
+ companion object {
33
+ const val NAME = "MappinteligencePlugin"
34
+ private val configAdapter: ConfigAdapter by lazy { ConfigAdapter() }
35
+ }
30
36
 
31
- private lateinit var instance: Webtrekk
32
- private val configAdapter = ConfigAdapter()
37
+ private var instance: Webtrekk? = null
38
+
39
+ init {
40
+ println("MappIntelligencePluginModule created!")
41
+ println("MappIntelligence instance: $instance")
42
+ }
33
43
 
34
44
  /**
35
- * Initialize native SDK with the provided trackIds and trackDomain and with the default other parameters
45
+ * Initialize native SDK with the provided trackIds and trackDomain and with the default other
46
+ * parameters
36
47
  */
37
48
  @ReactMethod
38
- fun initWithConfiguration(trackIds: ReadableArray, trackDomain: String, promise: Promise) {
49
+ override fun initWithConfiguration(
50
+ trackIds: ReadableArray,
51
+ trackDomain: String,
52
+ promise: Promise
53
+ ) {
39
54
  val trackValues = mutableListOf<Double?>()
40
55
  for (i in 0 until trackIds.size()) {
41
56
  trackValues.add(trackIds.getDouble(i))
42
57
  }
43
58
  val ids = trackValues.mapNotNull { it?.toBigDecimal()?.toPlainString() }
44
- runOnPlugin(whenInitialized = {
45
- instance.setIdsAndDomain(ids, trackDomain)
46
- }, whenNotInitialized = {
47
- configAdapter.trackIds = ids
48
- configAdapter.trackDomain = trackDomain
49
- })
59
+ runOnPlugin(
60
+ whenInitialized = { instance?.setIdsAndDomain(ids, trackDomain) },
61
+ whenNotInitialized = {
62
+ configAdapter.trackIds = ids
63
+ configAdapter.trackDomain = trackDomain
64
+ }
65
+ )
50
66
  promise.resolve(true)
51
67
  }
52
68
 
53
69
  /**
54
- * Check if SDK is initialized and ready for usage
55
- * Returns true if initialization was finished, otherwise false
70
+ * Check if SDK is initialized and ready for usage Returns true if initialization was finished,
71
+ * otherwise false
56
72
  */
57
73
  @ReactMethod
58
- fun isInitialized(promise: Promise) {
59
- runOnPlugin(whenInitialized = {
60
- promise.resolve(true)
61
- }, whenNotInitialized = {
62
- promise.resolve(false)
63
- })
74
+ override fun isInitialized(promise: Promise) {
75
+ runOnPlugin(
76
+ whenInitialized = { promise.resolve(true) },
77
+ whenNotInitialized = { promise.resolve(false) }
78
+ )
64
79
  }
65
80
 
66
81
  /**
67
- * Enable or disable anonymous tracking
68
- * When anonymous tracking is enabled, everId will be deleted and not created again while this value stays true
82
+ * Enable or disable anonymous tracking When anonymous tracking is enabled, everId will be deleted
83
+ * and not created again while this value stays true
69
84
  */
70
85
  @ReactMethod
71
- fun setAnonymousTracking(enabled: Boolean, promise: Promise) {
86
+ override fun setAnonymousTracking(enabled: Boolean, promise: Promise) {
72
87
  runOnPlugin(
73
- whenInitialized = {
74
- instance.anonymousTracking(enabled)
75
- }, whenNotInitialized = {
76
- configAdapter.anonymousTracking = enabled
77
- })
88
+ whenInitialized = { instance?.anonymousTracking(enabled) },
89
+ whenNotInitialized = { configAdapter.anonymousTracking = enabled }
90
+ )
78
91
  promise.resolve(true)
79
92
  }
80
93
 
81
- /**
82
- * Enable or disable sending appVersion parameter with a every request
83
- */
94
+ /** Enable or disable sending appVersion parameter with a every request */
84
95
  @ReactMethod
85
- fun setSendAppVersionInEveryRequest(enabled: Boolean, promise: Promise) {
86
- runOnPlugin(whenInitialized = {
87
- instance.setVersionInEachRequest(enabled)
88
- }, whenNotInitialized = {
89
- configAdapter.versionInEachRequest = enabled
90
- })
96
+ override fun setSendAppVersionInEveryRequest(enabled: Boolean, promise: Promise) {
97
+ runOnPlugin(
98
+ whenInitialized = { instance?.setVersionInEachRequest(enabled) },
99
+ whenNotInitialized = { configAdapter.versionInEachRequest = enabled }
100
+ )
91
101
  promise.resolve(true)
92
102
  }
93
103
 
94
104
  /**
95
- * Enable or disable user matching option
96
- * User matching provides connection between users on Engage and Intelligence systems
105
+ * Enable or disable user matching option User matching provides connection between users on
106
+ * Engage and Intelligence systems
97
107
  */
98
108
  @ReactMethod
99
- fun setEnableUserMatching(enabled: Boolean, promise: Promise) {
100
- runOnPlugin(whenInitialized = {
101
- instance.setUserMatchingEnabled(enabled)
102
- }, whenNotInitialized = {
103
- configAdapter.userMatchingEnabled = enabled
104
- })
109
+ override fun setEnableUserMatching(enabled: Boolean, promise: Promise) {
110
+ runOnPlugin(
111
+ whenInitialized = { instance?.setUserMatchingEnabled(enabled) },
112
+ whenNotInitialized = { configAdapter.userMatchingEnabled = enabled }
113
+ )
105
114
  promise.resolve(true)
106
115
  }
107
116
 
108
117
  /**
109
- * Set custom everId
110
- * If null or empty string passed, everId will be autogenerated
111
- * <b>It has effect only if anonymous tracking is disabled</b>
118
+ * Set custom everId If null or empty string passed, everId will be autogenerated <b>It has effect
119
+ * only if anonymous tracking is disabled</b>
112
120
  */
113
121
  @ReactMethod
114
- fun setEverId(everId: String?, promise: Promise) {
115
- runOnPlugin(whenInitialized = {
116
- instance.setEverId(everId)
117
- }, whenNotInitialized = {
118
- configAdapter.everId = everId
119
- })
122
+ override fun setEverId(everId: String?, promise: Promise) {
123
+ runOnPlugin(
124
+ whenInitialized = { instance?.setEverId(everId) },
125
+ whenNotInitialized = { configAdapter.everId = everId }
126
+ )
120
127
  promise.resolve(true)
121
128
  }
122
129
 
123
130
  @ReactMethod
124
- fun getEverId(promise: Promise) {
125
- runOnPlugin(whenInitialized = {
126
- val everId = instance.getEverId()
127
- promise.resolve(everId)
128
- }, whenNotInitialized = {
129
- promise.reject("", "SDK not initialized yet!")
130
- })
131
+ override fun getEverId(promise: Promise) {
132
+ runOnPlugin(
133
+ whenInitialized = {
134
+ val everId = instance?.getEverId()
135
+ promise.resolve(everId)
136
+ },
137
+ whenNotInitialized = { promise.reject("", "SDK not initialized yet!") }
138
+ )
131
139
  }
132
140
 
133
141
  @ReactMethod
134
- fun setTemporarySessionId(sessionId: String, promise: Promise) {
135
- runOnPlugin(whenInitialized = {
136
- instance.setTemporarySessionId(sessionId)
137
- }, whenNotInitialized = {
138
- configAdapter.temporarySessionId = sessionId
139
- })
142
+ override fun setTemporarySessionId(sessionId: String?, promise: Promise) {
143
+ runOnPlugin(
144
+ whenInitialized = { instance?.setTemporarySessionId(sessionId ?: "") },
145
+ whenNotInitialized = { configAdapter.temporarySessionId = sessionId ?: "" }
146
+ )
140
147
  promise.resolve(true)
141
148
  }
142
149
 
143
150
  @ReactMethod
144
- fun optOut(sendData: Boolean, promise: Promise) {
145
- runOnPlugin(whenInitialized = {
146
- instance.optOut(true, sendData)
147
- })
151
+ override fun optOut(sendData: Boolean, promise: Promise) {
152
+ runOnPlugin(whenInitialized = { instance?.optOut(true, sendData) })
148
153
  promise.resolve(true)
149
154
  }
150
155
 
151
156
  @ReactMethod
152
- fun optIn(sendData: Boolean, promise: Promise) {
153
- runOnPlugin(whenInitialized = {
154
- instance.optOut(false, sendData)
155
- })
157
+ override fun optIn(sendData: Boolean, promise: Promise) {
158
+ runOnPlugin(whenInitialized = { instance?.optOut(false, sendData) })
156
159
  promise.resolve(true)
157
160
  }
158
161
 
159
162
  @ReactMethod
160
- fun setExceptionLogLevel(exceptionLevel: Double, promise: Promise) {
163
+ override fun setExceptionLogLevel(exceptionLevel: Double, promise: Promise) {
161
164
  val exceptionType = ExceptionTypeMapper(exceptionLevel).getData()
162
- runOnPlugin(whenInitialized = {
163
- instance.setExceptionLogLevel(exceptionType)
164
- }, whenNotInitialized = {
165
- configAdapter.exceptionLogLevel = exceptionType
166
- })
165
+ runOnPlugin(
166
+ whenInitialized = { instance?.setExceptionLogLevel(exceptionType) },
167
+ whenNotInitialized = { configAdapter.exceptionLogLevel = exceptionType }
168
+ )
167
169
  promise.resolve(true)
168
170
  }
169
171
 
170
172
  /**
171
- * Sets log level for a library. Disable or enable logs in the logcat from the intelligence SDK and it's plugin
173
+ * Sets log level for a library. Disable or enable logs in the logcat from the intelligence SDK
174
+ * and it's plugin
172
175
  */
173
176
  @ReactMethod
174
- fun setLogLevel(level: Int, promise: Promise) {
175
- val nativeLevel = if (level == 7) {
176
- Logger.Level.NONE
177
- } else {
178
- Logger.Level.BASIC
179
- }
180
- runOnPlugin(whenInitialized = {
181
- instance.setLogLevel(nativeLevel)
182
- }, whenNotInitialized = {
183
- configAdapter.logLevel = nativeLevel
184
- })
177
+ override fun setLogLevel(level: Double, promise: Promise) {
178
+ val levelInt = level.toInt()
179
+ val nativeLevel =
180
+ if (levelInt == 7) {
181
+ Logger.Level.NONE
182
+ } else {
183
+ Logger.Level.BASIC
184
+ }
185
+ runOnPlugin(
186
+ whenInitialized = { instance?.setLogLevel(nativeLevel) },
187
+ whenNotInitialized = { configAdapter.logLevel = nativeLevel }
188
+ )
185
189
  promise.resolve(true)
186
190
  }
187
191
 
188
-
189
192
  /**
190
- * Enable or disable sending requests in a batch
191
- * When enabled, multiple track records are send via single Http request
193
+ * Enable or disable sending requests in a batch When enabled, multiple track records are send via
194
+ * single Http request
192
195
  */
193
196
  @ReactMethod
194
- fun setBatchSupportEnabled(enabled: Boolean, promise: Promise) {
195
- runOnPlugin(whenInitialized = {
196
- instance.setBatchEnabled(enabled)
197
- }, whenNotInitialized = {
198
- configAdapter.batchSupport = enabled
199
- })
197
+ override fun setBatchSupportEnabled(enabled: Boolean, promise: Promise) {
198
+ runOnPlugin(
199
+ whenInitialized = { instance?.setBatchEnabled(enabled) },
200
+ whenNotInitialized = { configAdapter.batchSupport = enabled }
201
+ )
200
202
  promise.resolve(true)
201
203
  }
202
204
 
203
205
  /**
204
- * Sets the number of records to be send in a single network request.
205
- * Value must be in the defined range for size
206
+ * Sets the number of records to be send in a single network request. Value must be in the defined
207
+ * range for size
206
208
  */
207
209
  @ReactMethod
208
- fun setBatchSupportSize(
209
- @IntRange size: Int, promise: Promise
210
- ) {
210
+ override fun setBatchSupportSize(size: Double, promise: Promise) {
211
+ val sizeInt = size.toInt()
211
212
  runOnPlugin(
212
- whenInitialized = {
213
- instance.setRequestPerBatch(size)
214
- }, whenNotInitialized = {
215
- configAdapter.requestPerBatch = size
216
- })
213
+ whenInitialized = { instance?.setRequestPerBatch(sizeInt) },
214
+ whenNotInitialized = { configAdapter.requestPerBatch = sizeInt }
215
+ )
217
216
  promise.resolve(true)
218
217
  }
219
218
 
220
219
  /**
221
- * Sets time interval, in minutes, for a job of automatic sending of the tracking records
222
- * Minimum value is 15 minutes, limited by Android OS.
220
+ * Sets time interval, in minutes, for a job of automatic sending of the tracking records Minimum
221
+ * value is 15 minutes, limited by Android OS.
223
222
  */
224
223
  @ReactMethod
225
- fun setRequestInterval(
226
- @IntRange(from = 15) interval: Int, promise: Promise
227
- ) {
224
+ override fun setRequestInterval(interval: Double, promise: Promise) {
225
+ val intervalInt = interval.toInt()
228
226
  runOnPlugin(
229
- whenInitialized = {
230
- instance.setRequestInterval(interval.toLong())
231
- }, whenNotInitialized = {
232
- configAdapter.requestsIntervalMinutes = interval
233
- })
227
+ whenInitialized = { instance?.setRequestInterval(intervalInt.toLong()) },
228
+ whenNotInitialized = { configAdapter.requestsIntervalMinutes = intervalInt }
229
+ )
234
230
  promise.resolve(true)
235
231
  }
236
232
 
237
- /**
238
- * This operation is not supported on android
239
- * Method exists only for compatibility
240
- */
233
+ /** This operation is not supported on android Method exists only for compatibility */
241
234
  @ReactMethod
242
- fun setRequestPerQueue(queue: Int, promise: Promise) {
235
+ override fun setRequestPerQueue(queue: Double, promise: Promise) {
243
236
  promise.resolve(true)
244
237
  }
245
238
 
246
239
  /**
247
- * Enable or disable migration from previous version of a native SDK
248
- * React Native plugin was not developed with a older version (v4) of the native plugin,
249
- * so migration for this plugin will always stay false.
240
+ * Enable or disable migration from previous version of a native SDK React Native plugin was not
241
+ * developed with a older version (v4) of the native plugin, so migration for this plugin will
242
+ * always stay false.
250
243
  */
251
244
  @ReactMethod
252
- fun setShouldMigrate(migrate: Boolean, promise: Promise) {
245
+ override fun setShouldMigrate(migrate: Boolean, promise: Promise) {
253
246
  runOnPlugin(
254
247
  whenInitialized = {
255
248
  if (migrate) {
256
249
  reset { it.enableMigration() }
257
250
  }
258
- }, whenNotInitialized = {
259
- configAdapter.shouldMigrate = migrate
260
- })
251
+ },
252
+ whenNotInitialized = { configAdapter.shouldMigrate = migrate }
253
+ )
261
254
  promise.resolve(true)
262
255
  }
263
256
 
264
- /**
265
- * Required only for iOS;
266
- * Method just returns success and exist only for compatibility
267
- */
257
+ /** Required only for iOS; Method just returns success and exist only for compatibility */
268
258
  @ReactMethod
269
- fun setEnableBackgroundSendout(enabled: Boolean, promise: Promise) {
259
+ override fun setEnableBackgroundSendout(enabled: Boolean, promise: Promise) {
270
260
  promise.resolve(true)
271
261
  }
272
262
 
273
263
  @ReactMethod
274
- fun trackCustomPage(
275
- pageTitle: String,
276
- pageParams: ReadableMap?,
277
- sessionParams: ReadableMap?,
278
- userCategoryParams: ReadableMap?,
279
- ecommerceParams: ReadableMap?,
280
- campaignParams: ReadableMap?,
264
+ override fun trackCustomPage(
265
+ pageTitle: String?,
266
+ pageParams: ReadableMap,
267
+ sessionParams: ReadableMap,
268
+ userCategoryParams: ReadableMap,
269
+ ecommerceParams: ReadableMap,
270
+ campaignParams: ReadableMap,
281
271
  promise: Promise
282
272
  ) {
283
273
  runOnPlugin(
@@ -288,55 +278,52 @@ class MappinteligencePluginModule(private val reactContext: ReactApplicationCont
288
278
  val ecommerce = ECommerceParametersMapper(ecommerceParams).getData()
289
279
  val campaign = CampaignParametersMapper(campaignParams).getData()
290
280
 
291
- val pageViewEvent = PageViewEvent(pageTitle).apply {
292
- this.pageParameters = page
293
- this.sessionParameters = session
294
- this.userCategories = userCat
295
- this.eCommerceParameters = ecommerce
296
- this.campaignParameters = campaign
297
- }
298
- instance.trackPage(pageViewEvent)
281
+ val pageViewEvent =
282
+ PageViewEvent(pageTitle ?: "NO_NAME_PAGE").apply {
283
+ this.pageParameters = page
284
+ this.sessionParameters = session
285
+ this.userCategories = userCat
286
+ this.eCommerceParameters = ecommerce
287
+ this.campaignParameters = campaign
288
+ }
289
+ instance?.trackPage(pageViewEvent)
299
290
  }
300
291
  )
301
292
  promise.resolve(true)
302
293
  }
303
294
 
304
- /**
305
- * Track page with a provided [PageViewEvent]
306
- */
295
+ /** Track page with a provided [PageViewEvent] */
307
296
  @ReactMethod
308
- fun trackPageWithCustomData(params: ReadableMap?, pageTitle: String, promise: Promise) {
309
- runOnPlugin(whenInitialized = {
310
- instance.trackCustomPage(pageTitle, params.toMap(keyTransform = {it.toString()}))
311
- })
297
+ override fun trackPageWithCustomData(params: ReadableMap, pageTitle: String, promise: Promise) {
298
+ runOnPlugin(
299
+ whenInitialized = {
300
+ instance?.trackCustomPage(pageTitle, params.toMap(keyTransform = { it.toString() }))
301
+ }
302
+ )
312
303
  promise.resolve(true)
313
304
  }
314
305
 
315
306
  @ReactMethod
316
- fun trackPage(pageTitle: String, promise: Promise) {
317
- runOnPlugin(whenInitialized = {
318
- instance.trackPage(PageViewEvent(pageTitle))
319
- })
307
+ override fun trackPage(pageTitle: String, promise: Promise) {
308
+ runOnPlugin(whenInitialized = { instance?.trackPage(PageViewEvent(pageTitle)) })
320
309
  promise.resolve(true)
321
310
  }
322
311
 
323
312
  @ReactMethod
324
- fun sendRequestsAndClean(promise: Promise) {
325
- runOnPlugin(
326
- whenInitialized = {
327
- instance.sendRequestsNowAndClean()
328
- })
313
+ override fun sendRequestsAndClean(promise: Promise) {
314
+ runOnPlugin(whenInitialized = { instance?.sendRequestsNowAndClean() })
329
315
  promise.resolve(true)
330
316
  }
331
317
 
318
+
332
319
  @ReactMethod
333
- fun trackAction(
320
+ override fun trackAction(
334
321
  name: String,
335
- eventParameters: ReadableMap?,
336
- sessionParameters: ReadableMap?,
337
- userCategories: ReadableMap?,
338
- eCommerceParameters: ReadableMap?,
339
- campaignParameters: ReadableMap?,
322
+ eventParameters: ReadableMap,
323
+ sessionParameters: ReadableMap,
324
+ userCategories: ReadableMap,
325
+ eCommerceParameters: ReadableMap,
326
+ campaignParameters: ReadableMap,
340
327
  promise: Promise
341
328
  ) {
342
329
  runOnPlugin(
@@ -346,15 +333,36 @@ class MappinteligencePluginModule(private val reactContext: ReactApplicationCont
346
333
  val userCat = UserCategoriesMapper(userCategories).getData()
347
334
  val ecommerce = ECommerceParametersMapper(eCommerceParameters).getData()
348
335
  val campaignParams = CampaignParametersMapper(campaignParameters).getData()
349
- val actionEvent = ActionEvent(name).apply {
350
- this.eventParameters = event
351
- this.sessionParameters = session
352
- this.userCategories = userCat
353
- this.eCommerceParameters = ecommerce
354
- this.campaignParameters = campaignParams
336
+ val actionEvent =
337
+ ActionEvent(name).apply {
338
+ this.eventParameters = event
339
+ this.sessionParameters = session
340
+ this.userCategories = userCat
341
+ this.eCommerceParameters = ecommerce
342
+ this.campaignParameters = campaignParams
343
+ }
344
+ instance?.trackAction(actionEvent)
345
+ }
346
+ )
347
+ promise.resolve(true)
348
+ }
349
+
350
+ @ReactMethod
351
+ override fun trackException(
352
+ name: String,
353
+ message: String,
354
+ stacktrace: String?,
355
+ promise: Promise
356
+ ) {
357
+ runOnPlugin(
358
+ whenInitialized = {
359
+ if (stacktrace.isNullOrEmpty()) {
360
+ instance?.trackException(name, message)
361
+ } else {
362
+ instance?.trackException(name, message + "\n${stacktrace}")
355
363
  }
356
- instance.trackAction(actionEvent)
357
- })
364
+ }
365
+ )
358
366
  promise.resolve(true)
359
367
  }
360
368
 
@@ -363,127 +371,153 @@ class MappinteligencePluginModule(private val reactContext: ReactApplicationCont
363
371
  runOnPlugin(
364
372
  whenInitialized = {
365
373
  val innerException = Exception(exception.getString("message"))
366
- instance.trackException(innerException)
367
-
368
- })
374
+ instance?.trackException(innerException)
375
+ }
376
+ )
369
377
  promise.resolve(true)
370
378
  }
371
379
 
372
380
  @ReactMethod
373
- fun trackMedia(readableMap: ReadableMap?, promise: Promise) {
374
- runOnPlugin(whenInitialized = {
375
- MediaEventMapper(readableMap).getData()?.let {
376
- instance.trackMedia(it)
381
+ override fun trackMedia(readableMap: ReadableMap, promise: Promise) {
382
+ runOnPlugin(
383
+ whenInitialized = {
384
+ MediaEventMapper(readableMap).getData()?.let { instance?.trackMedia(it) }
377
385
  }
378
- })
386
+ )
379
387
  promise.resolve(true)
380
388
  }
381
389
 
382
390
  @ReactMethod
383
- fun trackUrl(url: String, mediaCode: String?, promise: Promise) {
384
- runOnPlugin(
385
- whenInitialized = {
386
- instance.trackUrl(Uri.parse(url), mediaCode)
387
- })
391
+ override fun trackUrl(url: String, mediaCode: String?, promise: Promise) {
392
+ runOnPlugin(whenInitialized = { instance?.trackUrl(url.toUri(), mediaCode) })
388
393
  promise.resolve(true)
389
394
  }
390
395
 
391
396
  @ReactMethod
392
- fun trackException(name: String, message: String, stacktrace: String? = null, promise: Promise) {
393
- runOnPlugin(whenInitialized = {
394
- Log.d("MappIntelligencePlugin", "trackException")
395
- if (stacktrace.isNullOrEmpty()) {
396
- instance.trackException(name, message)
397
- } else {
398
- instance.trackException(name, message + "\n${stacktrace}")
397
+ override fun trackExceptionWithName(
398
+ name: String,
399
+ message: String,
400
+ stacktrace: String?,
401
+ promise: Promise
402
+ ) {
403
+ runOnPlugin(
404
+ whenInitialized = {
405
+ Log.d("MappIntelligencePlugin", "trackExceptionWithName")
406
+ if (stacktrace.isNullOrEmpty()) {
407
+ instance?.trackException(name, message)
408
+ } else {
409
+ instance?.trackException(name, message + "\n${stacktrace}")
410
+ }
399
411
  }
400
- })
412
+ )
401
413
  promise.resolve(true)
402
414
  }
403
415
 
404
- /**
405
- * Configure webtrekk SDK and initialize it
406
- */
416
+ /** Configure webtrekk SDK and initialize it */
407
417
  @ReactMethod
408
- fun build(promise: Promise) {
409
- runOnPlugin(whenNotInitialized = {
410
- val builder = WebtrekkConfiguration.Builder(configAdapter.trackIds, configAdapter.trackDomain)
411
- .logLevel(configAdapter.logLevel)
412
- .enableCrashTracking(configAdapter.exceptionLogLevel)
413
- .setBatchSupport(configAdapter.batchSupport, configAdapter.requestPerBatch)
414
- .requestsInterval(TimeUnit.MINUTES, configAdapter.requestsIntervalMinutes.toLong())
415
- .setEverId(configAdapter.everId)
416
- .sendAppVersionInEveryRequest(configAdapter.versionInEachRequest)
417
-
418
- if (configAdapter.shouldMigrate) builder.enableMigration()
419
-
420
- if (!configAdapter.autoTracking) builder.disableAutoTracking()
421
-
422
- if (!configAdapter.activityAutoTracking) builder.disableActivityAutoTracking()
423
-
424
- if (!configAdapter.fragmentsAutoTracking) builder.disableFragmentsAutoTracking()
425
-
426
- Webtrekk.getInstance().init(reactContext.applicationContext, builder.build())
427
-
428
- instance = Webtrekk.getInstance().apply {
429
- this.anonymousTracking(configAdapter.anonymousTracking)
430
- this.setTemporarySessionId(configAdapter.temporarySessionId)
418
+ override fun build(promise: Promise) {
419
+ runOnPlugin(
420
+ whenNotInitialized = {
421
+ val builder =
422
+ WebtrekkConfiguration.Builder(
423
+ configAdapter.trackIds,
424
+ configAdapter.trackDomain
425
+ )
426
+ .logLevel(configAdapter.logLevel)
427
+ .enableCrashTracking(configAdapter.exceptionLogLevel)
428
+ .setBatchSupport(
429
+ configAdapter.batchSupport,
430
+ configAdapter.requestPerBatch
431
+ )
432
+ .requestsInterval(
433
+ TimeUnit.MINUTES,
434
+ configAdapter.requestsIntervalMinutes.toLong()
435
+ )
436
+ .setEverId(configAdapter.everId)
437
+ .sendAppVersionInEveryRequest(configAdapter.versionInEachRequest)
438
+
439
+ if (configAdapter.shouldMigrate) builder.enableMigration()
440
+
441
+ if (!configAdapter.autoTracking) builder.disableAutoTracking()
442
+
443
+ if (!configAdapter.activityAutoTracking) builder.disableActivityAutoTracking()
444
+
445
+ if (!configAdapter.fragmentsAutoTracking) builder.disableFragmentsAutoTracking()
446
+
447
+ instance =
448
+ Webtrekk.getInstance().apply {
449
+ this.init(reactContext.applicationContext, builder.build())
450
+ this.anonymousTracking(configAdapter.anonymousTracking)
451
+ this.setTemporarySessionId(configAdapter.temporarySessionId)
452
+ }
453
+ promise.resolve(true)
454
+ println("MappIntelligence initialized!")
455
+ },
456
+ whenInitialized = {
457
+ promise.resolve(true)
458
+ println("MappIntelligence was already initialized!")
431
459
  }
432
- }, whenInitialized = {})
433
- promise.resolve(true)
460
+ )
434
461
  }
435
462
 
436
463
  /**
437
- * Helper function to execute actions based on Webtrekk instance state
438
- * Provide two functions as input parameters to be executed if instance is initialized or not
464
+ * Helper function to execute actions based on Webtrekk instance state Provide two functions as
465
+ * input parameters to be executed if instance is initialized or not
439
466
  */
440
467
  private fun runOnPlugin(whenInitialized: () -> Unit, whenNotInitialized: (() -> Unit)? = null) {
441
- if (::instance.isInitialized) whenInitialized.invoke()
442
- else whenNotInitialized?.invoke()
468
+ if (instance != null) {
469
+ whenInitialized.invoke()
470
+ } else {
471
+ whenNotInitialized?.invoke()
472
+ }
443
473
  }
444
474
 
445
475
  @ReactMethod
446
- private fun reset(promise: Promise) {
447
- runOnPlugin(whenInitialized = {
448
- reset { }
449
- })
476
+ override fun reset(promise: Promise) {
477
+ runOnPlugin(whenInitialized = { reset {} })
450
478
  promise.resolve(true)
451
479
  }
452
480
 
453
481
  /**
454
482
  * Reset underlying SDK and set new values via
455
- * @param presetAction - action that has access to WebtrekkConfiguration Builder
456
- * to change existing configuration and set new values
483
+ * @param presetAction
484
+ * - action that has access to WebtrekkConfiguration Builder to change existing configuration and
485
+ * set new values
457
486
  */
458
487
  private fun reset(presetAction: (WebtrekkConfiguration.Builder) -> Unit) {
459
488
  Webtrekk.reset(reactContext.applicationContext)
460
489
  val trackIds = configAdapter.trackIds
461
490
  val domain = configAdapter.trackDomain
462
491
 
463
- instance.setIdsAndDomain(trackIds,domain)
464
- // This requires some changes on native SDK
465
- // val builder = WebtrekkConfiguration.Builder(trackIds, domain)
466
- // presetAction.invoke(builder)
467
- // val config = builder.build()
468
- // Webtrekk.getInstance().init(reactContext.applicationContext, config = config)
469
- // instance = Webtrekk.getInstance()
492
+ instance?.setIdsAndDomain(trackIds, domain)
493
+ }
494
+
495
+ @ReactMethod
496
+ override fun getCurrentConfig(promise: Promise) {
497
+ runOnPlugin(
498
+ whenInitialized = {
499
+ val config = instance?.getCurrentConfiguration()
500
+ promise.resolve(config?.toString() ?: "")
501
+ },
502
+ whenNotInitialized = { promise.resolve("") }
503
+ )
504
+ }
505
+
506
+ @ReactMethod
507
+ override fun nativeCrash(promise: Promise) {
508
+ throw Exception("Native crash")
470
509
  }
471
510
 
472
511
  @ReactMethod
473
- fun getCurrentConfig(promise: Promise) {
474
- runOnPlugin(whenInitialized = {
475
- val config = Webtrekk.getInstance().getCurrentConfiguration()
476
- promise.resolve(config.toString())
477
- }, whenNotInitialized = {
478
- promise.resolve("")
479
- })
512
+ fun nativeCrash() {
513
+ throw Exception("Native crash");
480
514
  }
481
515
 
482
516
  override fun getName(): String {
483
517
  return NAME
484
518
  }
485
519
 
486
- companion object {
487
- const val NAME = "MappinteligencePlugin"
488
- }
520
+ override fun initialize() {}
521
+
522
+ override fun invalidate() {}
489
523
  }