Browse Source

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é 4 years ago
parent
commit
687a6c31ee

+ 2
- 6
android/sdk/build.gradle View File

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

+ 0
- 122
android/sdk/src/main/java/org/jitsi/meet/sdk/AmplitudeModule.java View File

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 View File

91
 
91
 
92
         nativeModules.add(new WebRTCModule(reactContext, options));
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
         return nativeModules;
94
         return nativeModules;
103
     }
95
     }
104
 
96
 
192
                 new com.facebook.react.shell.MainReactPackage(),
184
                 new com.facebook.react.shell.MainReactPackage(),
193
                 new com.horcrux.svg.SvgPackage(),
185
                 new com.horcrux.svg.SvgPackage(),
194
                 new com.kevinresol.react_native_default_preference.RNDefaultPreferencePackage(),
186
                 new com.kevinresol.react_native_default_preference.RNDefaultPreferencePackage(),
187
+                new com.learnium.RNDeviceInfo.RNDeviceInfo(),
195
                 new com.ocetnik.timer.BackgroundTimerPackage(),
188
                 new com.ocetnik.timer.BackgroundTimerPackage(),
196
                 new com.reactnativecommunity.asyncstorage.AsyncStoragePackage(),
189
                 new com.reactnativecommunity.asyncstorage.AsyncStoragePackage(),
197
                 new com.reactnativecommunity.netinfo.NetInfoPackage(),
190
                 new com.reactnativecommunity.netinfo.NetInfoPackage(),

+ 4
- 2
android/settings.gradle View File

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

+ 3
- 3
ios/Podfile View File

58
   pod 'react-native-calendar-events', :path => '../node_modules/react-native-calendar-events'
58
   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'
59
   pod 'react-native-keep-awake', :path => '../node_modules/react-native-keep-awake'
60
   pod 'react-native-netinfo', :path => '../node_modules/@react-native-community/netinfo'
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
   pod 'react-native-webview', :path => '../node_modules/react-native-webview'
62
   pod 'react-native-webview', :path => '../node_modules/react-native-webview'
62
   pod 'react-native-webrtc', :path => '../node_modules/react-native-webrtc'
63
   pod 'react-native-webrtc', :path => '../node_modules/react-native-webrtc'
63
   pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
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
   pod 'RNGoogleSignin', :path => '../node_modules/@react-native-community/google-signin'
67
   pod 'RNGoogleSignin', :path => '../node_modules/@react-native-community/google-signin'
66
   pod 'RNSound', :path => '../node_modules/react-native-sound'
68
   pod 'RNSound', :path => '../node_modules/react-native-sound'
67
   pod 'RNSVG', :path => '../node_modules/react-native-svg'
69
   pod 'RNSVG', :path => '../node_modules/react-native-svg'
68
   pod 'RNWatch', :path => '../node_modules/react-native-watch-connectivity'
70
   pod 'RNWatch', :path => '../node_modules/react-native-watch-connectivity'
69
   pod 'RNDefaultPreference', :path => '../node_modules/react-native-default-preference'
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
   # Native pod dependencies
73
   # Native pod dependencies
73
   #
74
   #
74
 
75
 
75
-  pod 'Amplitude-iOS', '~> 4.0.4'
76
   pod 'CocoaLumberjack', '~>3.5.3'
76
   pod 'CocoaLumberjack', '~>3.5.3'
77
   pod 'ObjectiveDropboxOfficial', '~> 3.9.4'
77
   pod 'ObjectiveDropboxOfficial', '~> 3.9.4'
78
 
78
 

+ 11
- 9
ios/Podfile.lock View File

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

+ 0
- 21
ios/sdk/sdk.xcodeproj/project.pbxproj View File

31
 		75635B0B20751D6D00F29C9F /* left.wav in Resources */ = {isa = PBXBuildFile; fileRef = 75635B0920751D6D00F29C9F /* left.wav */; };
31
 		75635B0B20751D6D00F29C9F /* left.wav in Resources */ = {isa = PBXBuildFile; fileRef = 75635B0920751D6D00F29C9F /* left.wav */; };
