Sfoglia il codice sorgente

fix(rn,amplitude) update Amplitude SDK on RN

Amplitude has gone back to having a separate package for RN, so switch to it.
master
Saúl Ibarra Corretgé 3 anni fa
parent
commit
08177af182
Nessun account collegato all'indirizzo email del committer

+ 1
- 0
android/sdk/build.gradle Vedi File

56
             exclude group: 'com.android.installreferrer'
56
             exclude group: 'com.android.installreferrer'
57
         }
57
         }
58
     } else {
58
     } else {
59
+        implementation project(':amplitudereactnative')
59
         implementation project(':react-native-device-info')
60
         implementation project(':react-native-device-info')
60
         implementation(project(":react-native-google-signin")) {
61
         implementation(project(":react-native-google-signin")) {
61
             exclude group: 'com.google.android.gms'
62
             exclude group: 'com.google.android.gms'

+ 10
- 0
android/sdk/src/main/java/org/jitsi/meet/sdk/ReactInstanceManagerHolder.java Vedi File

203
                     }
203
                     }
204
                 }));
204
                 }));
205
 
205
 
206
+        // AmplitudeReactNativePackage
207
+        try {
208
+            Class<?> amplitudePackageClass = Class.forName("com.amplitude.reactnative.AmplitudeReactNativePackage");
209
+            Constructor constructor = amplitudePackageClass.getConstructor();
210
+            packages.add((ReactPackage)constructor.newInstance());
211
+        } catch (Exception e) {
212
+            // Ignore any error, the module is not compiled when LIBRE_BUILD is enabled.
213
+        }
214
+
215
+        // RNGoogleSigninPackage
206
         try {
216
         try {
207
             Class<?> googlePackageClass = Class.forName("co.apptailor.googlesignin.RNGoogleSigninPackage");
217
             Class<?> googlePackageClass = Class.forName("co.apptailor.googlesignin.RNGoogleSigninPackage");
208
             Constructor constructor = googlePackageClass.getConstructor();
218
             Constructor constructor = googlePackageClass.getConstructor();

+ 2
- 0
android/settings.gradle Vedi File

1
 rootProject.name = 'jitsi-meet'
1
 rootProject.name = 'jitsi-meet'
2
 
2
 
3
 include ':app', ':sdk'
3
 include ':app', ':sdk'
4
+include ':amplitudereactnative'
5
+project(':amplitudereactnative').projectDir = new File(rootProject.projectDir, '../node_modules/@amplitude/react-native//android')
4
 include ':react-native-async-storage'
6
 include ':react-native-async-storage'
5
 project(':react-native-async-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-async-storage/async-storage/android')
7
 project(':react-native-async-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-async-storage/async-storage/android')
6
 include ':react-native-background-timer'
8
 include ':react-native-background-timer'

+ 2
- 1
ios/Podfile Vedi File

29
     'CoreModulesHeaders',
29
     'CoreModulesHeaders',
30
     'DevSupport',
30
     'DevSupport',
31
     'RCTWebSocket'
31
     'RCTWebSocket'
32
-  ]
32
+  ], :modular_headers => true
33
   pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
33
   pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
34
   pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
34
   pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
35
   pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
35
   pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
54
   # React Native plugins
54
   # React Native plugins
55
   #
55
   #
56
 
56
 
57
+  pod 'amplitude-react-native', :path => '../node_modules/@amplitude/react-native'
57
   pod 'react-native-background-timer', :path => '../node_modules/react-native-background-timer'
58
   pod 'react-native-background-timer', :path => '../node_modules/react-native-background-timer'
58
   pod 'react-native-calendar-events', :path => '../node_modules/react-native-calendar-events'
59
   pod 'react-native-calendar-events', :path => '../node_modules/react-native-calendar-events'
59
   pod 'react-native-keep-awake', :path => '../node_modules/react-native-keep-awake'
