fix(rn,amplitude) update Amplitude SDK on RN
Amplitude has gone back to having a separate package for RN, so switch to it.
This commit is contained in:
parent
229520f74f
commit
08177af182
|
@ -56,6 +56,7 @@ dependencies {
|
|||
exclude group: 'com.android.installreferrer'
|
||||
}
|
||||
} else {
|
||||
implementation project(':amplitudereactnative')
|
||||
implementation project(':react-native-device-info')
|
||||
implementation(project(":react-native-google-signin")) {
|
||||
exclude group: 'com.google.android.gms'
|
||||
|
|
|
@ -203,6 +203,16 @@ class ReactInstanceManagerHolder {
|
|||
}
|
||||
}));
|
||||
|
||||
// AmplitudeReactNativePackage
|
||||
try {
|
||||
Class<?> amplitudePackageClass = Class.forName("com.amplitude.reactnative.AmplitudeReactNativePackage");
|
||||
Constructor constructor = amplitudePackageClass.getConstructor();
|
||||
packages.add((ReactPackage)constructor.newInstance());
|
||||
} catch (Exception e) {
|
||||
// Ignore any error, the module is not compiled when LIBRE_BUILD is enabled.
|
||||
}
|
||||
|
||||
// RNGoogleSigninPackage
|
||||
try {
|
||||
Class<?> googlePackageClass = Class.forName("co.apptailor.googlesignin.RNGoogleSigninPackage");
|
||||
Constructor constructor = googlePackageClass.getConstructor();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
rootProject.name = 'jitsi-meet'
|
||||
|
||||
include ':app', ':sdk'
|
||||
include ':amplitudereactnative'
|
||||
project(':amplitudereactnative').projectDir = new File(rootProject.projectDir, '../node_modules/@amplitude/react-native//android')
|
||||
include ':react-native-async-storage'
|
||||
project(':react-native-async-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-async-storage/async-storage/android')
|
||||
include ':react-native-background-timer'
|
||||
|
|
|
@ -29,7 +29,7 @@ target 'JitsiMeetSDK' do
|
|||
'CoreModulesHeaders',
|
||||
'DevSupport',
|
||||
'RCTWebSocket'
|
||||
]
|
||||
], :modular_headers => true
|
||||
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
|
||||
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
|
||||
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
|
||||
|
@ -54,6 +54,7 @@ target 'JitsiMeetSDK' do
|
|||
# React Native plugins
|
||||
#
|
||||
|
||||
pod 'amplitude-react-native', :path => '../node_modules/@amplitude/react-native'
|
||||
pod 'react-native-background-timer', :path => '../node_modules/react-native-background-timer'
|
||||
pod 'react-native-calendar-events', :path => '../node_modules/react-native-calendar-events'
|
||||
pod 'react-native-keep-awake', :path => '../node_modules/react-native-keep-awake'
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
PODS:
|
||||
- Amplitude (8.2.0)
|
||||
- amplitude-react-native (2.3.3):
|
||||
- Amplitude (= 8.2.0)
|
||||
- React-Core
|
||||
- AppAuth (1.4.0):
|
||||
- AppAuth/Core (= 1.4.0)
|
||||
- AppAuth/ExternalUserAgent (= 1.4.0)
|
||||
|
@ -372,6 +376,7 @@ PODS:
|
|||
- Yoga (1.14.0)
|
||||
|
||||
DEPENDENCIES:
|
||||
- "amplitude-react-native (from `../node_modules/@amplitude/react-native`)"
|
||||
- CocoaLumberjack (~> 3.5.3)
|
||||
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
|
||||
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector/`)
|
||||
|
@ -423,6 +428,7 @@ DEPENDENCIES:
|
|||
|
||||
SPEC REPOS:
|
||||
trunk:
|
||||
- Amplitude
|
||||
- AppAuth
|
||||
- boost-for-react-native
|
||||
- CocoaLumberjack
|
||||
|
@ -444,6 +450,8 @@ SPEC REPOS:
|
|||
- PromisesObjC
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
amplitude-react-native:
|
||||
:path: "../node_modules/@amplitude/react-native"
|
||||
DoubleConversion:
|
||||
:podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
|
||||
FBLazyVector:
|
||||
|
@ -528,6 +536,8 @@ EXTERNAL SOURCES:
|
|||
:path: "../node_modules/react-native/ReactCommon/yoga"
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Amplitude: 263118b9e691e73a1c864b05bb08a3aff3636d16
|
||||
amplitude-react-native: 833a4bd7f656f826bda1de01a7b8593b58842209
|
||||
AppAuth: 31bcec809a638d7bd2f86ea8a52bd45f6e81e7c7
|
||||
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
|
||||
CocoaLumberjack: 2f44e60eb91c176d471fdba43b9e3eae6a721947
|
||||
|
@ -589,6 +599,6 @@ SPEC CHECKSUMS:
|
|||
RNWatch: a5320c959c75e72845c07985f3e935e58998f1d3
|
||||
Yoga: 96b469c5e81ff51b917b92e8c3390642d4ded30c
|
||||
|
||||
PODFILE CHECKSUM: f4db44d934caeae7212dbaa33abe62ed164363e8
|
||||
PODFILE CHECKSUM: 1ae1a9823f3eab0b6e735b9637ba7588e0890d08
|
||||
|
||||
COCOAPODS: 1.10.1
|
||||
|
|
|
@ -437,10 +437,12 @@
|
|||
);
|
||||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-JitsiMeetSDK/Pods-JitsiMeetSDK-resources.sh",
|
||||
"${PODS_ROOT}/Amplitude/Sources/Amplitude/Resources/ComodoRsaDomainValidationCA.der",
|
||||
"${PODS_ROOT}/GoogleSignIn/Resources/GoogleSignIn.bundle",
|
||||
);
|
||||
name = "[CP] Copy Pods Resources";
|
||||
outputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/ComodoRsaDomainValidationCA.der",
|
||||
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleSignIn.bundle",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@amplitude/react-native": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/@amplitude/react-native/-/react-native-2.3.3.tgz",
|
||||
"integrity": "sha512-QTpwy4lKy9kpBjB2334HCEIU7QwGFAkGRfp21aeDA87D6pkiUMAvyDYbz58CnB5HCXuqcvws3GN8d60RO9KF9A=="
|
||||
},
|
||||
"@amplitude/types": {
|
||||
"version": "1.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@amplitude/types/-/types-1.5.5.tgz",
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
"author": "",
|
||||
"readmeFilename": "README.md",
|
||||
"dependencies": {
|
||||
"@amplitude/react-native": "2.3.3",
|
||||
"@atlaskit/button": "15.1.4",
|
||||
"@atlaskit/checkbox": "12.0.0",
|
||||
"@atlaskit/dropdown-menu": "10.1.2",
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import amplitude from 'amplitude-js';
|
||||
|
||||
import logger from '../logger';
|
||||
|
||||
import AbstractHandler from './AbstractHandler';
|
||||
import { fixDeviceID } from './amplitude';
|
||||
import { fixDeviceID } from './amplitude/fixDeviceID';
|
||||
import amplitude from './amplitude/lib';
|
||||
|
||||
/**
|
||||
* Analytics handler for Amplitude.
|
||||
|
@ -19,41 +18,39 @@ export default class AmplitudeHandler extends AbstractHandler {
|
|||
constructor(options) {
|
||||
super(options);
|
||||
|
||||
const { amplitudeAPPKey, host, user } = options;
|
||||
const { amplitudeAPPKey, user } = options;
|
||||
|
||||
this._enabled = true;
|
||||
this._host = host; // Only used on React Native.
|
||||
|
||||
const onError = e => {
|
||||
logger.error('Error initializing Amplitude', e);
|
||||
this._enabled = false;
|
||||
};
|
||||
|
||||
const amplitudeOptions = {
|
||||
domain: navigator.product === 'ReactNative' ? host : undefined,
|
||||
includeReferrer: true,
|
||||
onError
|
||||
};
|
||||
if (navigator.product === 'ReactNative') {
|
||||
amplitude.getInstance().init(amplitudeAPPKey);
|
||||
fixDeviceID(amplitude.getInstance()).then(() => {
|
||||
amplitude.getInstance().getDeviceId()
|
||||
.then(deviceId => {
|
||||
this._deviceId = deviceId;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
const amplitudeOptions = {
|
||||
includeReferrer: true,
|
||||
onError
|
||||
};
|
||||
|
||||
this._getInstance().init(amplitudeAPPKey, undefined, amplitudeOptions);
|
||||
fixDeviceID(this._getInstance());
|
||||
amplitude.getInstance().init(amplitudeAPPKey, undefined, amplitudeOptions);
|
||||
fixDeviceID(amplitude.getInstance());
|
||||
}
|
||||
|
||||
if (user) {
|
||||
this._getInstance().setUserId(user);
|
||||
this._userId = user;
|
||||
amplitude.getInstance().setUserId(user);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the AmplitudeClient instance.
|
||||
*
|
||||
* @returns {AmplitudeClient}
|
||||
*/
|
||||
_getInstance() {
|
||||
const name = navigator.product === 'ReactNative' ? this._host : undefined;
|
||||
|
||||
return amplitude.getInstance(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Amplitude user properties.
|
||||
*
|
||||
|
@ -62,7 +59,7 @@ export default class AmplitudeHandler extends AbstractHandler {
|
|||
*/
|
||||
setUserProperties(userProps) {
|
||||
if (this._enabled) {
|
||||
this._getInstance().setUserProperties(userProps);
|
||||
amplitude.getInstance().setUserProperties(userProps);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +76,7 @@ export default class AmplitudeHandler extends AbstractHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
this._getInstance().logEvent(this._extractName(event), event);
|
||||
amplitude.getInstance().logEvent(this._extractName(event), event);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,10 +85,17 @@ export default class AmplitudeHandler extends AbstractHandler {
|
|||
* @returns {Object}
|
||||
*/
|
||||
getIdentityProps() {
|
||||
if (navigator.product === 'ReactNative') {
|
||||
return {
|
||||
deviceId: this._deviceId,
|
||||
userId: this._userId
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
sessionId: this._getInstance().getSessionId(),
|
||||
deviceId: this._getInstance().options.deviceId,
|
||||
userId: this._getInstance().options.userId
|
||||
sessionId: amplitude.getInstance().getSessionId(),
|
||||
deviceId: amplitude.getInstance().options.deviceId,
|
||||
userId: amplitude.getInstance().options.userId
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
export * from './fixDeviceID';
|
|
@ -0,0 +1,3 @@
|
|||
import { Amplitude } from '@amplitude/react-native';
|
||||
|
||||
export default Amplitude;
|
|
@ -0,0 +1,3 @@
|
|||
import amplitude from 'amplitude-js';
|
||||
|
||||
export default amplitude;
|
Loading…
Reference in New Issue