32
 		87FE6F3321E52437004A5DC7 /* incomingMessage.wav in Resources */ = {isa = PBXBuildFile; fileRef = 87FE6F3221E52437004A5DC7 /* incomingMessage.wav */; };
32
 		87FE6F3321E52437004A5DC7 /* incomingMessage.wav in Resources */ = {isa = PBXBuildFile; fileRef = 87FE6F3221E52437004A5DC7 /* incomingMessage.wav */; };
33
 		A4414AE020B37F1A003546E6 /* rejected.wav in Resources */ = {isa = PBXBuildFile; fileRef = A4414ADF20B37F1A003546E6 /* rejected.wav */; };
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
 		A4A934E9212F3ADB001E9388 /* Dropbox.m in Sources */ = {isa = PBXBuildFile; fileRef = A4A934E8212F3ADB001E9388 /* Dropbox.m */; };
34
 		A4A934E9212F3ADB001E9388 /* Dropbox.m in Sources */ = {isa = PBXBuildFile; fileRef = A4A934E8212F3ADB001E9388 /* Dropbox.m */; };
36
 		C30F88D0CB0F4F5593216D24 /* liveStreamingOff.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = C30F88D1CB0F4F5593216D24 /* liveStreamingOff.mp3 */; };
35
 		C30F88D0CB0F4F5593216D24 /* liveStreamingOff.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = C30F88D1CB0F4F5593216D24 /* liveStreamingOff.mp3 */; };
37
 		C30F88D2CB0F4F5593216D24 /* liveStreamingOn.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = C30F88D3CB0F4F5593216D24 /* liveStreamingOn.mp3 */; };
36
 		C30F88D2CB0F4F5593216D24 /* liveStreamingOn.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = C30F88D3CB0F4F5593216D24 /* liveStreamingOn.mp3 */; };
