Skip to content

Utilities API

Cross-platform utilities, analytics reporting, and advanced customization.

API Reference

openBrowser()

Open a URL in the system browser cross-platform (Electron: default system browser; Web: navigate or open new tab).

在 Electron / Native 嵌入场景下,应优先使用此 API 而不是直接调用 window.open, In Electron / Native embed scenarios, prefer this API over direct window.open so URLs always open in the system browser (not the in-app webview).

ParameterTypeDescription
urlstringFull URL (must include http:// or https://)

Returns: void

Example:

ts
classroom.openBrowser('https://cloud.tencent.com/');

register()

Register a custom business module (advanced usage, must be called before init()).

Most developers do not need this; intended for integrators with custom requirements.

ParameterTypeDescription
moduleIModuleCustom module instance (must implement IModule)

Returns: this

Example:

ts
classroom.register(new MyCustomModule()).init();

reportEvent()

Report a business analytics event (written to Logger and reported to monitoring backend).

Used for business-defined analytics events (e.g., button clicks, feature usage); shares the SDK's internal reporting channel.

ParameterTypeDescription
namestringEvent name (snake_case recommended)
data?unknownAdditional data (optional, JSON-serialized)
code?numberEvent status code (optional; 0 typically means success)

Returns: void

Example:

ts
classroom.reportEvent('beauty_open', { whiten: 30 });
classroom.reportEvent('upload_courseware', { docId, fileSize: file.size }, 0);

reportLog()

Report a log entry (written to Logger for troubleshooting).

Only writes to the local Logger buffer (not directly reported to the backend). Difference from reportEvent: logs are for debugging/replay; events are for analytics.

ParameterTypeDescription
actionstringAction identifier
messagestringLog description message

Returns: void

Example:

ts
classroom.reportLog('panel_toggle', 'user opened member panel');

useRtcAdapter()

Inject a custom RTC adapter for cross-platform support (must be called before init()).

允许在 Electron / Android WebView / iOS WebView 等平台传入自定义 IRtcAdapter 实现, Use this to replace the default WebRtcAdapter (TRTC Web SDK v5) on non-web platforms.

ParameterTypeDescription
adapterIRtcAdapterCustom RTC adapter instance

Returns: this

Example:

ts
classroom.useRtcAdapter(new ElectronRtcAdapter()).init();