@amplitude/plugin-engagement-react-native 1.8.0 → 2.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/PluginEngagementReactNative.podspec +6 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/amplitude/pluginengagementreactnative/PluginEngagementReactNativeModule.kt +36 -9
- package/ios/AmplitudeEngagementAdapter.swift +59 -2
- package/ios/PluginEngagementReactNative.mm +9 -2
- package/lib/module/AmplitudeEngagement.js +2 -2
- package/lib/module/AmplitudeEngagement.js.map +1 -1
- package/lib/module/AmplitudeEngagementPlugin.js +13 -2
- package/lib/module/AmplitudeEngagementPlugin.js.map +1 -1
- package/lib/module/build-version.json +1 -1
- package/lib/module/index.js +4 -4
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/AmplitudeEngagement.d.ts +2 -2
- package/lib/typescript/src/AmplitudeEngagement.d.ts.map +1 -1
- package/lib/typescript/src/AmplitudeEngagementPlugin.d.ts +3 -0
- package/lib/typescript/src/AmplitudeEngagementPlugin.d.ts.map +1 -1
- package/lib/typescript/src/NativePluginEngagementReactNative.d.ts +1 -1
- package/lib/typescript/src/NativePluginEngagementReactNative.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +10 -0
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/AmplitudeEngagement.ts +7 -3
- package/src/AmplitudeEngagementPlugin.ts +16 -2
- package/src/NativePluginEngagementReactNative.ts +1 -1
- package/src/index.tsx +7 -5
- package/src/types.ts +13 -0
|
@@ -15,6 +15,11 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
|
|
16
16
|
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
|
|
17
17
|
s.private_header_files = "ios/**/*.h"
|
|
18
|
+
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
|
|
19
|
+
|
|
20
|
+
# Our framework is statically linked to CQuickJS, so we need to set this to true
|
|
21
|
+
# to avoid having the user set `use_frameworks! :linkage => :static` in their Podfile
|
|
22
|
+
s.static_framework = true
|
|
18
23
|
|
|
19
24
|
# Conditionally vendor frameworks based on CI environment variable
|
|
20
25
|
# This functionality exists to enable development of the SDK locally in React Native/Flutter projects without having to publish the frameworks to a public repository.
|
|
@@ -28,7 +33,7 @@ Pod::Spec.new do |s|
|
|
|
28
33
|
]
|
|
29
34
|
s.dependency 'AmplitudeCore', '>=1.0.12', '<2.0.0'
|
|
30
35
|
else
|
|
31
|
-
s.dependency "AmplitudeEngagementSwift", "
|
|
36
|
+
s.dependency "AmplitudeEngagementSwift", "2.0.0"
|
|
32
37
|
end
|
|
33
38
|
|
|
34
39
|
install_modules_dependencies(s)
|
package/android/build.gradle
CHANGED
|
@@ -86,7 +86,7 @@ dependencies {
|
|
|
86
86
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
87
87
|
|
|
88
88
|
// Amplitude Engagement SDK
|
|
89
|
-
implementation "com.amplitude:amplitude-engagement-android:
|
|
89
|
+
implementation "com.amplitude:amplitude-engagement-android:2.0.0"
|
|
90
90
|
|
|
91
91
|
// Amplitude Analytics SDK (required dependency)
|
|
92
92
|
implementation "com.amplitude:analytics-android:1.+"
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
package com.amplitude.pluginengagementreactnative
|
|
2
2
|
|
|
3
|
-
import android.app.Activity
|
|
4
|
-
import android.app.Application
|
|
5
|
-
import android.content.Context
|
|
6
3
|
import android.content.Intent
|
|
7
|
-
import android.os.Bundle
|
|
8
4
|
import android.util.Log
|
|
9
5
|
import androidx.core.net.toUri
|
|
10
6
|
import com.amplitude.android.engagement.AmplitudeBootOptions
|
|
@@ -13,9 +9,7 @@ import com.amplitude.android.engagement.__ReactNative__AESDK
|
|
|
13
9
|
import com.amplitude.android.engagement.AmplitudeInitOptions
|
|
14
10
|
import com.amplitude.android.engagement.ui.theme.ThemeMode
|
|
15
11
|
import com.amplitude.core.events.BaseEvent
|
|
16
|
-
import com.facebook.react.bridge.ActivityEventListener
|
|
17
12
|
import com.facebook.react.bridge.Arguments
|
|
18
|
-
import com.facebook.react.bridge.Callback
|
|
19
13
|
import com.facebook.react.bridge.LifecycleEventListener
|
|
20
14
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
21
15
|
import com.facebook.react.bridge.ReadableMap
|
|
@@ -24,7 +18,8 @@ import com.facebook.react.module.annotations.ReactModule
|
|
|
24
18
|
import kotlinx.coroutines.Dispatchers
|
|
25
19
|
import kotlinx.coroutines.runBlocking
|
|
26
20
|
import java.util.concurrent.ConcurrentHashMap
|
|
27
|
-
|
|
21
|
+
import com.amplitude.android.engagement.AmplitudeServerZone
|
|
22
|
+
import com.amplitude.android.engagement.AmplitudeLogLevel
|
|
28
23
|
|
|
29
24
|
@ReactModule(name = PluginEngagementReactNativeModule.NAME)
|
|
30
25
|
class PluginEngagementReactNativeModule(val reactContext: ReactApplicationContext) :
|
|
@@ -39,7 +34,8 @@ class PluginEngagementReactNativeModule(val reactContext: ReactApplicationContex
|
|
|
39
34
|
return NAME
|
|
40
35
|
}
|
|
41
36
|
|
|
42
|
-
override fun newInstance(apiKey: String): Double {
|
|
37
|
+
override fun newInstance(apiKey: String, options: ReadableMap?): Double {
|
|
38
|
+
// --- remove this comment ---
|
|
43
39
|
val existingId = instances.entries.firstOrNull { it.value.apiKey == apiKey }?.key
|
|
44
40
|
if (existingId != null) {
|
|
45
41
|
return existingId
|
|
@@ -47,7 +43,37 @@ class PluginEngagementReactNativeModule(val reactContext: ReactApplicationContex
|
|
|
47
43
|
|
|
48
44
|
return synchronized(this) {
|
|
49
45
|
runBlocking(Dispatchers.Main) {
|
|
50
|
-
val
|
|
46
|
+
val serverZone = options?.getString("serverZone")?.let {
|
|
47
|
+
runCatching { AmplitudeServerZone.valueOf(it) }.getOrNull()
|
|
48
|
+
} ?: AmplitudeServerZone.US
|
|
49
|
+
|
|
50
|
+
val logLevel = options?.getString("logLevel")?.let { level ->
|
|
51
|
+
runCatching { AmplitudeLogLevel.valueOf(level.uppercase()) }.getOrNull()
|
|
52
|
+
} ?: AmplitudeLogLevel.WARN
|
|
53
|
+
|
|
54
|
+
val locale = if (options?.hasKey("locale") == true) options.getString("locale") else null
|
|
55
|
+
|
|
56
|
+
val serverUrl = if (options?.hasKey("serverUrl") == true) options.getString("serverUrl") else null
|
|
57
|
+
val cdnUrl = if (options?.hasKey("cdnUrl") == true) options.getString("cdnUrl") else null
|
|
58
|
+
val mediaUrl = if (options?.hasKey("mediaUrl") == true) options.getString("mediaUrl") else null
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
var initOptions = AmplitudeInitOptions(
|
|
62
|
+
serverZone = serverZone,
|
|
63
|
+
serverUrl = serverUrl,
|
|
64
|
+
cdnUrl = cdnUrl,
|
|
65
|
+
mediaUrl = mediaUrl,
|
|
66
|
+
logLevel = logLevel
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
if(locale != null) {
|
|
70
|
+
// this way, we get the default value for `locale` from AmplitudeInitOptions
|
|
71
|
+
// UNLESS a locale is specified
|
|
72
|
+
initOptions = initOptions.copy(locale = locale)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
Log.d("PluginEngagementReactNativeModule", "newInstance apiKey=${apiKey}, options=${options}, initOptions=${initOptions}")
|
|
76
|
+
val amplitudeEngagement = __ReactNative__AESDK(reactContext, apiKey, initOptions)
|
|
51
77
|
|
|
52
78
|
// The React Native environment seems to have a different activity management lifecycle;
|
|
53
79
|
// so we need to register our own listener to get the current activity.
|
|
@@ -68,6 +94,7 @@ class PluginEngagementReactNativeModule(val reactContext: ReactApplicationContex
|
|
|
68
94
|
|
|
69
95
|
_id++
|
|
70
96
|
val id = _id
|
|
97
|
+
Log.d("PluginEngagementReactNativeModule", "newInstance id=${id}")
|
|
71
98
|
instances[id] = InstanceInfo(
|
|
72
99
|
apiKey,
|
|
73
100
|
amplitudeEngagement
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import AmplitudeEngagementSwift
|
|
9
9
|
import Foundation
|
|
10
|
+
import os
|
|
10
11
|
|
|
11
12
|
extension Encodable {
|
|
12
13
|
/// Converting object to postable dictionary
|
|
@@ -27,17 +28,73 @@ var _id = 0
|
|
|
27
28
|
|
|
28
29
|
/// `@objc` attribute exposes Swift methods to the Objective-C runtime*
|
|
29
30
|
@objc public class AmplitudeEngagementAdapter: NSObject {
|
|
30
|
-
|
|
31
|
+
private static let logger = Logger(subsystem: "PluginEngagementReactNative",
|
|
32
|
+
category: "AmplitudeEngagementAdapter")
|
|
33
|
+
|
|
34
|
+
@objc public func newInstance(_ apiKey: String, _ options: [String: Any]?) -> Int {
|
|
31
35
|
if let existingId = instances.first(where: { $0.value.0 == apiKey })?.key {
|
|
32
36
|
return existingId
|
|
33
37
|
}
|
|
34
38
|
|
|
39
|
+
var logLevel: AmplitudeLogLevel = .verbose
|
|
40
|
+
if let logLevelStr: String = options?["logLevel"] as? String {
|
|
41
|
+
switch logLevelStr.lowercased() {
|
|
42
|
+
case "none":
|
|
43
|
+
logLevel = .none
|
|
44
|
+
case "error":
|
|
45
|
+
logLevel = .error
|
|
46
|
+
case "warn":
|
|
47
|
+
logLevel = .warn
|
|
48
|
+
case "verbose", "info":
|
|
49
|
+
logLevel = .verbose
|
|
50
|
+
case "debug":
|
|
51
|
+
logLevel = .debug
|
|
52
|
+
default:
|
|
53
|
+
AmplitudeEngagement.logger.log("Unknown logLevel: \(logLevelStr). Defaulting to 'verbose'.")
|
|
54
|
+
logLevel = .verbose
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var serverZone = AmplitudeServerZone.US
|
|
59
|
+
if let serverZoneStr: String = options?["serverZone"] as? String {
|
|
60
|
+
switch serverZoneStr.lowercased() {
|
|
61
|
+
case "us":
|
|
62
|
+
serverZone = .US
|
|
63
|
+
case "eu":
|
|
64
|
+
serverZone = .EU
|
|
65
|
+
default:
|
|
66
|
+
serverZone = .US
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let locale = options?["locale"] as? String
|
|
71
|
+
|
|
72
|
+
let serverUrl = options?["serverUrl"] as? String
|
|
73
|
+
let cdnUrl = options?["cdnUrl"] as? String
|
|
74
|
+
let mediaUrl = options?["mediaUrl"] as? String
|
|
75
|
+
|
|
76
|
+
let initOptions = AmplitudeInitOptions(
|
|
77
|
+
serverZone: serverZone,
|
|
78
|
+
locale: locale,
|
|
79
|
+
logLevel: logLevel,
|
|
80
|
+
serverUrl: serverUrl,
|
|
81
|
+
cdnUrl: cdnUrl,
|
|
82
|
+
mediaUrl: mediaUrl,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
AmplitudeEngagementAdapter.logger.debug(
|
|
86
|
+
"AmplitudeEngagementAdapter#newInstace apiKey=\(apiKey), options=\(String(describing: options), privacy: .public); initOptions=\(String(describing: initOptions), privacy: .public)"
|
|
87
|
+
)
|
|
88
|
+
|
|
35
89
|
return DispatchQueue.main.sync {
|
|
36
90
|
_id += 1
|
|
37
91
|
let id = _id + 1
|
|
92
|
+
AmplitudeEngagementAdapter.logger.debug(
|
|
93
|
+
"AmplitudeEngagementAdapter#newInstace id=\(id)"
|
|
94
|
+
)
|
|
38
95
|
instances[id] = (
|
|
39
96
|
apiKey,
|
|
40
|
-
__ReactNative__AESDK(apiKey,
|
|
97
|
+
__ReactNative__AESDK(apiKey, initOptions)
|
|
41
98
|
)
|
|
42
99
|
return id
|
|
43
100
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
#import "PluginEngagementReactNative.h"
|
|
2
|
+
|
|
3
|
+
// Support both static and dynamic framework contexts
|
|
4
|
+
// Static frameworks (Expo with use_frameworks! :linkage => :static) use modular header path
|
|
5
|
+
#if __has_include(<PluginEngagementReactNative/PluginEngagementReactNative-Swift.h>)
|
|
6
|
+
#import <PluginEngagementReactNative/PluginEngagementReactNative-Swift.h>
|
|
7
|
+
#else
|
|
2
8
|
#import "PluginEngagementReactNative-Swift.h"
|
|
9
|
+
#endif
|
|
3
10
|
|
|
4
11
|
//@interface RCT_EXTERN_MODULE(AmplitudeEngagementAdapter, NSObject)
|
|
5
12
|
|
|
@@ -40,8 +47,8 @@
|
|
|
40
47
|
return [adapter list:id];
|
|
41
48
|
}
|
|
42
49
|
|
|
43
|
-
- (NSNumber *)newInstance:(nonnull NSString *)apiKey {
|
|
44
|
-
return @([adapter newInstance:apiKey]);
|
|
50
|
+
- (NSNumber *)newInstance:(nonnull NSString *)apiKey options:(NSDictionary *)options {
|
|
51
|
+
return @([adapter newInstance:apiKey :options]);
|
|
45
52
|
}
|
|
46
53
|
|
|
47
54
|
- (NSNumber*)handleURL:(double)id url:(NSString *)url {
|
|
@@ -4,9 +4,9 @@ import { NativeModules } from 'react-native';
|
|
|
4
4
|
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
5
5
|
const PluginEngagementReactNative = isTurboModuleEnabled ? require('./NativePluginEngagementReactNative').default : NativeModules.PluginEngagementReactNative;
|
|
6
6
|
export class AmplitudeEngagement {
|
|
7
|
-
constructor(apiKey) {
|
|
7
|
+
constructor(apiKey, options) {
|
|
8
8
|
// Initialize the plugin with the API key
|
|
9
|
-
this.id = PluginEngagementReactNative.newInstance(apiKey);
|
|
9
|
+
this.id = PluginEngagementReactNative.newInstance(apiKey, options);
|
|
10
10
|
}
|
|
11
11
|
boot(user_id, device_id) {
|
|
12
12
|
PluginEngagementReactNative.boot(this.id, user_id, device_id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","isTurboModuleEnabled","global","__turboModuleProxy","PluginEngagementReactNative","require","default","AmplitudeEngagement","constructor","apiKey","id","newInstance","boot","user_id","device_id","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","isTurboModuleEnabled","global","__turboModuleProxy","PluginEngagementReactNative","require","default","AmplitudeEngagement","constructor","apiKey","options","id","newInstance","boot","user_id","device_id","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;AAU5C,MAAMC,oBAAoB,GAAIC,MAAM,CAASC,kBAAkB,IAAI,IAAI;AAEvE,MAAMC,2BAA4D,GAChEH,oBAAoB,GAChBI,OAAO,CAAC,qCAAqC,CAAC,CAACC,OAAO,GACtDN,aAAa,CAACI,2BAA2B;AAE/C,OAAO,MAAMG,mBAAmB,CAAC;EAG/BC,WAAWA,CAACC,MAAc,EAAEC,OAA8B,EAAE;IAC1D;IACA,IAAI,CAACC,EAAE,GAAGP,2BAA2B,CAACQ,WAAW,CAACH,MAAM,EAAEC,OAAO,CAAC;EACpE;EAEAG,IAAIA,CAACC,OAAgB,EAAEC,SAAkB,EAAQ;IAC/CX,2BAA2B,CAACS,IAAI,CAAC,IAAI,CAACF,EAAE,EAAEG,OAAO,EAAEC,SAAS,CAAC;EAC/D;EAEAC,YAAYA,CAACC,SAAoB,EAAQ;IACvC,OAAOb,2BAA2B,CAACY,YAAY,CAAC,IAAI,CAACL,EAAE,EAAEM,SAAS,CAAC;EACrE;EAEAC,KAAKA,CAACC,GAAW,EAAEC,SAAiB,EAAQ;IAC1C,OAAOhB,2BAA2B,CAACc,KAAK,CAAC,IAAI,CAACP,EAAE,EAAEQ,GAAG,EAAEC,SAAS,CAAC;EACnE;EAEAC,IAAIA,CAAA,EAAoB;IACtB,OAAOjB,2BAA2B,CAACiB,IAAI,CAAC,IAAI,CAACV,EAAE,CAAC;EAClD;EAEAW,IAAIA,CAACH,GAAW,EAAEC,SAAiB,EAAQ;IACzC,OAAOhB,2BAA2B,CAACkB,IAAI,CAAC,IAAI,CAACX,EAAE,EAAEQ,GAAG,EAAEC,SAAS,CAAC;EAClE;EAEAG,MAAMA,CAACC,UAAkB,EAAQ;IAC/B,OAAOpB,2BAA2B,CAACmB,MAAM,CAAC,IAAI,CAACZ,EAAE,EAAEa,UAAU,CAAC;EAChE;EAEAC,QAAQA,CAAA,EAAS;IACf,OAAOrB,2BAA2B,CAACqB,QAAQ,CAAC,IAAI,CAACd,EAAE,CAAC;EACtD;EAEAe,YAAYA,CAACC,KAAgB,EAAQ;IACnC,OAAOvB,2BAA2B,CAACsB,YAAY,CAAC,IAAI,CAACf,EAAE,EAAEgB,KAAK,CAAC;EACjE;EAEAC,WAAWA,CAACT,GAAW,EAAEU,IAAgB,EAAc;IACrDzB,2BAA2B,CAACwB,WAAW,CAAC,IAAI,CAACjB,EAAE,EAAEQ,GAAG,CAAC;IAErD,MAAMW,OAAO,GAAG1B,2BAA2B,CAAC2B,gBAAgB,CACzDC,UAAU,IAAK;MACd,IAAIA,UAAU,CAACrB,EAAE,KAAK,IAAI,CAACA,EAAE,IAAIqB,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,OAAO/B,2BAA2B,CAAC8B,SAAS,CAAC,IAAI,CAACvB,EAAE,EAAEwB,GAAG,CAAC;EAC5D;AACF","ignoreList":[]}
|
|
@@ -13,10 +13,21 @@ export class AmplitudeEngagementPlugin {
|
|
|
13
13
|
static SDK_LIBRARY = 'amplitude-engagement-react-native';
|
|
14
14
|
static SDK_VERSION = version;
|
|
15
15
|
trackEventSubscription = null;
|
|
16
|
+
constructor(initOptions) {
|
|
17
|
+
this.initOptions = initOptions;
|
|
18
|
+
}
|
|
16
19
|
async setup(config, client) {
|
|
17
20
|
try {
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
/* IMPORTANT do not take serverUrl from Analytics config, since Engagement uses its own backend */
|
|
22
|
+
const {
|
|
23
|
+
apiKey,
|
|
24
|
+
serverZone
|
|
25
|
+
} = config;
|
|
26
|
+
this.logger.log(`AmplitudeEngagementPlugin#setup; apiKey=${apiKey}, serverZone=${serverZone}`);
|
|
27
|
+
init(apiKey, {
|
|
28
|
+
serverZone,
|
|
29
|
+
...this.initOptions
|
|
30
|
+
});
|
|
20
31
|
this.client = client;
|
|
21
32
|
// TODO: grab identity from client when available -- need to wait until it's added.
|
|
22
33
|
// Need to wait until https://amplitude.atlassian.net/browse/AMP-133461 is resolved
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardEvent","init","screen","boot","NativePluginEngagementReactNative","Logger","version","AmplitudeEngagementPlugin","name","type","logger","SDK_LIBRARY","SDK_VERSION","trackEventSubscription","setup","config","client","
|
|
1
|
+
{"version":3,"names":["forwardEvent","init","screen","boot","NativePluginEngagementReactNative","Logger","version","AmplitudeEngagementPlugin","name","type","logger","SDK_LIBRARY","SDK_VERSION","trackEventSubscription","constructor","initOptions","setup","config","client","apiKey","serverZone","log","error","user_id","device_id","remove","onTrackEvent","event","eventProperties","event_properties","track","event_type","execute","context","JSON","stringify","screenName"],"sourceRoot":"../../src","sources":["AmplitudeEngagementPlugin.ts"],"mappings":";;AAMA,SAASA,YAAY,EAAEC,IAAI,EAAEC,MAAM,EAAEC,IAAI,QAAQ,YAAG;AACpD,OAAOC,iCAAiC,MAAM,wCAAqC;AAEnF,SAASC,MAAM,QAA8B,aAAU;AAEvD,SAASC,OAAO,QAAQ,sBAAsB;AAG9C,OAAO,MAAMC,yBAAyB,CAEtC;EACEC,IAAI,GAAG,2BAA2B;EAClCC,IAAI,GAAG,YAAY;EAWnBC,MAAM,GAAoB,IAAIL,MAAM,CAAC,2BAA2B,CAAC;;EA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AK,CAACI,UAAU,EAAEH,eAAe,CAAC;IACvD,CAAC,CAAC;EACN;EAEA,MAAMI,OAAOA,CAACC,OAAc,EAAyB;IACnD,IAAI,CAACvB,MAAM,CAACW,GAAG,CACb,qCAAqCa,IAAI,CAACC,SAAS,CAACF,OAAO,CAAC,EAC9D,CAAC;IAED,IACEA,OAAO,CAACF,UAAU,KAAK,2BAA2B,IAClD,OAAOE,OAAO,CAACJ,gBAAgB,GAAG,yBAAyB,CAAC,KAAK,QAAQ,EACzE;MACA,MAAMO,UAAU,GAAGH,OAAO,CAACJ,gBAAgB,CACzC,yBAAyB,CAChB;MACX3B,MAAM,CAACkC,UAAU,CAAC;IACpB;IAEApC,YAAY,CAACiC,OAAO,CAAC;IAErB,OAAOA,OAAO;EAChB;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"
|
|
1
|
+
{"version":"2.0.0"}
|
package/lib/module/index.js
CHANGED
|
@@ -15,12 +15,12 @@ async function getGlobalEngagement() {
|
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
export function init(apiKey) {
|
|
18
|
+
export function init(apiKey, options) {
|
|
19
19
|
// Initialize the plugin with the API key
|
|
20
20
|
if (globalEngagement) {
|
|
21
21
|
throw new Error('AmplitudeEngagement already initialized');
|
|
22
22
|
}
|
|
23
|
-
globalEngagement = new AmplitudeEngagement(apiKey);
|
|
23
|
+
globalEngagement = new AmplitudeEngagement(apiKey, options);
|
|
24
24
|
toNotify.forEach(callback => {
|
|
25
25
|
callback(globalEngagement);
|
|
26
26
|
});
|
|
@@ -63,9 +63,9 @@ export async function handleURL(url) {
|
|
|
63
63
|
return e.handleURL(url);
|
|
64
64
|
}
|
|
65
65
|
let plugin = null;
|
|
66
|
-
export function getPlugin() {
|
|
66
|
+
export function getPlugin(initOptions) {
|
|
67
67
|
if (!plugin) {
|
|
68
|
-
plugin = new AmplitudeEngagementPlugin();
|
|
68
|
+
plugin = new AmplitudeEngagementPlugin(initOptions);
|
|
69
69
|
}
|
|
70
70
|
return plugin;
|
|
71
71
|
}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AmplitudeEngagement","AmplitudeEngagementPlugin","globalEngagement","toNotify","getGlobalEngagement","Promise","resolve","_reject","push","engagement","init","apiKey","Error","forEach","callback","boot","user_id","device_id","e","list","show","key","stepIndex","screen","screenName","closeAll","forwardEvent","event","addCallback","func","removePromise","then","r","handleURL","url","plugin","getPlugin"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,mBAAmB,QAAQ,0BAAuB;AAC3D,SAASC,yBAAyB,QAAQ,gCAA6B;AAIvE,IAAIC,gBAAqC,GAAG,IAAW;AACvD,IAAIC,QAAuD,GAAG,EAAE;AAEhE,eAAeC,mBAAmBA,CAAA,EAAiC;EACjE,IAAIF,gBAAgB,EAAE;IACpB,OAAOA,gBAAgB;EACzB,CAAC,MAAM;IACL,OAAO,MAAM,IAAIG,OAAO,CAAC,CAACC,OAAO,EAAEC,OAAO,KAAK;MAC7CJ,QAAQ,CAACK,IAAI,CAAEC,UAAU,IAAK;QAC5BH,OAAO,CAACG,UAAU,CAAC;MACrB,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;AACF;AAEA,OAAO,SAASC,IAAIA,CAACC,MAAc,EAAQ;
|
|
1
|
+
{"version":3,"names":["AmplitudeEngagement","AmplitudeEngagementPlugin","globalEngagement","toNotify","getGlobalEngagement","Promise","resolve","_reject","push","engagement","init","apiKey","options","Error","forEach","callback","boot","user_id","device_id","e","list","show","key","stepIndex","screen","screenName","closeAll","forwardEvent","event","addCallback","func","removePromise","then","r","handleURL","url","plugin","getPlugin","initOptions"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,mBAAmB,QAAQ,0BAAuB;AAC3D,SAASC,yBAAyB,QAAQ,gCAA6B;AAIvE,IAAIC,gBAAqC,GAAG,IAAW;AACvD,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AAMN,CAAC,GAAG,MAAMf,mBAAmB,CAAC,CAAC;EACrC,OAAOe,CAAC,CAACK,MAAM,CAACC,UAAU,CAAC;AAC7B;AAEA,OAAO,eAAeC,QAAQA,CAAA,EAAkB;EAC9C,MAAMP,CAAC,GAAG,MAAMf,mBAAmB,CAAC,CAAC;EACrC,OAAOe,CAAC,CAACO,QAAQ,CAAC,CAAC;AACrB;AAEA,OAAO,eAAeC,YAAYA,CAACC,KAAgB,EAAiB;EAClE,MAAMT,CAAC,GAAG,MAAMf,mBAAmB,CAAC,CAAC;EACrC,OAAOe,CAAC,CAACQ,YAAY,CAACC,KAAK,CAAC;AAC9B;AAEA,OAAO,SAASC,WAAWA,CAACP,GAAW,EAAEQ,IAAgB,EAAc;EACrE,MAAMC,aAAa,GAAG3B,mBAAmB,CAAC,CAAC,CAAC4B,IAAI,CAAEvB,UAAU,IAAK;IAC/D,OAAOA,UAAU,CAACoB,WAAW,CAACP,GAAG,EAAEQ,IAAI,CAAC;EAC1C,CAAC,CAAC;EAEF,OAAO,MAAM;IACXC,aAAa,CAACC,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAAC,CAAC,CAAC;EAChC,CAAC;AACH;AAEA,OAAO,eAAeC,SAASA,CAACC,GAAW,EAAoB;EAC7D,MAAMhB,CAAC,GAAG,MAAMf,mBAAmB,CAAC,CAAC;EACrC,OAAOe,CAAC,CAACe,SAAS,CAACC,GAAG,CAAC;AACzB;AAEA,IAAIC,MAAwC,GAAG,IAAI;AACnD,OAAO,SAASC,SAASA,CACvBC,WAAkC,EACP;EAC3B,IAAI,CAACF,MAAM,EAAE;IACXA,MAAM,GAAG,IAAInC,yBAAyB,CAACqC,WAAW,CAAC;EACrD;EAEA,OAAOF,MAAM;AACf","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { GuideOrSurvey, ThemeMode } from './types';
|
|
1
|
+
import type { AmplitudeInitOptions, GuideOrSurvey, ThemeMode } from './types';
|
|
2
2
|
import type { BaseEvent } from '@amplitude/analytics-core';
|
|
3
3
|
export declare class AmplitudeEngagement {
|
|
4
4
|
id: number;
|
|
5
|
-
constructor(apiKey: string);
|
|
5
|
+
constructor(apiKey: string, options?: AmplitudeInitOptions);
|
|
6
6
|
boot(user_id?: string, device_id?: string): void;
|
|
7
7
|
setThemeMode(themeMode: ThemeMode): void;
|
|
8
8
|
reset(key: string, stepIndex: number): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmplitudeEngagement.d.ts","sourceRoot":"","sources":["../../../src/AmplitudeEngagement.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"AmplitudeEngagement.d.ts","sourceRoot":"","sources":["../../../src/AmplitudeEngagement.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,SAAS,EACV,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAW3D,qBAAa,mBAAmB;IAC9B,EAAE,EAAE,MAAM,CAAC;gBAEC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB;IAK1D,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAIhD,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"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { EnrichmentPlugin, Event, ReactNativeClient, ReactNativeConfig } from '@amplitude/analytics-core';
|
|
2
2
|
import { type AmplitudeLogger } from './logger';
|
|
3
3
|
import type { EventSubscription } from 'react-native';
|
|
4
|
+
import type { AmplitudeInitOptions } from './types';
|
|
4
5
|
export declare class AmplitudeEngagementPlugin implements EnrichmentPlugin<ReactNativeClient, ReactNativeConfig> {
|
|
5
6
|
name: string;
|
|
6
7
|
type: "enrichment";
|
|
8
|
+
initOptions?: AmplitudeInitOptions;
|
|
7
9
|
client?: ReactNativeClient;
|
|
8
10
|
userId?: string;
|
|
9
11
|
deviceId?: string;
|
|
@@ -13,6 +15,7 @@ export declare class AmplitudeEngagementPlugin implements EnrichmentPlugin<React
|
|
|
13
15
|
private static readonly SDK_LIBRARY;
|
|
14
16
|
private static readonly SDK_VERSION;
|
|
15
17
|
trackEventSubscription: EventSubscription | null;
|
|
18
|
+
constructor(initOptions?: AmplitudeInitOptions);
|
|
16
19
|
setup(config: ReactNativeConfig, client: ReactNativeClient): Promise<void>;
|
|
17
20
|
boot(user_id?: string, device_id?: string): void;
|
|
18
21
|
execute(context: Event): Promise<Event | null>;
|
|
@@ -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;AAInC,OAAO,EAAU,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"AmplitudeEngagementPlugin.d.ts","sourceRoot":"","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|
|
|
10
10
|
key: string;
|
|
11
11
|
};
|
|
12
12
|
export interface Spec extends TurboModule {
|
|
13
|
-
newInstance(apiKey: string): number;
|
|
13
|
+
newInstance(apiKey: string, options?: Object): number;
|
|
14
14
|
boot(id: number, user_id?: string, device_id?: string): void;
|
|
15
15
|
setThemeMode(id: number, themeMode: string): void;
|
|
16
16
|
reset(id: number, key: string, stepIndex: number): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativePluginEngagementReactNative.d.ts","sourceRoot":"","sources":["../../../src/NativePluginEngagementReactNative.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAE9E,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"NativePluginEngagementReactNative.d.ts","sourceRoot":"","sources":["../../../src/NativePluginEngagementReactNative.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAE9E,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,M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
|
1
1
|
import { AmplitudeEngagementPlugin } from './AmplitudeEngagementPlugin';
|
|
2
|
-
import type { GuideOrSurvey } from './types';
|
|
2
|
+
import type { AmplitudeInitOptions, GuideOrSurvey } from './types';
|
|
3
3
|
import type { BaseEvent } from '@amplitude/analytics-core';
|
|
4
|
-
export declare function init(apiKey: string): void;
|
|
4
|
+
export declare function init(apiKey: string, options?: AmplitudeInitOptions): void;
|
|
5
5
|
export declare function boot(user_id?: string, device_id?: string): Promise<void>;
|
|
6
6
|
export declare function list(): Promise<GuideOrSurvey[]>;
|
|
7
7
|
export declare function show(key: string, stepIndex: number): Promise<void>;
|
|
@@ -10,5 +10,5 @@ export declare function closeAll(): Promise<void>;
|
|
|
10
10
|
export declare function forwardEvent(event: BaseEvent): Promise<void>;
|
|
11
11
|
export declare function addCallback(key: string, func: () => void): () => void;
|
|
12
12
|
export declare function handleURL(url: string): Promise<boolean>;
|
|
13
|
-
export declare function getPlugin(): AmplitudeEngagementPlugin;
|
|
13
|
+
export declare function getPlugin(initOptions?: AmplitudeInitOptions): AmplitudeEngagementPlugin;
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAiB3D,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAUzE;AAED,wBAAsB,IAAI,CACxB,OAAO,CAAC,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAGf;AAED,wBAAsB,IAAI,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC,CAGrD;AAED,wBAAsB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGxE;AAED,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9D;AAED,wBAAsB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAG9C;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAGlE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAQrE;AAED,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAG7D;AAGD,wBAAgB,SAAS,CACvB,WAAW,CAAC,EAAE,oBAAoB,GACjC,yBAAyB,CAM3B"}
|
|
@@ -4,6 +4,16 @@ export type GuideOrSurvey = {
|
|
|
4
4
|
title: string;
|
|
5
5
|
};
|
|
6
6
|
export type ThemeMode = 'auto' | 'dark_mode' | 'light_mode';
|
|
7
|
+
export type AmplitudeLogLevel = 'none' | 'error' | 'warn' | 'verbose' | 'debug';
|
|
8
|
+
export type AmplitudeServerZone = 'US' | 'EU';
|
|
9
|
+
export type AmplitudeInitOptions = {
|
|
10
|
+
serverZone?: AmplitudeServerZone;
|
|
11
|
+
serverUrl?: string;
|
|
12
|
+
cdnUrl?: string;
|
|
13
|
+
mediaUrl?: string;
|
|
14
|
+
logLevel?: AmplitudeLogLevel;
|
|
15
|
+
locale?: string;
|
|
16
|
+
};
|
|
7
17
|
export type AmplitudeEndUser = {
|
|
8
18
|
user_id?: string;
|
|
9
19
|
device_id?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,WAAW,GAAG,YAAY,CAAC;AAE5D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,gBAAgB,CAAC;IACvB,YAAY,EAAE,CAAC,CACb,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,KACpC,IAAI,CAAC,EAAE,CAAC;CACd,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,WAAW,GAAG,YAAY,CAAC;AAE5D,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAEhF,MAAM,MAAM,mBAAmB,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9C,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,gBAAgB,CAAC;IACvB,YAAY,EAAE,CAAC,CACb,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,KACpC,IAAI,CAAC,EAAE,CAAC;CACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amplitude/plugin-engagement-react-native",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.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",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@react-native/babel-preset": "0.79.2",
|
|
67
67
|
"@react-native/eslint-config": "^0.78.0",
|
|
68
68
|
"@types/jest": "^29.5.5",
|
|
69
|
-
"@types/react": "
|
|
69
|
+
"@types/react": "19.0.1",
|
|
70
70
|
"commitlint": "^19.6.1",
|
|
71
71
|
"del-cli": "^5.1.0",
|
|
72
72
|
"eslint": "^9.22.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"eslint-plugin-prettier": "^5.2.3",
|
|
75
75
|
"jest": "^29.7.0",
|
|
76
76
|
"prettier": "^3.0.3",
|
|
77
|
-
"react": "19.0.
|
|
77
|
+
"react": "19.0.1",
|
|
78
78
|
"react-native": "0.79.2",
|
|
79
79
|
"react-native-builder-bob": "^0.40.11",
|
|
80
80
|
"tsx": "^4.20.3",
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Spec } from './NativePluginEngagementReactNative';
|
|
2
2
|
import { NativeModules } from 'react-native';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
AmplitudeInitOptions,
|
|
5
|
+
GuideOrSurvey,
|
|
6
|
+
ThemeMode,
|
|
7
|
+
} from './types';
|
|
4
8
|
import type { BaseEvent } from '@amplitude/analytics-core';
|
|
5
9
|
|
|
6
10
|
type PluginEngagementReactNativeType = Exclude<Spec, 'getConstants'>;
|
|
@@ -15,9 +19,9 @@ const PluginEngagementReactNative: PluginEngagementReactNativeType =
|
|
|
15
19
|
export class AmplitudeEngagement {
|
|
16
20
|
id: number;
|
|
17
21
|
|
|
18
|
-
constructor(apiKey: string) {
|
|
22
|
+
constructor(apiKey: string, options?: AmplitudeInitOptions) {
|
|
19
23
|
// Initialize the plugin with the API key
|
|
20
|
-
this.id = PluginEngagementReactNative.newInstance(apiKey);
|
|
24
|
+
this.id = PluginEngagementReactNative.newInstance(apiKey, options);
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
boot(user_id?: string, device_id?: string): void {
|
|
@@ -10,6 +10,7 @@ import NativePluginEngagementReactNative from './NativePluginEngagementReactNati
|
|
|
10
10
|
import { Logger, type AmplitudeLogger } from './logger';
|
|
11
11
|
import type { EventSubscription } from 'react-native';
|
|
12
12
|
import { version } from './build-version.json';
|
|
13
|
+
import type { AmplitudeInitOptions } from './types';
|
|
13
14
|
|
|
14
15
|
export class AmplitudeEngagementPlugin
|
|
15
16
|
implements EnrichmentPlugin<ReactNativeClient, ReactNativeConfig>
|
|
@@ -17,6 +18,8 @@ export class AmplitudeEngagementPlugin
|
|
|
17
18
|
name = 'AmplitudeEngagementPlugin';
|
|
18
19
|
type = 'enrichment' as const;
|
|
19
20
|
|
|
21
|
+
initOptions?: AmplitudeInitOptions;
|
|
22
|
+
|
|
20
23
|
client?: ReactNativeClient;
|
|
21
24
|
|
|
22
25
|
userId?: string;
|
|
@@ -32,13 +35,24 @@ export class AmplitudeEngagementPlugin
|
|
|
32
35
|
|
|
33
36
|
trackEventSubscription: EventSubscription | null = null;
|
|
34
37
|
|
|
38
|
+
constructor(initOptions?: AmplitudeInitOptions) {
|
|
39
|
+
this.initOptions = initOptions;
|
|
40
|
+
}
|
|
41
|
+
|
|
35
42
|
async setup(
|
|
36
43
|
config: ReactNativeConfig,
|
|
37
44
|
client: ReactNativeClient
|
|
38
45
|
): Promise<void> {
|
|
39
46
|
try {
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
/* IMPORTANT do not take serverUrl from Analytics config, since Engagement uses its own backend */
|
|
48
|
+
const { apiKey, serverZone } = config;
|
|
49
|
+
this.logger.log(
|
|
50
|
+
`AmplitudeEngagementPlugin#setup; apiKey=${apiKey}, serverZone=${serverZone}`
|
|
51
|
+
);
|
|
52
|
+
init(apiKey, {
|
|
53
|
+
serverZone,
|
|
54
|
+
...this.initOptions,
|
|
55
|
+
});
|
|
42
56
|
this.client = client;
|
|
43
57
|
// TODO: grab identity from client when available -- need to wait until it's added.
|
|
44
58
|
// Need to wait until https://amplitude.atlassian.net/browse/AMP-133461 is resolved
|
|
@@ -14,7 +14,7 @@ export type CallbackInvocation = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export interface Spec extends TurboModule {
|
|
17
|
-
newInstance(apiKey: string): number;
|
|
17
|
+
newInstance(apiKey: string, options?: Object): number;
|
|
18
18
|
|
|
19
19
|
boot(id: number, user_id?: string, device_id?: string): void;
|
|
20
20
|
setThemeMode(id: number, themeMode: string /* ThemeMode */): void;
|
package/src/index.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AmplitudeEngagement } from './AmplitudeEngagement';
|
|
2
2
|
import { AmplitudeEngagementPlugin } from './AmplitudeEngagementPlugin';
|
|
3
|
-
import type { GuideOrSurvey } from './types';
|
|
3
|
+
import type { AmplitudeInitOptions, GuideOrSurvey } from './types';
|
|
4
4
|
import type { BaseEvent } from '@amplitude/analytics-core';
|
|
5
5
|
|
|
6
6
|
let globalEngagement: AmplitudeEngagement = null as any;
|
|
@@ -18,12 +18,12 @@ async function getGlobalEngagement(): Promise<AmplitudeEngagement> {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export function init(apiKey: string): void {
|
|
21
|
+
export function init(apiKey: string, options?: AmplitudeInitOptions): void {
|
|
22
22
|
// Initialize the plugin with the API key
|
|
23
23
|
if (globalEngagement) {
|
|
24
24
|
throw new Error('AmplitudeEngagement already initialized');
|
|
25
25
|
}
|
|
26
|
-
globalEngagement = new AmplitudeEngagement(apiKey);
|
|
26
|
+
globalEngagement = new AmplitudeEngagement(apiKey, options);
|
|
27
27
|
toNotify.forEach((callback) => {
|
|
28
28
|
callback(globalEngagement);
|
|
29
29
|
});
|
|
@@ -79,9 +79,11 @@ export async function handleURL(url: string): Promise<boolean> {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
let plugin: AmplitudeEngagementPlugin | null = null;
|
|
82
|
-
export function getPlugin(
|
|
82
|
+
export function getPlugin(
|
|
83
|
+
initOptions?: AmplitudeInitOptions
|
|
84
|
+
): AmplitudeEngagementPlugin {
|
|
83
85
|
if (!plugin) {
|
|
84
|
-
plugin = new AmplitudeEngagementPlugin();
|
|
86
|
+
plugin = new AmplitudeEngagementPlugin(initOptions);
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
return plugin;
|
package/src/types.ts
CHANGED
|
@@ -6,6 +6,19 @@ export type GuideOrSurvey = {
|
|
|
6
6
|
|
|
7
7
|
export type ThemeMode = 'auto' | 'dark_mode' | 'light_mode';
|
|
8
8
|
|
|
9
|
+
export type AmplitudeLogLevel = 'none' | 'error' | 'warn' | 'verbose' | 'debug';
|
|
10
|
+
|
|
11
|
+
export type AmplitudeServerZone = 'US' | 'EU';
|
|
12
|
+
|
|
13
|
+
export type AmplitudeInitOptions = {
|
|
14
|
+
serverZone?: AmplitudeServerZone;
|
|
15
|
+
serverUrl?: string;
|
|
16
|
+
cdnUrl?: string;
|
|
17
|
+
mediaUrl?: string;
|
|
18
|
+
logLevel?: AmplitudeLogLevel;
|
|
19
|
+
locale?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
9
22
|
export type AmplitudeEndUser = {
|
|
10
23
|
user_id?: string;
|
|
11
24
|
device_id?: string;
|