Skip to content

Commit 217fdb0

Browse files
jeanregisserdavide-scalzo
authored andcommitted
Add support for clearing super props (davide-scalzo#165)
1 parent bff9901 commit 217fdb0

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

RNMixpanel/RNMixpanel.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,13 @@ -(Mixpanel*) getInstance: (NSString *)name {
159159
resolve(nil);
160160
}
161161

162+
RCT_EXPORT_METHOD(clearSuperProperties:(NSString *)apiToken
163+
resolve:(RCTPromiseResolveBlock)resolve
164+
reject:(RCTPromiseRejectBlock)reject) {
165+
[[self getInstance:apiToken] clearSuperProperties];
166+
resolve(nil);
167+
}
168+
162169
// Init push notification
163170
RCT_EXPORT_METHOD(initPushHandling:(NSString *) token
164171
apiToken:(NSString *)apiToken

android/src/main/java/com/kevinejohn/RNMixpanel/RNMixpanelModule.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,15 @@ public void registerSuperPropertiesOnce(final ReadableMap properties, final Stri
242242
promise.resolve(null);
243243
}
244244

245+
@ReactMethod
246+
public void clearSuperProperties(final String apiToken, Promise promise) {
247+
final MixpanelAPI instance = getInstance(apiToken);
248+
synchronized(instance) {
249+
instance.clearSuperProperties();
250+
}
251+
promise.resolve(null);
252+
}
253+
245254
@ReactMethod
246255
public void initPushHandling (final String token, final String apiToken, Promise promise) {
247256
final MixpanelAPI instance = getInstance(apiToken);

index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ export class MixpanelInstance {
106106
return RNMixpanel.registerSuperPropertiesOnce(properties, this.apiToken)
107107
}
108108

109+
clearSuperProperties(): Promise<void> {
110+
if (!this.initialized) throw new Error(uninitializedError('clearSuperProperties'))
111+
return RNMixpanel.clearSuperProperties(this.apiToken)
112+
}
113+
109114
initPushHandling(token: string): Promise<void> {
110115
if (!this.initialized) throw new Error(uninitializedError('initPushHandling'))
111116

@@ -288,6 +293,12 @@ export default {
288293
defaultInstance.registerSuperPropertiesOnce(properties)
289294
},
290295

296+
clearSuperProperties() {
297+
if (!defaultInstance) throw new Error(NO_INSTANCE_ERROR)
298+
299+
defaultInstance.clearSuperProperties()
300+
},
301+
291302
initPushHandling(token: string) {
292303
if (!defaultInstance) throw new Error(NO_INSTANCE_ERROR)
293304

0 commit comments

Comments
 (0)