@amplitude/plugin-engagement-react-native 3.3.1 → 3.5.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/PluginEngagementReactNative.podspec +4 -2
- package/android/build.gradle +3 -1
- package/android/src/main/java/com/amplitude/pluginengagementreactnative/PluginEngagementReactNativeModule.kt +251 -199
- package/android/src/main/java/com/amplitude/pluginengagementreactnative/PluginEngagementReactNativePackage.kt +27 -19
- package/android/src/main/java/com/amplitude/pluginengagementreactnative/Util.kt +35 -36
- package/ios/AmplitudeEngagementAdapter.swift +5 -2
- package/lib/module/AmplitudeEngagement.js +5 -2
- package/lib/module/AmplitudeEngagement.js.map +1 -1
- package/lib/module/AmplitudeEngagementPlugin.js +6 -6
- package/lib/module/AmplitudeEngagementPlugin.js.map +1 -1
- package/lib/module/build-version-android.json +3 -0
- package/lib/module/build-version-ios.json +3 -0
- package/lib/module/build-version.json +3 -1
- package/lib/module/constants.js +12 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/typescript/src/AmplitudeEngagement.d.ts.map +1 -1
- package/lib/typescript/src/AmplitudeEngagementPlugin.d.ts +0 -2
- package/lib/typescript/src/AmplitudeEngagementPlugin.d.ts.map +1 -1
- package/lib/typescript/src/constants.d.ts +7 -0
- package/lib/typescript/src/constants.d.ts.map +1 -0
- package/package.json +4 -3
- package/src/AmplitudeEngagement.ts +5 -2
- package/src/AmplitudeEngagementPlugin.ts +11 -6
- package/src/build-version-android.json +3 -0
- package/src/build-version-ios.json +3 -0
- package/src/build-version.json +1 -1
- package/src/constants.ts +10 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
require "json"
|
|
2
2
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
version =JSON.parse(File.read(File.join(__dir__, "src/build-version-ios.json")))
|
|
5
|
+
engagement_version = version["version"]
|
|
4
6
|
|
|
5
7
|
Pod::Spec.new do |s|
|
|
6
8
|
s.name = "PluginEngagementReactNative"
|
|
@@ -31,9 +33,9 @@ Pod::Spec.new do |s|
|
|
|
31
33
|
'ios/Frameworks/AmplitudeEngagementSwift.xcframework',
|
|
32
34
|
'ios/Frameworks/CQuickJS.xcframework',
|
|
33
35
|
]
|
|
34
|
-
s.dependency 'AmplitudeCore', '>=1.0
|
|
36
|
+
s.dependency 'AmplitudeCore', '>=1.3.0', '<2.0.0'
|
|
35
37
|
else
|
|
36
|
-
s.dependency "AmplitudeEngagementSwift",
|
|
38
|
+
s.dependency "AmplitudeEngagementSwift", engagement_version
|
|
37
39
|
end
|
|
38
40
|
|
|
39
41
|
install_modules_dependencies(s)
|
package/android/build.gradle
CHANGED
|
@@ -80,13 +80,15 @@ repositories {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
83
|
+
def versions = new groovy.json.JsonSlurper().parse(file("../src/build-version-android.json"))
|
|
84
|
+
def androidVersion = versions["version"]
|
|
83
85
|
|
|
84
86
|
dependencies {
|
|
85
87
|
implementation "com.facebook.react:react-android"
|
|
86
88
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
87
89
|
|
|
88
90
|
// Amplitude Engagement SDK
|
|
89
|
-
implementation "com.amplitude:amplitude-engagement-android
|
|
91
|
+
implementation "com.amplitude:amplitude-engagement-android:${androidVersion}"
|
|
90
92
|
|
|
91
93
|
// Amplitude Analytics SDK (required dependency)
|
|
92
94
|
implementation "com.amplitude:analytics-android:1.+"
|
|
@@ -23,238 +23,290 @@ import com.amplitude.android.engagement.AmplitudeLogLevel
|
|
|
23
23
|
|
|
24
24
|
@ReactModule(name = PluginEngagementReactNativeModule.NAME)
|
|
25
25
|
class PluginEngagementReactNativeModule(val reactContext: ReactApplicationContext) :
|
|
26
|
-
|
|
26
|
+
NativePluginEngagementReactNativeSpec(reactContext) {
|
|
27
|
+
private data class InstanceInfo(val apiKey: String, val instance: AmplitudeEngagement)
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
private var instances = ConcurrentHashMap<Double, InstanceInfo>()
|
|
30
|
+
private var nextId: Double = 0.0
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
override fun getName(): String {
|
|
34
|
-
return NAME
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
override fun newInstance(apiKey: String, options: ReadableMap?): Double {
|
|
38
|
-
// --- remove this comment ---
|
|
39
|
-
val existingId = instances.entries.firstOrNull { it.value.apiKey == apiKey }?.key
|
|
40
|
-
if (existingId != null) {
|
|
41
|
-
return existingId
|
|
32
|
+
override fun getName(): String {
|
|
33
|
+
return NAME
|
|
42
34
|
}
|
|
43
35
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
} ?: AmplitudeLogLevel.WARN
|
|
53
|
-
|
|
54
|
-
val locale = if (options?.hasKey("locale") == true) options.getString("locale") else null
|
|
55
|
-
val ignoreAnalyticsAutomaticScreenTracking = if (options?.hasKey("ignoreAnalyticsAutomaticScreenTracking") == true) options.getBoolean("ignoreAnalyticsAutomaticScreenTracking") else null
|
|
56
|
-
|
|
57
|
-
val serverUrl = if (options?.hasKey("serverUrl") == true) options.getString("serverUrl") else null
|
|
58
|
-
val cdnUrl = if (options?.hasKey("cdnUrl") == true) options.getString("cdnUrl") else null
|
|
59
|
-
val mediaUrl = if (options?.hasKey("mediaUrl") == true) options.getString("mediaUrl") else null
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var initOptions = AmplitudeInitOptions(
|
|
63
|
-
serverZone = serverZone,
|
|
64
|
-
serverUrl = serverUrl,
|
|
65
|
-
cdnUrl = cdnUrl,
|
|
66
|
-
mediaUrl = mediaUrl,
|
|
67
|
-
logLevel = logLevel
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
if(locale != null) {
|
|
71
|
-
// this way, we get the default value for `locale` from AmplitudeInitOptions
|
|
72
|
-
// UNLESS a locale is specified
|
|
73
|
-
initOptions = initOptions.copy(locale = locale)
|
|
36
|
+
override fun newInstance(
|
|
37
|
+
apiKey: String,
|
|
38
|
+
options: ReadableMap?,
|
|
39
|
+
): Double {
|
|
40
|
+
// --- remove this comment ---
|
|
41
|
+
val existingId = instances.entries.firstOrNull { it.value.apiKey == apiKey }?.key
|
|
42
|
+
if (existingId != null) {
|
|
43
|
+
return existingId
|
|
74
44
|
}
|
|
75
45
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
46
|
+
return synchronized(this) {
|
|
47
|
+
runBlocking(Dispatchers.Main) {
|
|
48
|
+
val serverZone =
|
|
49
|
+
options?.getString("serverZone")?.let {
|
|
50
|
+
runCatching { AmplitudeServerZone.valueOf(it) }.getOrNull()
|
|
51
|
+
} ?: AmplitudeServerZone.US
|
|
52
|
+
|
|
53
|
+
val logLevel =
|
|
54
|
+
options?.getString("logLevel")?.let { level ->
|
|
55
|
+
runCatching { AmplitudeLogLevel.valueOf(level.uppercase()) }.getOrNull()
|
|
56
|
+
} ?: AmplitudeLogLevel.WARN
|
|
57
|
+
|
|
58
|
+
val locale = if (options?.hasKey("locale") == true) options.getString("locale") else null
|
|
59
|
+
val ignoreAnalyticsAutomaticScreenTracking =
|
|
60
|
+
if (options?.hasKey("ignoreAnalyticsAutomaticScreenTracking") == true) {
|
|
61
|
+
options.getBoolean(
|
|
62
|
+
"ignoreAnalyticsAutomaticScreenTracking",
|
|
63
|
+
)
|
|
64
|
+
} else {
|
|
65
|
+
null
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
val serverUrl = if (options?.hasKey("serverUrl") == true) options.getString("serverUrl") else null
|
|
69
|
+
val cdnUrl = if (options?.hasKey("cdnUrl") == true) options.getString("cdnUrl") else null
|
|
70
|
+
val mediaUrl = if (options?.hasKey("mediaUrl") == true) options.getString("mediaUrl") else null
|
|
71
|
+
|
|
72
|
+
var initOptions =
|
|
73
|
+
AmplitudeInitOptions(
|
|
74
|
+
serverZone = serverZone,
|
|
75
|
+
serverUrl = serverUrl,
|
|
76
|
+
cdnUrl = cdnUrl,
|
|
77
|
+
mediaUrl = mediaUrl,
|
|
78
|
+
logLevel = logLevel,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
if (locale != null) {
|
|
82
|
+
// this way, we get the default value for `locale` from AmplitudeInitOptions
|
|
83
|
+
// UNLESS a locale is specified
|
|
84
|
+
initOptions = initOptions.copy(locale = locale)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (ignoreAnalyticsAutomaticScreenTracking != null) {
|
|
88
|
+
// this way, we get the default value for `ignoreAnalyticsAutomaticScreenTracking`
|
|
89
|
+
// from AmplitudeInitOptions UNLESS a value is specified
|
|
90
|
+
initOptions = initOptions.copy(ignoreAnalyticsAutomaticScreenTracking = ignoreAnalyticsAutomaticScreenTracking)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
val platformVersion = options?.getString("platformVersion") ?: ""
|
|
94
|
+
|
|
95
|
+
Log.d("PluginEngagementReactNativeModule", "newInstance apiKey=$apiKey, options=$options, initOptions=$initOptions")
|
|
96
|
+
val amplitudeEngagement = __ReactNative__AESDK(reactContext, apiKey, initOptions, platformVersion = platformVersion)
|
|
97
|
+
|
|
98
|
+
// The React Native environment seems to have a different activity management lifecycle;
|
|
99
|
+
// so we need to register our own listener to get the current activity.
|
|
100
|
+
amplitudeEngagement.setCurrentActivity(reactContext.currentActivity)
|
|
101
|
+
val lifecycleEventListener: LifecycleEventListener =
|
|
102
|
+
object : LifecycleEventListener {
|
|
103
|
+
override fun onHostResume() {
|
|
104
|
+
amplitudeEngagement.setCurrentActivity(reactContext.currentActivity)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
override fun onHostPause() {
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
override fun onHostDestroy() {
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
reactContext.addLifecycleEventListener(lifecycleEventListener)
|
|
115
|
+
|
|
116
|
+
nextId++
|
|
117
|
+
val id = nextId
|
|
118
|
+
Log.d("PluginEngagementReactNativeModule", "newInstance id=$id")
|
|
119
|
+
instances[id] =
|
|
120
|
+
InstanceInfo(
|
|
121
|
+
apiKey,
|
|
122
|
+
amplitudeEngagement,
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
id
|
|
126
|
+
}
|
|
80
127
|
}
|
|
128
|
+
}
|
|
81
129
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
val
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
130
|
+
override fun boot(
|
|
131
|
+
id: Double,
|
|
132
|
+
userId: String?,
|
|
133
|
+
deviceId: String?,
|
|
134
|
+
userProperties: ReadableMap?,
|
|
135
|
+
) {
|
|
136
|
+
val instance = instances[id]?.instance ?: return
|
|
137
|
+
val self = this
|
|
138
|
+
runBlocking(Dispatchers.Main) {
|
|
139
|
+
Log.d("PluginEngagementReactNativeModule", "boot: $userId, $deviceId, $userProperties")
|
|
140
|
+
val options =
|
|
141
|
+
AmplitudeBootOptions(
|
|
142
|
+
userId = userId,
|
|
143
|
+
deviceId = deviceId,
|
|
144
|
+
userProperties = userProperties?.toHashMap() ?: emptyMap(),
|
|
145
|
+
integrations =
|
|
146
|
+
arrayOf(
|
|
147
|
+
{ event: BaseEvent ->
|
|
148
|
+
try {
|
|
149
|
+
val serializedEvent =
|
|
150
|
+
mapOf(
|
|
151
|
+
"event_type" to event.eventType,
|
|
152
|
+
"event_properties" to event.eventProperties,
|
|
153
|
+
).toWritableMap()
|
|
154
|
+
self.emitOnTrackEvent(serializedEvent)
|
|
155
|
+
} catch (e: Exception) {
|
|
156
|
+
Log.e("PluginEngagementReactNativeModule", "Error tracking Event", e)
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
),
|
|
160
|
+
)
|
|
161
|
+
instance.boot(options)
|
|
98
162
|
}
|
|
99
|
-
|
|
100
|
-
reactContext.addLifecycleEventListener(lifecycleEventListener)
|
|
101
|
-
|
|
102
|
-
_id++
|
|
103
|
-
val id = _id
|
|
104
|
-
Log.d("PluginEngagementReactNativeModule", "newInstance id=${id}")
|
|
105
|
-
instances[id] = InstanceInfo(
|
|
106
|
-
apiKey,
|
|
107
|
-
amplitudeEngagement
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
id
|
|
111
|
-
}
|
|
112
163
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
runBlocking(Dispatchers.Main) {
|
|
119
|
-
Log.d("PluginEngagementReactNativeModule", "boot: $userId, $deviceId, $userProperties")
|
|
120
|
-
val options = AmplitudeBootOptions(userId = userId, deviceId = deviceId, userProperties = userProperties?.toHashMap() ?: emptyMap(), integrations = arrayOf(
|
|
121
|
-
{ event: BaseEvent ->
|
|
122
|
-
try {
|
|
123
|
-
val serializedEvent = mapOf(
|
|
124
|
-
"event_type" to event.eventType,
|
|
125
|
-
"event_properties" to event.eventProperties
|
|
126
|
-
).toWritableMap()
|
|
127
|
-
self.emitOnTrackEvent(serializedEvent)
|
|
128
|
-
} catch (e: Exception) {
|
|
129
|
-
Log.e("PluginEngagementReactNativeModule", "Error tracking Event", e)
|
|
130
|
-
}
|
|
164
|
+
|
|
165
|
+
override fun enable(id: Double) {
|
|
166
|
+
val instance = instances[id]?.instance ?: return
|
|
167
|
+
runBlocking(Dispatchers.Main) {
|
|
168
|
+
instance.enable()
|
|
131
169
|
}
|
|
132
|
-
))
|
|
133
|
-
instance.boot(options)
|
|
134
170
|
}
|
|
135
|
-
}
|
|
136
171
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
172
|
+
override fun disable(id: Double) {
|
|
173
|
+
val instance = instances[id]?.instance ?: return
|
|
174
|
+
runBlocking(Dispatchers.Main) {
|
|
175
|
+
instance.disable()
|
|
176
|
+
}
|
|
141
177
|
}
|
|
142
|
-
}
|
|
143
178
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
override fun shutdown(id: Double) {
|
|
151
|
-
val instance = instances[id]?.instance ?: return
|
|
152
|
-
runBlocking(Dispatchers.Main) {
|
|
153
|
-
instance.shutdown()
|
|
179
|
+
override fun shutdown(id: Double) {
|
|
180
|
+
val instance = instances[id]?.instance ?: return
|
|
181
|
+
runBlocking(Dispatchers.Main) {
|
|
182
|
+
instance.shutdown()
|
|
183
|
+
}
|
|
154
184
|
}
|
|
155
|
-
}
|
|
156
185
|
|
|
157
|
-
|
|
158
|
-
|
|
186
|
+
override fun setThemeMode(
|
|
187
|
+
id: Double,
|
|
188
|
+
themeMode: String?,
|
|
189
|
+
) {
|
|
190
|
+
val instance = instances[id]?.instance ?: return
|
|
159
191
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
192
|
+
runBlocking(Dispatchers.Main) {
|
|
193
|
+
if (themeMode != null) {
|
|
194
|
+
instance.setThemeMode(ThemeMode.valueOf(themeMode))
|
|
195
|
+
}
|
|
196
|
+
}
|
|
164
197
|
}
|
|
165
|
-
}
|
|
166
198
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
199
|
+
override fun reset(
|
|
200
|
+
id: Double,
|
|
201
|
+
key: String,
|
|
202
|
+
stepIndex: Double,
|
|
203
|
+
) {
|
|
204
|
+
val instance = instances[id]?.instance ?: return
|
|
205
|
+
runBlocking(Dispatchers.Main) {
|
|
206
|
+
instance.reset(key, stepIndex.toInt())
|
|
207
|
+
}
|
|
171
208
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
209
|
+
|
|
210
|
+
override fun list(id: Double): WritableArray {
|
|
211
|
+
val writableArray = Arguments.createArray()
|
|
212
|
+
val instance = instances[id]?.instance ?: return writableArray
|
|
213
|
+
runBlocking(Dispatchers.Main) {
|
|
214
|
+
val guidesAndSurveysList = instance.list()
|
|
215
|
+
guidesAndSurveysList.forEach { guide ->
|
|
216
|
+
Log.d("PluginEngagementReactNativeModule", "list: $guide")
|
|
217
|
+
val map = Arguments.createMap()
|
|
218
|
+
map.putInt("id", guide.id)
|
|
219
|
+
map.putString("title", guide.title)
|
|
220
|
+
map.putString("status", guide.status)
|
|
221
|
+
map.putInt("step", guide.step)
|
|
222
|
+
writableArray.pushMap(map)
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return writableArray
|
|
188
226
|
}
|
|
189
|
-
return writableArray
|
|
190
|
-
}
|
|
191
227
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
228
|
+
override fun show(
|
|
229
|
+
id: Double,
|
|
230
|
+
key: String,
|
|
231
|
+
stepIndex: Double,
|
|
232
|
+
) {
|
|
233
|
+
val instance = instances[id]?.instance ?: return
|
|
234
|
+
runBlocking(Dispatchers.Main) {
|
|
235
|
+
instance.show(key, stepIndex.toInt())
|
|
236
|
+
}
|
|
196
237
|
}
|
|
197
|
-
}
|
|
198
238
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
239
|
+
override fun screen(
|
|
240
|
+
id: Double,
|
|
241
|
+
screenName: String,
|
|
242
|
+
) {
|
|
243
|
+
val instance = instances[id]?.instance ?: return
|
|
244
|
+
runBlocking(Dispatchers.Main) {
|
|
245
|
+
instance.screen(screenName)
|
|
246
|
+
}
|
|
203
247
|
}
|
|
204
|
-
}
|
|
205
248
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
249
|
+
override fun closeAll(id: Double) {
|
|
250
|
+
val instance = instances[id]?.instance ?: return
|
|
251
|
+
runBlocking(Dispatchers.Main) {
|
|
252
|
+
instance.closeAll()
|
|
253
|
+
}
|
|
210
254
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
255
|
+
|
|
256
|
+
override fun forwardEvent(
|
|
257
|
+
id: Double,
|
|
258
|
+
event: ReadableMap,
|
|
259
|
+
) {
|
|
260
|
+
val instance = instances[id]?.instance ?: return
|
|
261
|
+
val baseEvent = BaseEvent()
|
|
262
|
+
baseEvent.eventType = event.getString("event_type") ?: return
|
|
263
|
+
baseEvent.eventId = event.getDouble("event_id").toLong()
|
|
264
|
+
baseEvent.platform = event.getString("platform")
|
|
265
|
+
baseEvent.osName = event.getString("os_name")
|
|
266
|
+
baseEvent.osVersion = event.getString("os_version")
|
|
267
|
+
baseEvent.eventProperties = event.getMap("event_properties")?.toHashMap()?.toMutableMap()
|
|
268
|
+
baseEvent.groupProperties = event.getMap("group_properties")?.toHashMap()?.toMutableMap()
|
|
269
|
+
baseEvent.groups = event.getMap("groups")?.toHashMap()?.toMutableMap()
|
|
270
|
+
baseEvent.userProperties = event.getMap("user_properties")?.toHashMap()?.toMutableMap()
|
|
271
|
+
Log.d("PluginEngagementReactNativeModule", "forwardEvent: $baseEvent")
|
|
272
|
+
runBlocking(Dispatchers.Main) {
|
|
273
|
+
instance.forwardEvent(baseEvent)
|
|
274
|
+
}
|
|
228
275
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
276
|
+
|
|
277
|
+
override fun addCallback(
|
|
278
|
+
id: Double,
|
|
279
|
+
key: String,
|
|
280
|
+
) {
|
|
281
|
+
val instance = instances[id]?.instance ?: return
|
|
282
|
+
val self = this
|
|
283
|
+
runBlocking(Dispatchers.Main) {
|
|
284
|
+
instance.addCallback(key) {
|
|
285
|
+
val serializedEvent =
|
|
286
|
+
mapOf(
|
|
287
|
+
"id" to id,
|
|
288
|
+
"key" to key,
|
|
289
|
+
).toWritableMap()
|
|
290
|
+
self.emitOnInvokeCallback(serializedEvent)
|
|
291
|
+
}
|
|
292
|
+
}
|
|
242
293
|
}
|
|
243
|
-
}
|
|
244
294
|
|
|
245
|
-
|
|
246
|
-
|
|
295
|
+
override fun handleURL(
|
|
296
|
+
id: Double,
|
|
297
|
+
url: String,
|
|
298
|
+
): Boolean {
|
|
299
|
+
val instance = instances[id]?.instance ?: return false
|
|
247
300
|
|
|
248
|
-
|
|
249
|
-
|
|
301
|
+
val uri = url.toUri()
|
|
302
|
+
val intent = Intent(Intent.ACTION_VIEW, uri)
|
|
250
303
|
|
|
251
|
-
|
|
252
|
-
|
|
304
|
+
return runBlocking(Dispatchers.Main) {
|
|
305
|
+
instance.handlePreviewLinkIntent(intent)
|
|
306
|
+
}
|
|
253
307
|
}
|
|
254
|
-
}
|
|
255
308
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
309
|
+
companion object {
|
|
310
|
+
const val NAME = "PluginEngagementReactNative"
|
|
311
|
+
}
|
|
260
312
|
}
|
|
@@ -8,26 +8,34 @@ import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
|
8
8
|
import java.util.HashMap
|
|
9
9
|
|
|
10
10
|
class PluginEngagementReactNativePackage : BaseReactPackage() {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
override fun getModule(
|
|
12
|
+
name: String,
|
|
13
|
+
reactContext: ReactApplicationContext,
|
|
14
|
+
): NativeModule? {
|
|
15
|
+
return if (name == PluginEngagementReactNativeModule.NAME) {
|
|
16
|
+
PluginEngagementReactNativeModule(reactContext)
|
|
17
|
+
} else {
|
|
18
|
+
null
|
|
19
|
+
}
|
|
16
20
|
}
|
|
17
|
-
}
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
23
|
+
return ReactModuleInfoProvider {
|
|
24
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
25
|
+
moduleInfos[PluginEngagementReactNativeModule.NAME] =
|
|
26
|
+
ReactModuleInfo(
|
|
27
|
+
PluginEngagementReactNativeModule.NAME,
|
|
28
|
+
PluginEngagementReactNativeModule.NAME,
|
|
29
|
+
// canOverrideExistingModule
|
|
30
|
+
false,
|
|
31
|
+
// needsEagerInit
|
|
32
|
+
false,
|
|
33
|
+
// isCxxModule
|
|
34
|
+
false,
|
|
35
|
+
// isTurboModule
|
|
36
|
+
true,
|
|
37
|
+
)
|
|
38
|
+
moduleInfos
|
|
39
|
+
}
|
|
31
40
|
}
|
|
32
|
-
}
|
|
33
41
|
}
|
|
@@ -5,47 +5,46 @@ import com.facebook.react.bridge.WritableArray
|
|
|
5
5
|
import com.facebook.react.bridge.WritableMap
|
|
6
6
|
|
|
7
7
|
fun Iterable<*>.toWritableArray(): WritableArray {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
val iter = this.iterator()
|
|
9
|
+
|
|
10
|
+
val writableArray: WritableArray = Arguments.createArray()
|
|
11
|
+
|
|
12
|
+
while (iter.hasNext()) {
|
|
13
|
+
val value = iter.next()
|
|
14
|
+
|
|
15
|
+
when (value) {
|
|
16
|
+
null -> writableArray.pushNull()
|
|
17
|
+
is Boolean -> writableArray.pushBoolean(value)
|
|
18
|
+
is Double -> writableArray.pushDouble(value)
|
|
19
|
+
is Int -> writableArray.pushInt(value)
|
|
20
|
+
is String -> writableArray.pushString(value)
|
|
21
|
+
is Map<*, *> -> writableArray.pushMap((value as Map<String, Any?>).toWritableMap())
|
|
22
|
+
else -> throw IllegalArgumentException("Cannot convert value of type ${value.javaClass.simpleName}")
|
|
23
|
+
}
|
|
23
24
|
}
|
|
24
|
-
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
return writableArray
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
29
|
fun Map<String, *>.toWritableMap(): WritableMap {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
val writableMap: WritableMap = Arguments.createMap()
|
|
31
|
+
val iterator = entries.iterator()
|
|
32
|
+
|
|
33
|
+
while (iterator.hasNext()) {
|
|
34
|
+
val pair = iterator.next()
|
|
35
|
+
val value = pair.value
|
|
36
|
+
|
|
37
|
+
when {
|
|
38
|
+
value == null -> writableMap.putNull(pair.key)
|
|
39
|
+
value is Boolean -> writableMap.putBoolean(pair.key, value)
|
|
40
|
+
value is Double -> writableMap.putDouble(pair.key, value)
|
|
41
|
+
value is Int -> writableMap.putInt(pair.key, value)
|
|
42
|
+
value is String -> writableMap.putString(pair.key, value)
|
|
43
|
+
value is Map<*, *> -> writableMap.putMap(pair.key, (value as Map<String, *>).toWritableMap())
|
|
44
|
+
value is Iterable<*> -> writableMap.putArray(pair.key, value.toWritableArray())
|
|
45
|
+
else -> throw IllegalArgumentException("Cannot convert value of type ${value.javaClass.simpleName}")
|
|
46
|
+
}
|
|
47
47
|
}
|
|
48
|
-
}
|
|
49
48
|
|
|
50
|
-
|
|
49
|
+
return writableMap
|
|
51
50
|
}
|
|
@@ -36,7 +36,8 @@ var _id = 0
|
|
|
36
36
|
guard let (_, instance) = instances[instanceId] else {
|
|
37
37
|
AmplitudeEngagementAdapter.logger.error(
|
|
38
38
|
"No AmplitudeEngagement instance found for id: \(instanceId). Returning no-op stub.")
|
|
39
|
-
return AmplitudeEngagementNoOpStub(
|
|
39
|
+
return AmplitudeEngagementNoOpStub(
|
|
40
|
+
"", AmplitudeInitOptions(), DevelopmentPlatform.reactNative(version: ""))
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
return instance
|
|
@@ -101,6 +102,8 @@ var _id = 0
|
|
|
101
102
|
"AmplitudeEngagementAdapter#newInstace apiKey=\(apiKey), options=\(String(describing: options), privacy: .public); initOptions=\(String(describing: initOptions), privacy: .public)"
|
|
102
103
|
)
|
|
103
104
|
|
|
105
|
+
let platformVersion = options?["platformVersion"] as? String ?? ""
|
|
106
|
+
|
|
104
107
|
return DispatchQueue.main.sync {
|
|
105
108
|
_id += 1
|
|
106
109
|
let id = _id + 1
|
|
@@ -109,7 +112,7 @@ var _id = 0
|
|
|
109
112
|
)
|
|
110
113
|
instances[id] = (
|
|
111
114
|
apiKey,
|
|
112
|
-
__ReactNative__AESDK_Factory.make(apiKey, initOptions)
|
|
115
|
+
__ReactNative__AESDK_Factory.make(apiKey, initOptions, platformVersion: platformVersion)
|
|
113
116
|
)
|
|
114
117
|
return id
|
|
115
118
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { NativeModules } from 'react-native';
|
|
4
|
+
import { SDK_VERSION } from "./constants.js";
|
|
4
5
|
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
5
6
|
const PluginEngagementReactNative = isTurboModuleEnabled ? require('./NativePluginEngagementReactNative').default : NativeModules.PluginEngagementReactNative;
|
|
6
7
|
export class AmplitudeEngagement {
|
|
7
8
|
constructor(apiKey, options) {
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
this.id = PluginEngagementReactNative.newInstance(apiKey, {
|
|
10
|
+
...options,
|
|
11
|
+
platformVersion: SDK_VERSION
|
|
12
|
+
});
|
|
10
13
|
}
|
|
11
14
|
boot(user_id, device_id, user_properties) {
|
|
12
15
|
PluginEngagementReactNative.boot(this.id, user_id, device_id, user_properties);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","isTurboModuleEnabled","global","__turboModuleProxy","PluginEngagementReactNative","require","default","AmplitudeEngagement","constructor","apiKey","options","id","newInstance","boot","user_id","device_id","user_properties","enable","disable","shutdown","setThemeMode","themeMode","reset","key","stepIndex","list","show","screen","screenName","closeAll","forwardEvent","event","addCallback","func","handler","onInvokeCallback","invocation","remove","handleURL","url"],"sourceRoot":"../../src","sources":["AmplitudeEngagement.ts"],"mappings":";;AACA,SAASA,aAAa,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["NativeModules","SDK_VERSION","isTurboModuleEnabled","global","__turboModuleProxy","PluginEngagementReactNative","require","default","AmplitudeEngagement","constructor","apiKey","options","id","newInstance","platformVersion","boot","user_id","device_id","user_properties","enable","disable","shutdown","setThemeMode","themeMode","reset","key","stepIndex","list","show","screen","screenName","closeAll","forwardEvent","event","addCallback","func","handler","onInvokeCallback","invocation","remove","handleURL","url"],"sourceRoot":"../../src","sources":["AmplitudeEngagement.ts"],"mappings":";;AACA,SAASA,aAAa,QAAQ,cAAc;AAG5C,SAASC,WAAW,QAAQ,gBAAa;AAIzC,MAAMC,oBAAoB,GAAIC,MAAM,CAASC,kBAAkB,IAAI,IAAI;AAEvE,MAAMC,2BAA4D,GAChEH,oBAAoB,GAChBI,OAAO,CAAC,qCAAqC,CAAC,CAACC,OAAO,GACtDP,aAAa,CAACK,2BAA2B;AAE/C,OAAO,MAAMG,mBAAmB,CAAC;EAG/BC,WAAWA,CAACC,MAAc,EAAEC,OAA8B,EAAE;IAC1D,IAAI,CAACC,EAAE,GAAGP,2BAA2B,CAACQ,WAAW,CAACH,MAAM,EAAE;MACxD,GAAGC,OAAO;MACVG,eAAe,EAAEb;IACnB,CAAC,CAAC;EACJ;EAEAc,IAAIA,CAACC,OAAgB,EAAEC,SAAkB,EAAEC,eAAwB,EAAQ;IACzEb,2BAA2B,CAACU,IAAI,CAC9B,IAAI,CAACH,EAAE,EACPI,OAAO,EACPC,SAAS,EACTC,eACF,CAAC;EACH;EAEAC,MAAMA,CAAA,EAAS;IACbd,2BAA2B,CAACc,MAAM,CAAC,IAAI,CAACP,EAAE,CAAC;EAC7C;EAEAQ,OAAOA,CAAA,EAAS;IACdf,2BAA2B,CAACe,OAAO,CAAC,IAAI,CAACR,EAAE,CAAC;EAC9C;EAEAS,QAAQA,CAAA,EAAS;IACfhB,2BAA2B,CAACgB,QAAQ,CAAC,IAAI,CAACT,EAAE,CAAC;EAC/C;EAEAU,YAAYA,CAACC,SAAoB,EAAQ;IACvC,OAAOlB,2BAA2B,CAACiB,YAAY,CAAC,IAAI,CAACV,EAAE,EAAEW,SAAS,CAAC;EACrE;EAEAC,KAAKA,CAACC,GAAW,EAAEC,SAAiB,EAAQ;IAC1C,OAAOrB,2BAA2B,CAACmB,KAAK,CAAC,IAAI,CAACZ,EAAE,EAAEa,GAAG,EAAEC,SAAS,CAAC;EACnE;EAEAC,IAAIA,CAAA,EAAoB;IACtB,OAAOtB,2BAA2B,CAACsB,IAAI,CAAC,IAAI,CAACf,EAAE,CAAC;EAClD;EAEAgB,IAAIA,CAACH,GAAW,EAAEC,SAAiB,EAAQ;IACzC,OAAOrB,2BAA2B,CAACuB,IAAI,CAAC,IAAI,CAAChB,EAAE,EAAEa,GAAG,EAAEC,SAAS,CAAC;EAClE;EAEAG,MAAMA,CAACC,UAAkB,EAAQ;IAC/B,OAAOzB,2BAA2B,CAACwB,MAAM,CAAC,IAAI,CAACjB,EAAE,EAAEkB,UAAU,CAAC;EAChE;EAEAC,QAAQA,CAAA,EAAS;IACf,OAAO1B,2BAA2B,CAAC0B,QAAQ,CAAC,IAAI,CAACnB,EAAE,CAAC;EACtD;EAEAoB,YAAYA,CAACC,KAAgB,EAAQ;IACnC,OAAO5B,2BAA2B,CAAC2B,YAAY,CAAC,IAAI,CAACpB,EAAE,EAAEqB,KAAK,CAAC;EACjE;EAEAC,WAAWA,CAACT,GAAW,EAAEU,IAAgB,EAAc;IACrD9B,2BAA2B,CAAC6B,WAAW,CAAC,IAAI,CAACtB,EAAE,EAAEa,GAAG,CAAC;IAErD,MAAMW,OAAO,GAAG/B,2BAA2B,CAACgC,gBAAgB,CACzDC,UAAU,IAAK;MACd,IAAIA,UAAU,CAAC1B,EAAE,KAAK,IAAI,CAACA,EAAE,IAAI0B,UAAU,CAACb,GAAG,KAAKA,GAAG,EAAE;QACvDU,IAAI,CAAC,CAAC;MACR;IACF,CACF,CAAC;IAED,OAAO,MAAMC,OAAO,CAACG,MAAM,CAAC,CAAC;EAC/B;EAEAC,SAASA,CAACC,GAAW,EAAW;IAC9B,OAAOpC,2BAA2B,CAACmC,SAAS,CAAC,IAAI,CAAC5B,EAAE,EAAE6B,GAAG,CAAC;EAC5D;AACF","ignoreList":[]}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { Platform } from 'react-native';
|
|
3
4
|
import { forwardEvent, init, screen, boot, enable, disable } from "./index.js";
|
|
4
5
|
import NativePluginEngagementReactNative from "./NativePluginEngagementReactNative.js";
|
|
5
6
|
import { Logger } from "./logger.js";
|
|
6
|
-
import
|
|
7
|
+
import * as Constants from "./constants.js";
|
|
7
8
|
export class AmplitudeEngagementPlugin {
|
|
8
9
|
name = 'AmplitudeEngagementPlugin';
|
|
9
10
|
type = 'enrichment';
|
|
10
11
|
logger = new Logger('AmplitudeEngagementPlugin');
|
|
11
|
-
|
|
12
|
-
// SDK library information for version tracking
|
|
13
|
-
static SDK_LIBRARY = 'amplitude-engagement-react-native';
|
|
14
|
-
static SDK_VERSION = version;
|
|
15
12
|
trackEventSubscription = null;
|
|
16
13
|
constructor(initOptions) {
|
|
17
14
|
this.initOptions = initOptions;
|
|
@@ -37,10 +34,13 @@ export class AmplitudeEngagementPlugin {
|
|
|
37
34
|
this.logger.error('AmplitudeEngagementPlugin#onIdentityChanged client is not initialized');
|
|
38
35
|
return;
|
|
39
36
|
}
|
|
37
|
+
const nativeTag = Platform.OS === 'ios' ? `${Constants.SDK_IOS_LIBRARY}/${Constants.SDK_IOS_VERSION}` : `${Constants.SDK_ANDROID_LIBRARY}/${Constants.SDK_ANDROID_VERSION}`;
|
|
38
|
+
const rnTag = `${Constants.SDK_LIBRARY}/${Constants.SDK_VERSION}`;
|
|
39
|
+
|
|
40
40
|
// Add the Guides & Surveys library version to events
|
|
41
41
|
const eventProperties = {
|
|
42
42
|
...event.event_properties,
|
|
43
|
-
'[Guides-Surveys] Library': `${
|
|
43
|
+
'[Guides-Surveys] Library': `${rnTag}_${nativeTag}`
|
|
44
44
|
};
|
|
45
45
|
this.client?.track(event.event_type, eventProperties);
|
|
46
46
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardEvent","init","screen","boot","enable","disable","NativePluginEngagementReactNative","Logger","
|
|
1
|
+
{"version":3,"names":["Platform","forwardEvent","init","screen","boot","enable","disable","NativePluginEngagementReactNative","Logger","Constants","AmplitudeEngagementPlugin","name","type","logger","trackEventSubscription","constructor","initOptions","setup","config","client","apiKey","serverZone","log","remove","onTrackEvent","event","error","nativeTag","OS","SDK_IOS_LIBRARY","SDK_IOS_VERSION","SDK_ANDROID_LIBRARY","SDK_ANDROID_VERSION","rnTag","SDK_LIBRARY","SDK_VERSION","eventProperties","event_properties","track","event_type","user_id","device_id","execute","context","JSON","stringify","screenName","ignoreAnalyticsAutomaticScreenTracking"],"sourceRoot":"../../src","sources":["AmplitudeEngagementPlugin.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { version as reactNativeVersion } from './build-version.json';
|
|
4
|
+
import { version as iosVersion } from './build-version-ios.json';
|
|
5
|
+
import { version as androidVersion } from './build-version-android.json';
|
|
6
|
+
export const SDK_LIBRARY = 'amplitude-engagement-react-native';
|
|
7
|
+
export const SDK_VERSION = reactNativeVersion;
|
|
8
|
+
export const SDK_IOS_LIBRARY = 'amplitude-engagement-swift';
|
|
9
|
+
export const SDK_IOS_VERSION = iosVersion;
|
|
10
|
+
export const SDK_ANDROID_LIBRARY = 'amplitude-engagement-android';
|
|
11
|
+
export const SDK_ANDROID_VERSION = androidVersion;
|
|
12
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["version","reactNativeVersion","iosVersion","androidVersion","SDK_LIBRARY","SDK_VERSION","SDK_IOS_LIBRARY","SDK_IOS_VERSION","SDK_ANDROID_LIBRARY","SDK_ANDROID_VERSION"],"sourceRoot":"../../src","sources":["constants.ts"],"mappings":";;AAAA,SAASA,OAAO,IAAIC,kBAAkB,QAAQ,sBAAsB;AACpE,SAASD,OAAO,IAAIE,UAAU,QAAQ,0BAA0B;AAChE,SAASF,OAAO,IAAIG,cAAc,QAAQ,8BAA8B;AAExE,OAAO,MAAMC,WAAW,GAAG,mCAAmC;AAC9D,OAAO,MAAMC,WAAW,GAAGJ,kBAAkB;AAC7C,OAAO,MAAMK,eAAe,GAAG,4BAA4B;AAC3D,OAAO,MAAMC,eAAe,GAAGL,UAAU;AACzC,OAAO,MAAMM,mBAAmB,GAAG,8BAA8B;AACjE,OAAO,MAAMC,mBAAmB,GAAGN,cAAc","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmplitudeEngagement.d.ts","sourceRoot":"","sources":["../../../src/AmplitudeEngagement.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"AmplitudeEngagement.d.ts","sourceRoot":"","sources":["../../../src/AmplitudeEngagement.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAY3D,qBAAa,mBAAmB;IAC9B,EAAE,EAAE,MAAM,CAAC;gBAEC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB;IAO1D,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI;IAS1E,MAAM,IAAI,IAAI;IAId,OAAO,IAAI,IAAI;IAIf,QAAQ,IAAI,IAAI;IAIhB,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAIxC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAI3C,IAAI,IAAI,aAAa,EAAE;IAIvB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAI1C,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIhC,QAAQ,IAAI,IAAI;IAIhB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAIpC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IActD,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;CAGhC"}
|
|
@@ -12,8 +12,6 @@ export declare class AmplitudeEngagementPlugin implements EnrichmentPlugin<React
|
|
|
12
12
|
sessionId?: number;
|
|
13
13
|
userProperties?: Record<string, any>;
|
|
14
14
|
logger: AmplitudeLogger;
|
|
15
|
-
private static readonly SDK_LIBRARY;
|
|
16
|
-
private static readonly SDK_VERSION;
|
|
17
15
|
trackEventSubscription: EventSubscription | null;
|
|
18
16
|
constructor(initOptions?: AmplitudeInitOptions);
|
|
19
17
|
setup(config: ReactNativeConfig, client: ReactNativeClient): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmplitudeEngagementPlugin.d.ts","sourceRoot":"","sources":["../../../src/AmplitudeEngagementPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,KAAK,EACL,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"AmplitudeEngagementPlugin.d.ts","sourceRoot":"","sources":["../../../src/AmplitudeEngagementPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,KAAK,EACL,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAKnC,OAAO,EAAU,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAGpD,qBAAa,yBACX,YAAW,gBAAgB,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAEjE,IAAI,SAA+B;IACnC,IAAI,EAAG,YAAY,CAAU;IAE7B,WAAW,CAAC,EAAE,oBAAoB,CAAC;IAEnC,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAE3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAErC,MAAM,EAAE,eAAe,CAA2C;IAElE,sBAAsB,EAAE,iBAAiB,GAAG,IAAI,CAAQ;gBAE5C,WAAW,CAAC,EAAE,oBAAoB;IAIxC,KAAK,CACT,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,IAAI,CAAC;IAuDhB,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAIhD,oEAAoE;IACpE,MAAM,IAAI,IAAI;IAId,8GAA8G;IAC9G,OAAO,IAAI,IAAI;IAIT,OAAO,CAAC,OAAO,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;CA2BrD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const SDK_LIBRARY = "amplitude-engagement-react-native";
|
|
2
|
+
export declare const SDK_VERSION: string;
|
|
3
|
+
export declare const SDK_IOS_LIBRARY = "amplitude-engagement-swift";
|
|
4
|
+
export declare const SDK_IOS_VERSION: string;
|
|
5
|
+
export declare const SDK_ANDROID_LIBRARY = "amplitude-engagement-android";
|
|
6
|
+
export declare const SDK_ANDROID_VERSION: string;
|
|
7
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/constants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,sCAAsC,CAAC;AAC/D,eAAO,MAAM,WAAW,QAAqB,CAAC;AAC9C,eAAO,MAAM,eAAe,+BAA+B,CAAC;AAC5D,eAAO,MAAM,eAAe,QAAa,CAAC;AAC1C,eAAO,MAAM,mBAAmB,iCAAiC,CAAC;AAClE,eAAO,MAAM,mBAAmB,QAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amplitude/plugin-engagement-react-native",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "Amplitude Engagement plugin for React Native",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -38,9 +38,10 @@
|
|
|
38
38
|
"e2e:android": "scripts/prepare-e2e-tests.sh && cd testproject && yarn e2e:android",
|
|
39
39
|
"e2e:android:headless": "scripts/prepare-e2e-tests.sh && cd testproject && yarn e2e:android:headless",
|
|
40
40
|
"typecheck": "tsc",
|
|
41
|
-
"lint": "eslint \"
|
|
41
|
+
"lint": "eslint \"src/**/*.{js,ts,tsx}\"",
|
|
42
|
+
"lint:fix": "eslint --fix \"src/**/*.{js,ts,tsx}\"",
|
|
42
43
|
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
43
|
-
"prepare": "bob build
|
|
44
|
+
"prepare": "bob build",
|
|
44
45
|
"release": "npm publish --tag latest --ddd"
|
|
45
46
|
},
|
|
46
47
|
"keywords": [
|
|
@@ -2,6 +2,7 @@ import type { Spec } from './NativePluginEngagementReactNative';
|
|
|
2
2
|
import { NativeModules } from 'react-native';
|
|
3
3
|
import type { AmplitudeInitOptions, GuideOrSurvey, ThemeMode } from './types';
|
|
4
4
|
import type { BaseEvent } from '@amplitude/analytics-core';
|
|
5
|
+
import { SDK_VERSION } from './constants';
|
|
5
6
|
|
|
6
7
|
type PluginEngagementReactNativeType = Exclude<Spec, 'getConstants'>;
|
|
7
8
|
|
|
@@ -16,8 +17,10 @@ export class AmplitudeEngagement {
|
|
|
16
17
|
id: number;
|
|
17
18
|
|
|
18
19
|
constructor(apiKey: string, options?: AmplitudeInitOptions) {
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
this.id = PluginEngagementReactNative.newInstance(apiKey, {
|
|
21
|
+
...options,
|
|
22
|
+
platformVersion: SDK_VERSION,
|
|
23
|
+
});
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
boot(user_id?: string, device_id?: string, user_properties?: Object): void {
|
|
@@ -4,13 +4,14 @@ import type {
|
|
|
4
4
|
ReactNativeClient,
|
|
5
5
|
ReactNativeConfig,
|
|
6
6
|
} from '@amplitude/analytics-core';
|
|
7
|
+
import { Platform } from 'react-native';
|
|
7
8
|
import { forwardEvent, init, screen, boot, enable, disable } from '.';
|
|
8
9
|
import NativePluginEngagementReactNative from './NativePluginEngagementReactNative';
|
|
9
10
|
|
|
10
11
|
import { Logger, type AmplitudeLogger } from './logger';
|
|
11
12
|
import type { EventSubscription } from 'react-native';
|
|
12
|
-
import { version } from './build-version.json';
|
|
13
13
|
import type { AmplitudeInitOptions } from './types';
|
|
14
|
+
import * as Constants from './constants';
|
|
14
15
|
|
|
15
16
|
export class AmplitudeEngagementPlugin
|
|
16
17
|
implements EnrichmentPlugin<ReactNativeClient, ReactNativeConfig>
|
|
@@ -29,10 +30,6 @@ export class AmplitudeEngagementPlugin
|
|
|
29
30
|
|
|
30
31
|
logger: AmplitudeLogger = new Logger('AmplitudeEngagementPlugin');
|
|
31
32
|
|
|
32
|
-
// SDK library information for version tracking
|
|
33
|
-
private static readonly SDK_LIBRARY = 'amplitude-engagement-react-native';
|
|
34
|
-
private static readonly SDK_VERSION = version;
|
|
35
|
-
|
|
36
33
|
trackEventSubscription: EventSubscription | null = null;
|
|
37
34
|
|
|
38
35
|
constructor(initOptions?: AmplitudeInitOptions) {
|
|
@@ -67,10 +64,18 @@ export class AmplitudeEngagementPlugin
|
|
|
67
64
|
);
|
|
68
65
|
return;
|
|
69
66
|
}
|
|
67
|
+
|
|
68
|
+
const nativeTag =
|
|
69
|
+
Platform.OS === 'ios'
|
|
70
|
+
? `${Constants.SDK_IOS_LIBRARY}/${Constants.SDK_IOS_VERSION}`
|
|
71
|
+
: `${Constants.SDK_ANDROID_LIBRARY}/${Constants.SDK_ANDROID_VERSION}`;
|
|
72
|
+
|
|
73
|
+
const rnTag = `${Constants.SDK_LIBRARY}/${Constants.SDK_VERSION}`;
|
|
74
|
+
|
|
70
75
|
// Add the Guides & Surveys library version to events
|
|
71
76
|
const eventProperties = {
|
|
72
77
|
...event.event_properties,
|
|
73
|
-
'[Guides-Surveys] Library': `${
|
|
78
|
+
'[Guides-Surveys] Library': `${rnTag}_${nativeTag}`,
|
|
74
79
|
};
|
|
75
80
|
this.client?.track(event.event_type, eventProperties);
|
|
76
81
|
});
|
package/src/build-version.json
CHANGED
package/src/constants.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { version as reactNativeVersion } from './build-version.json';
|
|
2
|
+
import { version as iosVersion } from './build-version-ios.json';
|
|
3
|
+
import { version as androidVersion } from './build-version-android.json';
|
|
4
|
+
|
|
5
|
+
export const SDK_LIBRARY = 'amplitude-engagement-react-native';
|
|
6
|
+
export const SDK_VERSION = reactNativeVersion;
|
|
7
|
+
export const SDK_IOS_LIBRARY = 'amplitude-engagement-swift';
|
|
8
|
+
export const SDK_IOS_VERSION = iosVersion;
|
|
9
|
+
export const SDK_ANDROID_LIBRARY = 'amplitude-engagement-android';
|
|
10
|
+
export const SDK_ANDROID_VERSION = androidVersion;
|