60
   pod 'react-native-keep-awake', :path => '../node_modules/react-native-keep-awake'

+ 11
- 1
ios/Podfile.lock Vedi File

1
 PODS:
1
 PODS:
2
+  - Amplitude (8.2.0)
3
+  - amplitude-react-native (2.3.3):
4
+    - Amplitude (= 8.2.0)
5
+    - React-Core
2
   - AppAuth (1.4.0):
6
   - AppAuth (1.4.0):
3
     - AppAuth/Core (= 1.4.0)
7
     - AppAuth/Core (= 1.4.0)
4
     - AppAuth/ExternalUserAgent (= 1.4.0)
8
     - AppAuth/ExternalUserAgent (= 1.4.0)
372
   - Yoga (1.14.0)
376
   - Yoga (1.14.0)
373
 
377
 
374
 DEPENDENCIES:
378
 DEPENDENCIES:
379
+  - "amplitude-react-native (from `../node_modules/@amplitude/react-native`)"
375
   - CocoaLumberjack (~> 3.5.3)
380
   - CocoaLumberjack (~> 3.5.3)
376
   - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
381
   - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
377
   - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector/`)
382
   - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector/`)
423
 
428
 
424
 SPEC REPOS:
429
 SPEC REPOS:
425
   trunk:
430
   trunk:
431
+    - Amplitude
426
     - AppAuth
432
     - AppAuth
427
     - boost-for-react-native
433
     - boost-for-react-native
428
     - CocoaLumberjack
434
     - CocoaLumberjack
444
     - PromisesObjC
450
     - PromisesObjC
445
 
451
 
446
 EXTERNAL SOURCES:
452
 EXTERNAL SOURCES:
453
+  amplitude-react-native:
454
+    :path: "../node_modules/@amplitude/react-native"
447
   DoubleConversion:
455
   DoubleConversion:
448
     :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
456
     :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
449
   FBLazyVector:
457
   FBLazyVector:
528
     :path: "../node_modules/react-native/ReactCommon/yoga"
536
     :path: "../node_modules/react-native/ReactCommon/yoga"
529
 
537
 
530
 SPEC CHECKSUMS:
538
 SPEC CHECKSUMS:
539
+  Amplitude: 263118b9e691e73a1c864b05bb08a3aff3636d16
540
+  amplitude-react-native: 833a4bd7f656f826bda1de01a7b8593b58842209
531
   AppAuth: 31bcec809a638d7bd2f86ea8a52bd45f6e81e7c7
541
   AppAuth: 31bcec809a638d7bd2f86ea8a52bd45f6e81e7c7
532
   boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
542
   boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
533
   CocoaLumberjack: 2f44e60eb91c176d471fdba43b9e3eae6a721947
543
   CocoaLumberjack: 2f44e60eb91c176d471fdba43b9e3eae6a721947
589
   RNWatch: a5320c959c75e72845c07985f3e935e58998f1d3
599
   RNWatch: a5320c959c75e72845c07985f3e935e58998f1d3
590
   Yoga: 96b469c5e81ff51b917b92e8c3390642d4ded30c
600
   Yoga: 96b469c5e81ff51b917b92e8c3390642d4ded30c
591
 
601
 
592
-PODFILE CHECKSUM: f4db44d934caeae7212dbaa33abe62ed164363e8
602
+PODFILE CHECKSUM: 1ae1a9823f3eab0b6e735b9637ba7588e0890d08
593
 
603
 
594
 COCOAPODS: 1.10.1
604
 COCOAPODS: 1.10.1

+ 2
- 0
ios/sdk/sdk.xcodeproj/project.pbxproj Vedi File

437
 			);
437
 			);
