From dddda7f66ecf53d3422e8f36911a60c3d63dd4ab Mon Sep 17 00:00:00 2001 From: Matthew Yarmolinsky Date: Mon, 11 May 2026 11:56:39 -0400 Subject: [PATCH] Add Amplitude Engagement Guides & Surveys helper and typing Change-type: minor --- src/index.tsx | 2 ++ src/typings/window-augmentation.ts | 14 ++++++++++++++ src/utils/amplitude.ts | 3 +++ 3 files changed, 19 insertions(+) create mode 100644 src/typings/window-augmentation.ts create mode 100644 src/utils/amplitude.ts diff --git a/src/index.tsx b/src/index.tsx index 3e40bffb..6b35cb74 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -192,3 +192,5 @@ export * as designTokens from '@balena/design-tokens'; export * as ReactQuery from '@tanstack/react-query'; export { default as dayjs } from 'dayjs'; export * as XDatePickers from '@mui/x-date-pickers'; +export { getHasGuidesAndSurveysEnabled } from './utils/amplitude'; +import './typings/window-augmentation'; diff --git a/src/typings/window-augmentation.ts b/src/typings/window-augmentation.ts new file mode 100644 index 00000000..d127c6f2 --- /dev/null +++ b/src/typings/window-augmentation.ts @@ -0,0 +1,14 @@ +export {}; + +declare global { + // This needs to be a separate interface instead of directly on Window.engagement so that it could merge with whatever the user adds to Window.engagement in their package + interface Engagement { + gs: { + list: () => undefined | Record; + }; + } + + interface Window { + engagement: Engagement; + } +} diff --git a/src/utils/amplitude.ts b/src/utils/amplitude.ts new file mode 100644 index 00000000..5d7058dc --- /dev/null +++ b/src/utils/amplitude.ts @@ -0,0 +1,3 @@ +export const getHasGuidesAndSurveysEnabled = () => { + return window.engagement.gs.list() !== undefined; +};