affise-attribution-lib 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 +21 -0
- package/README.md +549 -0
- package/affise-attribution-native.podspec +37 -0
- package/android/build.gradle +87 -0
- package/android/gradle.properties +5 -0
- package/android/libs/attribution-release.aar +0 -0
- package/android/libs/oaid_sdk_1.0.26.aar +0 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/affise/attribution/react/AffiseAttributionNativeModule.kt +147 -0
- package/android/src/main/java/com/affise/attribution/react/AffiseAttributionNativePackage.kt +17 -0
- package/android/src/main/java/com/affise/attribution/react/ext/AffiseInitPropertiesExt.kt +29 -0
- package/android/src/main/java/com/affise/attribution/react/ext/AutoCatchingTypeExt.kt +15 -0
- package/android/src/main/java/com/affise/attribution/react/ext/JSONObjectExt.kt +15 -0
- package/android/src/main/java/com/affise/attribution/react/ext/PredefinedParametersExt.kt +82 -0
- package/android/src/main/java/com/affise/attribution/react/ext/TouchTypeExt.kt +12 -0
- package/android/src/main/java/com/affise/attribution/react/factories/AffiseBaseEvensFactory.kt +97 -0
- package/android/src/main/java/com/affise/attribution/react/factories/AffiseEvensFactory.kt +781 -0
- package/android/src/main/java/com/affise/attribution/react/factories/AffiseSubtypeEventsFactory.kt +266 -0
- package/ios/AffiseAttributionNative-Bridging-Header.h +3 -0
- package/ios/AffiseAttributionNative.m +90 -0
- package/ios/AffiseAttributionNative.swift +148 -0
- package/ios/AffiseAttributionNative.xcodeproj/project.pbxproj +305 -0
- package/ios/extensions/AffiseInitPropertiesExt.swift +29 -0
- package/ios/extensions/PredefinedParametersExt.swift +83 -0
- package/ios/extensions/TouchTypeExt.swift +13 -0
- package/ios/factories/AffiseBaseEvensFactory.swift +110 -0
- package/ios/factories/AffiseEvensFactory.swift +782 -0
- package/ios/factories/AffiseSubtypeEventsFactory.swift +261 -0
- package/ios/log/Log.swift +19 -0
- package/ios/log/RCTSwiftLog.h +16 -0
- package/ios/log/RCTSwiftLog.m +32 -0
- package/package.json +162 -0
- package/src/AffiseInitProperties.ts +32 -0
- package/src/Export.ts +73 -0
- package/src/events/AutoCatchingType.ts +9 -0
- package/src/events/PredefinedParameters.ts +75 -0
- package/src/events/TouchType.ts +5 -0
- package/src/events/base/AffiseEvent.ts +60 -0
- package/src/events/base/NativeEvent.ts +9 -0
- package/src/events/custom/CustomId01Event.ts +21 -0
- package/src/events/custom/CustomId02Event.ts +21 -0
- package/src/events/custom/CustomId03Event.ts +21 -0
- package/src/events/custom/CustomId04Event.ts +21 -0
- package/src/events/custom/CustomId05Event.ts +21 -0
- package/src/events/custom/CustomId06Event.ts +21 -0
- package/src/events/custom/CustomId07Event.ts +21 -0
- package/src/events/custom/CustomId08Event.ts +21 -0
- package/src/events/custom/CustomId09Event.ts +21 -0
- package/src/events/custom/CustomId10Event.ts +21 -0
- package/src/events/predefined/AchieveLevelEvent.ts +14 -0
- package/src/events/predefined/AddPaymentInfoEvent.ts +14 -0
- package/src/events/predefined/AddToCartEvent.ts +14 -0
- package/src/events/predefined/AddToWishlistEvent.ts +14 -0
- package/src/events/predefined/ClickAdvEvent.ts +14 -0
- package/src/events/predefined/CompleteRegistrationEvent.ts +14 -0
- package/src/events/predefined/CompleteStreamEvent.ts +14 -0
- package/src/events/predefined/CompleteTrialEvent.ts +14 -0
- package/src/events/predefined/CompleteTutorialEvent.ts +14 -0
- package/src/events/predefined/ContentItemsViewEvent.ts +13 -0
- package/src/events/predefined/DeepLinkedEvent.ts +13 -0
- package/src/events/predefined/InitiatePurchaseEvent.ts +14 -0
- package/src/events/predefined/InitiateStreamEvent.ts +14 -0
- package/src/events/predefined/InviteEvent.ts +14 -0
- package/src/events/predefined/LastAttributedTouchEvent.ts +15 -0
- package/src/events/predefined/ListViewEvent.ts +13 -0
- package/src/events/predefined/LoginEvent.ts +14 -0
- package/src/events/predefined/OpenedFromPushNotificationEvent.ts +13 -0
- package/src/events/predefined/PurchaseEvent.ts +14 -0
- package/src/events/predefined/RateEvent.ts +14 -0
- package/src/events/predefined/ReEngageEvent.ts +13 -0
- package/src/events/predefined/ReserveEvent.ts +14 -0
- package/src/events/predefined/SearchEvent.ts +14 -0
- package/src/events/predefined/ShareEvent.ts +14 -0
- package/src/events/predefined/SpendCreditsEvent.ts +14 -0
- package/src/events/predefined/StartRegistrationEvent.ts +14 -0
- package/src/events/predefined/StartTrialEvent.ts +14 -0
- package/src/events/predefined/StartTutorialEvent.ts +14 -0
- package/src/events/predefined/SubscribeEvent.ts +14 -0
- package/src/events/predefined/TravelBookingEvent.ts +13 -0
- package/src/events/predefined/UnlockAchievementEvent.ts +14 -0
- package/src/events/predefined/UnsubscribeEvent.ts +14 -0
- package/src/events/predefined/UpdateEvent.ts +13 -0
- package/src/events/predefined/ViewAdvEvent.ts +14 -0
- package/src/events/predefined/ViewCartEvent.ts +13 -0
- package/src/events/predefined/ViewItemEvent.ts +13 -0
- package/src/events/predefined/ViewItemsEvent.ts +13 -0
- package/src/events/subscription/BaseSubscriptionEvent.ts +32 -0
- package/src/events/subscription/ConvertedOfferEvent.ts +13 -0
- package/src/events/subscription/ConvertedOfferFromRetryEvent.ts +14 -0
- package/src/events/subscription/ConvertedTrialEvent.ts +13 -0
- package/src/events/subscription/ConvertedTrialFromRetryEvent.ts +13 -0
- package/src/events/subscription/FailedOfferFromRetryEvent.ts +13 -0
- package/src/events/subscription/FailedOfferiseEvent.ts +13 -0
- package/src/events/subscription/FailedSubscriptionEvent.ts +13 -0
- package/src/events/subscription/FailedSubscriptionFromRetryEvent.ts +13 -0
- package/src/events/subscription/FailedTrialEvent.ts +13 -0
- package/src/events/subscription/FailedTrialFromRetryEvent.ts +13 -0
- package/src/events/subscription/InitialOfferEvent.ts +13 -0
- package/src/events/subscription/InitialSubscriptionEvent.ts +13 -0
- package/src/events/subscription/InitialTrialEvent.ts +13 -0
- package/src/events/subscription/OfferInRetryEvent.ts +13 -0
- package/src/events/subscription/ReactivatedSubscriptionEvent.ts +13 -0
- package/src/events/subscription/RenewedSubscriptionEvent.ts +13 -0
- package/src/events/subscription/RenewedSubscriptionFromRetryEvent.ts +13 -0
- package/src/events/subscription/SubscriptionInRetryEvent.ts +13 -0
- package/src/events/subscription/SubscriptionParameters.ts +36 -0
- package/src/events/subscription/TrialInRetryEvent.ts +13 -0
- package/src/index.tsx +172 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
package com.affise.attribution.react
|
|
2
|
+
|
|
3
|
+
import android.app.Application
|
|
4
|
+
import android.net.Uri
|
|
5
|
+
import com.affise.attribution.Affise
|
|
6
|
+
import com.affise.attribution.react.ext.toAffiseInitProperties
|
|
7
|
+
import com.affise.attribution.react.ext.toAutoCatchingType
|
|
8
|
+
import com.affise.attribution.react.factories.AffiseEvensFactory
|
|
9
|
+
import com.facebook.react.bridge.*
|
|
10
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class AffiseAttributionNativeModule(
|
|
14
|
+
val reactContext: ReactApplicationContext
|
|
15
|
+
) : ReactContextBaseJavaModule(reactContext) {
|
|
16
|
+
|
|
17
|
+
private var evensFactory: AffiseEvensFactory = AffiseEvensFactory()
|
|
18
|
+
|
|
19
|
+
private fun sendEvent(reactContext: ReactContext, eventName: String, params: WritableMap?) {
|
|
20
|
+
reactContext
|
|
21
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
22
|
+
.emit(eventName, params)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private fun sendDeeplinkEvent(uri: Uri) {
|
|
26
|
+
sendEvent(reactContext, DEEPLINK_CALLBACK_EVENT, Arguments.createMap().apply {
|
|
27
|
+
putString(DEEPLINK_CALLBACK_URI_PARAMETER, uri.toString())
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
override fun getName(): String {
|
|
32
|
+
return NAME
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@ReactMethod
|
|
36
|
+
fun nativeInit(initProperties: ReadableMap) {
|
|
37
|
+
(reactContext.applicationContext as? Application)?.let { application ->
|
|
38
|
+
Affise.init(application, initProperties.toHashMap().toAffiseInitProperties())
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@ReactMethod
|
|
43
|
+
fun nativeSendEvents() {
|
|
44
|
+
Affise.sendEvents()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@ReactMethod
|
|
48
|
+
fun nativeSendEvent(event: ReadableMap) {
|
|
49
|
+
evensFactory.event(event.toHashMap())?.let {
|
|
50
|
+
Affise.sendEvent(it)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@ReactMethod
|
|
55
|
+
fun nativeAddPushToken(pushToken: String) {
|
|
56
|
+
Affise.addPushToken(pushToken)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@ReactMethod
|
|
61
|
+
fun nativeRegisterDeeplinkCallback() {
|
|
62
|
+
Affise.registerDeeplinkCallback {
|
|
63
|
+
sendDeeplinkEvent(it)
|
|
64
|
+
true
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@ReactMethod
|
|
69
|
+
fun addListener(eventName: String) {
|
|
70
|
+
// Set up any upstream listeners or background tasks as necessary
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@ReactMethod
|
|
74
|
+
fun removeListeners(count: Int) {
|
|
75
|
+
// Remove upstream listeners, stop unnecessary background tasks
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@ReactMethod
|
|
79
|
+
fun nativeSetSecretId(secretId: String) {
|
|
80
|
+
Affise.setSecretId(secretId)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@ReactMethod
|
|
84
|
+
fun nativeSetAutoCatchingTypes(types: ReadableArray) {
|
|
85
|
+
val autoCatchingTypes = types.toArrayList().mapNotNull {
|
|
86
|
+
it.toString().toAutoCatchingType()
|
|
87
|
+
}
|
|
88
|
+
Affise.setAutoCatchingTypes(autoCatchingTypes)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@ReactMethod
|
|
92
|
+
fun nativeSetOfflineModeEnabled(enabled: Boolean) {
|
|
93
|
+
Affise.setOfflineModeEnabled(enabled)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@ReactMethod
|
|
97
|
+
fun nativeIsOfflineModeEnabled(result: Promise) {
|
|
98
|
+
result.resolve(Affise.isOfflineModeEnabled())
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@ReactMethod
|
|
102
|
+
fun nativeSetBackgroundTrackingEnabled(enabled: Boolean) {
|
|
103
|
+
Affise.setBackgroundTrackingEnabled(enabled)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@ReactMethod
|
|
107
|
+
fun nativeIsBackgroundTrackingEnabled(result: Promise) {
|
|
108
|
+
result.resolve(Affise.isBackgroundTrackingEnabled())
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@ReactMethod
|
|
112
|
+
fun nativeSetTrackingEnabled(enabled: Boolean) {
|
|
113
|
+
Affise.setTrackingEnabled(enabled)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@ReactMethod
|
|
117
|
+
fun nativeIsTrackingEnabled(result: Promise) {
|
|
118
|
+
result.resolve(Affise.isTrackingEnabled())
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@ReactMethod
|
|
122
|
+
fun nativeForget(userData: String) {
|
|
123
|
+
Affise.forget(userData)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@ReactMethod
|
|
127
|
+
fun nativeSetEnabledMetrics(enabled: Boolean) {
|
|
128
|
+
Affise.setEnabledMetrics(enabled)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@ReactMethod
|
|
132
|
+
fun nativeCrashApplication() {
|
|
133
|
+
Affise.crashApplication()
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@ReactMethod
|
|
137
|
+
fun nativeGetReferrer(result: Promise) {
|
|
138
|
+
result.resolve(Affise.getReferrer())
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
companion object {
|
|
142
|
+
const val NAME = "AffiseAttributionNative"
|
|
143
|
+
|
|
144
|
+
private const val DEEPLINK_CALLBACK_EVENT = "affiseDeeplinkEvent"
|
|
145
|
+
private const val DEEPLINK_CALLBACK_URI_PARAMETER = "uri"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.affise.attribution.react
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AffiseAttributionNativePackage : ReactPackage {
|
|
10
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
11
|
+
return listOf(AffiseAttributionNativeModule(reactContext))
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
15
|
+
return emptyList()
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package com.affise.attribution.react.ext
|
|
2
|
+
|
|
3
|
+
import com.affise.attribution.init.AffiseInitProperties
|
|
4
|
+
|
|
5
|
+
internal object AffisePropertiesFields {
|
|
6
|
+
const val FIELD_AFFISE_APP_ID = "affiseAppId"
|
|
7
|
+
const val FIELD_PART_PARAM_NAME = "partParamName"
|
|
8
|
+
const val FIELD_PART_PARAM_NAME_TOKEN = "partParamNameToken"
|
|
9
|
+
const val FIELD_APP_TOKEN = "appToken"
|
|
10
|
+
const val FIELD_SECRET_ID = "secretId"
|
|
11
|
+
const val FIELD_AUTO_CATCHING_CLICK_EVENTS = "autoCatchingClickEvents"
|
|
12
|
+
const val FIELD_IS_PRODUCTION = "isProduction"
|
|
13
|
+
const val FIELD_ENABLED_METRICS = "enabledMetrics"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
fun Map<*, *>.toAffiseInitProperties(): AffiseInitProperties {
|
|
17
|
+
return AffiseInitProperties(
|
|
18
|
+
this[AffisePropertiesFields.FIELD_AFFISE_APP_ID]?.toString(),
|
|
19
|
+
(this[AffisePropertiesFields.FIELD_IS_PRODUCTION] as? Boolean) ?: false,
|
|
20
|
+
this[AffisePropertiesFields.FIELD_PART_PARAM_NAME]?.toString(),
|
|
21
|
+
this[AffisePropertiesFields.FIELD_PART_PARAM_NAME_TOKEN]?.toString(),
|
|
22
|
+
this[AffisePropertiesFields.FIELD_APP_TOKEN]?.toString(),
|
|
23
|
+
this[AffisePropertiesFields.FIELD_SECRET_ID]?.toString(),
|
|
24
|
+
(this[AffisePropertiesFields.FIELD_AUTO_CATCHING_CLICK_EVENTS] as? List<*>)?.mapNotNull {
|
|
25
|
+
it.toString().toAutoCatchingType()
|
|
26
|
+
},
|
|
27
|
+
this[AffisePropertiesFields.FIELD_ENABLED_METRICS]?.toString()?.toBoolean() ?: false
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
package com.affise.attribution.react.ext
|
|
2
|
+
|
|
3
|
+
import com.affise.attribution.events.autoCatchingClick.AutoCatchingType
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
fun String.toAutoCatchingType(): AutoCatchingType? {
|
|
7
|
+
return when (this) {
|
|
8
|
+
"BUTTON" -> AutoCatchingType.BUTTON
|
|
9
|
+
"TEXT" -> AutoCatchingType.TEXT
|
|
10
|
+
"IMAGE_BUTTON" -> AutoCatchingType.IMAGE_BUTTON
|
|
11
|
+
"IMAGE" -> AutoCatchingType.IMAGE
|
|
12
|
+
"GROUP" -> AutoCatchingType.GROUP
|
|
13
|
+
else -> null
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
package com.affise.attribution.react.ext
|
|
2
|
+
|
|
3
|
+
import android.util.Log
|
|
4
|
+
import org.json.JSONObject
|
|
5
|
+
|
|
6
|
+
fun Map<*,*>?.toJSONObject(): JSONObject? {
|
|
7
|
+
return this?.let {
|
|
8
|
+
try {
|
|
9
|
+
JSONObject(it)
|
|
10
|
+
} catch (e: Exception) {
|
|
11
|
+
Log.d("JSONObjectExt", e.stackTraceToString())
|
|
12
|
+
null
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
package com.affise.attribution.react.ext
|
|
2
|
+
|
|
3
|
+
import com.affise.attribution.events.predefined.PredefinedParameters
|
|
4
|
+
|
|
5
|
+
fun String.toPredefinedParameters(): PredefinedParameters? {
|
|
6
|
+
return when (this) {
|
|
7
|
+
"affise_p_adrev_ad_type" -> PredefinedParameters.ADREV_AD_TYPE
|
|
8
|
+
"affise_p_city" -> PredefinedParameters.CITY
|
|
9
|
+
"affise_p_country" -> PredefinedParameters.COUNTRY
|
|
10
|
+
"affise_p_region" -> PredefinedParameters.REGION
|
|
11
|
+
"affise_p_class" -> PredefinedParameters.CLASS
|
|
12
|
+
"affise_p_content" -> PredefinedParameters.CONTENT
|
|
13
|
+
"affise_p_content_id" -> PredefinedParameters.CONTENT_ID
|
|
14
|
+
"affise_p_content_list" -> PredefinedParameters.CONTENT_LIST
|
|
15
|
+
"affise_p_content_type" -> PredefinedParameters.CONTENT_TYPE
|
|
16
|
+
"affise_p_currency" -> PredefinedParameters.CURRENCY
|
|
17
|
+
"affise_p_customer_user_id" -> PredefinedParameters.CUSTOMER_USER_ID
|
|
18
|
+
"affise_p_date_a" -> PredefinedParameters.DATE_A
|
|
19
|
+
"affise_p_date_b" -> PredefinedParameters.DATE_B
|
|
20
|
+
"affise_p_departing_arrival_date" -> PredefinedParameters.DEPARTING_ARRIVAL_DATE
|
|
21
|
+
"affise_p_departing_departure_date" -> PredefinedParameters.DEPARTING_DEPARTURE_DATE
|
|
22
|
+
"affise_p_description" -> PredefinedParameters.DESCRIPTION
|
|
23
|
+
"affise_p_destination_a" -> PredefinedParameters.DESTINATION_A
|
|
24
|
+
"affise_p_destination_b" -> PredefinedParameters.DESTINATION_B
|
|
25
|
+
"affise_p_destination_list" -> PredefinedParameters.DESTINATION_LIST
|
|
26
|
+
"affise_p_hotel_score" -> PredefinedParameters.HOTEL_SCORE
|
|
27
|
+
"affise_p_level" -> PredefinedParameters.LEVEL
|
|
28
|
+
"affise_p_max_rating_value" -> PredefinedParameters.MAX_RATING_VALUE
|
|
29
|
+
"affise_p_num_adults" -> PredefinedParameters.NUM_ADULTS
|
|
30
|
+
"affise_p_num_children" -> PredefinedParameters.NUM_CHILDREN
|
|
31
|
+
"affise_p_num_infants" -> PredefinedParameters.NUM_INFANTS
|
|
32
|
+
"affise_p_order_id" -> PredefinedParameters.ORDER_ID
|
|
33
|
+
"affise_p_payment_info_available" -> PredefinedParameters.PAYMENT_INFO_AVAILABLE
|
|
34
|
+
"affise_p_preferred_neighborhoods" -> PredefinedParameters.PREFERRED_NEIGHBORHOODS
|
|
35
|
+
"affise_p_preferred_num_stops" -> PredefinedParameters.PREFERRED_NUM_STOPS
|
|
36
|
+
"affise_p_preferred_price_range" -> PredefinedParameters.PREFERRED_PRICE_RANGE
|
|
37
|
+
"affise_p_preferred_star_ratings" -> PredefinedParameters.PREFERRED_STAR_RATINGS
|
|
38
|
+
"affise_p_price" -> PredefinedParameters.PRICE
|
|
39
|
+
"affise_p_purchase_currency" -> PredefinedParameters.PURCHASE_CURRENCY
|
|
40
|
+
"affise_p_quantity" -> PredefinedParameters.QUANTITY
|
|
41
|
+
"affise_p_rating_value" -> PredefinedParameters.RATING_VALUE
|
|
42
|
+
"affise_p_receipt_id" -> PredefinedParameters.RECEIPT_ID
|
|
43
|
+
"affise_p_registration_method" -> PredefinedParameters.REGISTRATION_METHOD
|
|
44
|
+
"affise_p_returning_arrival_date" -> PredefinedParameters.RETURNING_ARRIVAL_DATE
|
|
45
|
+
"affise_p_returning_departure_date" -> PredefinedParameters.RETURNING_DEPARTURE_DATE
|
|
46
|
+
"affise_p_revenue" -> PredefinedParameters.REVENUE
|
|
47
|
+
"affise_p_score" -> PredefinedParameters.SCORE
|
|
48
|
+
"affise_p_search_string" -> PredefinedParameters.SEARCH_STRING
|
|
49
|
+
"affise_p_subscription_id" -> PredefinedParameters.SUBSCRIPTION_ID
|
|
50
|
+
"affise_p_success" -> PredefinedParameters.SUCCESS
|
|
51
|
+
"affise_p_suggested_destinations" -> PredefinedParameters.SUGGESTED_DESTINATIONS
|
|
52
|
+
"affise_p_suggested_hotels" -> PredefinedParameters.SUGGESTED_HOTELS
|
|
53
|
+
"affise_p_travel_start" -> PredefinedParameters.TRAVEL_START
|
|
54
|
+
"affise_p_travel_end" -> PredefinedParameters.TRAVEL_END
|
|
55
|
+
"affise_p_user_score" -> PredefinedParameters.USER_SCORE
|
|
56
|
+
"affise_p_validated" -> PredefinedParameters.VALIDATED
|
|
57
|
+
"affise_p_achievement_id" -> PredefinedParameters.ACHIEVEMENT_ID
|
|
58
|
+
"affise_p_coupon_code" -> PredefinedParameters.COUPON_CODE
|
|
59
|
+
"affise_p_customer_segment" -> PredefinedParameters.CUSTOMER_SEGMENT
|
|
60
|
+
"affise_p_deep_link" -> PredefinedParameters.DEEP_LINK
|
|
61
|
+
"affise_p_event_start" -> PredefinedParameters.EVENT_START
|
|
62
|
+
"affise_p_event_end" -> PredefinedParameters.EVENT_END
|
|
63
|
+
"affise_p_lat" -> PredefinedParameters.LAT
|
|
64
|
+
"affise_p_long" -> PredefinedParameters.LONG
|
|
65
|
+
"affise_p_new_version" -> PredefinedParameters.NEW_VERSION
|
|
66
|
+
"affise_p_old_version" -> PredefinedParameters.OLD_VERSION
|
|
67
|
+
"affise_p_param_01" -> PredefinedParameters.PARAM_01
|
|
68
|
+
"affise_p_param_02" -> PredefinedParameters.PARAM_02
|
|
69
|
+
"affise_p_param_03" -> PredefinedParameters.PARAM_03
|
|
70
|
+
"affise_p_param_04" -> PredefinedParameters.PARAM_04
|
|
71
|
+
"affise_p_param_05" -> PredefinedParameters.PARAM_05
|
|
72
|
+
"affise_p_param_06" -> PredefinedParameters.PARAM_06
|
|
73
|
+
"affise_p_param_07" -> PredefinedParameters.PARAM_07
|
|
74
|
+
"affise_p_param_08" -> PredefinedParameters.PARAM_08
|
|
75
|
+
"affise_p_param_09" -> PredefinedParameters.PARAM_09
|
|
76
|
+
"affise_p_param_10" -> PredefinedParameters.PARAM_10
|
|
77
|
+
"affise_p_review_text" -> PredefinedParameters.REVIEW_TEXT
|
|
78
|
+
"affise_p_tutorial_id" -> PredefinedParameters.TUTORIAL_ID
|
|
79
|
+
"affise_p_virtual_currency_name" -> PredefinedParameters.VIRTUAL_CURRENCY_NAME
|
|
80
|
+
else -> null
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.affise.attribution.react.ext
|
|
2
|
+
|
|
3
|
+
import com.affise.attribution.events.predefined.TouchType
|
|
4
|
+
|
|
5
|
+
fun String.toTouchType(): TouchType? {
|
|
6
|
+
return when (this) {
|
|
7
|
+
"CLICK" -> TouchType.CLICK
|
|
8
|
+
"WEB_TO_APP_AUTO_REDIRECT" -> TouchType.WEB_TO_APP_AUTO_REDIRECT
|
|
9
|
+
"IMPRESSION" -> TouchType.IMPRESSION
|
|
10
|
+
else -> null
|
|
11
|
+
}
|
|
12
|
+
}
|
package/android/src/main/java/com/affise/attribution/react/factories/AffiseBaseEvensFactory.kt
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
package com.affise.attribution.react.factories
|
|
2
|
+
|
|
3
|
+
import com.affise.attribution.events.Event
|
|
4
|
+
import com.affise.attribution.react.ext.toJSONObject
|
|
5
|
+
import com.affise.attribution.react.ext.toPredefinedParameters
|
|
6
|
+
import org.json.JSONArray
|
|
7
|
+
import org.json.JSONObject
|
|
8
|
+
|
|
9
|
+
abstract class AffiseBaseEvensFactory {
|
|
10
|
+
|
|
11
|
+
companion object {
|
|
12
|
+
private const val KEY_SERIALIZE = "serialize"
|
|
13
|
+
private const val KEY_USERDATA = "userData"
|
|
14
|
+
private const val KEY_PREDEFINED_PARAMETERS = "predefinedParameters"
|
|
15
|
+
|
|
16
|
+
const val KEY_NAME = "name"
|
|
17
|
+
const val KEY_SUBTYPE = "subtype"
|
|
18
|
+
const val KEY_DATA = "data"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
abstract fun event(map: Map<*, *>?): Event?
|
|
22
|
+
|
|
23
|
+
private fun getSerialize(map: Map<*, *>): Map<*, *>? {
|
|
24
|
+
return map[KEY_SERIALIZE] as? Map<*, *>
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private fun getSerializeKey(map: Map<*, *>, key: String): Any? {
|
|
28
|
+
return getSerialize(map)?.get(key)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private fun getSerializeMap(map: Map<*, *>, dataKey: String): Map<*, *> {
|
|
32
|
+
return getSerializeKey(map, dataKey) as? Map<*, *>
|
|
33
|
+
?: emptyMap<String, Any?>()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private fun getSerializeList(map: Map<*, *>, dataKey: String): List<*> {
|
|
37
|
+
return getSerializeKey(map, dataKey) as? List<*>
|
|
38
|
+
?: emptyList<Any>()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
protected fun getSerializeStringOrNull(map: Map<*, *>, dataKey: String): String? {
|
|
42
|
+
return getSerializeKey(map, dataKey)?.toString()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
protected fun getSerializeString(map: Map<*, *>, dataKey: String): String {
|
|
46
|
+
return getSerializeKey(map, dataKey)?.toString() ?: ""
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
protected fun getJSONObjectOrNull(map: Map<*, *>, key: String): JSONObject? {
|
|
50
|
+
return getSerializeMap(map, key).toJSONObject()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
protected fun getJSONObject(map: Map<*, *>, key: String): JSONObject {
|
|
54
|
+
return getSerializeMap(map, key).toJSONObject() ?: JSONObject()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
protected fun addPredefinedParameters(event: Event, map: Map<*, *>) {
|
|
58
|
+
(map[KEY_PREDEFINED_PARAMETERS] as? Map<*, *>)?.map {
|
|
59
|
+
it.key?.toString()?.toPredefinedParameters() to it.value.toString()
|
|
60
|
+
}?.toMap()?.forEach { entry ->
|
|
61
|
+
entry.key?.let {
|
|
62
|
+
event.addPredefinedParameter(it, entry.value)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
protected fun getUserData(map: Map<*, *>): String? {
|
|
68
|
+
return map[KEY_USERDATA]?.toString()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
protected fun getUserDataAndTimeStamp(map: Map<*, *>, timeStampKey: String): Pair<Long, String?> {
|
|
72
|
+
val timeStamp = getSerializeStringOrNull(map, timeStampKey)?.toLong() ?: 0L
|
|
73
|
+
val userData = getUserData(map)
|
|
74
|
+
return Pair(timeStamp, userData)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
protected fun getJsonList(map: Map<*, *>, dataKey: String): List<JSONObject> {
|
|
78
|
+
val data = getSerializeList(map, dataKey)
|
|
79
|
+
|
|
80
|
+
val jsonList = JSONArray(data).let { jsonArray ->
|
|
81
|
+
val list = mutableListOf<JSONObject>()
|
|
82
|
+
for (i in 0 until jsonArray.length()) {
|
|
83
|
+
jsonArray.getJSONObject(i)?.let {
|
|
84
|
+
list.add(it)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return@let list
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return jsonList
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
protected fun getJSONArray(map: Map<*, *>, dataKey: String): JSONArray {
|
|
94
|
+
val data = getSerializeList(map, dataKey)
|
|
95
|
+
return JSONArray(data)
|
|
96
|
+
}
|
|
97
|
+
}
|