438
 			inputPaths = (
438
 			inputPaths = (
439
 				"${PODS_ROOT}/Target Support Files/Pods-JitsiMeetSDK/Pods-JitsiMeetSDK-resources.sh",
439
 				"${PODS_ROOT}/Target Support Files/Pods-JitsiMeetSDK/Pods-JitsiMeetSDK-resources.sh",
440
+				"${PODS_ROOT}/Amplitude/Sources/Amplitude/Resources/ComodoRsaDomainValidationCA.der",
440
 				"${PODS_ROOT}/GoogleSignIn/Resources/GoogleSignIn.bundle",
441
 				"${PODS_ROOT}/GoogleSignIn/Resources/GoogleSignIn.bundle",
441
 			);
442
 			);
442
 			name = "[CP] Copy Pods Resources";
443
 			name = "[CP] Copy Pods Resources";
443
 			outputPaths = (
444
 			outputPaths = (
445
+				"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/ComodoRsaDomainValidationCA.der",
444
 				"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleSignIn.bundle",
446
 				"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleSignIn.bundle",
445
 			);
447
 			);
446
 			runOnlyForDeploymentPostprocessing = 0;
448
 			runOnlyForDeploymentPostprocessing = 0;

+ 5
- 0
package-lock.json Vedi File

4
   "lockfileVersion": 1,
4
   "lockfileVersion": 1,
5
   "requires": true,
5
   "requires": true,
