@amplytools/react-native-amply-sdk 0.2.3 → 0.2.5

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.
@@ -0,0 +1,89 @@
1
+ buildscript {
2
+ ext {
3
+ kotlin_version = "1.9.24"
4
+ }
5
+ repositories {
6
+ google()
7
+ mavenCentral()
8
+ }
9
+ dependencies {
10
+ classpath("com.android.tools.build:gradle:8.2.2")
11
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
12
+ }
13
+ }
14
+
15
+ apply plugin: 'com.android.library'
16
+ apply plugin: 'org.jetbrains.kotlin.android'
17
+
18
+ def amplySdkVersion = project.findProperty('amplySdkVersion') ?: System.getenv('AMPLY_SDK_VERSION') ?: '0.2.4'
19
+ group = 'tools.amply'
20
+ version = amplySdkVersion
21
+
22
+ def reactNativeRootDir = file("$projectDir/../node_modules/react-native")
23
+ def reactNativeArchitectures =
24
+ project.hasProperty("reactNativeArchitectures") ?
25
+ project.getProperty("reactNativeArchitectures").split(",") :
26
+ ["armeabi-v7a", "arm64-v8a", "x86", "x86_64"]
27
+
28
+ android {
29
+ namespace 'tools.amply.sdk.reactnative'
30
+ compileSdkVersion 34
31
+
32
+ defaultConfig {
33
+ minSdkVersion 24
34
+ targetSdkVersion 34
35
+ consumerProguardFiles 'consumer-rules.pro'
36
+
37
+ ndk {
38
+ abiFilters(*reactNativeArchitectures)
39
+ }
40
+
41
+ externalNativeBuild {
42
+ cmake {
43
+ arguments "-DREACT_NATIVE_DIR=${reactNativeRootDir.absolutePath}", "-DANDROID_STL=c++_shared"
44
+ }
45
+ }
46
+ }
47
+
48
+ compileOptions {
49
+ sourceCompatibility JavaVersion.VERSION_17
50
+ targetCompatibility JavaVersion.VERSION_17
51
+ }
52
+
53
+ kotlinOptions {
54
+ jvmTarget = '17'
55
+ }
56
+
57
+ lintOptions {
58
+ abortOnError false
59
+ }
60
+
61
+ buildFeatures {
62
+ prefab true
63
+ }
64
+
65
+ sourceSets {
66
+ main {
67
+ java.srcDirs += ["src/newarch/java"]
68
+ }
69
+ }
70
+
71
+ externalNativeBuild {
72
+ cmake {
73
+ path file("src/main/jni/CMakeLists.txt")
74
+ }
75
+ }
76
+ }
77
+
78
+ repositories {
79
+ mavenLocal()
80
+ google()
81
+ mavenCentral()
82
+ }
83
+
84
+ dependencies {
85
+ implementation("com.facebook.react:react-android")
86
+ implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
87
+ implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
88
+ implementation("tools.amply:sdk-android:${amplySdkVersion}")
89
+ }
@@ -155,6 +155,34 @@ class AmplyModule(reactContext: ReactApplicationContext) :
155
155
  return client.getLogLevel().toString()
156
156
  }
157
157
 
158
+ override fun setCustomProperties(properties: ReadableMap) {
159
+ val props = properties.toHashMap()
160
+ client.setCustomProperties(props)
161
+ }
162
+
163
+ override fun getCustomProperty(key: String, promise: Promise) {
164
+ scope.launch {
165
+ try {
166
+ val value = client.getCustomProperty(key)
167
+ val result = Arguments.createMap()
168
+ if (value != null) {
169
+ result.putDynamic("value", value)
170
+ }
171
+ promise.resolve(result)
172
+ } catch (throwable: Throwable) {
173
+ promise.reject(CUSTOM_PROP_ERROR, throwable)
174
+ }
175
+ }
176
+ }
177
+
178
+ override fun removeCustomProperty(key: String) {
179
+ client.removeCustomProperty(key)
180
+ }
181
+
182
+ override fun clearCustomProperties() {
183
+ client.clearCustomProperties()
184
+ }
185
+
158
186
  override fun addListener(eventName: String) {
159
187
  // Required by RN EventEmitter contracts. The native TurboModule infrastructure
160
188
  // handles the actual listener bookkeeping through the C++ event emitter.
@@ -415,5 +443,6 @@ class AmplyModule(reactContext: ReactApplicationContext) :
415
443
  private const val TRACK_ERROR = "AMP_TRACK_FAILED"
416
444
  private const val EVENTS_ERROR = "AMP_EVENTS_FAILED"
417
445
  private const val DATASET_ERROR = "AMP_DATASET_FAILED"
446
+ private const val CUSTOM_PROP_ERROR = "AMP_CUSTOM_PROP_FAILED"
418
447
  }
