Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(watchrtc) don't log RN warning unless WatchRTC is used #2501

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions modules/statistics/statistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@ Statistics.init = function(options) {
Statistics.disableThirdPartyRequests = options.disableThirdPartyRequests;

LocalStats.init();

// WatchRTC is not required to work for react native
browser.isReactNative()
? logger.warn('Cannot initialize WatchRTC in a react native environment!')
: WatchRTC.init(options);

WatchRTC.init(options);
RTCStats.init(options);
};

Expand Down
12 changes: 10 additions & 2 deletions modules/watchRTC/WatchRTC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import Logger from '@jitsi/logger';
import watchRTC from '@testrtc/watchrtc-sdk';

import { isAnalyticsEnabled, isRtcstatsEnabled, isWatchRTCEnabled } from './functions';
import browser from '../browser';

import { isAnalyticsEnabled, isWatchRTCEnabled } from './functions';
import { IWatchRTCConfiguration } from './interfaces';

const logger = Logger.getLogger(__filename);
Expand All @@ -13,6 +15,7 @@ const logger = Logger.getLogger(__filename);
*/
class WatchRTCHandler {
options?: IWatchRTCConfiguration;

/**
* Initialize watchRTC, it overwrites GUM and PeerConnection global functions and adds a proxy over them
* used to capture stats.
Expand All @@ -21,9 +24,14 @@ class WatchRTCHandler {
* @returns {void}
*/
init(options: any): void {

if (isWatchRTCEnabled(options)) {

// @ts-ignore
if (browser.isReactNative()) {
logger.warn('Cannot initialize WatchRTC in a react native environment!');
return;
}

if (!isAnalyticsEnabled(options)) {
logger.error('Cannot initialize WatchRTC when analytics or third party requests are disabled.');
return;
Expand Down
Loading