Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

1.1 KB
Raw Blame
import type { FC, ReactNode } from "react";

import { useTrackSdkComponentMount } from "embedding-sdk-bundle/analytics/component-events";
import type { UseMetabotResult } from "embedding-sdk-bundle/types/metabot";
import type { FunctionSchema } from "embedding-sdk-bundle/types/schema";

import type { MetabotQuestionProps } from "./types";

type MetabotQuestionComponent = FC<MetabotQuestionProps> & {
  schema?: FunctionSchema;
};

export const METABOT_SDK_EE_PLUGIN: {
  MetabotQuestion: MetabotQuestionComponent;
  MetabotProvider: ({ children }: { children: ReactNode }) => ReactNode;
  useMetabot: () => UseMetabotResult | null;
} = {
  // Placeholder implementation – replaced by EE plugin at runtime
  MetabotQuestion: ((_props: MetabotQuestionProps) =>
    null) as MetabotQuestionComponent,
  MetabotProvider: ({ children }: { children: ReactNode }) => children,
  useMetabot: () => null,
};

export const MetabotQuestion = (props: MetabotQuestionProps) => {
  useTrackSdkComponentMount("MetabotQuestion", null, {
    layout: props.layout,
  });

  return <METABOT_SDK_EE_PLUGIN.MetabotQuestion {...props} />;
};