Explorar el Código

feat(analytics) unify Amplitude handlers across web and mobile

The amplitude-js library gained React Native support so there is no need to keep
separate implementations.
master
Saúl Ibarra Corretgé hace 4 años
padre
commit
687a6c31ee

+ 2
- 6
android/sdk/build.gradle Ver fichero

@@ -25,10 +25,6 @@ android {
25 25
     sourceSets {
26 26
         main {
27 27
             java {
28
-                if (rootProject.ext.libreBuild) {
29
-                    srcDir "src"
30
-                    exclude "**/AmplitudeModule.java"
31
-                }
32 28
                 exclude "test/"
33 29
             }
34 30
         }
@@ -52,18 +48,18 @@ dependencies {
52 48
     implementation 'com.squareup.duktape:duktape-android:1.3.0'
53 49
 
54 50
     if (!rootProject.ext.libreBuild) {
55
-        implementation 'com.amplitude:android-sdk:2.14.1'
56 51
         implementation(project(":react-native-google-signin")) {
57 52
             exclude group: 'com.google.android.gms'
58 53
             exclude group: 'androidx'
59 54
         }
60 55
     }
61 56
 
57
+    implementation project(':react-native-async-storage')
62 58
     implementation project(':react-native-background-timer')
63 59
     implementation project(':react-native-calendar-events')
64
-    implementation project(':react-native-community-async-storage')
65 60
     implementation project(':react-native-community_netinfo')
66 61
     implementation project(':react-native-default-preference')
62
+    implementation project(':react-native-device-info')
67 63
     implementation project(':react-native-immersive')
68 64
     implementation project(':react-native-keep-awake')
69 65
     implementation project(':react-native-linear-gradient')

+ 0
- 122
android/sdk/src/main/java/org/jitsi/meet/sdk/AmplitudeModule.java Ver fichero

@@ -1,122 +0,0 @@
1
-/*
2
- * Copyright @ 2019-present 8x8, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- *     http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
-package org.jitsi.meet.sdk;
18
-
19
-import android.annotation.SuppressLint;
20
-import android.content.Context;
21
-import android.content.SharedPreferences;
22
-import android.provider.Settings;
23
-import android.text.TextUtils;
24
-
25
-import com.facebook.react.bridge.ReactApplicationContext;
26
-import com.facebook.react.bridge.ReactContextBaseJavaModule;
27
-import com.facebook.react.bridge.ReactMethod;
28
-import com.facebook.react.bridge.ReadableMap;
29
-
30
-import com.amplitude.api.Amplitude;
31
-import com.facebook.react.module.annotations.ReactModule;
32
-
33
-import org.jitsi.meet.sdk.log.JitsiMeetLogger;
34
-import org.json.JSONException;
35
-import org.json.JSONObject;
36
-
37
-/**
38
- * Implements the react-native module for the Amplitude integration.
39
- */
40
-@ReactModule(name = AmplitudeModule.NAME)
41
-class AmplitudeModule
42
-        extends ReactContextBaseJavaModule {
43
-
44
-    public static final String NAME = "Amplitude";
45
-    public static final String JITSI_PREFERENCES = "jitsi-preferences";
46
-    public static final String AMPLITUDE_DEVICE_ID_KEY = "amplitudeDeviceId";
47
-
48
-    public AmplitudeModule(ReactApplicationContext reactContext) {
49
-        super(reactContext);
50
-    }
51
-
52
-    /**
53
-     * Initializes the Amplitude SDK.
54
-     *
55
-     * @param instanceName The name of the Amplitude instance. Should
56
-     * be used only for multi-project logging.
57
-     * @param apiKey The API_KEY of the Amplitude project.
58
-     */
59
-    @ReactMethod
60
-    @SuppressLint("HardwareIds")
61
-    public void init(String instanceName, String apiKey) {
62
-        Amplitude.getInstance(instanceName).initialize(getCurrentActivity(), apiKey);
63
-
64
-        // Set the device ID to something consistent.
65
-        SharedPreferences sharedPreferences = getReactApplicationContext().getSharedPreferences(JITSI_PREFERENCES, Context.MODE_PRIVATE);
66
-        String android_id = sharedPreferences.getString(AMPLITUDE_DEVICE_ID_KEY, "");
67
-        if (!TextUtils.isEmpty(android_id)) {
68
-            Amplitude.getInstance(instanceName).setDeviceId(android_id);
69
-        } else {
70
-            String amplitudeId = Amplitude.getInstance(instanceName).getDeviceId();
71
-            SharedPreferences.Editor editor = sharedPreferences.edit();
72
-            editor.putString(JITSI_PREFERENCES, amplitudeId).apply();
73
-        }
74
-    }
75
-
76
-    /**
77
-     * Sets the user ID for an Amplitude instance.
78
-     *
79
-     * @param instanceName The name of the Amplitude instance.
80
-     * @param userId The new value for the user ID.
81
-     */
82
-    @ReactMethod
83
-    public void setUserId(String instanceName, String userId) {
84
-            Amplitude.getInstance(instanceName).setUserId(userId);
85
-    }
86
-
87
-    /**
88
-     * Sets the user properties for an Amplitude instance.
89
-     *
90
-     * @param instanceName The name of the Amplitude instance.
91
-     * @param userProps JSON string with user properties to be set.
92
-     */
93
-    @ReactMethod
94
-    public void setUserProperties(String instanceName, ReadableMap userProps) {
95
-        if (userProps != null) {
96
-            Amplitude.getInstance(instanceName).setUserProperties(
97
-                    new JSONObject(userProps.toHashMap()));
98
-        }
99
-    }
100
-
101
-    /**
102
-     * Log an analytics event.
103
-     *
104
-     * @param instanceName The name of the Amplitude instance.
105
-     * @param eventType The event type.
106
-     * @param eventPropsString JSON string with the event properties.
107
-     */
108
-    @ReactMethod
109
-    public void logEvent(String instanceName, String eventType, String eventPropsString) {
110
-        try {
111
-            JSONObject eventProps = new JSONObject(eventPropsString);
112
-            Amplitude.getInstance(instanceName).logEvent(eventType, eventProps);
113
-        } catch (JSONException e) {
114
-            JitsiMeetLogger.e(e, "Error logging event");
115
-        }
116
-    }
117
-
118
-    @Override
119
-    public String getName() {
120
-        return NAME;
121
-    }
122
-}

+ 1
- 8
android/sdk/src/main/java/org/jitsi/meet/sdk/ReactInstanceManagerHolder.java Ver fichero

@@ -91,14 +91,6 @@ class ReactInstanceManagerHolder {
91 91
 
92 92
         nativeModules.add(new WebRTCModule(reactContext, options));
93 93
 
94
-        try {
95
-            Class<?> amplitudeModuleClass = Class.forName("org.jitsi.meet.sdk.AmplitudeModule");
96
-            Constructor constructor = amplitudeModuleClass.getConstructor(ReactApplicationContext.class);
97
-            nativeModules.add((NativeModule)constructor.newInstance(reactContext));
98
-        } catch (Exception e) {
99
-            // Ignore any error, the module is not compiled when LIBRE_BUILD is enabled.
100
-        }
101
-
102 94
         return nativeModules;
103 95
     }
104 96
 
@@ -192,6 +184,7 @@ class ReactInstanceManagerHolder {
192 184
                 new com.facebook.react.shell.MainReactPackage(),
193 185
                 new com.horcrux.svg.SvgPackage(),
194 186
                 new com.kevinresol.react_native_default_preference.RNDefaultPreferencePackage(),
187
+                new com.learnium.RNDeviceInfo.RNDeviceInfo(),
195 188
                 new com.ocetnik.timer.BackgroundTimerPackage(),
196 189
                 new com.reactnativecommunity.asyncstorage.AsyncStoragePackage(),
197 190
                 new com.reactnativecommunity.netinfo.NetInfoPackage(),

+ 4
- 2
android/settings.gradle Ver fichero

@@ -1,16 +1,18 @@
1 1
 rootProject.name = 'jitsi-meet'
2 2
 
3 3
 include ':app', ':sdk'
4
+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')
4 6
 include ':react-native-background-timer'
5 7
 project(':react-native-background-timer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-background-timer/android')
6 8
 include ':react-native-calendar-events'
7 9
 project(':react-native-calendar-events').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-calendar-events/android')
8
-include ':react-native-community-async-storage'
9
-project(':react-native-community-async-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/async-storage/android')
10 10
 include ':react-native-community_netinfo'
11 11
 project(':react-native-community_netinfo').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/netinfo/android')
12 12
 include ':react-native-default-preference'
13 13
 project(':react-native-default-preference').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-default-preference/android')
14
+include ':react-native-device-info'
15
+project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
14 16
 include ':react-native-google-signin'
15 17
 project(':react-native-google-signin').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/google-signin/android')
16 18
 include ':react-native-immersive'

+ 3
- 3
ios/Podfile Ver fichero

@@ -58,21 +58,21 @@ target 'JitsiMeetSDK' do
58 58
   pod 'react-native-calendar-events', :path => '../node_modules/react-native-calendar-events'
59 59
   pod 'react-native-keep-awake', :path => '../node_modules/react-native-keep-awake'
60 60
   pod 'react-native-netinfo', :path => '../node_modules/@react-native-community/netinfo'
61
+  pod 'react-native-splash-screen', :path => '../node_modules/react-native-splash-screen'
61 62
   pod 'react-native-webview', :path => '../node_modules/react-native-webview'
62 63
   pod 'react-native-webrtc', :path => '../node_modules/react-native-webrtc'
63 64
   pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
64
-  pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage'
65
+  pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-async-storage/async-storage'
66
+  pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'
65 67
   pod 'RNGoogleSignin', :path => '../node_modules/@react-native-community/google-signin'
66 68
   pod 'RNSound', :path => '../node_modules/react-native-sound'
67 69
   pod 'RNSVG', :path => '../node_modules/react-native-svg'
68 70
   pod 'RNWatch', :path => '../node_modules/react-native-watch-connectivity'
69 71
   pod 'RNDefaultPreference', :path => '../node_modules/react-native-default-preference'
70
-  pod 'react-native-splash-screen', :path => '../node_modules/react-native-splash-screen'
71 72
 
72 73
   # Native pod dependencies
73 74
   #
74 75
 
75
-  pod 'Amplitude-iOS', '~> 4.0.4'
76 76
   pod 'CocoaLumberjack', '~>3.5.3'
77 77
   pod 'ObjectiveDropboxOfficial', '~> 3.9.4'
78 78
 

+ 11
- 9
ios/Podfile.lock Ver fichero

@@ -1,5 +1,4 @@
1 1
 PODS:
2
-  - Amplitude-iOS (4.0.4)
3 2
   - AppAuth (1.2.0):
4 3
     - AppAuth/Core (= 1.2.0)
5 4
     - AppAuth/ExternalUserAgent (= 1.2.0)
@@ -351,10 +350,12 @@ PODS:
351 350
     - React-jsi (= 0.61.5-jitsi.2)
352 351
     - ReactCommon/jscallinvoker (= 0.61.5-jitsi.2)
353 352
     - ReactCommon/turbomodule/core (= 0.61.5-jitsi.2)
354
-  - RNCAsyncStorage (1.3.4):
353
+  - RNCAsyncStorage (1.13.2):
355 354
     - React
356 355
   - RNDefaultPreference (1.4.2):
357 356
     - React
357
+  - RNDeviceInfo (7.3.1):
358
+    - React-Core
358 359
   - RNGoogleSignin (3.0.1):
359 360
     - GoogleSignIn (~> 5.0.0)
360 361
     - React
@@ -370,7 +371,6 @@ PODS:
370 371
   - Yoga (1.14.0)
371 372
 
372 373
 DEPENDENCIES:
373
-  - Amplitude-iOS (~> 4.0.4)
374 374
   - BVLinearGradient (from `../node_modules/react-native-linear-gradient`)
375 375
   - CocoaLumberjack (~> 3.5.3)
376 376
   - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
@@ -410,8 +410,9 @@ DEPENDENCIES:
410 410
   - React-RCTText (from `../node_modules/react-native/Libraries/Text`)
411 411
   - React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
412 412
   - ReactCommon/turbomodule (from `../node_modules/react-native/ReactCommon`)
413
-  - "RNCAsyncStorage (from `../node_modules/@react-native-community/async-storage`)"
413
+  - "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)"
414 414
   - RNDefaultPreference (from `../node_modules/react-native-default-preference`)
415
+  - RNDeviceInfo (from `../node_modules/react-native-device-info`)
415 416
   - "RNGoogleSignin (from `../node_modules/@react-native-community/google-signin`)"
416 417
   - RNSound (from `../node_modules/react-native-sound`)
417 418
   - RNSVG (from `../node_modules/react-native-svg`)
@@ -420,7 +421,6 @@ DEPENDENCIES:
420 421
 
421 422
 SPEC REPOS:
422 423
   trunk:
423
-    - Amplitude-iOS
424 424
     - AppAuth
425 425
     - boost-for-react-native
426 426
     - CocoaLumberjack
@@ -507,9 +507,11 @@ EXTERNAL SOURCES:
507 507
   ReactCommon:
508 508
     :path: "../node_modules/react-native/ReactCommon"
509 509
   RNCAsyncStorage:
510
-    :path: "../node_modules/@react-native-community/async-storage"
510
+    :path: "../node_modules/@react-native-async-storage/async-storage"
511 511
   RNDefaultPreference:
512 512
     :path: "../node_modules/react-native-default-preference"
513
+  RNDeviceInfo:
514
+    :path: "../node_modules/react-native-device-info"
513 515
   RNGoogleSignin:
514 516
     :path: "../node_modules/@react-native-community/google-signin"
515 517
   RNSound:
@@ -522,7 +524,6 @@ EXTERNAL SOURCES:
522 524
     :path: "../node_modules/react-native/ReactCommon/yoga"
523 525
 
524 526
 SPEC CHECKSUMS:
525
-  Amplitude-iOS: 2ad4d7270c99186236c1272a3a9425463b1ae1a7
526 527
   AppAuth: bce82c76043657c99d91e7882e8a9e1a93650cd4
527 528
   boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
528 529
   BVLinearGradient: e3aad03778a456d77928f594a649e96995f1c872
@@ -574,14 +575,15 @@ SPEC CHECKSUMS:
574 575
   React-RCTText: 4f1b99f228278d2a5e9008eced8dc9c974c4a270
575 576
   React-RCTVibration: c1041024893fdfdb8371e7c720c437751b711676
576 577
   ReactCommon: 18014e1d98dbeb9141e935cfe35fc93bd511ffb6
577
-  RNCAsyncStorage: 8e31405a9f12fbf42c2bb330e4560bfd79c18323
578
+  RNCAsyncStorage: bc2f81cc1df90c267ce9ed30bb2dbc93b945a8ee
578 579
   RNDefaultPreference: 56a405ce61033ac77b95004dccd7ac54c2eb50d1
580
+  RNDeviceInfo: 57bb2806fb7bd982a1434e9f0b4e6a6ab1f6702e
579 581
   RNGoogleSignin: 39336070b35fc4cea6a98cf111e00480317be0ae
580 582
   RNSound: c980916b596cc15c8dcd2f6ecd3b13c4881dbe20
581 583
   RNSVG: 069864be08c9fe065a2cf7e63656a34c78653c99
582 584
   RNWatch: a5320c959c75e72845c07985f3e935e58998f1d3
583 585
   Yoga: 96b469c5e81ff51b917b92e8c3390642d4ded30c
584 586
 
585
-PODFILE CHECKSUM: e77f7134cda53f089046f29cb1f32b08c00c8a2e
587
+PODFILE CHECKSUM: 5be5132e41831a98362eeed760558227a4df89ae
586 588
 
587 589
 COCOAPODS: 1.10.0

+ 0
- 21
ios/sdk/sdk.xcodeproj/project.pbxproj Ver fichero

@@ -31,7 +31,6 @@
31 31
 		75635B0B20751D6D00F29C9F /* left.wav in Resources */ = {isa = PBXBuildFile; fileRef = 75635B0920751D6D00F29C9F /* left.wav */; };
32 32
 		87FE6F3321E52437004A5DC7 /* incomingMessage.wav in Resources */ = {isa = PBXBuildFile; fileRef = 87FE6F3221E52437004A5DC7 /* incomingMessage.wav */; };
33 33
 		A4414AE020B37F1A003546E6 /* rejected.wav in Resources */ = {isa = PBXBuildFile; fileRef = A4414ADF20B37F1A003546E6 /* rejected.wav */; };
34
-		A480429C21EE335600289B73 /* AmplitudeModule.m in Sources */ = {isa = PBXBuildFile; fileRef = A480429B21EE335600289B73 /* AmplitudeModule.m */; };
35 34
 		A4A934E9212F3ADB001E9388 /* Dropbox.m in Sources */ = {isa = PBXBuildFile; fileRef = A4A934E8212F3ADB001E9388 /* Dropbox.m */; };
36 35
 		C30F88D0CB0F4F5593216D24 /* liveStreamingOff.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = C30F88D1CB0F4F5593216D24 /* liveStreamingOff.mp3 */; };
37 36
 		C30F88D2CB0F4F5593216D24 /* liveStreamingOn.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = C30F88D3CB0F4F5593216D24 /* liveStreamingOn.mp3 */; };
@@ -94,7 +93,6 @@
94 93
 		98E09B5C73D9036B4ED252FC /* Pods-JitsiMeet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JitsiMeet.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-JitsiMeet/Pods-JitsiMeet.debug.xcconfig"; sourceTree = "<group>"; };
95 94
 		9C77CA3CC919B081F1A52982 /* Pods-JitsiMeet.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JitsiMeet.release.xcconfig"; path = "../Pods/Target Support Files/Pods-JitsiMeet/Pods-JitsiMeet.release.xcconfig"; sourceTree = "<group>"; };
96 95
 		A4414ADF20B37F1A003546E6 /* rejected.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = rejected.wav; path = ../../sounds/rejected.wav; sourceTree = "<group>"; };
97
-		A480429B21EE335600289B73 /* AmplitudeModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AmplitudeModule.m; path = src/analytics/AmplitudeModule.m; sourceTree = SOURCE_ROOT; };
98 96
 		A4A934E8212F3ADB001E9388 /* Dropbox.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Dropbox.m; sourceTree = "<group>"; };
99 97
 		A4A934EB21349A06001E9388 /* Dropbox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Dropbox.h; sourceTree = "<group>"; };
100 98
 		C30F88D1CB0F4F5593216D24 /* liveStreamingOff.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; name = liveStreamingOff.mp3; path = ../../sounds/liveStreamingOff.mp3; sourceTree = "<group>"; };
@@ -190,7 +188,6 @@
190 188
 		0BD906E71EC0C00300C8C18E /* src */ = {
191 189
 			isa = PBXGroup;
192 190
 			children = (
193
-				A480429821ECE2D800289B73 /* analytics */,
194 191
 				0BB9AD7C1F60356D001C08DB /* AppInfo.m */,
195 192
 				0BCA495C1EC4B6C600B793EE /* AudioMode.m */,
196 193
 				C69EFA02209A0EFD0027712B /* callkit */,
@@ -246,15 +243,6 @@
246 243
 			name = Frameworks;
247 244
 			sourceTree = "<group>";
248 245
 		};
249
-		A480429821ECE2D800289B73 /* analytics */ = {
250
-			isa = PBXGroup;
251
-			children = (
252
-				A480429B21EE335600289B73 /* AmplitudeModule.m */,
253
-			);
254
-			name = analytics;
255
-			path = "New Group";
256
-			sourceTree = "<group>";
257
-		};
258 246
 		A4A934E7212F3AB8001E9388 /* dropbox */ = {
259 247
 			isa = PBXGroup;
260 248
 			children = (
@@ -438,18 +426,10 @@
438 426
 			);
439 427
 			inputPaths = (
440 428
 				"${PODS_ROOT}/Target Support Files/Pods-JitsiMeetSDK/Pods-JitsiMeetSDK-resources.sh",
441
-				"${PODS_ROOT}/Amplitude-iOS/Amplitude/api.amplitude.com.der",
442
-				"${PODS_ROOT}/Amplitude-iOS/Amplitude/ComodoCaLimitedRsaCertificationAuthority.der",
443
-				"${PODS_ROOT}/Amplitude-iOS/Amplitude/ComodoRsaCA.der",
444
-				"${PODS_ROOT}/Amplitude-iOS/Amplitude/ComodoRsaDomainValidationCA.der",
445 429
 				"${PODS_ROOT}/GoogleSignIn/Resources/GoogleSignIn.bundle",
446 430
 			);
447 431
 			name = "[CP] Copy Pods Resources";
448 432
 			outputPaths = (
449
-				"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/api.amplitude.com.der",
450
-				"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/ComodoCaLimitedRsaCertificationAuthority.der",
451
-				"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/ComodoRsaCA.der",
452
-				"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/ComodoRsaDomainValidationCA.der",
453 433
 				"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleSignIn.bundle",
454 434
 			);
455 435
 			runOnlyForDeploymentPostprocessing = 0;
@@ -479,7 +459,6 @@
479 459
 				DEFC743F21B178FA00E4DD96 /* LocaleDetector.m in Sources */,
480 460
 				0BCA495F1EC4B6C600B793EE /* AudioMode.m in Sources */,
481 461
 				0BCA49611EC4B6C600B793EE /* Proximity.m in Sources */,
482
-				A480429C21EE335600289B73 /* AmplitudeModule.m in Sources */,
483 462
 				C69EFA0C209A0F660027712B /* JMCallKitEmitter.swift in Sources */,
484 463
 				DEFE535621FB2E8300011A3A /* ReactUtils.m in Sources */,
485 464
 				C6A34261204EF76800E062DD /* DragGestureController.swift in Sources */,

+ 0
- 61
ios/sdk/src/analytics/AmplitudeModule.m Ver fichero

@@ -1,61 +0,0 @@
1
-/*
2
- * Copyright @ 2018-present 8x8, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- *     http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
-#import <React/RCTBridgeModule.h>
18
-
19
-#import "Amplitude.h"
20
-#import "LogUtils.h"
21
-
22
-
23
-@interface AmplitudeModule : NSObject<RCTBridgeModule>
24
-@end
25
-
26
-@implementation AmplitudeModule
27
-
28
-RCT_EXPORT_MODULE(Amplitude)
29
-
30
-+ (BOOL)requiresMainQueueSetup {
31
-    return NO;
32
-}
33
-
34
-RCT_EXPORT_METHOD(init:(NSString*)instanceName API_KEY:(NSString*)apiKey) {
35
-    [[Amplitude instanceWithName:instanceName] initializeApiKey:apiKey];
36
-}
37
-
38
-RCT_EXPORT_METHOD(setUserId:(NSString*)instanceName userId: (NSString *) userId) {
39
-    [[Amplitude instanceWithName:instanceName] setUserId:userId];
40
-}
41
-
42
-RCT_EXPORT_METHOD(setUserProperties:(NSString*)instanceName userPropsString:(NSDictionary*)userProps) {
43
-    if (userProps != nil) {
44
-        [[Amplitude instanceWithName:instanceName] setUserProperties:userProps];
45
-    }
46
-}
47
-
48
-RCT_EXPORT_METHOD(logEvent:(NSString*)instanceName eventType:(NSString*)eventType eventPropsString:(NSString*)eventPropsString) {
49
-    NSError *error;
50
-    NSData *eventPropsData = [eventPropsString dataUsingEncoding:NSUTF8StringEncoding];
51
-    NSDictionary *eventProperties = [NSJSONSerialization JSONObjectWithData:eventPropsData
52
-                                                                   options:NSJSONReadingMutableContainers
53
-                                                                     error:&error];
54
-    if (eventProperties == nil) {
55
-        DDLogError(@"[Amplitude] Error parsing event properties: %@", error);
56
-    } else {
57
-        [[Amplitude instanceWithName:instanceName] logEvent:eventType withEventProperties:eventProperties];
58
-    }
59
-}
60
-
61
-@end

+ 52
- 7
package-lock.json Ver fichero

@@ -4,11 +4,34 @@
4 4
   "lockfileVersion": 1,
5 5
   "requires": true,
6 6
   "dependencies": {
7
+    "@amplitude/eslint-config-typescript": {
8
+      "version": "1.1.0",
9
+      "resolved": "https://registry.npmjs.org/@amplitude/eslint-config-typescript/-/eslint-config-typescript-1.1.0.tgz",
10
+      "integrity": "sha512-N8sKkwtFakPD2/cSOrBnM5Wudjp4qeDD69U1cG7dZ6DDczxBhUEqnJDJ0wiYmKMPXqr+bmFOsDdbCcOmb/CLYA=="
11
+    },
12
+    "@amplitude/types": {
13
+      "version": "1.1.0",
14
+      "resolved": "https://registry.npmjs.org/@amplitude/types/-/types-1.1.0.tgz",
15
+      "integrity": "sha512-aJebJlI1hfRrzsbcRzW1heTDEClhElwEJ4ODyYZbBacKzH29q3OKZCkgNfaEYdxfgLpoDSh/ffHYpl7fWm3SQA==",
16
+      "requires": {
17
+        "@amplitude/eslint-config-typescript": "^1.1.0"
18
+      }
19
+    },
7 20
     "@amplitude/ua-parser-js": {
8 21
       "version": "0.7.24",
9 22
       "resolved": "https://registry.npmjs.org/@amplitude/ua-parser-js/-/ua-parser-js-0.7.24.tgz",
10 23
       "integrity": "sha512-VbQuJymJ20WEw0HtI2np7EdC3NJGUWi8+Xdbc7uk8WfMIF308T0howpzkQ3JFMN7ejnrcSM/OyNGveeE3TP3TA=="
11 24
     },
25
+    "@amplitude/utils": {
26
+      "version": "1.1.0",
27
+      "resolved": "https://registry.npmjs.org/@amplitude/utils/-/utils-1.1.0.tgz",
28
+      "integrity": "sha512-TbKgBZNSRFu5RfYTKpprn/DFlZqr8jnmjXASZyQ/m8XDdbD2VoRqHDmKUwFiruX9OhAb2m9BhjLuaiwRYHCcqQ==",
29
+      "requires": {
30
+        "@amplitude/eslint-config-typescript": "^1.1.0",
31
+        "@amplitude/types": "^1.1.0",
32
+        "tslib": "^1.9.3"
33
+      }
34
+    },
12 35
     "@atlaskit/analytics-next": {
13 36
       "version": "3.2.1",
14 37
       "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-3.2.1.tgz",
@@ -3343,10 +3366,13 @@
3343 3366
         "isomorphic-fetch": "^2.2.1"
3344 3367
       }
3345 3368
     },
3346
-    "@react-native-community/async-storage": {
3347
-      "version": "1.3.4",
3348
-      "resolved": "https://registry.npmjs.org/@react-native-community/async-storage/-/async-storage-1.3.4.tgz",
3349
-      "integrity": "sha512-fJmzL27x0BEjhmMXPnDPnUNCZK7bph+NBVCfAz9fzHzAamaiOkdUwuL3PvE4Oj4Kw4knP8ocw5VRDGorAidZ2g=="
3369
+    "@react-native-async-storage/async-storage": {
3370
+      "version": "1.13.2",
3371
+      "resolved": "https://registry.npmjs.org/@react-native-async-storage/async-storage/-/async-storage-1.13.2.tgz",
3372
+      "integrity": "sha512-isTDvUApRJPVWFxV15yrQSOGqarX7cIedq/y4N5yWSnotf68D9qvDEv1I7rCXhkBDi0u4OJt6GA9dksUT0D3wg==",
3373
+      "requires": {
3374
+        "deep-assign": "^3.0.0"
3375
+      }
3350 3376
     },
3351 3377
     "@react-native-community/cli-debugger-ui": {
3352 3378
       "version": "3.0.0",
@@ -4922,11 +4948,12 @@
4922 4948
       "dev": true
4923 4949
     },
4924 4950
     "amplitude-js": {
4925
-      "version": "7.3.1",
4926
-      "resolved": "https://registry.npmjs.org/amplitude-js/-/amplitude-js-7.3.1.tgz",
4927
-      "integrity": "sha512-dsJU9MdtDDAOtKnbHrJuVBgsL5UGxD1P2B7doGdAQ1hxxT/5mFrmJTFzi1tKe+2ir3QtcRa9B0qvH8TMsGw22A==",
4951
+      "version": "7.3.3",
4952
+      "resolved": "https://registry.npmjs.org/amplitude-js/-/amplitude-js-7.3.3.tgz",
4953
+      "integrity": "sha512-krSXUXeHqbQk15ozx0kC3h0K3i7wQ1ycSG08OfZBga2Vfbi3Y30CP6UXLdtJX4AiBB8EkjMePdMgU6kyuIpi/A==",
4928 4954
       "requires": {
4929 4955
         "@amplitude/ua-parser-js": "0.7.24",
4956
+        "@amplitude/utils": "^1.0.5",
4930 4957
         "blueimp-md5": "^2.10.0",
4931 4958
         "query-string": "5"
4932 4959
       }
@@ -7246,6 +7273,14 @@
7246 7273
       "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz",
7247 7274
       "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU="
7248 7275
     },
7276
+    "deep-assign": {
7277
+      "version": "3.0.0",
7278
+      "resolved": "https://registry.npmjs.org/deep-assign/-/deep-assign-3.0.0.tgz",
7279
+      "integrity": "sha512-YX2i9XjJ7h5q/aQ/IM9PEwEnDqETAIYbggmdDB3HLTlSgo1CxPsj6pvhPG68rq6SVE0+p+6Ywsm5fTYNrYtBWw==",
7280
+      "requires": {
7281
+        "is-obj": "^1.0.0"
7282
+      }
7283
+    },
7249 7284
     "deep-equal": {
7250 7285
       "version": "1.1.1",
7251 7286
       "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.1.1.tgz",
@@ -10245,6 +10280,11 @@
10245 10280
         "kind-of": "^3.0.2"
10246 10281
       }
10247 10282
     },
10283
+    "is-obj": {
10284
+      "version": "1.0.1",
10285
+      "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz",
10286
+      "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8="
10287
+    },
10248 10288
     "is-path-cwd": {
10249 10289
       "version": "1.0.0",
10250 10290
       "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz",
@@ -14158,6 +14198,11 @@
14158 14198
       "resolved": "https://registry.npmjs.org/react-native-default-preference/-/react-native-default-preference-1.4.2.tgz",
14159 14199
       "integrity": "sha512-kNhBLv8s6kO2gJJFEKM7qew7oRvJnygjgG1CU2ZEY6SlG5qsRX8z1Ms7z1Oo/XB7fVfyXrAoZDGhIvy+uiByrg=="
14160 14200
     },
14201
+    "react-native-device-info": {
14202
+      "version": "7.3.1",
14203
+      "resolved": "https://registry.npmjs.org/react-native-device-info/-/react-native-device-info-7.3.1.tgz",
14204
+      "integrity": "sha512-RQP3etbmXsOlcaxHeHNug68nRli02S9iGC7TbaXpkvyyevIuRogfnrI71sWtqmlT91kdpYAOYKmNfRL9LOSKVw=="
14205
+    },
14161 14206
     "react-native-immersive": {
14162 14207
       "version": "2.0.0",
14163 14208
       "resolved": "https://registry.npmjs.org/react-native-immersive/-/react-native-immersive-2.0.0.tgz",

+ 3
- 2
package.json Ver fichero

@@ -34,13 +34,13 @@
34 34
     "@atlaskit/tooltip": "12.1.13",
35 35
     "@jitsi/js-utils": "1.0.3",
36 36
     "@microsoft/microsoft-graph-client": "1.1.0",
37
-    "@react-native-community/async-storage": "1.3.4",
37
+    "@react-native-async-storage/async-storage": "1.13.2",
38 38
     "@react-native-community/google-signin": "3.0.1",
39 39
     "@react-native-community/netinfo": "4.1.5",
40 40
     "@svgr/webpack": "4.3.2",
41 41
     "@tensorflow-models/body-pix": "2.0.4",
42 42
     "@tensorflow/tfjs": "1.5.1",
43
-    "amplitude-js": "7.3.1",
43
+    "amplitude-js": "7.3.3",
44 44
     "base64-js": "1.3.1",
45 45
     "bc-css-flags": "3.0.0",
46 46
     "dropbox": "4.0.9",
@@ -75,6 +75,7 @@
75 75
     "react-native-callstats": "3.61.0",
76 76
     "react-native-collapsible": "1.5.1",
77 77
     "react-native-default-preference": "1.4.2",
78
+    "react-native-device-info": "7.3.1",
78 79
     "react-native-immersive": "2.0.0",
79 80
     "react-native-keep-awake": "4.0.0",
80 81
     "react-native-linear-gradient": "2.5.6",

+ 34
- 23
react/features/analytics/handlers/AmplitudeHandler.js Ver fichero

@@ -1,5 +1,9 @@
1
+import amplitude from 'amplitude-js';
2
+
3
+import logger from '../logger';
4
+
1 5
 import AbstractHandler from './AbstractHandler';
2
-import { amplitude, fixDeviceID } from './amplitude';
6
+import { fixDeviceID } from './amplitude';
3 7
 
4 8
 /**
5 9
  * Analytics handler for Amplitude.
@@ -17,24 +21,39 @@ export default class AmplitudeHandler extends AbstractHandler {
17 21
 
18 22
         const { amplitudeAPPKey, host, user } = options;
19 23
 
20
-        if (!amplitudeAPPKey) {
21
-            throw new Error('Failed to initialize Amplitude handler, no APP key');
22
-        }
23
-
24 24
         this._enabled = true;
25
+        this._host = host; // Only used on React Native.
25 26
 
26
-        this._amplitudeOptions = {
27
-            host
27
+        const onError = e => {
28
+            logger.error('Error initializing Amplitude', e);
29
+            this._enabled = false;
28 30
         };
29 31
 
30
-        amplitude.getInstance(this._amplitudeOptions).init(amplitudeAPPKey, undefined, { includeReferrer: true });
31
-        fixDeviceID(amplitude.getInstance(this._amplitudeOptions));
32
+        const amplitudeOptions = {
33
+            domain: navigator.product === 'ReactNative' ? host : undefined,
34
+            includeReferrer: true,
35
+            onError
36
+        };
37
+
38
+        this._getInstance().init(amplitudeAPPKey, undefined, amplitudeOptions);
39
+        fixDeviceID(this._getInstance());
32 40
 
33 41
         if (user) {
34
-            amplitude.getInstance(this._amplitudeOptions).setUserId(user);
42
+            this._getInstance().setUserId(user);
35 43
         }
36 44
     }
37 45
 
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
+
38 57
     /**
39 58
      * Sets the Amplitude user properties.
40 59
      *
@@ -43,8 +62,7 @@ export default class AmplitudeHandler extends AbstractHandler {
43 62
      */
44 63
     setUserProperties(userProps) {
45 64
         if (this._enabled) {
46
-            amplitude.getInstance(this._amplitudeOptions)
47
-                .setUserProperties(userProps);
65
+            this._getInstance().setUserProperties(userProps);
48 66
         }
49 67
     }
50 68
 
@@ -61,9 +79,7 @@ export default class AmplitudeHandler extends AbstractHandler {
61 79
             return;
62 80
         }
63 81
 
64
-        amplitude.getInstance(this._amplitudeOptions).logEvent(
65
-            this._extractName(event),
66
-            event);
82
+        this._getInstance().logEvent(this._extractName(event), event);
67 83
     }
68 84
 
69 85
     /**
@@ -72,15 +88,10 @@ export default class AmplitudeHandler extends AbstractHandler {
72 88
      * @returns {Object}
73 89
      */
74 90
     getIdentityProps() {
75
-        // TODO: Remove when web and native Aplitude implementations are unified.
76
-        if (navigator.product === 'ReactNative') {
77
-            return {};
78
-        }
79
-
80 91
         return {
81
-            sessionId: amplitude.getInstance(this._amplitudeOptions).getSessionId(),
82
-            deviceId: amplitude.getInstance(this._amplitudeOptions).options.deviceId,
83
-            userId: amplitude.getInstance(this._amplitudeOptions).options.userId
92
+            sessionId: this._getInstance().getSessionId(),
93
+            deviceId: this._getInstance().options.deviceId,
94
+            userId: this._getInstance().options.userId
84 95
         };
85 96
     }
86 97
 }

+ 0
- 115
react/features/analytics/handlers/amplitude/Amplitude.native.js Ver fichero

@@ -1,115 +0,0 @@
1
-import { NativeModules } from 'react-native';
2
-
3
-const { Amplitude: AmplitudeNative } = NativeModules;
4
-
5
-/**
6
- * Wrapper for the Amplitude native module.
7
- */
8
-class Amplitude {
9
-    /**
10
-     * Create new Amplitude instance.
11
-     *
12
-     * @param {string} instanceName - The name of the Amplitude instance. Should
13
-     * be used only for multi-project logging.
14
-     */
15
-    constructor(instanceName) {
16
-        // It might not have been included in the build.
17
-        if (!AmplitudeNative) {
18
-            throw new Error('Amplitude analytics is not supported');
19
-        }
20
-
21
-        this._instanceName = instanceName;
22
-    }
23
-
24
-    /**
25
-     * Initializes the Amplitude SDK.
26
-     *
27
-     * @param {string} apiKey - The API_KEY of the Amplitude project.
28
-     * @returns {void}
29
-     */
30
-    init(apiKey) {
31
-        AmplitudeNative.init(this._instanceName, apiKey);
32
-    }
33
-
34
-    /**
35
-     * Sets an identifier for the current user.
36
-     *
37
-     * @param {string} userId - The new user id.
38
-     * @param {string} opt_userId - Currently not used.
39
-     * @param {Object} opt_config - Currently not used.
40
-     * @param {Function} opt_callback - Currently not used.
41
-     * @returns {void}
42
-     */
43
-    setUserId(userId, opt_userId, opt_config, opt_callback) { // eslint-disable-line camelcase, no-unused-vars
44
-        AmplitudeNative.setUserId(this._instanceName, userId);
45
-    }
46
-
47
-    /**
48
-     * Sets user properties for the current user.
49
-     *
50
-     * @param {Object} userProperties - The user properties to be set.
51
-     * @returns {void}
52
-     */
53
-    setUserProperties(userProperties) {
54
-        AmplitudeNative.setUserProperties(this._instanceName, userProperties);
55
-    }
56
-
57
-    /**
58
-     * Log an event with eventType and eventProperties.
59
-     *
60
-     * @param {string} eventType - The type of the event.
61
-     * @param {Object} eventProperties - The properties of the event.
62
-     * @returns {void}
63
-     */
64
-    logEvent(eventType, eventProperties) {
65
-        // The event properties are converted to JSON string because of known
66
-        // performance issue when passing objects trough the RN bridge too
67
-        // often (a few times a second).
68
-        AmplitudeNative.logEvent(
69
-            this._instanceName, eventType, JSON.stringify(eventProperties));
70
-    }
71
-
72
-}
73
-
74
-/**
75
- * Cache of <tt>Amplitude</tt> instances by instanceName.
76
- */
77
-const instances = {};
78
-
79
-/**
80
- * The default (with instanceName - undefined) <tt>Amplitude</tt> instance.
81
- */
82
-let defaultInstance;
83
-
84
-export default {
85
-    /**
86
-     * Returns a <tt>Amplitude</tt> instance.
87
-     *
88
-     * @param {Object} options - Optional parameters.
89
-     * @param {string} options.host - The host property from the current URL.
90
-     * @param {string|undefined} options.instanceName - The name of the
91
-     * amplitude instance. Should be used only for multi-project logging.
92
-     * @returns {Amplitude}
93
-     */
94
-    getInstance(options = {}) {
95
-        let instance;
96
-
97
-        const { host = '', instanceName = '' } = options;
98
-
99
-        let internalInstanceName = host;
100
-
101
-        if (instanceName !== '') {
102
-            internalInstanceName += `-${instanceName}`;
103
-        }
104
-
105
-        if (internalInstanceName === '') {
106
-            instance = defaultInstance = defaultInstance || new Amplitude();
107
-        } else {
108
-            instance = instances[internalInstanceName]
109
-                = instances[internalInstanceName]
110
-                    || new Amplitude(internalInstanceName);
111
-        }
112
-
113
-        return instance;
114
-    }
115
-};

+ 0
- 14
react/features/analytics/handlers/amplitude/Amplitude.web.js Ver fichero

@@ -1,14 +0,0 @@
1
-import amplitude from 'amplitude-js';
2
-
3
-export default {
4
-    /**
5
-     * Returns the AmplitudeClient instance.
6
-     *
7
-     * @param {Object} options - Optional parameters.
8
-     * @property {string} options.instanceName - The name of the AmplitudeClient instance.
9
-     * @returns {AmplitudeClient}
10
-     */
11
-    getInstance(options = {}) {
12
-        return amplitude.getInstance(options.instanceName);
13
-    }
14
-};

+ 15
- 1
react/features/analytics/handlers/amplitude/fixDeviceID.native.js Ver fichero

@@ -1,9 +1,23 @@
1
+import DefaultPreference from 'react-native-default-preference';
2
+import DeviceInfo from 'react-native-device-info';
3
+
1 4
 /**
2 5
  * Custom logic for setting the correct device id.
3 6
  *
4 7
  * @param {AmplitudeClient} amplitude - The amplitude instance.
5 8
  * @returns {void}
6 9
  */
7
-export function fixDeviceID(amplitude) { // eslint-disable-line no-unused-vars
10
+export async function fixDeviceID(amplitude) {
11
+    await DefaultPreference.setName('jitsi-preferences');
12
+
13
+    const current = await DefaultPreference.get('amplitudeDeviceId');
14
+
15
+    if (current) {
16
+        amplitude.setDeviceId(current);
17
+    } else {
18
+        const uid = DeviceInfo.getUniqueId();
8 19
 
20
+        amplitude.setDeviceId(uid);
21
+        DefaultPreference.set('amplitudeDeviceId', uid);
22
+    }
9 23
 }

+ 0
- 1
react/features/analytics/handlers/amplitude/index.js Ver fichero

@@ -1,2 +1 @@
1
-export { default as amplitude } from './Amplitude';
2 1
 export * from './fixDeviceID';

+ 1
- 1
react/features/mobile/polyfills/Storage.js Ver fichero

@@ -1,4 +1,4 @@
1
-import AsyncStorage from '@react-native-community/async-storage';
1
+import AsyncStorage from '@react-native-async-storage/async-storage';
2 2
 
3 3
 /**
4 4
  * A Web Sorage API implementation used for polyfilling

Loading…
Cancelar
Guardar