diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/AmplitudeModule.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/AmplitudeModule.java index b1c3f4d1a..eb6cff759 100644 --- a/android/sdk/src/main/java/org/jitsi/meet/sdk/AmplitudeModule.java +++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/AmplitudeModule.java @@ -52,6 +52,17 @@ class AmplitudeModule 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. * diff --git a/ios/sdk/src/analytics/AmplitudeModule.m b/ios/sdk/src/analytics/AmplitudeModule.m index cfb3ebe5d..f5864728c 100644 --- a/ios/sdk/src/analytics/AmplitudeModule.m +++ b/ios/sdk/src/analytics/AmplitudeModule.m @@ -33,6 +33,10 @@ RCT_EXPORT_METHOD(init:(NSString*)instanceName API_KEY:(NSString*)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) { if (userProps != nil) { [[Amplitude instanceWithName:instanceName] setUserProperties:userProps]; diff --git a/react/features/analytics/handlers/AmplitudeHandler.js b/react/features/analytics/handlers/AmplitudeHandler.js index 08d68b5b4..5e128bb49 100644 --- a/react/features/analytics/handlers/AmplitudeHandler.js +++ b/react/features/analytics/handlers/AmplitudeHandler.js @@ -15,7 +15,7 @@ export default class AmplitudeHandler extends AbstractHandler { constructor(options) { super(); - const { amplitudeAPPKey, host } = options; + const { amplitudeAPPKey, host, user } = options; if (!amplitudeAPPKey) { 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); + + if (user) { + amplitude.getInstance(this._amplitudeOptions).setUserId(user); + } } /** diff --git a/react/features/analytics/handlers/amplitude/Amplitude.native.js b/react/features/analytics/handlers/amplitude/Amplitude.native.js index 01e16b73b..7ee23ed73 100644 --- a/react/features/analytics/handlers/amplitude/Amplitude.native.js +++ b/react/features/analytics/handlers/amplitude/Amplitude.native.js @@ -31,6 +31,16 @@ class Amplitude { 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. *