适用于 React 的嵌入式分析 SDK

快速构建自定义应用内分析

此 React 工具包可实现应用内报告,它在外观、功能和感受上都像是您应用的一部分。您可以完全控制,无需复杂的开发即可快速原型化、风格化并发布复杂的分析。

npx @metabase/embedding-sdk-react@latest start
探索实时演示 前往快速入门

多租户和安全

确保客户只能看到他们需要看到的内容。您的数据永远不会离开您的服务器。

几分钟内即可开始

安装 SDK,快速嵌入您的第一个图表。随着需求的增长,构建更高级的分析。

丰富的文档和支持

面向开发者的工具和专家支持,确保集成过程按您的计划进行。

Metabase 值得超过 90,000 家公司信赖
huggingface logo mcdonalds logo huma logo capital-one logo airbyte logo betterment logo Deutsche Telekom logo kong logo

集成到您的 UI

嵌入独立的组件 — 从单个图表到查询生成器 — 使它们与您的产品融为一体。像素级精确的布局,没有固定的宽度或高度,可适应响应式设计。您可以覆盖菜单、重新排列字段、移动按钮以及布局组件以适应您的 UI。

Integrate With Ui 1
        
import {
  MetabaseProvider,
  InteractiveQuestion,
  defineEmbeddingSdkConfig
} from "@metabase/embedding-sdk-react";

const config = defineEmbeddingSdkConfig({
  metabaseInstanceUrl: "https://metabase.example.com", // Required: Your Metabase instance URL
  authProviderUri: "https://app.example.com/sso/metabase", // Required: An endpoint in your app that signs the user in and returns a session
});

<MetabaseProvider config={config}>
  <InteractiveQuestion
    questionId={questionId}
    isSaveEnabled={false}
    withResetButton={true}
    customTitle="Orders over time"
  />
</MetabaseProvider>
        
      

动态主题

为每个组件设置样式,以匹配您应用的外观和感觉。自定义字体、背景颜色、工具提示、阴影等。可以为每个组织、团队甚至每个用户应用不同的样式。

Dynamic Theming 1 Dynamic Theming 2 Dynamic Theming 3
        
const metabase: MetabaseTheme = {
  fontFamily: "Inter",
  fontSize: "14px",
  colors: {
    brand: colors.primary,
    "brand-hover": colors.darkGrey,
    "brand-hover-light": colors.darkGrey,
    filter: colors.filter,
    "text-primary": colors.lighterGrey,
    "text-secondary": colors.lighterGrey,
    "text-tertiary": colors.lighterGrey,
    border: colors.darkGrey,
    background: colors.background,
    "background-secondary": colors.darkGrey,
    "background-hover": colors.background,
    "background-disabled": colors.darkGrey,
    charts: [
      colors.primary,
      colors.filter,
      "#ED6A5A",
      "#FED18C",
      "#82A74B",
      "#FF8D69",
      "#ED6A5A",
      "#FED18C",
    ],
    positive: "#45DF4C",
    negative: "#FF3389",
  },
  components: {
    cartesian: {
      padding: "6px 16px",
    },
    dashboard: {
      card: {
        border: `"1px solid ${colors.darkGrey}"`,
        backgroundColor: "#212426",
      },
    },
    number: {
      value: {
        fontSize: "18px",
        lineHeight: "22px",
      },
    },
    popover: {
      zIndex: 201,
    },
  },
};
        
      
        
const metabase: MetabaseTheme = {
  fontFamily: "Arsenal",
  fontSize: "14px",
  colors: {
    brand: colors.primary,
    "brand-hover": "#fff",
    "brand-hover-light": "#fff",
    filter: colors.viz1,
    summarize: "#BE54C0",
    "text-primary": colors.green3,
    "text-secondary": colors.green3,
    "text-tertiary": colors.green3,
    border: colors.green1,
    background: colors.background,
    "background-secondary": colors.background,
    "background-hover": colors.background,
    "background-disabled": colors.green2,
    charts: [
      colors.viz1,
      "#E09862",
      "#BE54C0",
      "#DDA51F",
      "#B34332",
      "#4998E3",
      "#BE54C0",
      "#DDA51F",
    ],
    positive: colors.green3,
    negative: "#B34332",
    shadow: "rgba(0, 0, 0, 0.1)",
  },
  components: {
    cartesian: {
      padding: "6px 16px",
    },
    dashboard: {
      backgroundColor: "transparent",
    },
    number: {
      value: {
        fontSize: "36px",
        lineHeight: "36px",
      },
    },
    popover: {
      zIndex: 201,
    },
  },
};
        
      
        
