Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ export class WebSocketBroadcastService {
private readonly managementApiClient: ApiGatewayManagementApiClient | null;

constructor() {
const managementEndpoint = outputs.custom?.APIs?.WebSocketDevServerApi?.managementEndpoint;
const websocketConfig = outputs.custom?.APIs?.WebSocketDevServerApi;
const managementEndpoint = websocketConfig?.managementEndpoint;
if (!managementEndpoint) {
logger.warn(
'WebSocket management endpoint not found. WebSocket broadcast will be disabled.',
`WebSocket management endpoint not found. WebSocket broadcast disabled. Config snapshot: ${JSON.stringify(
websocketConfig || {}
)}`,
'WebSocketBroadcastService'
);
this.managementApiClient = null;
Expand All @@ -42,14 +45,21 @@ export class WebSocketBroadcastService {
this.managementApiClient = new ApiGatewayManagementApiClient({
endpoint: managementEndpoint,
});
logger.info(
`WebSocketBroadcastService initialized with management endpoint ${managementEndpoint}`,
'WebSocketBroadcastService'
);
}

/**
* Envía un mensaje a todas las conexiones WebSocket de un storeId:templateType
*/
async broadcastMessage(storeId: string, templateType: TemplateType, message: string): Promise<void> {
if (!this.managementApiClient) {
logger.warn('WebSocket broadcast service is not available', 'WebSocketBroadcastService');
logger.warn(
`WebSocket broadcast service is not available (storeId=${storeId}, templateType=${templateType})`,
'WebSocketBroadcastService'
);
return;
}

Expand Down
16 changes: 16 additions & 0 deletions app/store/[slug]/studio/studioClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ export default function StudioClient() {
return outputs.custom?.APIs?.WebSocketDevServerApi?.endpoint;
}, []);

useMemo(() => {
if (!websocketEndpoint) {
console.warn('[ThemeStudio] WebSocket endpoint missing in amplify_outputs.json', {
outputsWebsocketConfig: outputs.custom?.APIs?.WebSocketDevServerApi,
env: process.env.NODE_ENV,
storeId,
});
} else {
console.info('[ThemeStudio] WebSocket endpoint detected', {
websocketEndpoint,
env: process.env.NODE_ENV,
storeId,
});
}
}, [websocketEndpoint, storeId]);

if (loading || !domain) {
return <Loading />;
}
Expand Down
Loading