419
448
  }
@@ -31,6 +31,12 @@ interface AmplyClient {
31
31
  fun setLogLevel(level: LogLevel)
32
32
  fun getLogLevel(): LogLevel
33
33
 
34
+ fun setCustomProperty(key: String, value: Any)
35
+ fun setCustomProperties(properties: Map<String, Any?>)
36
+ fun removeCustomProperty(key: String)
37
+ fun clearCustomProperties()
38
+ suspend fun getCustomProperty(key: String): Any?
39
+
34
40
  fun onHostResume(activity: Activity?)
35
41
 
36
42
  fun shutdown()
@@ -36,7 +36,9 @@ class DefaultAmplyClient(
36
36
  ) : AmplyClient {
37
37
 
38
38
  private val mutex = Mutex()
39
- private var amplyInstance: Amply? = null
39
+ @Volatile private var amplyInstance: Amply? = null
40
+ private val propertyLock = Any()
41
+ private val pendingPropertyOps = mutableListOf<(Amply) -> Unit>()
40
42
  private val deepLinkRegistered = AtomicBoolean(false)
41
43
  private val systemEventsRegistered = AtomicBoolean(false)
42
44
  private val deepLinkSequence = AtomicLong(0L)
@@ -100,7 +102,17 @@ class DefaultAmplyClient(
100
102
  }
101
103
 
102
104
  ensureSystemEventsListener(instance)
103
- amplyInstance = instance
105
+
106
+ // Drain buffered property operations under propertyLock
107
+ synchronized(propertyLock) {
108
+ amplyInstance = instance
109
+ if (pendingPropertyOps.isNotEmpty()) {
110
+ android.util.Log.i("AmplyReactNative", "Draining ${pendingPropertyOps.size} buffered property operations")
111
+ pendingPropertyOps.forEach { op -> op(instance) }
112
+ pendingPropertyOps.clear()
113
+ }
114
+ }
115
+
104
116
  createdInstance = true
105
117
  }
106
118
  }
@@ -217,6 +229,66 @@ class DefaultAmplyClient(
217
229
  android.util.Log.i("AmplyReactNative", "User ID set to: ${userId ?: "<null>"}")
218
230
  }
219
231
 
