fix(Amplitude): user id
This commit is contained in:
parent
fecbef0aff
commit
9712804040
|
@ -52,6 +52,17 @@ class AmplitudeModule
|
||||||
Amplitude.getInstance(instanceName).initialize(getCurrentActivity(), apiKey);
|
Amplitude.getInstance(instanceName).initialize(getCurrentActivity(), apiKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the user ID for an Amplitude instance.
|
||||||
|
*
|
||||||
|
* @param instanceName The name of the Amplitude instance.
|
||||||
|
* @param userId The new value for the user ID.
|
||||||
|
*/
|
||||||
|
@ReactMethod
|
||||||
|
public void setUserId(String instanceName, String userId) {
|
||||||
|
Amplitude.getInstance(instanceName).setUserId(userId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the user properties for an Amplitude instance.
|
* Sets the user properties for an Amplitude instance.
|
||||||
*
|
*
|
||||||
|
|
|
@ -33,6 +33,10 @@ RCT_EXPORT_METHOD(init:(NSString*)instanceName API_KEY:(NSString*)apiKey) {
|
||||||
[[Amplitude instanceWithName:instanceName] initializeApiKey:apiKey];
|
[[Amplitude instanceWithName:instanceName] initializeApiKey:apiKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RCT_EXPORT_METHOD(setUserId:(NSString*)instanceName userId: (NSString *) userId) {
|
||||||
|
[[Amplitude instanceWithName:instanceName] setUserId:userId];
|
||||||
|
}
|
||||||
|
|
||||||
RCT_EXPORT_METHOD(setUserProperties:(NSString*)instanceName userPropsString:(NSDictionary*)userProps) {
|
RCT_EXPORT_METHOD(setUserProperties:(NSString*)instanceName userPropsString:(NSDictionary*)userProps) {
|
||||||
if (userProps != nil) {
|
if (userProps != nil) {
|
||||||
[[Amplitude instanceWithName:instanceName] setUserProperties:userProps];
|
[[Amplitude instanceWithName:instanceName] setUserProperties:userProps];
|
||||||
|
|
|
@ -15,7 +15,7 @@ export default class AmplitudeHandler extends AbstractHandler {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
const { amplitudeAPPKey, host } = options;
|
const { amplitudeAPPKey, host, user } = options;
|
||||||
|
|
||||||
if (!amplitudeAPPKey) {
|
if (!amplitudeAPPKey) {
|
||||||
throw new Error('Failed to initialize Amplitude handler, no APP key');
|
throw new Error('Failed to initialize Amplitude handler, no APP key');
|
||||||
|
@ -28,6 +28,10 @@ export default class AmplitudeHandler extends AbstractHandler {
|
||||||
};
|
};
|
||||||
|
|
||||||
amplitude.getInstance(this._amplitudeOptions).init(amplitudeAPPKey);
|
amplitude.getInstance(this._amplitudeOptions).init(amplitudeAPPKey);
|
||||||
|
|
||||||
|
if (user) {
|
||||||
|
amplitude.getInstance(this._amplitudeOptions).setUserId(user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -31,6 +31,16 @@ class Amplitude {
|
||||||
AmplitudeNative.init(this._instanceName, apiKey);
|
AmplitudeNative.init(this._instanceName, apiKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets an identifier for the current user.
|
||||||
|
*
|
||||||
|
* @param {string} userId - The new user id.
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
setUserId(userId) {
|
||||||
|
AmplitudeNative.setUserId(this._instanceName, userId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets user properties for the current user.
|
* Sets user properties for the current user.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue