@launchdarkly/toolbar 2.3.0-beta.1 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/README.md +255 -19
  2. package/cdn/toolbar.min.js +660 -15
  3. package/cdn/toolbar.min.js.LICENSE.txt +14 -0
  4. package/dist/angular/launchdarkly-toolbar.service.d.ts +104 -0
  5. package/dist/angular.cjs +439 -0
  6. package/dist/angular.cjs.map +1 -0
  7. package/dist/angular.d.ts +51 -0
  8. package/dist/core/index.d.ts +0 -1
  9. package/dist/core/services/DevServerClient.d.ts +9 -3
  10. package/dist/core/services/FlagStateManager.d.ts +2 -0
  11. package/dist/core/styles/constants.d.ts +24 -0
  12. package/dist/core/styles/index.d.ts +2 -0
  13. package/dist/core/styles/shadowDomStyles.d.ts +41 -0
  14. package/dist/core/tests/mocks/providers.d.ts +132 -0
  15. package/dist/core/ui/Buttons/IconButton.d.ts +2 -1
  16. package/dist/core/ui/JsonEditor/JsonEditor.d.ts +2 -1
  17. package/dist/core/ui/Toolbar/LaunchDarklyToolbar.d.ts +2 -8
  18. package/dist/core/ui/Toolbar/components/AuthenticationModal/AuthenticationModal.d.ts +1 -1
  19. package/dist/core/ui/Toolbar/components/CircleLogo.d.ts +1 -2
  20. package/dist/core/ui/Toolbar/components/{FlagKeyWithCopy.css.d.ts → CopyableText.css.d.ts} +1 -1
  21. package/dist/core/ui/Toolbar/components/CopyableText.d.ts +18 -0
  22. package/dist/core/ui/Toolbar/components/FilterOptions/FilterOptions.css.d.ts +1 -0
  23. package/dist/core/ui/Toolbar/components/FilterOptions/FilterOptions.d.ts +1 -0
  24. package/dist/core/ui/Toolbar/components/FilterOptions/ShareUrlButton.css.d.ts +2 -0
  25. package/dist/core/ui/Toolbar/components/FilterOptions/ShareUrlButton.d.ts +7 -0
  26. package/dist/core/ui/Toolbar/components/IFrameErrorScreen/IFrameErrorScreen.css.d.ts +7 -0
  27. package/dist/core/ui/Toolbar/components/IFrameErrorScreen/IFrameErrorScreen.d.ts +5 -0
  28. package/dist/core/ui/Toolbar/components/IFrameErrorScreen/index.d.ts +1 -0
  29. package/dist/core/ui/Toolbar/components/LoadingScreen/LoadingScreen.css.d.ts +7 -0
  30. package/dist/core/ui/Toolbar/components/LoadingScreen/LoadingScreen.d.ts +5 -0
  31. package/dist/core/ui/Toolbar/components/LoadingScreen/index.d.ts +1 -0
  32. package/dist/core/ui/Toolbar/components/ShareStatePopover/ShareStatePopover.css.d.ts +10 -0
  33. package/dist/core/ui/Toolbar/components/ShareStatePopover/ShareStatePopover.d.ts +15 -0
  34. package/dist/core/ui/Toolbar/components/ShareStatePopover/index.d.ts +2 -0
  35. package/dist/core/ui/Toolbar/components/icons/ShareIcon.d.ts +5 -0
  36. package/dist/core/ui/Toolbar/components/icons/index.d.ts +2 -0
  37. package/dist/core/ui/Toolbar/components/index.d.ts +1 -2
  38. package/dist/core/ui/Toolbar/components/new/AnalyticsConsentToast/AnalyticsConsentToast.d.ts +5 -0
  39. package/dist/core/ui/Toolbar/components/new/AnalyticsConsentToast/AnalyticsConsentToast.module.css.d.ts +13 -0
  40. package/dist/core/ui/Toolbar/components/new/AnalyticsConsentToast/index.d.ts +1 -0
  41. package/dist/core/ui/Toolbar/components/new/ContentActions.module.css.d.ts +4 -0
  42. package/dist/core/ui/Toolbar/components/new/Contexts/AddContextForm.d.ts +6 -0
  43. package/dist/core/ui/Toolbar/components/new/Contexts/AddContextForm.module.css.d.ts +14 -0
  44. package/dist/core/ui/Toolbar/components/new/Contexts/ContextItem.d.ts +9 -0
  45. package/dist/core/ui/Toolbar/components/new/Contexts/ContextItem.module.css.d.ts +19 -0
  46. package/dist/core/ui/Toolbar/components/new/Contexts/ContextList.d.ts +1 -0
  47. package/dist/core/ui/Toolbar/components/new/Contexts/ContextList.module.css.d.ts +8 -0
  48. package/dist/core/ui/Toolbar/components/new/Contexts/ContextListContent.d.ts +1 -0
  49. package/dist/core/ui/Toolbar/components/new/Contexts/index.d.ts +4 -0
  50. package/dist/core/ui/Toolbar/components/new/ExpandedToolbarContent.d.ts +4 -3
  51. package/dist/core/ui/Toolbar/components/new/FeatureFlags/FlagControls.d.ts +5 -5
  52. package/dist/core/ui/Toolbar/components/new/FeatureFlags/FlagItem.d.ts +2 -1
  53. package/dist/core/ui/Toolbar/components/new/FeatureFlags/FlagListContent.d.ts +1 -1
  54. package/dist/core/ui/Toolbar/components/new/FilterOverlay/FilterOverlay.module.css.d.ts +1 -0
  55. package/dist/core/ui/Toolbar/components/new/Settings/Privacy/PrivacySettings.d.ts +1 -0
  56. package/dist/core/ui/Toolbar/components/new/Settings/SettingsContent.module.css.d.ts +2 -0
  57. package/dist/core/ui/Toolbar/components/new/Settings/ShareButton.d.ts +5 -0
  58. package/dist/core/ui/Toolbar/components/new/Settings/ShareButton.module.css.d.ts +1 -0
  59. package/dist/core/ui/Toolbar/components/new/Settings/index.d.ts +1 -1
  60. package/dist/core/ui/Toolbar/components/new/Tooltip.d.ts +3 -1
  61. package/dist/core/ui/Toolbar/components/new/context/TabSearchProvider.d.ts +7 -5
  62. package/dist/core/ui/Toolbar/components/new/types.d.ts +2 -2
  63. package/dist/core/ui/Toolbar/constants/animations.d.ts +14 -0
  64. package/dist/core/ui/Toolbar/context/DevServerProvider.d.ts +2 -0
  65. package/dist/core/ui/Toolbar/context/api/AuthProvider.d.ts +1 -0
  66. package/dist/core/ui/Toolbar/context/api/ContextsProvider.d.ts +19 -0
  67. package/dist/core/ui/Toolbar/context/api/FlagsProvider.d.ts +1 -0
  68. package/dist/core/ui/Toolbar/context/api/IFrameProvider.d.ts +2 -0
  69. package/dist/core/ui/Toolbar/context/api/index.d.ts +1 -0
  70. package/dist/core/ui/Toolbar/context/state/ToolbarStateProvider.d.ts +6 -0
  71. package/dist/core/ui/Toolbar/context/telemetry/AnalyticsPreferencesProvider.d.ts +14 -0
  72. package/dist/core/ui/Toolbar/context/telemetry/InternalClientProvider.d.ts +11 -1
  73. package/dist/core/ui/Toolbar/context/telemetry/TelemetryBundleProvider.d.ts +2 -0
  74. package/dist/core/ui/Toolbar/context/telemetry/index.d.ts +1 -0
  75. package/dist/core/ui/Toolbar/hooks/index.d.ts +2 -0
  76. package/dist/core/ui/Toolbar/hooks/useLocalStorage.d.ts +10 -0
  77. package/dist/core/ui/Toolbar/hooks/useReducedMotion.d.ts +5 -0
  78. package/dist/core/ui/Toolbar/hooks/useToolbarAnimations.d.ts +1 -1
  79. package/dist/core/ui/Toolbar/types/toolbar.d.ts +1 -1
  80. package/dist/core/ui/Toolbar/utils/context.d.ts +33 -0
  81. package/dist/core/ui/Toolbar/utils/localStorage.d.ts +21 -2
  82. package/dist/core/utils/analytics.d.ts +48 -2
  83. package/dist/core/utils/feedback.d.ts +18 -0
  84. package/dist/core/utils/urlOverrides.d.ts +105 -0
  85. package/dist/flags/toolbarFlags.d.ts +3 -2
  86. package/dist/index.cjs +8 -4
  87. package/dist/index.cjs.map +1 -1
  88. package/dist/js/374.js +446 -0
  89. package/dist/js/374.js.map +1 -0
  90. package/dist/js/816.js +56 -0
  91. package/dist/js/816.js.map +1 -0
  92. package/dist/js/96.js +38 -0
  93. package/dist/js/96.js.map +1 -0
  94. package/dist/js/angular.js +353 -0
  95. package/dist/js/angular.js.map +1 -0
  96. package/dist/js/index.js +3 -527
  97. package/dist/js/index.js.map +1 -1
  98. package/dist/js/plugins.js +1 -0
  99. package/dist/js/react.js +2 -0
  100. package/dist/js/types-entry.js +0 -0
  101. package/dist/js/vue.js +34 -0
  102. package/dist/js/vue.js.map +1 -0
  103. package/dist/plugins.cjs +483 -0
  104. package/dist/plugins.cjs.map +1 -0
  105. package/dist/plugins.d.ts +21 -0
  106. package/dist/react/useLaunchDarklyToolbar.d.ts +1 -1
  107. package/dist/react.cjs +127 -0
  108. package/dist/react.cjs.map +1 -0
  109. package/dist/react.d.ts +25 -0
  110. package/dist/types-entry.cjs +20 -0
  111. package/dist/types-entry.cjs.map +1 -0
  112. package/dist/types-entry.d.ts +12 -0
  113. package/dist/vue/useLaunchDarklyToolbar.d.ts +20 -0
  114. package/dist/vue.cjs +122 -0
  115. package/dist/vue.cjs.map +1 -0
  116. package/dist/vue.d.ts +24 -0
  117. package/package.json +145 -48
  118. package/dist/core/ui/Toolbar/components/FlagKeyWithCopy.d.ts +0 -6
  119. package/dist/core/ui/Toolbar/components/legacy/ActionButtonsContainer.css.d.ts +0 -4
  120. package/dist/core/ui/Toolbar/components/legacy/ActionButtonsContainer.d.ts +0 -6
  121. package/dist/core/ui/Toolbar/components/legacy/ExpandedToolbarContentLegacy.d.ts +0 -25
  122. package/dist/core/ui/Toolbar/components/legacy/FlagControls.css.d.ts +0 -12
  123. package/dist/core/ui/Toolbar/components/legacy/FlagControls.d.ts +0 -20
  124. package/dist/core/ui/Toolbar/components/legacy/Header/Header.css.d.ts +0 -20
  125. package/dist/core/ui/Toolbar/components/legacy/Header/Header.d.ts +0 -13
  126. package/dist/core/ui/Toolbar/components/legacy/Header/components/ActionButtons.d.ts +0 -12
  127. package/dist/core/ui/Toolbar/components/legacy/Header/components/EnvironmentLabel.d.ts +0 -5
  128. package/dist/core/ui/Toolbar/components/legacy/Header/components/LogoSection.d.ts +0 -6
  129. package/dist/core/ui/Toolbar/components/legacy/Header/components/SearchSection.d.ts +0 -8
  130. package/dist/core/ui/Toolbar/components/legacy/Header/components/index.d.ts +0 -4
  131. package/dist/core/ui/Toolbar/components/legacy/LocalFlagControls.css.d.ts +0 -5
  132. package/dist/core/ui/Toolbar/components/legacy/LocalFlagControls.d.ts +0 -25
  133. package/dist/core/ui/Toolbar/components/legacy/LocalObjectFlagControlListItem.css.d.ts +0 -4
  134. package/dist/core/ui/Toolbar/components/legacy/LocalObjectFlagControlListItem.d.ts +0 -13
  135. package/dist/core/ui/Toolbar/components/legacy/TabContent/EventsTabContent.css.d.ts +0 -24
  136. package/dist/core/ui/Toolbar/components/legacy/TabContent/EventsTabContent.d.ts +0 -7
  137. package/dist/core/ui/Toolbar/components/legacy/TabContent/FlagDevServerTabContent.css.d.ts +0 -10
  138. package/dist/core/ui/Toolbar/components/legacy/TabContent/FlagDevServerTabContent.d.ts +0 -5
  139. package/dist/core/ui/Toolbar/components/legacy/TabContent/FlagSdkOverrideTabContent.d.ts +0 -7
  140. package/dist/core/ui/Toolbar/components/legacy/TabContent/SettingsTab.css.d.ts +0 -13
  141. package/dist/core/ui/Toolbar/components/legacy/TabContent/SettingsTabContent.d.ts +0 -10
  142. package/dist/core/ui/Toolbar/components/legacy/TabContentRenderer.css.d.ts +0 -1
  143. package/dist/core/ui/Toolbar/components/legacy/TabContentRenderer.d.ts +0 -16
  144. package/dist/core/ui/Toolbar/components/legacy/index.d.ts +0 -1
  145. package/dist/core/ui/Toolbar/components/new/Settings/SettingsContent.d.ts +0 -1
  146. /package/dist/{react → core}/lazyLoadToolbar.d.ts +0 -0