const metabase: MetabaseTheme = {
  fontFamily: "DM Mono",
  fontSize: "14px",
  colors: {
    brand: colors.primary,
    filter: colors.secondary,
    "text-primary": colors.darkGrey,
    "text-secondary": colors.lightGrey,
    "text-tertiary": colors.lightGrey,
    border: "#3B3F3F",
    background: colors.background,
    "background-hover": "#FCFAF1",
    "background-disabled": colors.lighterGrey,
    charts: [
      colors.primary,
      colors.negative,
      "#ECB405",
      "#BD37C9",
      colors.positive,
      "#545455",
      colors.primary,
      colors.negative,
    ],
    positive: colors.positive,
    negative: colors.negative,
  },
  components: {
    cartesian: {
      padding: "6px 16px",
    },
    dashboard: {
      card: {
        border: "1px solid var(--mantine-color-gray-3)",
      },
    },
    number: {
      value: {
        fontSize: "24px",
        lineHeight: "30px",
      },
    },
    popover: {
      zIndex: 201,
    },
  },
};
        
      

管理人们可以看到和做什么,按组件区分

在大规模定义数据发现的权限和交互式工具。让某些人拥有只读访问权限。有些人可以在图表上进行钻取而不保存。其他人可以获得完全访问权限,创建、修改和保存问题,创建仪表板等。

        
switch(currentUser.role) {
  case curator: {
    return (
      <MetabaseProvider config={config} theme={theme}>
        <InteractiveQuestion questionId={questionId} />
      </MetabaseProvider>
    );
    break;
  }
  default: {
    <MetabaseProvider config={config} theme={theme}>
      <StaticQuestion questionId={questionId} />
    </MetabaseProvider>
  }
}
return <GuestGreeting />;
        
      
        
switch (currentUser.role) {
  case (curator): {
    return (
      <MetabaseProvider config={config} theme={theme}>
        <InteractiveQuestion questionId={questionId} />
      </MetabaseProvider>
    );
  }
  default: {
    return (
      <MetabaseProvider config={config} theme={theme}>
        <StaticQuestion questionId={questionId} />
      </MetabaseProvider>
    )
  }
}

return <GuestGreeting />;
        
      

查看 SDK 的成功案例

客户使用 SDK 快速交付自定义分析的真实成果。

Marketfuel logo

一名开发者,30 天:从概念到生产

Marketfuel 需要紧密集成的分析,以在其电子商务平台中保持品牌体验。使用嵌入式分析 SDK,他们在不到一个月的时间内就与一名开发者完成了概念验证。

“使用 Metabase 对我们来说是一次改变游戏规则的体验。它使我们能够专注于我们最擅长的事情,而无需重新发明分析,从而节省了我们的时间和资源。”

Brian Urso

Marketfuel 联合创始人兼首席技术官

了解 Marketfuel 如何通过 SDK 将报告构建到他们的产品中
Owlery logo

仪表板迭代时间从几天缩短到几小时

Owlery 需要一种解决方案,让他们的团队和客户都能创建和管理仪表板,而无需工程师的持续介入。SDK 为他们提供了将分析无缝集成到产品中的灵活性。

“我们对决定使用 SDK 非常满意。它使我们能够控制我们产品的未来发展,并为我们的客户提供最佳的分析体验。”

Travis Downs

Owlery 联合创始人

了解 Owlery 如何通过 SDK 更快地推向市场

由您定义的用户体验

为每个组件自定义行为和流程,例如向菜单添加自定义操作,或彻底改造查询生成器的布局。没有任何限制。

Ux by You 1
        
<MetabaseProvider
  config={config}
  theme={theme}
  pluginsConfig={{
    mapQuestionClickActions: (clickActions, clicked) => {
      const nextClickActions = [...clickActions]

      // If we are drilling down on the user id, add a custom action to view the user profile.
      if (clicked.column?.name === "user_id") {
        nextClickActions.push({
          buttonType: "horizontal",
          name: "view-profile",
          section: "info",
          type: "custom",
          icon: "person",
          title: "View user profile",
          onClick: ({ closePopover }) => {
            console.log(`View Profile > user_id = ${clicked.value}`)
            closePopover()
          },
        })
      }

      return nextClickActions
    },
  }}
/>
        
      

适合您任何需求的实现类型

快速

Iframe 嵌入

适用于需要快速嵌入分析且工程开销较小的组织。
  • 您的应用中的图表、仪表板和报告。提供交互式或静态版本。
  • 交互式嵌入允许您进行白标并设置权限,以便客户可以查询、可视化和钻取数据。
  • 静态嵌入允许您的用户在简单的仪表板中查看数据,但不能点击进入。
查看实时演示
Interactive Embedding
量身定制

适用于 React 的嵌入式分析 SDK

适用于需要定制的嵌入式分析的组织。您获得 iframe 的所有功能,并具有更多控制和灵活性。
  • 选择您嵌入的组件以及它们放置的位置,以实现与您应用的深度集成。
  • 按组件和用户管理权限和交互性。
  • 精细的主题设置,使分析看起来就像您产品的一部分。
了解更多
Interactive Embedding
仍有问题? 我们很乐意为您提供帮助
联系我们
© . This site is unofficial and not affiliated with Metabase, Inc.