6
   "dependencies": {
6
   "dependencies": {
7
+    "@amplitude/react-native": {
8
+      "version": "2.3.3",
9
+      "resolved": "https://registry.npmjs.org/@amplitude/react-native/-/react-native-2.3.3.tgz",
10
+      "integrity": "sha512-QTpwy4lKy9kpBjB2334HCEIU7QwGFAkGRfp21aeDA87D6pkiUMAvyDYbz58CnB5HCXuqcvws3GN8d60RO9KF9A=="
11
+    },
7
     "@amplitude/types": {
12
     "@amplitude/types": {
8
       "version": "1.5.5",
13
       "version": "1.5.5",
9
       "resolved": "https://registry.npmjs.org/@amplitude/types/-/types-1.5.5.tgz",
14
       "resolved": "https://registry.npmjs.org/@amplitude/types/-/types-1.5.5.tgz",

+ 1
- 0
package.json Vedi File

15
   "author": "",
15
   "author": "",
16
   "readmeFilename": "README.md",
16
   "readmeFilename": "README.md",
17
   "dependencies": {
17
   "dependencies": {
18
+    "@amplitude/react-native": "2.3.3",
18
     "@atlaskit/button": "15.1.4",
19
     "@atlaskit/button": "15.1.4",
19
     "@atlaskit/checkbox": "12.0.0",
20
     "@atlaskit/checkbox": "12.0.0",
20
     "@atlaskit/dropdown-menu": "10.1.2",
21
     "@atlaskit/dropdown-menu": "10.1.2",

+ 33
- 29
react/features/analytics/handlers/AmplitudeHandler.js Vedi File

1
-import amplitude from 'amplitude-js';
2
-
3
 import logger from '../logger';
1
 import logger from '../logger';
4
 
2
 
5
 import AbstractHandler from './AbstractHandler';
3
 import AbstractHandler from './AbstractHandler';
6
-import { fixDeviceID } from './amplitude';
4
+import { fixDeviceID } from './amplitude/fixDeviceID';
5
+import amplitude from './amplitude/lib';
7
 
6
 
8
 /**
7
 /**
9
  * Analytics handler for Amplitude.
8
  * Analytics handler for Amplitude.
19
     constructor(options) {
18
     constructor(options) {
20
         super(options);
19
         super(options);
21
 
20
 
22
-        const { amplitudeAPPKey, host, user } = options;
21
+        const { amplitudeAPPKey, user } = options;
23
 
22
 
24
         this._enabled = true;
23
         this._enabled = true;
25
-        this._host = host; // Only used on React Native.
26
 
24
 
27
         const onError = e => {
25
         const onError = e => {
28
             logger.error('Error initializing Amplitude', e);
26
             logger.error('Error initializing Amplitude', e);
29
             this._enabled = false;
27
             this._enabled = false;
30
         };
28
         };
31
 
29
 
32
-        const amplitudeOptions = {
33
-            domain: navigator.product === 'ReactNative' ? host : undefined,
34
-            includeReferrer: true,
35
-            onError
36
-        };
30
+        if (navigator.product === 'ReactNative') {
31
+            amplitude.getInstance().init(amplitudeAPPKey);
32
+            fixDeviceID(amplitude.getInstance()).then(() => {
33
+                amplitude.getInstance().getDeviceId()
34
+                    .then(deviceId => {
35
+                        this._deviceId = deviceId;
36
+                    });
37
+            });
38
+        } else {
39
+            const amplitudeOptions = {
40
+                includeReferrer: true,
41
+                onError
42
+            };
37
 
43
 
38
-        this._getInstance().init(amplitudeAPPKey, undefined, amplitudeOptions);
39
-        fixDeviceID(this._getInstance());
44
+            amplitude.getInstance().init(amplitudeAPPKey, undefined, amplitudeOptions);
45
+            fixDeviceID(amplitude.getInstance());
46
+        }
40
 
47
 
41
         if (user) {
48
         if (user) {
42
-            this._getInstance().setUserId(user);
49
+            this._userId = user;
50
+            amplitude.getInstance().setUserId(user);
43
         }
51
         }
44
     }
52
     }
45
 
53
 
46
-    /**
47
-     * Returns the AmplitudeClient instance.
48
-     *
49
-     * @returns {AmplitudeClient}
50
-     */
51
-    _getInstance() {
52
-        const name = navigator.product === 'ReactNative' ? this._host : undefined;
53
-
54
-        return amplitude.getInstance(name);
55
-    }
56
-
57
     /**
54
     /**
58
      * Sets the Amplitude user properties.
55
      * Sets the Amplitude user properties.
59
      *
56
      *
62
      */
59
      */
63
     setUserProperties(userProps) {
60
     setUserProperties(userProps) {
64
         if (this._enabled) {
61
         if (this._enabled) {
65
-            this._getInstance().setUserProperties(userProps);
62
+            amplitude.getInstance().setUserProperties(userProps);
66
         }
63
         }
67
     }
64
     }
68
 
65
 
79
             return;
76
             return;
80
         }
77
         }
81
 
78
 
82
-        this._getInstance().logEvent(this._extractName(event), event);
79
+        amplitude.getInstance().logEvent(this._extractName(event), event);
83
     }
80
     }
84
 
81
 
85
     /**
82
     /**
88
      * @returns {Object}
85
      * @returns {Object}
89
      */
86
      */
90
     getIdentityProps() {
87
     getIdentityProps() {
88
+        if (navigator.product === 'ReactNative') {
89
+            return {
90
+                deviceId: this._deviceId,
91
+                userId: this._userId
92
+            };
93
+        }
94
+
91
         return {
95
         return {
92
-            sessionId: this._getInstance().getSessionId(),
93
-            deviceId: this._getInstance().options.deviceId,
94
-            userId: this._getInstance().options.userId
96
+            sessionId: amplitude.getInstance().getSessionId(),
97
+            deviceId: amplitude.getInstance().options.deviceId,
98
+            userId: amplitude.getInstance().options.userId
95
         };
99
         };
96
     }
100
     }
97
 }
101
 }

+ 0
- 1
react/features/analytics/handlers/amplitude/index.js Vedi File

1
-export * from './fixDeviceID';

+ 3
- 0
react/features/analytics/handlers/amplitude/lib.native.js Vedi File

1
+import { Amplitude } from '@amplitude/react-native';
2
+
3
+export default Amplitude;

+ 3
- 0
react/features/analytics/handlers/amplitude/lib.web.js Vedi File

1
+import amplitude from 'amplitude-js';
2
+
3
+export default amplitude;

Loading…
Annulla
Salva