From 9f7d541e4164bc83af2f2724fba4057819065376 Mon Sep 17 00:00:00 2001 From: Ricardoaar Date: Wed, 6 May 2026 10:24:49 -0600 Subject: [PATCH 1/3] :sparkles: [SC-2310] CustomMetric: Add support for data and info --- src/context/UbidotsReducer.ts | 5 ++ src/context/__tests__/actions.test.ts | 48 +++++++++++--------- src/context/actions.ts | 34 +++++++------- src/context/constants.ts | 5 ++ src/context/messageHandlers.ts | 7 +++ src/hooks/__tests__/useWidgetEvents.test.tsx | 12 ++--- src/hooks/useWidgetEvents.ts | 43 +++++++++++++++++- src/types/index.ts | 5 +- 8 files changed, 113 insertions(+), 46 deletions(-) diff --git a/src/context/UbidotsReducer.ts b/src/context/UbidotsReducer.ts index 208f01b..cd3ebc8 100644 --- a/src/context/UbidotsReducer.ts +++ b/src/context/UbidotsReducer.ts @@ -21,6 +21,7 @@ export const initialState: UbidotsState = { deviceObject: null, selectedDeviceObjects: null, selectedFilters: null, + dashboardDevices: null, realTime: null, widget: null, widgetId: null, @@ -69,6 +70,10 @@ const reducerHandlers: Record< ...state, selectedFilters: action.payload as FilterValue[] | null, }), + [ACTION_TYPES.DASHBOARD_DEVICES]: (state, action) => ({ + ...state, + dashboardDevices: action.payload as Device[] | null, + }), [ACTION_TYPES.REAL_TIME_STATUS]: (state, action) => ({ ...state, realTime: action.payload as boolean | null, diff --git a/src/context/__tests__/actions.test.ts b/src/context/__tests__/actions.test.ts index 65b5b92..cd0d767 100644 --- a/src/context/__tests__/actions.test.ts +++ b/src/context/__tests__/actions.test.ts @@ -19,7 +19,7 @@ describe('actions', () => { describe('setDashboardDevice', () => { it('should emit both V1 and V2 events', () => { - const actions = createActions(null, 'token', null); + const actions = createActions(null, 'token', null, null); actions.setDashboardDevice('device-123'); @@ -37,7 +37,7 @@ describe('actions', () => { }); it('should convert single device ID to array format for V2', () => { - const actions = createActions(null, 'token', null); + const actions = createActions(null, 'token', null, null); actions.setDashboardDevice('my-device'); @@ -54,7 +54,7 @@ describe('actions', () => { describe('setDashboardMultipleDevices', () => { it('should emit both V1 and V2 events', () => { - const actions = createActions(null, 'token', null); + const actions = createActions(null, 'token', null, null); actions.setDashboardMultipleDevices(['dev1', 'dev2', 'dev3']); @@ -75,7 +75,7 @@ describe('actions', () => { }); it('should convert string array to Device array for V2', () => { - const actions = createActions(null, 'token', null); + const actions = createActions(null, 'token', null, null); actions.setDashboardMultipleDevices(['a', 'b']); @@ -93,7 +93,7 @@ describe('actions', () => { describe('setDashboardDateRange', () => { it('should emit both V1 and V2 events for valid date range', () => { - const actions = createActions(null, 'token', null); + const actions = createActions(null, 'token', null, null); const dateRange = { startTime: 1000, endTime: 2000 }; actions.setDashboardDateRange(dateRange); @@ -112,7 +112,7 @@ describe('actions', () => { }); it('should NOT emit events for invalid date range (startTime >= endTime)', () => { - const actions = createActions(null, 'token', null); + const actions = createActions(null, 'token', null, null); const invalidRange = { startTime: 2000, endTime: 1000 }; actions.setDashboardDateRange(invalidRange); @@ -121,7 +121,7 @@ describe('actions', () => { }); it('should NOT emit events for null date range', () => { - const actions = createActions(null, 'token', null); + const actions = createActions(null, 'token', null, null); actions.setDashboardDateRange( null as unknown as { startTime: number; endTime: number } @@ -132,22 +132,26 @@ describe('actions', () => { }); describe('setDashboardLayer', () => { - it('should only emit V1 event (no V2 equivalent)', () => { - const actions = createActions(null, 'token', null); + it('should emit both V1 and V2 events', () => { + const actions = createActions(null, 'token', null, null); actions.setDashboardLayer('layer-1'); - expect(postMessageSpy).toHaveBeenCalledTimes(1); + expect(postMessageSpy).toHaveBeenCalledTimes(2); expect(postMessageSpy).toHaveBeenCalledWith( { event: OUTBOUND_EVENTS.SET_DASHBOARD_LAYER, payload: 'layer-1' }, '*' ); + expect(postMessageSpy).toHaveBeenCalledWith( + { event: OUTBOUND_EVENTS_V2.SET_DASHBOARD_LAYER, payload: 'layer-1' }, + '*' + ); }); }); describe('setRealTime', () => { it('should emit both V1 and V2 events with true', () => { - const actions = createActions(null, 'token', null); + const actions = createActions(null, 'token', null, null); actions.setRealTime(true); @@ -162,7 +166,7 @@ describe('actions', () => { }); it('should emit both V1 and V2 events with false', () => { - const actions = createActions(null, 'token', null); + const actions = createActions(null, 'token', null, null); actions.setRealTime(false); @@ -179,7 +183,7 @@ describe('actions', () => { describe('refreshDashboard', () => { it('should emit both V1 and V2 events without payload', () => { - const actions = createActions(null, 'token', null); + const actions = createActions(null, 'token', null, null); actions.refreshDashboard(); @@ -196,7 +200,7 @@ describe('actions', () => { describe('openDrawer', () => { it('should emit both V1 and V2 events with drawer info', () => { - const actions = createActions(null, 'token', null); + const actions = createActions(null, 'token', null, null); const drawerOpts = { url: 'https://example.com', width: 400 }; actions.openDrawer(drawerOpts); @@ -218,7 +222,7 @@ describe('actions', () => { }); it('should use widgetId from context state when provided', () => { - const actions = createActions(null, 'token', 'custom-widget-id'); + const actions = createActions(null, 'token', 'custom-widget-id', null); const drawerOpts = { url: 'https://example.com', width: 300 }; actions.openDrawer(drawerOpts); @@ -241,7 +245,7 @@ describe('actions', () => { describe('setFullScreen', () => { it('should emit both V1 and V2 events with toggle', () => { - const actions = createActions(null, 'token', null); + const actions = createActions(null, 'token', null, null); actions.setFullScreen('toggle'); @@ -256,7 +260,7 @@ describe('actions', () => { }); it('should emit both V1 and V2 events with enable', () => { - const actions = createActions(null, 'token', null); + const actions = createActions(null, 'token', null, null); actions.setFullScreen('enable'); @@ -271,7 +275,7 @@ describe('actions', () => { }); it('should emit both V1 and V2 events with disable', () => { - const actions = createActions(null, 'token', null); + const actions = createActions(null, 'token', null, null); actions.setFullScreen('disable'); @@ -288,7 +292,7 @@ describe('actions', () => { describe('getHeaders', () => { it('should return JWT Bearer header when jwtToken is provided', () => { - const actions = createActions('jwt-token-123', null, null); + const actions = createActions('jwt-token-123', null, null, null); const headers = actions.getHeaders(); @@ -299,7 +303,7 @@ describe('actions', () => { }); it('should return X-Auth-Token header when only token is provided', () => { - const actions = createActions(null, 'api-token-456', null); + const actions = createActions(null, 'api-token-456', null, null); const headers = actions.getHeaders(); @@ -310,7 +314,7 @@ describe('actions', () => { }); it('should prefer JWT token over API token', () => { - const actions = createActions('jwt-token', 'api-token', null); + const actions = createActions('jwt-token', 'api-token', null, null); const headers = actions.getHeaders(); @@ -321,7 +325,7 @@ describe('actions', () => { }); it('should return only Content-type when no tokens are provided', () => { - const actions = createActions(null, null, null); + const actions = createActions(null, null, null, null); const headers = actions.getHeaders(); diff --git a/src/context/actions.ts b/src/context/actions.ts index b5e10f5..a05817e 100644 --- a/src/context/actions.ts +++ b/src/context/actions.ts @@ -27,21 +27,19 @@ function postMessageWithV2( */ function generateHeaders( jwtToken: string | null, - token: string | null + token: string | null, + receivedHeaders: Record | null ): Record { + const base: Record = { + ...receivedHeaders, + 'Content-type': 'application/json', + }; if (jwtToken) { - return { - Authorization: `Bearer ${jwtToken}`, - 'Content-type': 'application/json', - }; - } - if (token) { - return { - 'X-Auth-Token': token, - 'Content-type': 'application/json', - }; + base['Authorization'] = `Bearer ${jwtToken}`; + } else if (token) { + base['X-Auth-Token'] = token; } - return { 'Content-type': 'application/json' }; + return base; } /** @@ -103,8 +101,11 @@ const actionCreators = { }, setDashboardLayer: (layerId: string) => { - // V2 protocol has no equivalent for layer yet — only V1 is sent. - postMessage(OUTBOUND_EVENTS.SET_DASHBOARD_LAYER, layerId); + postMessageWithV2( + OUTBOUND_EVENTS.SET_DASHBOARD_LAYER, + OUTBOUND_EVENTS_V2.SET_DASHBOARD_LAYER, + layerId + ); }, setRealTime: (rt: boolean) => @@ -136,7 +137,8 @@ const actionCreators = { export function createActions( jwtToken: string | null, token: string | null, - widgetId: string | null + widgetId: string | null, + receivedHeaders: Record | null ): OutboundActions { return { ...actionCreators, @@ -148,6 +150,6 @@ export function createActions( payload ); }, - getHeaders: () => generateHeaders(jwtToken, token), + getHeaders: () => generateHeaders(jwtToken, token, receivedHeaders), }; } diff --git a/src/context/constants.ts b/src/context/constants.ts index 21d5056..1ca6669 100644 --- a/src/context/constants.ts +++ b/src/context/constants.ts @@ -44,6 +44,11 @@ export const INBOUND_EVENTS_V2 = { REFRESH_DASHBOARD: 'v2:dashboard:settings:refreshed', REALTIME_ACTIVE: 'v2:dashboard:settings:rt', SELECTED_DASHBOARD_OBJECT: 'v2:dashboard:self', + // Widget events (base names — full event is v2:widget::) + WIDGET_DATA: 'v2:widget:data', + WIDGET_INFO: 'v2:widget:info', + WIDGET_READY: 'v2:widget:ready', + WIDGET_ERROR: 'v2:widget:error', SELECTED_FILTERS: 'v2:dashboard:settings:filters', } as const; diff --git a/src/context/messageHandlers.ts b/src/context/messageHandlers.ts index 54de333..e96a76c 100644 --- a/src/context/messageHandlers.ts +++ b/src/context/messageHandlers.ts @@ -183,6 +183,13 @@ const messageHandlers: Record = { }); satisfiedEventsRef.current.add(INBOUND_EVENTS_V2.JWT); }, + [INBOUND_EVENTS_V2.DEVICES_ALL]: (payload, dispatch, satisfiedEventsRef) => { + dispatch({ + type: ACTION_TYPES.DASHBOARD_DEVICES, + payload: payload as Device[] | null, + }); + satisfiedEventsRef.current.add(INBOUND_EVENTS_V2.DEVICES_ALL); + }, [INBOUND_EVENTS_V2.SELECTED_DEVICES]: ( payload, diff --git a/src/hooks/__tests__/useWidgetEvents.test.tsx b/src/hooks/__tests__/useWidgetEvents.test.tsx index 5a8ed35..644beef 100644 --- a/src/hooks/__tests__/useWidgetEvents.test.tsx +++ b/src/hooks/__tests__/useWidgetEvents.test.tsx @@ -43,7 +43,7 @@ describe('useWidgetEvents', () => { expect(postMessageSpy).toHaveBeenCalledWith( { - event: 'v2:widget:widget-123:custom-event', + event: 'v2:widget:custom-event:widget-123', payload: { data: 'test' }, }, '*' @@ -75,7 +75,7 @@ describe('useWidgetEvents', () => { expect(postMessageSpy).toHaveBeenCalledWith( { - event: 'v2:widget:provider-widget:test-event', + event: 'v2:widget:test-event:provider-widget', payload: { value: 42 }, }, '*' @@ -140,7 +140,7 @@ describe('useWidgetEvents', () => { expect(postMessageSpy).toHaveBeenCalledWith( { - event: 'v2:widget:widget-abc:ping', + event: 'v2:widget:ping:widget-abc', payload: undefined, }, '*' @@ -454,7 +454,7 @@ describe('useWidgetEvents', () => { call[0] && typeof call[0] === 'object' && 'event' in call[0] && - call[0].event === 'v2:widget:lifecycle-widget:ready' + call[0].event === 'v2:widget:ready:lifecycle-widget' ); expect(readyCall).toBeDefined(); }); @@ -464,11 +464,11 @@ describe('useWidgetEvents', () => { call[0] && typeof call[0] === 'object' && 'event' in call[0] && - call[0].event === 'v2:widget:lifecycle-widget:ready' + call[0].event === 'v2:widget:ready:lifecycle-widget' ); expect(readyCall![0]).toMatchObject({ - event: 'v2:widget:lifecycle-widget:ready', + event: 'v2:widget:ready:lifecycle-widget', payload: expect.objectContaining({ widgetId: 'lifecycle-widget', timestamp: expect.any(Number), diff --git a/src/hooks/useWidgetEvents.ts b/src/hooks/useWidgetEvents.ts index 143b6fb..01ea529 100644 --- a/src/hooks/useWidgetEvents.ts +++ b/src/hooks/useWidgetEvents.ts @@ -1,5 +1,6 @@ import { useCallback, useEffect, useRef } from 'react'; import { useUbidots } from '../context/ubidots'; +import { INBOUND_EVENTS_V2 } from '../context/constants'; import { useUbidotsWidgetId } from './useUbidotsSelections'; /** @@ -31,7 +32,7 @@ export function useWidgetEvents(widgetIdParam?: string) { return; } - const eventName = `v2:widget:${widgetId}:${event}`; + const eventName = `v2:widget:${event}:${widgetId}`; // Emit to parent window window.parent.postMessage( @@ -123,6 +124,42 @@ export function useWidgetEvents(widgetIdParam?: string) { }; }, []); + const onData = useCallback( + (callback: (payload: unknown) => void) => { + if (!widgetId) return () => {}; + const event = `${INBOUND_EVENTS_V2.WIDGET_DATA}:${widgetId}`; + return onWidgetEvent(event, callback); + }, + [widgetId, onWidgetEvent] + ); + + const onInfo = useCallback( + (callback: (payload: unknown) => void) => { + if (!widgetId) return () => {}; + const event = `${INBOUND_EVENTS_V2.WIDGET_INFO}:${widgetId}`; + return onWidgetEvent(event, callback); + }, + [widgetId, onWidgetEvent] + ); + + const onError = useCallback( + (callback: (payload: unknown) => void) => { + if (!widgetId) return () => {}; + const event = `${INBOUND_EVENTS_V2.WIDGET_ERROR}:${widgetId}`; + return onWidgetEvent(event, callback); + }, + [widgetId, onWidgetEvent] + ); + + const onReady = useCallback( + (callback: (payload: unknown) => void) => { + if (!widgetId) return () => {}; + const event = `${INBOUND_EVENTS_V2.WIDGET_READY}:${widgetId}`; + return onWidgetEvent(event, callback); + }, + [widgetId, onWidgetEvent] + ); + // Emit lifecycle events useEffect(() => { if (widgetId && state.ready) { @@ -134,6 +171,10 @@ export function useWidgetEvents(widgetIdParam?: string) { emitWidgetEvent, onWidgetEvent, onAnyWidgetEvent, + onData, + onInfo, + onError, + onReady, widgetId, }; } diff --git a/src/types/index.ts b/src/types/index.ts index e921516..392524f 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -21,7 +21,8 @@ export type ReadyEventV2 = | 'v2:dashboard:settings:refreshed' | 'v2:dashboard:settings:rt' | 'v2:dashboard:self' - | 'v2:dashboard:settings:filters'; + | 'v2:dashboard:settings:filters' + | 'v2:dashboard:devices:self'; // Combined type for backward compatibility export type ReadyEvent = ReadyEventV1 | ReadyEventV2; @@ -72,6 +73,7 @@ export interface UbidotsState { deviceObject: DeviceObject | null; selectedDeviceObjects: DeviceObject[] | null; selectedFilters: FilterValue[] | null; + dashboardDevices: Device[] | null; realTime: boolean | null; widget: WidgetInfo | null; widgetId: string | null; @@ -87,6 +89,7 @@ export type UbidotsAction = | { type: 'SELECTED_DEVICE_OBJECT'; payload: DeviceObject | null } | { type: 'SELECTED_DEVICE_OBJECTS'; payload: DeviceObject[] | null } | { type: 'SELECTED_FILTERS'; payload: FilterValue[] | null } + | { type: 'DASHBOARD_DEVICES'; payload: Device[] | null } | { type: 'REAL_TIME_STATUS'; payload: boolean | null } | { type: 'SET_READY'; payload: boolean } | { type: 'SET_WIDGET'; payload: WidgetInfo | null } From d05b5dbdcdb4fb51253ff10a645dd4d6152eab5a Mon Sep 17 00:00:00 2001 From: Ricardo Rito Date: Wed, 6 May 2026 14:42:11 -0600 Subject: [PATCH 2/3] :sparkles: [SC-2310] Data: Add support to widget data and info --- src/context/__tests__/actions.test.ts | 48 ++++++++++++--------------- src/context/actions.ts | 34 +++++++++---------- 2 files changed, 38 insertions(+), 44 deletions(-) diff --git a/src/context/__tests__/actions.test.ts b/src/context/__tests__/actions.test.ts index cd0d767..65b5b92 100644 --- a/src/context/__tests__/actions.test.ts +++ b/src/context/__tests__/actions.test.ts @@ -19,7 +19,7 @@ describe('actions', () => { describe('setDashboardDevice', () => { it('should emit both V1 and V2 events', () => { - const actions = createActions(null, 'token', null, null); + const actions = createActions(null, 'token', null); actions.setDashboardDevice('device-123'); @@ -37,7 +37,7 @@ describe('actions', () => { }); it('should convert single device ID to array format for V2', () => { - const actions = createActions(null, 'token', null, null); + const actions = createActions(null, 'token', null); actions.setDashboardDevice('my-device'); @@ -54,7 +54,7 @@ describe('actions', () => { describe('setDashboardMultipleDevices', () => { it('should emit both V1 and V2 events', () => { - const actions = createActions(null, 'token', null, null); + const actions = createActions(null, 'token', null); actions.setDashboardMultipleDevices(['dev1', 'dev2', 'dev3']); @@ -75,7 +75,7 @@ describe('actions', () => { }); it('should convert string array to Device array for V2', () => { - const actions = createActions(null, 'token', null, null); + const actions = createActions(null, 'token', null); actions.setDashboardMultipleDevices(['a', 'b']); @@ -93,7 +93,7 @@ describe('actions', () => { describe('setDashboardDateRange', () => { it('should emit both V1 and V2 events for valid date range', () => { - const actions = createActions(null, 'token', null, null); + const actions = createActions(null, 'token', null); const dateRange = { startTime: 1000, endTime: 2000 }; actions.setDashboardDateRange(dateRange); @@ -112,7 +112,7 @@ describe('actions', () => { }); it('should NOT emit events for invalid date range (startTime >= endTime)', () => { - const actions = createActions(null, 'token', null, null); + const actions = createActions(null, 'token', null); const invalidRange = { startTime: 2000, endTime: 1000 }; actions.setDashboardDateRange(invalidRange); @@ -121,7 +121,7 @@ describe('actions', () => { }); it('should NOT emit events for null date range', () => { - const actions = createActions(null, 'token', null, null); + const actions = createActions(null, 'token', null); actions.setDashboardDateRange( null as unknown as { startTime: number; endTime: number } @@ -132,26 +132,22 @@ describe('actions', () => { }); describe('setDashboardLayer', () => { - it('should emit both V1 and V2 events', () => { - const actions = createActions(null, 'token', null, null); + it('should only emit V1 event (no V2 equivalent)', () => { + const actions = createActions(null, 'token', null); actions.setDashboardLayer('layer-1'); - expect(postMessageSpy).toHaveBeenCalledTimes(2); + expect(postMessageSpy).toHaveBeenCalledTimes(1); expect(postMessageSpy).toHaveBeenCalledWith( { event: OUTBOUND_EVENTS.SET_DASHBOARD_LAYER, payload: 'layer-1' }, '*' ); - expect(postMessageSpy).toHaveBeenCalledWith( - { event: OUTBOUND_EVENTS_V2.SET_DASHBOARD_LAYER, payload: 'layer-1' }, - '*' - ); }); }); describe('setRealTime', () => { it('should emit both V1 and V2 events with true', () => { - const actions = createActions(null, 'token', null, null); + const actions = createActions(null, 'token', null); actions.setRealTime(true); @@ -166,7 +162,7 @@ describe('actions', () => { }); it('should emit both V1 and V2 events with false', () => { - const actions = createActions(null, 'token', null, null); + const actions = createActions(null, 'token', null); actions.setRealTime(false); @@ -183,7 +179,7 @@ describe('actions', () => { describe('refreshDashboard', () => { it('should emit both V1 and V2 events without payload', () => { - const actions = createActions(null, 'token', null, null); + const actions = createActions(null, 'token', null); actions.refreshDashboard(); @@ -200,7 +196,7 @@ describe('actions', () => { describe('openDrawer', () => { it('should emit both V1 and V2 events with drawer info', () => { - const actions = createActions(null, 'token', null, null); + const actions = createActions(null, 'token', null); const drawerOpts = { url: 'https://example.com', width: 400 }; actions.openDrawer(drawerOpts); @@ -222,7 +218,7 @@ describe('actions', () => { }); it('should use widgetId from context state when provided', () => { - const actions = createActions(null, 'token', 'custom-widget-id', null); + const actions = createActions(null, 'token', 'custom-widget-id'); const drawerOpts = { url: 'https://example.com', width: 300 }; actions.openDrawer(drawerOpts); @@ -245,7 +241,7 @@ describe('actions', () => { describe('setFullScreen', () => { it('should emit both V1 and V2 events with toggle', () => { - const actions = createActions(null, 'token', null, null); + const actions = createActions(null, 'token', null); actions.setFullScreen('toggle'); @@ -260,7 +256,7 @@ describe('actions', () => { }); it('should emit both V1 and V2 events with enable', () => { - const actions = createActions(null, 'token', null, null); + const actions = createActions(null, 'token', null); actions.setFullScreen('enable'); @@ -275,7 +271,7 @@ describe('actions', () => { }); it('should emit both V1 and V2 events with disable', () => { - const actions = createActions(null, 'token', null, null); + const actions = createActions(null, 'token', null); actions.setFullScreen('disable'); @@ -292,7 +288,7 @@ describe('actions', () => { describe('getHeaders', () => { it('should return JWT Bearer header when jwtToken is provided', () => { - const actions = createActions('jwt-token-123', null, null, null); + const actions = createActions('jwt-token-123', null, null); const headers = actions.getHeaders(); @@ -303,7 +299,7 @@ describe('actions', () => { }); it('should return X-Auth-Token header when only token is provided', () => { - const actions = createActions(null, 'api-token-456', null, null); + const actions = createActions(null, 'api-token-456', null); const headers = actions.getHeaders(); @@ -314,7 +310,7 @@ describe('actions', () => { }); it('should prefer JWT token over API token', () => { - const actions = createActions('jwt-token', 'api-token', null, null); + const actions = createActions('jwt-token', 'api-token', null); const headers = actions.getHeaders(); @@ -325,7 +321,7 @@ describe('actions', () => { }); it('should return only Content-type when no tokens are provided', () => { - const actions = createActions(null, null, null, null); + const actions = createActions(null, null, null); const headers = actions.getHeaders(); diff --git a/src/context/actions.ts b/src/context/actions.ts index a05817e..b5e10f5 100644 --- a/src/context/actions.ts +++ b/src/context/actions.ts @@ -27,19 +27,21 @@ function postMessageWithV2( */ function generateHeaders( jwtToken: string | null, - token: string | null, - receivedHeaders: Record | null + token: string | null ): Record { - const base: Record = { - ...receivedHeaders, - 'Content-type': 'application/json', - }; if (jwtToken) { - base['Authorization'] = `Bearer ${jwtToken}`; - } else if (token) { - base['X-Auth-Token'] = token; + return { + Authorization: `Bearer ${jwtToken}`, + 'Content-type': 'application/json', + }; + } + if (token) { + return { + 'X-Auth-Token': token, + 'Content-type': 'application/json', + }; } - return base; + return { 'Content-type': 'application/json' }; } /** @@ -101,11 +103,8 @@ const actionCreators = { }, setDashboardLayer: (layerId: string) => { - postMessageWithV2( - OUTBOUND_EVENTS.SET_DASHBOARD_LAYER, - OUTBOUND_EVENTS_V2.SET_DASHBOARD_LAYER, - layerId - ); + // V2 protocol has no equivalent for layer yet — only V1 is sent. + postMessage(OUTBOUND_EVENTS.SET_DASHBOARD_LAYER, layerId); }, setRealTime: (rt: boolean) => @@ -137,8 +136,7 @@ const actionCreators = { export function createActions( jwtToken: string | null, token: string | null, - widgetId: string | null, - receivedHeaders: Record | null + widgetId: string | null ): OutboundActions { return { ...actionCreators, @@ -150,6 +148,6 @@ export function createActions( payload ); }, - getHeaders: () => generateHeaders(jwtToken, token, receivedHeaders), + getHeaders: () => generateHeaders(jwtToken, token), }; } From 7b7b520bd4ecb60843be84127e2458a559600776 Mon Sep 17 00:00:00 2001 From: Ricardoaar Date: Thu, 7 May 2026 08:42:45 -0600 Subject: [PATCH 3/3] :sparkles: [SC-2310] Data: Add support to widget data and info --- src/context/constants.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/context/constants.ts b/src/context/constants.ts index 1ca6669..426ef7e 100644 --- a/src/context/constants.ts +++ b/src/context/constants.ts @@ -73,6 +73,7 @@ export const ACTION_TYPES = { SELECTED_DEVICE_OBJECT: 'SELECTED_DEVICE_OBJECT', SELECTED_DEVICE_OBJECTS: 'SELECTED_DEVICE_OBJECTS', SELECTED_FILTERS: 'SELECTED_FILTERS', + DASHBOARD_DEVICES: 'DASHBOARD_DEVICES', REAL_TIME_STATUS: 'REAL_TIME_STATUS', SET_READY: 'SET_READY', SET_WIDGET: 'SET_WIDGET',