94
 		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>"; };
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
 		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>"; };
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
 		A4414ADF20B37F1A003546E6 /* rejected.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = rejected.wav; path = ../../sounds/rejected.wav; sourceTree = "<group>"; };
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
 		A4A934E8212F3ADB001E9388 /* Dropbox.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Dropbox.m; sourceTree = "<group>"; };
96
 		A4A934E8212F3ADB001E9388 /* Dropbox.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Dropbox.m; sourceTree = "<group>"; };
99
 		A4A934EB21349A06001E9388 /* Dropbox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Dropbox.h; sourceTree = "<group>"; };
97
 		A4A934EB21349A06001E9388 /* Dropbox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Dropbox.h; sourceTree = "<group>"; };
100
 		C30F88D1CB0F4F5593216D24 /* liveStreamingOff.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; name = liveStreamingOff.mp3; path = ../../sounds/liveStreamingOff.mp3; sourceTree = "<group>"; };
98
 		C30F88D1CB0F4F5593216D24 /* liveStreamingOff.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; name = liveStreamingOff.mp3; path = ../../sounds/liveStreamingOff.mp3; sourceTree = "<group>"; };
190
 		0BD906E71EC0C00300C8C18E /* src */ = {
188
 		0BD906E71EC0C00300C8C18E /* src */ = {
191
 			isa = PBXGroup;
189
 			isa = PBXGroup;
192
 			children = (
190
 			children = (
193
-				A480429821ECE2D800289B73 /* analytics */,
194
 				0BB9AD7C1F60356D001C08DB /* AppInfo.m */,
191
 				0BB9AD7C1F60356D001C08DB /* AppInfo.m */,
195
 				0BCA495C1EC4B6C600B793EE /* AudioMode.m */,
192
 				0BCA495C1EC4B6C600B793EE /* AudioMode.m */,
196
 				C69EFA02209A0EFD0027712B /* callkit */,
193
 				C69EFA02209A0EFD0027712B /* callkit */,
246
 			name = Frameworks;
243
 			name = Frameworks;
247
 			sourceTree = "<group>";
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
 		A4A934E7212F3AB8001E9388 /* dropbox */ = {
246
 		A4A934E7212F3AB8001E9388 /* dropbox */ = {
259
 			isa = PBXGroup;
247
 			isa = PBXGroup;
260
 			children = (
248
 			children = (
438
 			);
426
 			);
439
 			inputPaths = (
427
 			inputPaths = (
440
 				"${PODS_ROOT}/Target Support Files/Pods-JitsiMeetSDK/Pods-JitsiMeetSDK-resources.sh",
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
 				"${PODS_ROOT}/GoogleSignIn/Resources/GoogleSignIn.bundle",
429
 				"${PODS_ROOT}/GoogleSignIn/Resources/GoogleSignIn.bundle",
446
 			);
430
 			);
447
 			name = "[CP] Copy Pods Resources";
431
 			name = "[CP] Copy Pods Resources";
448
 			outputPaths = (
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
 				"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleSignIn.bundle",
433
 				"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleSignIn.bundle",
454
 			);
434
 			);
455
 			runOnlyForDeploymentPostprocessing = 0;
435
 			runOnlyForDeploymentPostprocessing = 0;
479
 				DEFC743F21B178FA00E4DD96 /* LocaleDetector.m in Sources */,
459
 				DEFC743F21B178FA00E4DD96 /* LocaleDetector.m in Sources */,
480
 				0BCA495F1EC4B6C600B793EE /* AudioMode.m in Sources */,
460
 				0BCA495F1EC4B6C600B793EE /* AudioMode.m in Sources */,
481
 				0BCA49611EC4B6C600B793EE /* Proximity.m in Sources */,
461
 				0BCA49611EC4B6C600B793EE /* Proximity.m in Sources */,
482
-				A480429C21EE335600289B73 /* AmplitudeModule.m in Sources */,
483
 				C69EFA0C209A0F660027712B /* JMCallKitEmitter.swift in Sources */,
462
 				C69EFA0C209A0F660027712B /* JMCallKitEmitter.swift in Sources */,
484
 				DEFE535621FB2E8300011A3A /* ReactUtils.m in Sources */,
463
 				DEFE535621FB2E8300011A3A /* ReactUtils.m in Sources */,
485
 				C6A34261204EF76800E062DD /* DragGestureController.swift in Sources */,
464
 				C6A34261204EF76800E062DD /* DragGestureController.swift in Sources */,

+ 0
- 61
ios/sdk/src/analytics/AmplitudeModule.m View File

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 View File

4
   "lockfileVersion": 1,
4
   "lockfileVersion": 1,
5
   "requires": true,
5
   "requires": true,
6
   "dependencies": {
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
     "@amplitude/ua-parser-js": {
20
     "@amplitude/ua-parser-js": {
8
       "version": "0.7.24",
21
       "version": "0.7.24",
9
       "resolved": "https://registry.npmjs.org/@amplitude/ua-parser-js/-/ua-parser-js-0.7.24.tgz",
22
       "resolved": "https://registry.npmjs.org/@amplitude/ua-parser-js/-/ua-parser-js-0.7.24.tgz",
10
       "integrity": "sha512-VbQuJymJ20WEw0HtI2np7EdC3NJGUWi8+Xdbc7uk8WfMIF308T0howpzkQ3JFMN7ejnrcSM/OyNGveeE3TP3TA=="
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
     "@atlaskit/analytics-next": {
35
     "@atlaskit/analytics-next": {
13
       "version": "3.2.1",
36
       "version": "3.2.1",
14
       "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-3.2.1.tgz",
37
       "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-3.2.1.tgz",
3343
         "isomorphic-fetch": "^2.2.1"
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
     "@react-native-community/cli-debugger-ui": {
3377
     "@react-native-community/cli-debugger-ui": {
3352
       "version": "3.0.0",
3378
       "version": "3.0.0",
4922
       "dev": true
4948
       "dev": true
4923
     },
4949
     },
4924
     "amplitude-js": {
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
       "requires": {
4954
       "requires": {
4929
         "@amplitude/ua-parser-js": "0.7.24",
4955
         "@amplitude/ua-parser-js": "0.7.24",
4956
+        "@amplitude/utils": "^1.0.5",
4930
         "blueimp-md5": "^2.10.0",
4957
         "blueimp-md5": "^2.10.0",
4931
         "query-string": "5"
4958
         "query-string": "5"
4932
       }
4959
       }
7246
       "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz",
7273
       "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz",
7247
       "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU="
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
     "deep-equal": {
7284
     "deep-equal": {
7250
       "version": "1.1.1",
7285
       "version": "1.1.1",
7251
       "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.1.1.tgz",
7286
       "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.1.1.tgz",
10245
         "kind-of": "^3.0.2"
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
     "is-path-cwd": {
10288
     "is-path-cwd": {
10249
       "version": "1.0.0",
10289
       "version": "1.0.0",
10250
       "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz",
10290
       "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz",
14158
       "resolved": "https://registry.npmjs.org/react-native-default-preference/-/react-native-default-preference-1.4.2.tgz",
14198
       "resolved": "https://registry.npmjs.org/react-native-default-preference/-/react-native-default-preference-1.4.2.tgz",
14159
       "integrity": "sha512-kNhBLv8s6kO2gJJFEKM7qew7oRvJnygjgG1CU2ZEY6SlG5qsRX8z1Ms7z1Oo/XB7fVfyXrAoZDGhIvy+uiByrg=="
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
     "react-native-immersive": {
14206
     "react-native-immersive": {
14162
       "version": "2.0.0",
14207
       "version": "2.0.0",
14163
       "resolved": "https://registry.npmjs.org/react-native-immersive/-/react-native-immersive-2.0.0.tgz",
14208
       "resolved": "https://registry.npmjs.org/react-native-immersive/-/react-native-immersive-2.0.0.tgz",

+ 3
- 2
package.json View File

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

+ 34
- 23
react/features/analytics/handlers/AmplitudeHandler.js View File

1
+import amplitude from 'amplitude-js';
2
+
3
+import logger from '../logger';
4
+
1
 import AbstractHandler from './AbstractHandler';
5
 import AbstractHandler from './AbstractHandler';
2
-import { amplitude, fixDeviceID } from './amplitude';
6
+import { fixDeviceID } from './amplitude';
3
 
7
 
4
 /**
8
 /**
5
  * Analytics handler for Amplitude.
9
  * Analytics handler for Amplitude.
17
 
21
 
18
         const { amplitudeAPPKey, host, user } = options;
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
         this._enabled = true;
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
         if (user) {
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
      * Sets the Amplitude user properties.
58
      * Sets the Amplitude user properties.
40
      *
59
      *
43
      */
62
      */
44
     setUserProperties(userProps) {
63
     setUserProperties(userProps) {
45
         if (this._enabled) {
64
         if (this._enabled) {
46
-            amplitude.getInstance(this._amplitudeOptions)
47
-                .setUserProperties(userProps);
65
+            this._getInstance().setUserProperties(userProps);
48
         }
66
         }
49
     }
67
     }
50
 
68
 
61
             return;
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
      * @returns {Object}
88
      * @returns {Object}
73
      */
89
      */
74
     getIdentityProps() {
90
     getIdentityProps() {
75
-        // TODO: Remove when web and native Aplitude implementations are unified.
76
-        if (navigator.product === 'ReactNative') {
77
-            return {};
78
-        }
79
-
80
         return {
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 View File

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 View File

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 View File

1
+import DefaultPreference from 'react-native-default-preference';
2
+import DeviceInfo from 'react-native-device-info';
3
+
1
 /**
4
 /**
2
  * Custom logic for setting the correct device id.
5
  * Custom logic for setting the correct device id.
3
  *
6
  *
4
  * @param {AmplitudeClient} amplitude - The amplitude instance.
7
  * @param {AmplitudeClient} amplitude - The amplitude instance.
5
  * @returns {void}
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 View File

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

+ 1
- 1
react/features/mobile/polyfills/Storage.js View File

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

Loading…
Cancel
Save