Skip to content

Commit d5a2c4a

Browse files
committed
Show Debug Tools for embedded users
1 parent fb357f0 commit d5a2c4a

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

web/src/components/devtools/UserDebugTools.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { SettingsBlock } from "../common/SettingsBlock";
44
import { getApp } from "../../helpers/app";
55
import { getDashboardState } from "apps";
66
import { get, set } from "lodash";
7+
import { getParsedIframeInfo } from "../../helpers/origin";
8+
import { useSelector } from "react-redux";
9+
import { RootState } from "../../state/store";
710

811

912
const useAppStore = getApp().useStore()
@@ -61,6 +64,21 @@ const downloadState = async (pageType: string) => {
6164

6265
export const UserDebugTools: React.FC = () => {
6366
const pageType = useAppStore((state) => state.toolContext.pageType)
67+
const isEmbedded = getParsedIframeInfo().isEmbedded as unknown === 'true'
68+
const activeThread = useSelector((state: RootState) => state.chat.threads[state.chat.activeThread])
69+
const conversationID = activeThread.id
70+
// In embedded mode, just display converstaion ID
71+
if (isEmbedded) {
72+
return <>
73+
<VStack mb={4} alignItems={"stretch"} spacing={2} width="100%">
74+
<Text fontSize="2xl" fontWeight="bold">User Debug Tools</Text>
75+
<Text > Tools for users to debug and look into Metabase internal workings</Text>
76+
<SettingsBlock title="Conversation ID">
77+
<Text>{conversationID}</Text>
78+
</SettingsBlock>
79+
</VStack>
80+
</>
81+
}
6482
return <>
6583
<VStack mb={4} alignItems={"stretch"} spacing={2} width="100%">
6684
<Text fontSize="2xl" fontWeight="bold">User Debug Tools</Text>

web/src/components/devtools/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { RootState } from '../../state/store';
2727
import { UserDebugTools } from './UserDebugTools';
2828
import { History } from './History';
2929
import { getParsedIframeInfo } from '../../helpers/origin'
30+
import { useGetUserStateQuery } from '../../app/api/userStateApi';
3031

3132
const Monitors: MonitorDef[] = [
3233
{
@@ -89,6 +90,8 @@ const Monitors: MonitorDef[] = [
8990
]
9091

9192
export const DevToolsBox: React.FC = () => {
93+
const { data: userState, isLoading } = useGetUserStateQuery({})
94+
const isInfoPageEnabled = userState?.flags?.isInfoPageEnabled || false
9295
const enableStyleCustomization = useSelector((state: RootState) => state.settings.enableStyleCustomization)
9396
const enableUserDebugTools = useSelector((state: RootState) => state.settings.enableUserDebugTools)
9497
const isEmbedded = getParsedIframeInfo().isEmbedded as unknown === 'true'
@@ -101,6 +104,9 @@ export const DevToolsBox: React.FC = () => {
101104
if (Monitor.title === 'History' || Monitor.title === 'Memory') {
102105
return true
103106
}
107+
if (isInfoPageEnabled && Monitor.title == 'Debug Tools') {
108+
return true
109+
}
104110
return false
105111
}
106112

0 commit comments

Comments
 (0)