Skip to content

Commit

Permalink
s/relay/sidecar
Browse files Browse the repository at this point in the history
  • Loading branch information
Lms24 committed Oct 31, 2023
1 parent e654f9c commit e54a2f3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { SentryEventsContextProvider } from './lib/sentryEventsContext';
import { NavigationProvider } from './lib/navigationContext';
import { OnlineContextProvider } from './lib/onlineContext';
import type { Integration } from './integrations/integration';
import { connectToRelay } from '.';
import { connectToSidecar } from '.';

const DEFAULT_RELAY = 'http://localhost:8969/stream';
const DEFAULT_SIDECAR = 'http://localhost:8969/stream';

export default function App({
eventTarget,
Expand Down Expand Up @@ -39,7 +39,7 @@ export default function App({
}),
);

const cleanupListeners = connectToRelay(DEFAULT_RELAY, contentTypeToIntegrations, setIntegrationData);
const cleanupListeners = connectToSidecar(DEFAULT_SIDECAR, contentTypeToIntegrations, setIntegrationData);

return () => {
console.log('[Spotlight] useeffect cleanup');
Expand Down
2 changes: 1 addition & 1 deletion src/components/Debugger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function Debugger({
isOnline ? 'bg-green-400' : 'bg-red-400 animate-pulse',
)}
/>
{isOnline ? 'Connected to Relay' : 'Not connected to Relay'}
{isOnline ? 'Connected to Sidecar' : 'Not connected to Sidecar'}
</div>
</div>
</h1>
Expand Down
12 changes: 5 additions & 7 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ export async function init({
integrations?: Integration[];
fullScreen?: boolean;
defaultEventId?: string;
relay?: string;
sidecarUrl?: string;
showTriggerButton?: boolean;
} = {}) {
if (typeof document === 'undefined') return;

const initializedIntegrations = await initIntegrations(integrations);

// connectToRelay(relay, contentTypeToIntegrations);

// build shadow dom container to contain styles
const docRoot = document.createElement('div');
docRoot.id = 'sentry-spotlight-root';
Expand Down Expand Up @@ -95,13 +93,13 @@ export function pushEnvelope(envelope: Envelope) {
dataCache.pushEnvelope(envelope);
}

export function connectToRelay(
relayUrl: string,
export function connectToSidecar(
sidecarUrl: string,
contentTypeToIntegrations: Map<string, Integration<unknown>[]>,
setIntegrationData: React.Dispatch<React.SetStateAction<Record<string, Array<unknown>>>>,
): () => void {
console.log('[Spotlight] Connecting to relay');
const source = new EventSource(relayUrl);
console.log('[Spotlight] Connecting to sidecar at', sidecarUrl);
const source = new EventSource(sidecarUrl);

source.addEventListener('application/x-sentry-envelope', event => {
console.log('[spotlight] Received new envelope');
Expand Down

0 comments on commit e54a2f3

Please sign in to comment.