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).
| Parameter | Type | Description |
|---|---|---|
| url | string | Full URL (must include http:// or https://) |
Returns: void
Example:
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.
| Parameter | Type | Description |
|---|---|---|
| module | IModule | Custom module instance (must implement IModule) |
Returns: this
Example:
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.
| Parameter | Type | Description |
|---|---|---|
| name | string | Event name (snake_case recommended) |
| data? | unknown | Additional data (optional, JSON-serialized) |
| code? | number | Event status code (optional; 0 typically means success) |
Returns: void
Example:
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.
| Parameter | Type | Description |
|---|---|---|
| action | string | Action identifier |
| message | string | Log description message |
Returns: void
Example:
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.
| Parameter | Type | Description |
|---|---|---|
| adapter | IRtcAdapter | Custom RTC adapter instance |
Returns: this
Example:
classroom.useRtcAdapter(new ElectronRtcAdapter()).init();