@@ -0,0 +1,5 @@
1
+ interface ShareButtonProps {
2
+ onClick: (e: React.MouseEvent) => void;
3
+ }
4
+ export declare function ShareButton({ onClick }: ShareButtonProps): import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -0,0 +1 @@
1
+ export declare const button: string;
@@ -1,5 +1,5 @@
1
- export * from './SettingsContent';
2
1
  export * from './GeneralSettings';
2
+ export * from './Privacy/PrivacySettings';
3
3
  export * from './SettingsSection';
4
4
  export * from './SettingsItem';
5
5
  export * from './ProjectSelector';
@@ -2,6 +2,8 @@ import React from 'react';
2
2
  interface TooltipProps {
3
3
  content: string;
4
4
  children: React.ReactNode;
5
+ offsetTop?: number;
6
+ offsetLeft?: number;
5
7
  }
6
- export declare function Tooltip({ content, children }: TooltipProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function Tooltip({ content, children, offsetTop, offsetLeft }: TooltipProps): import("react/jsx-runtime").JSX.Element;
7
9
  export {};
@@ -1,10 +1,12 @@
1
- import { TabId } from '../../../types';
2
- type TabSearchContextType = {
3
- searchTerms: Record<TabId, string>;
4
- setSearchTerm: (tab: TabId, searchTerm: string) => void;
1
+ import { SubTab } from '../types';
2
+ type SubTabSearchContextType = {
3
+ searchTerms: Record<SubTab, string>;
4
+ setSearchTerm: (subtab: SubTab, searchTerm: string) => void;
5
+ clearSearchTerm: (subtab: SubTab) => void;
6
+ clearAllSearchTerms: () => void;
5
7
  };
6
8
  export declare function TabSearchProvider({ children }: {
7
9
  children: React.ReactNode;
8
10
  }): import("react/jsx-runtime").JSX.Element;
9
- export declare function useTabSearchContext(): TabSearchContextType;
11
+ export declare function useTabSearchContext(): SubTabSearchContextType;
10
12
  export {};
@@ -1,6 +1,6 @@
1
- export type FlagsSubtab = 'flags' | 'context';
1
+ export type FlagsSubtab = 'flags' | 'contexts';
2
2
  export type MonitoringSubtab = 'events';
3
- export type SettingsSubtab = 'general';
3
+ export type SettingsSubtab = 'general' | 'privacy';
4
4
  export type InteractiveSubtab = 'workflows';
5
5
  export type SubTab = FlagsSubtab | MonitoringSubtab | SettingsSubtab | InteractiveSubtab;
6
6
  export interface TabConfig {
@@ -40,6 +40,20 @@ export declare const ANIMATION_CONFIG: {
40
40
  readonly ease: "easeInOut";
41
41
  };
42
42
  };
43
+ readonly containerInstant: {
44
+ readonly width: {
45
+ readonly duration: 0.01;
46
+ };
47
+ readonly height: {
48
+ readonly duration: 0.01;
49
+ };
50
+ readonly borderRadius: {
51
+ readonly duration: 0.01;
52
+ };
53
+ readonly boxShadow: {
54
+ readonly duration: 0.01;
55
+ };
56
+ };
43
57
  readonly container: {
44
58
  readonly width: {
45
59
  readonly duration: 0.25;
@@ -1,4 +1,5 @@
1
1
  import type { FC, ReactNode } from 'react';
2
+ import { DevServerClient } from '../../../services/DevServerClient';
2
3
  import { LdToolbarConfig, ToolbarState } from '../../../types/devServer';
3
4
  interface DevServerContextValue {
4
5
  state: ToolbarState;
@@ -6,6 +7,7 @@ interface DevServerContextValue {
6
7
  clearOverride: (flagKey: string) => Promise<void>;
7
8
  clearAllOverrides: () => Promise<void>;
8
9
  refresh: () => Promise<void>;
10
+ devServerClient: DevServerClient | null;
9
11
  }
10
12
  export declare const useDevServerContext: () => DevServerContextValue;
11
13
  export interface DevServerProviderProps {
@@ -3,6 +3,7 @@ interface AuthContextType {
3
3
  authenticated: boolean;
4
4
  authenticating: boolean;
5
5
  loading: boolean;
6
+ iframeError: boolean;
6
7
  setAuthenticating: Dispatch<SetStateAction<boolean>>;
7
8
  logout: () => void;
8
9
  }
@@ -0,0 +1,19 @@
1
+ import type { LDContext } from 'launchdarkly-js-client-sdk';
2
+ interface ContextsContextType {
3
+ contexts: LDContext[];
4
+ filter: string;
5
+ setFilter: (filter: string) => void;
6
+ addContext: (context: LDContext) => void;
7
+ removeContext: (contextId: string) => void;
8
+ updateContext: (contextId: string, newContext: LDContext) => void;
9
+ setContext: (context: LDContext) => Promise<void>;
10
+ activeContext: LDContext | null;
11
+ isAddFormOpen: boolean;
12
+ setIsAddFormOpen: (isOpen: boolean) => void;
13
+ clearContexts: () => void;
14
+ }
15
+ export declare const ContextsProvider: ({ children }: {
16
+ children: React.ReactNode;
17
+ }) => import("react/jsx-runtime").JSX.Element;
18
+ export declare function useContextsContext(): ContextsContextType;
19
+ export {};
@@ -4,6 +4,7 @@ interface FlagsContextType {
4
4
  loading: boolean;
5
5
  getProjectFlags: (projectKey: string) => Promise<FlagsResponse>;
6
6
  resetFlags: () => void;
7
+ refreshFlags: () => Promise<void>;
7
8
  }
8
9
  export declare const FlagsProvider: ({ children }: {
9
10
  children: React.ReactNode;
@@ -20,6 +20,8 @@ interface IFrameProviderProps {
20
20
  type IFrameProviderType = {
21
21
  ref: RefObject<HTMLIFrameElement | null>;
22
22
  iframeSrc: string;
23
+ iframeLoaded: boolean;
24
+ onIFrameLoad: () => void;
23
25
  };
24
26
  export declare function IFrameProvider({ children, authUrl }: IFrameProviderProps): import("react/jsx-runtime").JSX.Element;
25
27
  export declare function useIFrameContext(): IFrameProviderType;
@@ -1,6 +1,7 @@
1
1
  export * from './ApiBundleProvider';
2
2
  export * from './ApiProvider';
3
3
  export * from './AuthProvider';
4
+ export * from './ContextsProvider';
4
5
  export * from './EnvironmentProvider';
5
6
  export * from './FlagsProvider';
6
7
  export * from './IFrameProvider';
@@ -10,6 +10,9 @@ export interface ToolbarStateContextValue {
10
10
  reloadOnFlagChangeIsEnabled: boolean;
11
11
  isAutoCollapseEnabled: boolean;
12
12
  mode: ToolbarMode;
13
+ isOptedInToAnalytics: boolean;
14
+ isOptedInToEnhancedAnalytics: boolean;
15
+ isOptedInToSessionReplay: boolean;
13
16
  toolbarRef: React.RefObject<HTMLDivElement | null>;
14
17
  handleTabChange: (tabId: string) => void;
15
18
  handleClose: () => void;
@@ -19,6 +22,9 @@ export interface ToolbarStateContextValue {
19
22
  handleCircleClick: () => void;
20
23
  setIsAnimating: Dispatch<SetStateAction<boolean>>;
21
24
  setSearchIsExpanded: Dispatch<SetStateAction<boolean>>;
25
+ handleToggleAnalyticsOptOut: (enabled: boolean) => void;
26
+ handleToggleEnhancedAnalyticsOptOut: (enabled: boolean) => void;
27
+ handleToggleSessionReplayOptOut: (enabled: boolean) => void;
22
28
  }
23
29
  export interface ToolbarStateProviderProps {
24
30
  children: ReactNode;
@@ -0,0 +1,14 @@
1
+ import { ReactNode } from 'react';
2
+ export interface AnalyticsPreferencesContextValue {
3
+ isOptedInToAnalytics: boolean;
4
+ isOptedInToEnhancedAnalytics: boolean;
5
+ isOptedInToSessionReplay: boolean;
6
+ handleToggleAnalyticsOptOut: (enabled: boolean) => void;
7
+ handleToggleEnhancedAnalyticsOptOut: (enabled: boolean) => void;
8
+ handleToggleSessionReplayOptOut: (enabled: boolean) => void;
9
+ }
10
+ export interface AnalyticsPreferencesProviderProps {
11
+ children: ReactNode;
12
+ }
13
+ export declare function AnalyticsPreferencesProvider({ children }: AnalyticsPreferencesProviderProps): import("react/jsx-runtime").JSX.Element;
14
+ export declare function useAnalyticsPreferences(): AnalyticsPreferencesContextValue;
@@ -56,6 +56,16 @@ export interface InternalClientProviderProps {
56
56
  * Set this if using a custom LaunchDarkly instance.
57
57
  */
58
58
  eventsUrl?: string;
59
+ /**
60
+ * Backend URL for Observability and Session Replay.
61
+ * Defaults to standard LaunchDarkly observability backend.
62
+ */
63
+ backendUrl?: string;
64
+ /**
65
+ * OTLP HTTP endpoint for Observability tracing (OpenTelemetry).
66
+ * If not provided, Observability will use its default endpoint.
67
+ */
68
+ observabilityOtlpEndpoint?: string;
59
69
  }
60
70
  /**
61
71
  * InternalClientProvider manages the toolbar's internal LaunchDarkly client.
@@ -67,7 +77,7 @@ export interface InternalClientProviderProps {
67
77
  *
68
78
  * The external client (user's app client) is accessed separately via plugins.
69
79
  */
70
- export declare function InternalClientProvider({ children, clientSideId, initialContext, baseUrl, streamUrl, eventsUrl, }: InternalClientProviderProps): import("react/jsx-runtime").JSX.Element;
80
+ export declare function InternalClientProvider({ children, clientSideId, initialContext, baseUrl, streamUrl, eventsUrl, backendUrl, observabilityOtlpEndpoint, }: InternalClientProviderProps): import("react/jsx-runtime").JSX.Element;
71
81
  /**
72
82
  * Hook to access the internal LaunchDarkly client.
73
83
  */
@@ -5,6 +5,8 @@ interface TelemetryBundleProviderProps {
5
5
  clientSideId?: string;
6
6
  streamUrl?: string;
7
7
  eventsUrl?: string;
8
+ backendUrl?: string;
9
+ observabilityOtlpEndpoint?: string;
8
10
  children: React.ReactNode;
9
11
  }
10
12
  export declare function TelemetryBundleProvider(props: TelemetryBundleProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,4 @@
1
1
  export * from './TelemetryBundleProvider';
2
2
  export * from './AnalyticsProvider';
3
3
  export * from './InternalClientProvider';
4
+ export * from './AnalyticsPreferencesProvider';
@@ -3,3 +3,5 @@ export { useToolbarVisibility } from './useToolbarVisibility';
3
3
  export { useToolbarDrag } from './useToolbarDrag';
4
4
  export { useEvents } from './useEvents';
5
5
  export { useCurrentDate } from './useCurrentDate';
6
+ export { useLocalStorage } from './useLocalStorage';
7
+ export { useReducedMotion } from './useReducedMotion';
@@ -0,0 +1,10 @@
1
+ interface UseLocalStorageOptions<T> {
2
+ /** Sync across browser tabs (default: false) */
3
+ syncTabs?: boolean;
4
+ /** Custom serializer (default: JSON.stringify) */
5
+ serialize?: (value: T) => string;
6
+ /** Custom deserializer (default: JSON.parse) */
7
+ deserialize?: (value: string) => T;
8
+ }
9
+ export declare function useLocalStorage<T>(key: string, defaultValue: T, options?: UseLocalStorageOptions<T>): [T, (value: T | ((prev: T) => T)) => void, () => void];
10
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Hook to detect user's reduced motion preference.
3
+ * Returns true if the user has requested reduced motion in their OS settings.
4
+ */
5
+ export declare function useReducedMotion(): boolean;
@@ -6,7 +6,7 @@ export interface UseToolbarAnimationsProps {
6
6
  onExpandComplete?: () => void;
7
7
  onCollapseComplete?: () => void;
8
8
  }
9
- type AnimationConfig = typeof ANIMATION_CONFIG.containerExpand | typeof ANIMATION_CONFIG.containerCollapse;
9
+ type AnimationConfig = typeof ANIMATION_CONFIG.containerExpand | typeof ANIMATION_CONFIG.containerCollapse | typeof ANIMATION_CONFIG.containerInstant;
10
10
  export interface UseToolbarAnimationsReturn {
11
11
  containerAnimations: {
12
12
  width: number;
@@ -7,7 +7,7 @@ export declare const SDK_MODE_TABS: readonly TabId[];
7
7
  export declare const NEW_TOOLBAR_TABS: readonly TabId[];
8
8
  export declare function getToolbarMode(devServerUrl?: string): ToolbarMode;
9
9
  export declare function getTabsForMode(mode: ToolbarMode, hasFlagOverridePlugin: boolean, hasEventInterceptionPlugin: boolean): readonly TabId[];
10
- export declare function getDefaultActiveTab(mode: ToolbarMode, hasFlagOverridePlugin?: boolean, hasEventInterceptionPlugin?: boolean, useNewToolbarDesign?: boolean): TabId;
10
+ export declare function getDefaultActiveTab(): TabId;
11
11
  export interface FeatureFlag {
12
12
  id: string;
13
13
  name: string;
@@ -0,0 +1,33 @@
1
+ import type { LDContext } from 'launchdarkly-js-client-sdk';
2
+ /**
3
+ * Check if two contexts are the same using their stable IDs (kind+key)
4
+ * @deprecated Prefer comparing getStableContextId(a) === getStableContextId(b) directly
5
+ */
6
+ export declare function areContextsEqual(a: LDContext | null | undefined, b: LDContext | null | undefined): boolean;
7
+ /**
8
+ * Gets the kind of an LDContext (handles multi-kind and single-kind)
9
+ */
10
+ export declare function getContextKind(context: LDContext | null | undefined): string;
11
+ /**
12
+ * Gets the key of an LDContext
13
+ * For multi-kind contexts, returns the key of the first nested context
14
+ */
15
+ export declare function getContextKey(context: LDContext | null | undefined): string;
16
+ /**
17
+ * Gets a display name for an LDContext
18
+ * Uses name if available, otherwise falls back to key
19
+ */
20
+ export declare function getContextDisplayName(context: LDContext | null | undefined): string;
21
+ /**
22
+ * Check if a context is anonymous
23
+ */
24
+ export declare function isContextAnonymous(context: LDContext | null | undefined): boolean;
25
+ /**
26
+ * Generates a stable identifier for a context based on kind+key.
27
+ * This identifier remains the same even if other properties change,
28
+ * allowing contexts to be updated rather than duplicated.
29
+ *
30
+ * For single-kind contexts: "kind:key"
31
+ * For multi-kind contexts: "multi:kind1:key1:kind2:key2" (sorted by kind name)
32
+ */
33
+ export declare function getStableContextId(context: LDContext | null | undefined): string;
@@ -1,11 +1,13 @@
1
+ import type { LDContext } from 'launchdarkly-js-client-sdk';
1
2
  import { ToolbarPosition } from '../types/toolbar';
2
3
  export declare const TOOLBAR_STORAGE_KEYS: {
3
- readonly ENVIRONMENT: "ld-toolbar-environment";
4
4
  readonly SETTINGS: "ld-toolbar-settings";
5
5
  readonly DISABLED: "ld-toolbar-disabled";
6
- readonly PROJECT: "ld-toolbar-project";
7
6
  readonly STARRED_FLAGS: "ld-toolbar-starred-flags";
8
7
  readonly MCP_ALERT_DISMISSED: "ld-toolbar-mcp-alert-dismissed";
8
+ readonly ANALYTICS_CONSENT_SHOWN: "ld-toolbar-analytics-consent-shown";
9
+ readonly CONTEXTS: "ld-toolbar-contexts";
10
+ readonly ACTIVE_CONTEXT: "ld-toolbar-active-context";
9
11
  };
10
12
  export type PreferredIde = 'cursor' | 'windsurf' | 'vscode' | 'github-copilot';
11
13
  export declare const PREFERRED_IDES: PreferredIde[];
@@ -14,6 +16,9 @@ export interface ToolbarSettings {
14
16
  reloadOnFlagChange: boolean;
15
17
  autoCollapse: boolean;
16
18
  preferredIde: PreferredIde;
19
+ isOptedInToAnalytics: boolean;
20
+ isOptedInToEnhancedAnalytics: boolean;
21
+ isOptedInToSessionReplay: boolean;
17
22
  }
18
23
  export declare const DEFAULT_SETTINGS: ToolbarSettings;
19
24
  export declare function saveToolbarPosition(position: ToolbarPosition): void;
@@ -28,3 +33,17 @@ export declare function savePreferredIde(ide: PreferredIde): void;
28
33
  export declare function loadPreferredIde(): PreferredIde;
29
34
  export declare function saveMCPAlertDismissed(dismissed: boolean): void;
30
35
  export declare function loadMCPAlertDismissed(): boolean;
36
+ export declare function loadContexts(): Array<LDContext>;
37
+ export declare function saveContexts(contexts: Array<LDContext>): void;
38
+ export declare function loadActiveContext(): LDContext | null;
39
+ export declare function saveActiveContext(context: LDContext | null): void;
40
+ export declare function saveIsOptedInToAnalytics(isOptedInToAnalytics: boolean): void;
41
+ export declare function loadIsOptedInToAnalytics(): boolean;
42
+ export declare function saveIsOptedInToEnhancedAnalytics(isOptedInToEnhancedAnalytics: boolean): void;
43
+ export declare function saveIsOptedInToSessionReplay(isOptedInToSessionReplay: boolean): void;
44
+ export declare function loadIsOptedInToSessionReplay(): boolean;
45
+ export declare function loadIsOptedInToEnhancedAnalytics(): boolean;
46
+ export declare function saveAnalyticsConsentShown(shown: boolean): void;
47
+ export declare function loadAnalyticsConsentShown(): boolean;
48
+ export declare function loadAllSettings(): Partial<ToolbarSettings>;
49
+ export declare function saveAllSettings(settings: Partial<ToolbarSettings>): void;
@@ -8,8 +8,9 @@ export declare const ANALYTICS_EVENT_PREFIX = "ld.toolbar";
8
8
  export declare class ToolbarAnalytics {
9
9
  private ldClient;
10
10
  private mode;
11
+ private isOptedInToAnalytics;
11
12
  private searchDebounceTimer;
12
- constructor(ldClient?: LDClient | null, mode?: ToolbarMode);
13
+ constructor(ldClient?: LDClient | null, mode?: ToolbarMode, isOptedInToAnalytics?: boolean);
13
14
  /**
14
15
  * Internal method to send tracking events
15
16
  */
@@ -30,6 +31,10 @@ export declare class ToolbarAnalytics {
30
31
  * Track toolbar tab navigation
31
32
  */
32
33
  trackTabChange(fromTab: string | null, toTab: string): void;
34
+ /**
35
+ * Track toolbar subtab navigation
36
+ */
37
+ trackSubtabChange(fromSubtab: string | null, toSubtab: string): void;
33
38
  /**
34
39
  * Track search usage
35
40
  */
@@ -97,9 +102,50 @@ export declare class ToolbarAnalytics {
97
102
  /**
98
103
  * Track user feedback
99
104
  */
100
- trackFeedback(feedback: string, sentiment: FeedbackSentiment): void;
105
+ trackFeedback(feedback: string, sentiment: FeedbackSentiment, options?: {
106
+ flagKey?: string;
107
+ prompt?: string;
108
+ customProperties?: Record<string, unknown>;
109
+ }): void;
101
110
  /**
102
111
  * Track flag key copy
103
112
  */
104
113
  trackFlagKeyCopy(flagKey: string): void;
114
+ /**
115
+ * Track context added
116
+ */
117
+ trackContextAdded(contextKind: string, contextKey: string, isMultiKind: boolean): void;
118
+ /**
119
+ * Track context removed
120
+ */
121
+ trackContextRemoved(contextKind: string, contextKey: string): void;
122
+ /**
123
+ * Track context updated
124
+ */
125
+ trackContextUpdated(oldKind: string, oldKey: string, newKind: string, newKey: string): void;
126
+ /**
127
+ * Track context selected/activated
128
+ */
129
+ trackContextSelected(contextKind: string, contextKey: string): void;
130
+ /**
131
+ * Track context edit started
132
+ */
133
+ trackContextEditStarted(contextKind: string, contextKey: string): void;
134
+ /**
135
+ * Track context edit cancelled
136
+ */
137
+ trackContextEditCancelled(contextKind: string, contextKey: string): void;
138
+ /**
139
+ * Track context key copy
140
+ */
141
+ trackContextKeyCopy(contextKey: string): void;
142
+ /**
143
+ * Track state sharing via URL
144
+ */
145
+ trackShareState(options: {
146
+ includeSettings: boolean;
147
+ overrideCount: number;
148
+ contextCount: number;
149
+ starredFlagCount: number;
150
+ }): void;
105
151
  }
@@ -0,0 +1,18 @@
1
+ import type { LDClient } from 'launchdarkly-js-client-sdk';
2
+ export type LDFeedbackSentiment = 'positive' | 'neutral' | 'negative';
3
+ export type LDFeedbackData = {
4
+ feedback_answer: string;
5
+ flag_key: string;
6
+ sentiment?: LDFeedbackSentiment;
7
+ feedback_prompt?: string;
8
+ o11y_session_id?: string;
9
+ custom_properties?: Record<string, unknown>;
10
+ };
11
+ export interface SendFeedbackOptions {
12
+ flagKey: string;
13
+ feedback: string;
14
+ sentiment?: LDFeedbackSentiment;
15
+ prompt?: string;
16
+ customProperties?: Record<string, unknown>;
17
+ }
18
+ export declare function sendFeedback(client: LDClient, options: SendFeedbackOptions): void;
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Utilities for sharing and loading toolbar state via URL query parameters.
3
+ *
4
+ * State is encoded as a single base64-encoded JSON object in the ldToolbarState parameter.
5
+ * The state includes: flag overrides, contexts, settings, starred flags, etc.
6
+ */
7
+ import { LDContext } from 'launchdarkly-js-client-sdk';
8
+ import { ToolbarSettings } from '../ui/Toolbar/utils/localStorage';
9
+ /** Current version of the shared state format */
10
+ export declare const SHARED_STATE_VERSION = 1;
11
+ /** Default query parameter name for shared toolbar state */
12
+ export declare const DEFAULT_STATE_PARAM = "ldToolbarState";
13
+ /** Maximum size of encoded state in characters (warning threshold) */
14
+ export declare const MAX_STATE_SIZE_WARNING = 2000;
15
+ /** Maximum size of encoded state in characters (hard limit) */
16
+ export declare const MAX_STATE_SIZE_LIMIT = 8192;
17
+ /**
18
+ * Structure of the shared toolbar state
19
+ */
20
+ export interface SharedToolbarState {
21
+ /** Version of the state format */
22
+ version: number;
23
+ /** Flag overrides (flag key -> value) */
24
+ overrides: Record<string, any>;
25
+ /** Saved contexts */
26
+ contexts: LDContext[];
27
+ /** Currently active context */
28
+ activeContext: LDContext | null;
29
+ /** Toolbar settings */
30
+ settings: Partial<ToolbarSettings>;
31
+ /** Starred flag keys */
32
+ starredFlags: string[];
33
+ }
34
+ /**
35
+ * Result of serializing shared state
36
+ */
37
+ export interface SerializeStateResult {
38
+ /** The full URL with the state parameter */
39
+ url: string;
40
+ /** Size of the encoded state in characters */
41
+ size: number;
42
+ /** Whether the size exceeds the warning threshold */
43
+ exceedsWarning: boolean;
44
+ /** Whether the size exceeds the hard limit */
45
+ exceedsLimit: boolean;
46
+ }
47
+ /**
48
+ * Result of parsing shared state from URL
49
+ */
50
+ export interface ParseStateResult {
51
+ /** Whether a state parameter was found in the URL */
52
+ found: boolean;
53
+ /** The parsed state (if found and valid) */
54
+ state: SharedToolbarState | null;
55
+ /** Error message if parsing failed */
56
+ error: string | null;
57
+ }
58
+ /**
59
+ * Serializes toolbar state into a URL with a query parameter
60
+ *
61
+ * @param state - The state to serialize
62
+ * @param baseUrl - The base URL to append the parameter to (defaults to current URL without params)
63
+ * @param paramName - The query parameter name (defaults to 'ldToolbarState')
64
+ * @returns Result containing the URL and size information
65
+ *
66
+ */
67
+ export declare function serializeToolbarState(state: SharedToolbarState, baseUrl?: string, paramName?: string): SerializeStateResult;
68
+ /**
69
+ * Parses toolbar state from a URL query parameter
70
+ *
71
+ * @param url - The URL to parse (defaults to window.location.href)
72
+ * @param paramName - The query parameter name (defaults to 'ldToolbarState')
73
+ * @returns Result containing whether state was found, the parsed state, and any error
74
+ *
75
+ */
76
+ export declare function parseToolbarState(url?: string, paramName?: string): ParseStateResult;
77
+ /**
78
+ * Checks if the current URL contains a toolbar state parameter
79
+ *
80
+ * @param url - The URL to check (defaults to window.location.href)
81
+ * @param paramName - The query parameter name (defaults to 'ldToolbarState')
82
+ * @returns True if the URL contains a state parameter
83
+ */
84
+ export declare function hasToolbarState(url?: string, paramName?: string): boolean;
85
+ /**
86
+ * Removes the toolbar state parameter from the current URL
87
+ * Uses history.replaceState to avoid affecting browser history
88
+ *
89
+ * @param paramName - The query parameter name (defaults to 'ldToolbarState')
90
+ */
91
+ export declare function clearToolbarStateFromUrl(paramName?: string): void;
92
+ /**
93
+ * Loads shared toolbar state from URL and applies it to localStorage
94
+ * Should be called during toolbar initialization, before any components render
95
+ *
96
+ * @param paramName - The query parameter name (defaults to 'ldToolbarState')
97
+ * @param flagOverrideStorageNamespace - The storage namespace for flag overrides (defaults to 'ld-flag-override')
98
+ * @param flagOverridePlugin - Optional flag override plugin to apply overrides to directly
99
+ * @returns Object indicating whether state was loaded and if there were any errors
100
+ *
101
+ */
102
+ export declare function loadSharedStateFromUrl(paramName?: string, flagOverrideStorageNamespace?: string, flagOverridePlugin?: any): {
103
+ loaded: boolean;
104
+ error: string | null;
105
+ };
@@ -7,7 +7,8 @@
7
7
  * To add a toolbar feature flag, export it here like:
8
8
  * export const myFeature = createToolbarFlagFunction('my-feature-key', defaultValue);
9
9
  */
10
- export declare const useNewToolbarDesign: () => boolean;
11
- export declare const enableInteractiveIcon: () => boolean;
10
+ export declare const ENABLE_SESSION_REPLAY_FLAG_KEY = "toolbar-enable-session-replay";
12
11
  export declare const enableAiIcon: () => boolean;
12
+ export declare const enableInteractiveIcon: () => boolean;
13
13
  export declare const enableOptimizeIcon: () => boolean;
14
+ export declare const enableSessionReplay: () => boolean;
package/dist/index.cjs CHANGED
@@ -13,7 +13,7 @@ var __webpack_require__ = {};
13
13
  })();
14
14
  (()=>{
15
15
  __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
17
  value: 'Module'
18
18
  });
19
19
  Object.defineProperty(exports1, '__esModule', {
@@ -127,7 +127,7 @@ class AfterTrackHook {
127
127
  data: hookContext.data,
128
128
  metricValue: hookContext.metricValue,
129
129
  creationDate: Date.now(),
130
- url: 'undefined' != typeof window ? window.location.href : void 0
130
+ url: "u" > typeof window ? window.location.href : void 0
131
131
  };
132
132
  if (!this.shouldProcessEvent()) return;
133
133
  const processedEvent = this.processEvent(syntheticContext);
@@ -462,7 +462,7 @@ class FlagOverridePlugin {
462
462
  return this.ldClient;
463
463
  }
464
464
  getStorage() {
465
- if ('undefined' == typeof window) return null;
465
+ if ("u" < typeof window) return null;
466
466
  return window.localStorage;
467
467
  }
468
468
  persistOverride(flagKey, value) {
@@ -552,7 +552,9 @@ async function lazyLoad(signal, url) {
552
552
  throw new Error(`Could not load LaunchDarkly developer toolbar bundle from ${url}`);
553
553
  }
554
554
  }
555
- var package_namespaceObject = JSON.parse('{"rE":"2.3.0-beta.1"}');
555
+ var package_namespaceObject = {
556
+ rE: "2.3.0"
557
+ };
556
558
  function useLaunchDarklyToolbar(args) {
557
559
  const { toolbarBundleUrl, enabled, ...initConfig } = args;
558
560
  const configRef = (0, external_react_namespaceObject.useRef)(null);
@@ -571,6 +573,8 @@ function useLaunchDarklyToolbar(args) {
571
573
  lazyLoadToolbar(controller.signal, url).then((importedToolbar)=>{
572
574
  if (null === configRef.current) return;
573
575
  cleanup = importedToolbar.init(configRef.current);
576
+ }).catch((error)=>{
577
+ console.error('[LaunchDarkly Toolbar] Failed to initialize:', error);
574
578
  });
575
579
  return ()=>{
576
580
  controller.abort();