Skip to content
Draft
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
1 change: 1 addition & 0 deletions playground/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ <h2>Session ID:</h2>
<div class="section-label">SDK Actions</div>
<div class="button-group">
<button id="stop-btn">Stop Session</button>
<button id="new-window-btn">New Window</button>
<button id="generate-activity">Generate Activity</button>
<button id="generate-telemetry-error">Generate Telemetry Error</button>
<button id="generate-uncaught-exception">Generate Uncaught Exception</button>
Expand Down
19 changes: 19 additions & 0 deletions playground/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,32 @@ function createWindow() {
});
}

function createNewWindow() {
const win = new BrowserWindow({
width: 1024,
height: 768,
show: !isTestMode,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
contextIsolation: true,
nodeIntegration: false,
},
});

void win.loadFile(path.join(__dirname, 'index.html'));
}

// IPC handler to get internal context
ipcMain.handle('get-internal-context', () => getInternalContext());

ipcMain.handle('stop-session', () => {
stopSession();
});

ipcMain.handle('open-new-window', () => {
createNewWindow();
});

ipcMain.handle('generateTelemetryError', () => {
_generateTelemetryError();
});
Expand Down
1 change: 1 addition & 0 deletions playground/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { contextBridge, ipcRenderer } from 'electron';
contextBridge.exposeInMainWorld('electronAPI', {
getInternalContext: () => ipcRenderer.invoke('get-internal-context'),
stopSession: () => ipcRenderer.invoke('stop-session'),
openNewWindow: () => ipcRenderer.invoke('open-new-window'),
generateTelemetryError: () => ipcRenderer.invoke('generateTelemetryError'),
generateUncaughtException: () => ipcRenderer.invoke('generateUncaughtException'),
generateUnhandledRejection: () => ipcRenderer.invoke('generateUnhandledRejection'),
Expand Down
7 changes: 7 additions & 0 deletions playground/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ datadogRum.init({
interface ElectronAPI {
getInternalContext: () => Promise<{ session_id: string } | undefined>;
stopSession: () => Promise<void>;
openNewWindow: () => Promise<void>;
generateTelemetryError: () => Promise<void>;
generateUncaughtException: () => Promise<void>;
generateUnhandledRejection: () => Promise<void>;
Expand Down Expand Up @@ -120,6 +121,12 @@ crashBtn.addEventListener('click', () => {
void window.electronAPI.crash();
});

// Handle new window button click
const newWindowBtn = document.getElementById('new-window-btn') as HTMLButtonElement;
newWindowBtn.addEventListener('click', () => {
void window.electronAPI.openNewWindow();
});

// Handle open in RUM Explorer button click
const openRumExplorerBtn = document.getElementById('open-rum-explorer') as HTMLButtonElement;
openRumExplorerBtn.addEventListener('click', () => {
Expand Down