232
+ override fun setCustomProperty(key: String, value: Any) {
233
+ synchronized(propertyLock) {
234
+ val instance = amplyInstance
235
+ if (instance != null) {
236
+ instance.setCustomProperty(key, value)
237
+ android.util.Log.i("AmplyReactNative", "Custom property set: $key")
238
+ } else {
239
+ android.util.Log.i("AmplyReactNative", "Buffering setCustomProperty until init: $key")
240
+ pendingPropertyOps.add { it.setCustomProperty(key, value) }
241
+ }
242
+ }
243
+ }
244
+
245
+ override fun setCustomProperties(properties: Map<String, Any?>) {
246
+ synchronized(propertyLock) {
247
+ val instance = amplyInstance
248
+ if (instance != null) {
249
+ instance.setCustomProperties(properties.toNonNullMap())
250
+ android.util.Log.i("AmplyReactNative", "Custom properties set: ${properties.keys}")
251
+ } else {
252
+ android.util.Log.i("AmplyReactNative", "Buffering setCustomProperties until init: ${properties.keys}")
253
+ val snapshot = properties.toNonNullMap()
254
+ pendingPropertyOps.add { it.setCustomProperties(snapshot) }
255
+ }
256
+ }
257
+ }
258
+
259
+ override fun removeCustomProperty(key: String) {
260
+ synchronized(propertyLock) {
261
+ val instance = amplyInstance
262
+ if (instance != null) {
263
+ instance.removeCustomProperty(key)
264
+ android.util.Log.i("AmplyReactNative", "Custom property removed: $key")
265
+ } else {
266
+ android.util.Log.i("AmplyReactNative", "Buffering removeCustomProperty until init: $key")
267
+ pendingPropertyOps.add { it.removeCustomProperty(key) }
268
+ }
269
+ }
270
+ }
271
+
272
+ override fun clearCustomProperties() {
273
+ synchronized(propertyLock) {
274
+ val instance = amplyInstance
275
+ if (instance != null) {
276
+ instance.clearCustomProperties()
277
+ android.util.Log.i("AmplyReactNative", "All custom properties cleared")
278
+ } else {
279
+ android.util.Log.i("AmplyReactNative", "Buffering clearCustomProperties until init")
280
+ pendingPropertyOps.add { it.clearCustomProperties() }
281
+ }
282
+ }
283
+ }
284
+
285
+ override suspend fun getCustomProperty(key: String): Any? {
286
+ val instance = requireInstance()
287
+ return withContext(Dispatchers.IO) {
288
+ instance.getCustomProperty(key)
289
+ }
290
+ }
291
+
220
292
  override fun setLogLevel(level: tools.amply.sdk.reactnative.model.LogLevel) {
221
293
  val instance = amplyInstance ?: return
222
294
  instance.setLogLevel(level.toString())
@@ -20,6 +20,7 @@ import com.facebook.react.bridge.ReactMethod;
20
20
  import com.facebook.react.bridge.ReadableMap;
21
21
  import com.facebook.react.turbomodule.core.interfaces.TurboModule;
22
22
  import javax.annotation.Nonnull;
23
+ import javax.annotation.Nullable;
23
24
 
24
25
  public abstract class NativeAmplyModuleSpec extends ReactContextBaseJavaModule implements TurboModule {
25
26
  public static final String NAME = "Amply";
@@ -67,7 +68,7 @@ public abstract class NativeAmplyModuleSpec extends ReactContextBaseJavaModule i
67
68
 
68
69
  @ReactMethod
69
70
  @DoNotStrip
70
- public abstract void setUserId(String userId);
71
+ public abstract void setUserId(@Nullable String userId);
71
72
 
72
73
  @ReactMethod
73
74
  @DoNotStrip
@@ -77,6 +78,22 @@ public abstract class NativeAmplyModuleSpec extends ReactContextBaseJavaModule i
77
78
  @DoNotStrip
78
79
  public abstract String getLogLevel();
79
80
 
81
+ @ReactMethod
82
+ @DoNotStrip
83
+ public abstract void setCustomProperties(ReadableMap properties);
84
+
85
+ @ReactMethod
86
+ @DoNotStrip
87
+ public abstract void getCustomProperty(String key, Promise promise);
88
+
89
+ @ReactMethod
90
+ @DoNotStrip
91
+ public abstract void removeCustomProperty(String key);
92
+
93
+ @ReactMethod
94
+ @DoNotStrip
95
+ public abstract void clearCustomProperties();
96
+
80
97
  @ReactMethod
81
98
  @DoNotStrip
82
99
  public abstract void addListener(String eventName);
@@ -57,6 +57,26 @@ static facebook::jsi::Value __hostFunction_NativeAmplyModuleSpecJSI_getLogLevel(
57
57
  return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, StringKind, "getLogLevel", "()Ljava/lang/String;", args, count, cachedMethodId);
58
58
  }
59
59
 
60
+ static facebook::jsi::Value __hostFunction_NativeAmplyModuleSpecJSI_setCustomProperties(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
61
+ static jmethodID cachedMethodId = nullptr;
62
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "setCustomProperties", "(Lcom/facebook/react/bridge/ReadableMap;)V", args, count, cachedMethodId);
63
+ }
64
+
65
+ static facebook::jsi::Value __hostFunction_NativeAmplyModuleSpecJSI_getCustomProperty(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
66
+ static jmethodID cachedMethodId = nullptr;
67
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getCustomProperty", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
68
+ }
69
+
70
+ static facebook::jsi::Value __hostFunction_NativeAmplyModuleSpecJSI_removeCustomProperty(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
71
+ static jmethodID cachedMethodId = nullptr;
72
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "removeCustomProperty", "(Ljava/lang/String;)V", args, count, cachedMethodId);
73
+ }
74
+
75
+ static facebook::jsi::Value __hostFunction_NativeAmplyModuleSpecJSI_clearCustomProperties(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
76
+ static jmethodID cachedMethodId = nullptr;
77
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "clearCustomProperties", "()V", args, count, cachedMethodId);
78
+ }
79
+
60
80
  static facebook::jsi::Value __hostFunction_NativeAmplyModuleSpecJSI_addListener(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
61
81
  static jmethodID cachedMethodId = nullptr;
62
82
  return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "addListener", "(Ljava/lang/String;)V", args, count, cachedMethodId);
