Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(rn,amplitude) update Amplitude SDK on RN
Saúl Ibarra Corretgé08177af1829e
diff --git a/android/sdk/build.gradle b/android/sdk/build.gradleindex 0aa458e821..f6a4fb0c12 100644--- a/android/sdk/build.gradle+++ b/android/sdk/build.gradle@@ -56,6 +56,7 @@ dependencies {exclude group: 'com.android.installreferrer'}} else {+ implementation project(':amplitudereactnative')implementation project(':react-native-device-info')implementation(project(":react-native-google-signin")) {exclude group: 'com.google.android.gms'diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/ReactInstanceManagerHolder.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/ReactInstanceManagerHolder.javaindex 4e51c03b93..b809b02ae3 100644--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/ReactInstanceManagerHolder.java+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/ReactInstanceManagerHolder.java@@ -203,6 +203,16 @@ class ReactInstanceManagerHolder {}}));+ // AmplitudeReactNativePackage+ try {+ Class<?> amplitudePackageClass = Class.forName("com.amplitude.reactnative.AmplitudeReactNativePackage");+ Constructor constructor = amplitudePackageClass.getConstructor();+ packages.add((ReactPackage)constructor.newInstance());+ } catch (Exception e) {+ // Ignore any error, the module is not compiled when LIBRE_BUILD is enabled.+ }++ // RNGoogleSigninPackagetry {Class<?> googlePackageClass = Class.forName("co.apptailor.googlesignin.RNGoogleSigninPackage");Constructor constructor = googlePackageClass.getConstructor();diff --git a/android/settings.gradle b/android/settings.gradleindex 88945b1c4f..d7fe43f8c3 100644--- a/android/settings.gradle+++ b/android/settings.gradle@@ -1,6 +1,8 @@rootProject.name = 'jitsi-meet'include ':app', ':sdk'+include ':amplitudereactnative'+project(':amplitudereactnative').projectDir = new File(rootProject.projectDir, '../node_modules/@amplitude/react-native//android')include ':react-native-async-storage'project(':react-native-async-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-async-storage/async-storage/android')include ':react-native-background-timer'diff --git a/ios/Podfile b/ios/Podfileindex 1e2e18062e..d32552ebce 100644--- a/ios/Podfile+++ b/ios/Podfile@@ -29,7 +29,7 @@ target 'JitsiMeetSDK' do'CoreModulesHeaders','DevSupport','RCTWebSocket'- ]+ ], :modular_headers => truepod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'@@ -54,6 +54,7 @@ target 'JitsiMeetSDK' do# React Native plugins#+ pod 'amplitude-react-native', :path => '../node_modules/@amplitude/react-native'pod 'react-native-background-timer', :path => '../node_modules/react-native-background-timer'pod 'react-native-calendar-events', :path => '../node_modules/react-native-calendar-events'pod 'react-native-keep-awake', :path => '../node_modules/react-native-keep-awake'diff --git a/ios/Podfile.lock b/ios/Podfile.lockindex d0d0f5cc3b..35182a95f3 100644--- a/ios/Podfile.lock+++ b/ios/Podfile.lock@@ -1,4 +1,8 @@PODS:+ - Amplitude (8.2.0)+ - amplitude-react-native (2.3.3):+ - Amplitude (= 8.2.0)+ - React-Core- AppAuth (1.4.0):- AppAuth/Core (= 1.4.0)- AppAuth/ExternalUserAgent (= 1.4.0)@@ -372,6 +376,7 @@ PODS:- Yoga (1.14.0)DEPENDENCIES:+ - "amplitude-react-native (from `../node_modules/@amplitude/react-native`)"- CocoaLumberjack (~> 3.5.3)- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector/`)@@ -423,6 +428,7 @@ DEPENDENCIES:SPEC REPOS:trunk:+ - Amplitude- AppAuth- boost-for-react-native- CocoaLumberjack@@ -444,6 +450,8 @@ SPEC REPOS:- PromisesObjCEXTERNAL SOURCES:+ amplitude-react-native:+ :path: "../node_modules/@amplitude/react-native"DoubleConversion::podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"FBLazyVector:@@ -528,6 +536,8 @@ EXTERNAL SOURCES::path: "../node_modules/react-native/ReactCommon/yoga"SPEC CHECKSUMS:+ Amplitude: 263118b9e691e73a1c864b05bb08a3aff3636d16+ amplitude-react-native: 833a4bd7f656f826bda1de01a7b8593b58842209AppAuth: 31bcec809a638d7bd2f86ea8a52bd45f6e81e7c7boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2cCocoaLumberjack: 2f44e60eb91c176d471fdba43b9e3eae6a721947@@ -589,6 +599,6 @@ SPEC CHECKSUMS:RNWatch: a5320c959c75e72845c07985f3e935e58998f1d3Yoga: 96b469c5e81ff51b917b92e8c3390642d4ded30c-PODFILE CHECKSUM: f4db44d934caeae7212dbaa33abe62ed164363e8+PODFILE CHECKSUM: 1ae1a9823f3eab0b6e735b9637ba7588e0890d08COCOAPODS: 1.10.1diff --git a/ios/sdk/sdk.xcodeproj/project.pbxproj b/ios/sdk/sdk.xcodeproj/project.pbxprojindex ef152dbf42..b729da2440 100644--- a/ios/sdk/sdk.xcodeproj/project.pbxproj+++ b/ios/sdk/sdk.xcodeproj/project.pbxproj@@ -437,10 +437,12 @@);inputPaths = ("${PODS_ROOT}/Target Support Files/Pods-JitsiMeetSDK/Pods-JitsiMeetSDK-resources.sh",+ "${PODS_ROOT}/Amplitude/Sources/Amplitude/Resources/ComodoRsaDomainValidationCA.der","${PODS_ROOT}/GoogleSignIn/Resources/GoogleSignIn.bundle",);name = "[CP] Copy Pods Resources";outputPaths = (+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/ComodoRsaDomainValidationCA.der","${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleSignIn.bundle",);runOnlyForDeploymentPostprocessing = 0;diff --git a/package-lock.json b/package-lock.jsonindex 79251c97eb..2989d97cc0 100644--- a/package-lock.json+++ b/package-lock.json@@ -4,6 +4,11 @@"lockfileVersion": 1,"requires": true,"dependencies": {+ "@amplitude/react-native": {+ "version": "2.3.3",+ "resolved": "https://registry.npmjs.org/@amplitude/react-native/-/react-native-2.3.3.tgz",+ "integrity": "sha512-QTpwy4lKy9kpBjB2334HCEIU7QwGFAkGRfp21aeDA87D6pkiUMAvyDYbz58CnB5HCXuqcvws3GN8d60RO9KF9A=="+ },"@amplitude/types": {"version": "1.5.5","resolved": "https://registry.npmjs.org/@amplitude/types/-/types-1.5.5.tgz",diff --git a/package.json b/package.jsonindex ed6730f4c4..49b6d0c305 100644--- a/package.json+++ b/package.json@@ -15,6 +15,7 @@"author": "","readmeFilename": "README.md","dependencies": {+ "@amplitude/react-native": "2.3.3","@atlaskit/button": "15.1.4","@atlaskit/checkbox": "12.0.0","@atlaskit/dropdown-menu": "10.1.2",diff --git a/react/features/analytics/handlers/AmplitudeHandler.js b/react/features/analytics/handlers/AmplitudeHandler.jsindex f36d56d11b..3c0ccaef06 100644--- a/react/features/analytics/handlers/AmplitudeHandler.js+++ b/react/features/analytics/handlers/AmplitudeHandler.js@@ -1,9 +1,8 @@-import amplitude from 'amplitude-js';-import logger from '../logger';import AbstractHandler from './AbstractHandler';-import { fixDeviceID } from './amplitude';+import { fixDeviceID } from './amplitude/fixDeviceID';+import amplitude from './amplitude/lib';/*** Analytics handler for Amplitude.@@ -19,41 +18,39 @@ export default class AmplitudeHandler extends AbstractHandler {constructor(options) {super(options);- const { amplitudeAPPKey, host, user } = options;+ const { amplitudeAPPKey, user } = options;this._enabled = true;- this._host = host; // Only used on React Native.const onError = e => {logger.error('Error initializing Amplitude', e);this._enabled = false;};- const amplitudeOptions = {- domain: navigator.product === 'ReactNative' ? host : undefined,- includeReferrer: true,- onError- };+ if (navigator.product === 'ReactNative') {+ amplitude.getInstance().init(amplitudeAPPKey);+ fixDeviceID(amplitude.getInstance()).then(() => {+ amplitude.getInstance().getDeviceId()+ .then(deviceId => {+ this._deviceId = deviceId;+ });+ });+ } else {+ const amplitudeOptions = {+ includeReferrer: true,+ onError+ };- this._getInstance().init(amplitudeAPPKey, undefined, amplitudeOptions);- fixDeviceID(this._getInstance());+ amplitude.getInstance().init(amplitudeAPPKey, undefined, amplitudeOptions);+ fixDeviceID(amplitude.getInstance());+ }if (user) {- this._getInstance().setUserId(user);+ this._userId = user;+ amplitude.getInstance().setUserId(user);}}- /**- * Returns the AmplitudeClient instance.- *- * @returns {AmplitudeClient}- */- _getInstance() {- const name = navigator.product === 'ReactNative' ? this._host : undefined;-- return amplitude.getInstance(name);- }-/*** Sets the Amplitude user properties.*@@ -62,7 +59,7 @@ export default class AmplitudeHandler extends AbstractHandler {*/setUserProperties(userProps) {if (this._enabled) {- this._getInstance().setUserProperties(userProps);+ amplitude.getInstance().setUserProperties(userProps);}}@@ -79,7 +76,7 @@ export default class AmplitudeHandler extends AbstractHandler {return;}- this._getInstance().logEvent(this._extractName(event), event);+ amplitude.getInstance().logEvent(this._extractName(event), event);}/**@@ -88,10 +85,17 @@ export default class AmplitudeHandler extends AbstractHandler {* @returns {Object}*/getIdentityProps() {+ if (navigator.product === 'ReactNative') {+ return {+ deviceId: this._deviceId,+ userId: this._userId+ };+ }+return {- sessionId: this._getInstance().getSessionId(),- deviceId: this._getInstance().options.deviceId,- userId: this._getInstance().options.userId+ sessionId: amplitude.getInstance().getSessionId(),+ deviceId: amplitude.getInstance().options.deviceId,+ userId: amplitude.getInstance().options.userId};}}diff --git a/react/features/analytics/handlers/amplitude/index.js b/react/features/analytics/handlers/amplitude/index.jsdeleted file mode 100644index 00a09625e8..0000000000--- a/react/features/analytics/handlers/amplitude/index.js+++ /dev/null@@ -1 +0,0 @@-export * from './fixDeviceID';diff --git a/react/features/analytics/handlers/amplitude/lib.native.js b/react/features/analytics/handlers/amplitude/lib.native.jsnew file mode 100644index 0000000000..f0c2d6365a--- /dev/null+++ b/react/features/analytics/handlers/amplitude/lib.native.js@@ -0,0 +1,3 @@+import { Amplitude } from '@amplitude/react-native';++export default Amplitude;diff --git a/react/features/analytics/handlers/amplitude/lib.web.js b/react/features/analytics/handlers/amplitude/lib.web.jsnew file mode 100644index 0000000000..150da2efd8--- /dev/null+++ b/react/features/analytics/handlers/amplitude/lib.web.js@@ -0,0 +1,3 @@+import amplitude from 'amplitude-js';++export default amplitude;