@@ -78,6 +98,10 @@ NativeAmplyModuleSpecJSI::NativeAmplyModuleSpecJSI(const JavaTurboModule::InitPa
78
98
  methodMap_["setUserId"] = MethodMetadata {1, __hostFunction_NativeAmplyModuleSpecJSI_setUserId};
79
99
  methodMap_["setLogLevel"] = MethodMetadata {1, __hostFunction_NativeAmplyModuleSpecJSI_setLogLevel};
80
100
  methodMap_["getLogLevel"] = MethodMetadata {0, __hostFunction_NativeAmplyModuleSpecJSI_getLogLevel};
101
+ methodMap_["setCustomProperties"] = MethodMetadata {1, __hostFunction_NativeAmplyModuleSpecJSI_setCustomProperties};
102
+ methodMap_["getCustomProperty"] = MethodMetadata {1, __hostFunction_NativeAmplyModuleSpecJSI_getCustomProperty};
103
+ methodMap_["removeCustomProperty"] = MethodMetadata {1, __hostFunction_NativeAmplyModuleSpecJSI_removeCustomProperty};
104
+ methodMap_["clearCustomProperties"] = MethodMetadata {0, __hostFunction_NativeAmplyModuleSpecJSI_clearCustomProperties};
81
105
  methodMap_["addListener"] = MethodMetadata {1, __hostFunction_NativeAmplyModuleSpecJSI_addListener};
82
106
  methodMap_["removeListeners"] = MethodMetadata {1, __hostFunction_NativeAmplyModuleSpecJSI_removeListeners};
83
107
  eventEmitterMap_["onSystemEvent"] = std::make_shared<AsyncEventEmitter<folly::dynamic>>();
@@ -11,6 +11,10 @@ const mockNativeModule = {
11
11
  removeListeners: jest.fn(),
12
12
  onSystemEvent: jest.fn(),
13
13
  onDeepLink: jest.fn(),
14
+ setCustomProperties: jest.fn(),
15
+ getCustomProperty: jest.fn(),
16
+ removeCustomProperty: jest.fn(),
17
+ clearCustomProperties: jest.fn(),
14
18
  };
15
19
  describe('Amply JS API', () => {
16
20
  afterEach(() => {
@@ -64,6 +68,39 @@ describe('Amply JS API', () => {
64
68
  unsubscribe();
65
69
  expect(remove).toHaveBeenCalledTimes(1);
66
70
  });
71
+ it('sets a single custom property via setCustomProperties', () => {
72
+ Amply.setCustomProperty('plan', 'premium');
73
+ expect(mockNativeModule.setCustomProperties).toHaveBeenCalledWith({
74
+ plan: 'premium',
75
+ });
76
+ });
77
+ it('sets multiple custom properties at once', () => {
78
+ Amply.setCustomProperties({ plan: 'premium', age: 25, active: true });
79
+ expect(mockNativeModule.setCustomProperties).toHaveBeenCalledWith({
80
+ plan: 'premium',
81
+ age: 25,
82
+ active: true,
83
+ });
84
+ });
85
+ it('gets a custom property value', async () => {
86
+ mockNativeModule.getCustomProperty.mockResolvedValueOnce({ value: 'premium' });
87
+ const result = await Amply.getCustomProperty('plan');
88
+ expect(mockNativeModule.getCustomProperty).toHaveBeenCalledWith('plan');
89
+ expect(result).toBe('premium');
90
+ });
91
+ it('returns null for a missing custom property', async () => {
92
+ mockNativeModule.getCustomProperty.mockResolvedValueOnce({});
93
+ const result = await Amply.getCustomProperty('nonexistent');
94
+ expect(result).toBeNull();
95
+ });
96
+ it('removes a custom property', () => {
97
+ Amply.removeCustomProperty('plan');
98
+ expect(mockNativeModule.removeCustomProperty).toHaveBeenCalledWith('plan');
99
+ });
100
+ it('clears all custom properties', () => {
101
+ Amply.clearCustomProperties();
102
+ expect(mockNativeModule.clearCustomProperties).toHaveBeenCalled();
103
+ });
67
104
  it('registers deep links once and subscribes via the TurboModule emitter', async () => {
68
105
  const remove = jest.fn();
69
106
  mockNativeModule.onDeepLink.mockReturnValue({ remove });
@@ -24,6 +24,36 @@ export declare function getRecentEvents(limit: number): Promise<EventRecord[]>;
24
24
  export declare function getDataSetSnapshot(type: DataSetType): Promise<DataSetSnapshot>;
25
25
  export declare function addDeepLinkListener(listener: (event: DeepLinkEvent) => void): Promise<() => void>;
26
26
  export declare function addSystemEventListener(listener: (event: EventRecord) => void): Promise<() => void>;
27
+ /**
28
+ * Custom property value type. Supports string, number, and boolean values.
29
+ */
30
+ export type CustomPropertyValue = string | number | boolean;
31
+ /**
32
+ * Set a single custom property.
33
+ * @param key The property key (max 32 characters)
34
+ * @param value The property value (string max 255 characters)
35
+ */
36
+ export declare function setCustomProperty(key: string, value: CustomPropertyValue): void;
37
+ /**
38
+ * Set multiple custom properties at once.
39
+ * @param properties Key-value map of properties to set
40
+ */
41
+ export declare function setCustomProperties(properties: Record<string, CustomPropertyValue>): void;
42
+ /**
43
+ * Get a custom property value by key.
44
+ * @param key The property key
45
+ * @returns The property value, or null if not found
46
+ */
47
+ export declare function getCustomProperty(key: string): Promise<CustomPropertyValue | null>;
48
+ /**
49
+ * Remove a custom property by key.
50
+ * @param key The property key to remove
51
+ */
52
+ export declare function removeCustomProperty(key: string): void;
53
+ /**
54
+ * Remove all custom properties.
55
+ */
56
+ export declare function clearCustomProperties(): void;
27
57
  export declare function removeAllListeners(): void;
28
58
  export type { AmplyInitializationConfig, DataSetSnapshot, DataSetType, DeepLinkEvent, EventRecord, LogLevel, TrackEventPayload, };
29
59
  export declare function addSystemEventsListener(listener: (event: EventRecord) => void): Promise<() => void>;
@@ -43,6 +73,11 @@ declare const _default: {
43
73
  setUserId: typeof setUserId;
44
74
  setLogLevel: typeof setLogLevel;
45
75
  getLogLevel: typeof getLogLevel;
76
+ setCustomProperty: typeof setCustomProperty;
77
+ setCustomProperties: typeof setCustomProperties;
78
+ getCustomProperty: typeof getCustomProperty;
79
+ removeCustomProperty: typeof removeCustomProperty;
80
+ clearCustomProperties: typeof clearCustomProperties;
46
81
  systemEvents: {
47
82
  addListener: typeof addSystemEventsListener;
48
83
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,oBAAoB,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAC,sBAAsB,EAAC,MAAM,oBAAoB,CAAC;AAC1D,YAAY,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EACV,yBAAyB,EACzB,eAAe,EACf,WAAW,EACX,aAAa,EACb,WAAW,EACX,QAAQ,EACR,iBAAiB,EAClB,MAAM,iCAAiC,CAAC;AA8EzC,wBAAsB,UAAU,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAMjF;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAErD;AAED;;;GAGG;AACH,wBAA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;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAIxF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEtD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CASzC;AAED,YAAY,EACV,yBAAyB,EACzB,eAAe,EACf,WAAW,EACX,aAAa,EACb,WAAW,EACX,QAAQ,EACR,iBAAiB,GAClB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GACrC,OAAO,CAAC,MAAM,IAAI,CAAC,CAErB;AAED,eAAO,MAAM,YAAY;;CAExB,CAAC;;;;;;;;;;;;;;;;;;;;;;;AAEF,wBAmBE"}
package/dist/src/index.js CHANGED
@@ -121,6 +121,45 @@ export async function addDeepLinkListener(listener) {
121
121
  export async function addSystemEventListener(listener) {
122
122
  return addSystemEventListenerInternal(listener);
123
123
  }
124
+ /**
125
+ * Set a single custom property.
126
+ * @param key The property key (max 32 characters)
127
+ * @param value The property value (string max 255 characters)
128
+ */
129
+ export function setCustomProperty(key, value) {
130
+ getNativeModule().setCustomProperties({ [key]: value });
131
+ }
132
+ /**
133
+ * Set multiple custom properties at once.
134
+ * @param properties Key-value map of properties to set
135
+ */
136
+ export function setCustomProperties(properties) {
137
+ getNativeModule().setCustomProperties(properties);
138
+ }
139
+ /**
140
+ * Get a custom property value by key.
141
+ * @param key The property key
142
+ * @returns The property value, or null if not found
143
+ */
144
+ export async function getCustomProperty(key) {
145
+ var _a;
146
+ const result = await getNativeModule().getCustomProperty(key);
147
+ const map = result;
148
+ return (_a = map.value) !== null && _a !== void 0 ? _a : null;
149
+ }
150
+ /**
151
+ * Remove a custom property by key.
152
+ * @param key The property key to remove
153
+ */
154
+ export function removeCustomProperty(key) {
155
+ getNativeModule().removeCustomProperty(key);
156
+ }
157
+ /**
158
+ * Remove all custom properties.
159
+ */
160
+ export function clearCustomProperties() {
161
+ getNativeModule().clearCustomProperties();
162
+ }
124
163
  export function removeAllListeners() {
125
164
  deepLinkSubscriptions.forEach(unsubscribe => {
126
165
  try {
@@ -151,5 +190,10 @@ export default {
151
190
  setUserId,
152
191
  setLogLevel,
153
192
  getLogLevel,
193
+ setCustomProperty,
194
+ setCustomProperties,
195
+ getCustomProperty,
196
+ removeCustomProperty,
197
+ clearCustomProperties,
154
198
  systemEvents,
155
199
  };
@@ -99,6 +99,26 @@ export interface Spec extends TurboModule {
99
99
  * @returns The current log level as a string
100
100
  */
101
101
  getLogLevel(): string;
102
+ /**
103
+ * Set one or more custom properties. Values can be string, number, or boolean.
104
+ * @param properties Key-value map of properties to set
105
+ */
106
+ setCustomProperties(properties: JsonMap): void;
107
+ /**
108
+ * Get a custom property value by key.
109
+ * @param key The property key
110
+ * @returns A map containing the value, or an empty map if not found
111
+ */
112
+ getCustomProperty(key: string): Promise<JsonMap>;
113
+ /**
114
+ * Remove a custom property by key.
115
+ * @param key The property key to remove
116
+ */
117
+ removeCustomProperty(key: string): void;
118
+ /**
119
+ * Remove all custom properties.
120
+ */
121
+ clearCustomProperties(): void;
102
122
  readonly onSystemEvent: EventEmitter<SystemEventPayload>;
103
123
  readonly onDeepLink: EventEmitter<DeepLinkEvent>;
104
124
  addListener(eventName: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"NativeAmplyModule.d.ts","sourceRoot":"","sources":["../../../src/nativeSpecs/NativeAmplyModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,2CAA2C,CAAC;AAE5E,KAAK,OAAO,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAC,CAAC;AAExC;;;;;;;GAOG;A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