@launchdarkly/toolbar 0.11.1-beta.1 → 0.13.0-beta.1

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 (35) hide show
  1. package/README.md +17 -13
  2. package/dist/hooks/AfterEvaluationHook.d.ts +17 -0
  3. package/dist/hooks/AfterIdentifyHook.d.ts +18 -0
  4. package/dist/hooks/AfterTrackHook.d.ts +17 -0
  5. package/dist/hooks/EventStore.d.ts +11 -0
  6. package/dist/hooks/index.d.ts +7 -0
  7. package/dist/index.d.ts +6 -3
  8. package/dist/js/index.js +3355 -2475
  9. package/dist/js/plugins/FlagOverridePlugin.js +133 -0
  10. package/dist/js/plugins/index.js +425 -0
  11. package/dist/plugins/EventInterceptionPlugin.d.ts +30 -0
  12. package/dist/plugins/FlagOverridePlugin.d.ts +8 -3
  13. package/dist/plugins/index.d.ts +2 -0
  14. package/dist/tests/hooks/AfterEvaluationHook.test.d.ts +1 -0
  15. package/dist/tests/hooks/AfterIdentifyHook.test.d.ts +1 -0
  16. package/dist/tests/hooks/AfterTrackHook.test.d.ts +1 -0
  17. package/dist/tests/hooks/EventStore.test.d.ts +1 -0
  18. package/dist/types/events.d.ts +64 -0
  19. package/dist/types/plugin.d.ts +21 -0
  20. package/dist/ui/Toolbar/LaunchDarklyToolbar.d.ts +4 -2
  21. package/dist/ui/Toolbar/TabContent/EventsTabContent.css.d.ts +18 -0
  22. package/dist/ui/Toolbar/TabContent/EventsTabContent.d.ts +6 -1
  23. package/dist/ui/Toolbar/components/DoNotTrackWarning.css.d.ts +5 -0
  24. package/dist/ui/Toolbar/components/DoNotTrackWarning.d.ts +1 -0
  25. package/dist/ui/Toolbar/components/ExpandedToolbarContent.d.ts +3 -2
  26. package/dist/ui/Toolbar/components/TabContentRenderer.d.ts +3 -2
  27. package/dist/ui/Toolbar/components/index.d.ts +1 -0
  28. package/dist/ui/Toolbar/constants/animations.d.ts +27 -0
  29. package/dist/ui/Toolbar/hooks/index.d.ts +2 -0
  30. package/dist/ui/Toolbar/hooks/useCurrentDate.d.ts +5 -0
  31. package/dist/ui/Toolbar/hooks/useEvents.d.ts +13 -0
  32. package/dist/ui/Toolbar/types/toolbar.d.ts +3 -3
  33. package/dist/utils/browser.d.ts +7 -0
  34. package/dist/utils/index.d.ts +1 -0
  35. package/package.json +18 -6
@@ -0,0 +1,64 @@
1
+ export interface SyntheticEventContext {
2
+ readonly kind: EventKind;
3
+ readonly key?: string;
4
+ readonly context?: object;
5
+ readonly creationDate: number;
6
+ readonly data?: unknown;
7
+ readonly metricValue?: number;
8
+ readonly url?: string;
9
+ readonly value?: any;
10
+ readonly variation?: number | null;
11
+ readonly default?: any;
12
+ readonly reason?: object;
13
+ readonly version?: number;
14
+ readonly trackEvents?: boolean;
15
+ readonly debugEventsUntilDate?: number;
16
+ readonly contextKind?: string;
17
+ }
18
+ /**
19
+ * Valid event kinds that can be emitted by the LaunchDarkly SDK
20
+ */
21
+ declare const VALID_EVENT_KINDS: readonly ["identify", "feature", "custom", "debug", "summary", "diagnostic"];
22
+ /**
23
+ * Valid event categories used for organizing events
24
+ */
25
+ declare const VALID_EVENT_CATEGORIES: readonly ["flag", "custom", "identify", "debug"];
26
+ /**
27
+ * Strict typing for event kinds based on LaunchDarkly's event system
28
+ */
29
+ export type EventKind = (typeof VALID_EVENT_KINDS)[number];
30
+ /**
31
+ * Event categories for UI organization
32
+ */
33
+ export type EventCategory = (typeof VALID_EVENT_CATEGORIES)[number];
34
+ /**
35
+ * Enhanced processed event
36
+ */
37
+ export interface ProcessedEvent {
38
+ readonly id: string;
39
+ readonly kind: EventKind;
40
+ readonly key?: string;
41
+ readonly timestamp: number;
42
+ readonly context: SyntheticEventContext;
43
+ readonly displayName: string;
44
+ readonly category: EventCategory;
45
+ readonly metadata?: Readonly<Record<string, unknown>>;
46
+ }
47
+ /**
48
+ * Event filter configuration
49
+ */
50
+ export interface EventFilter {
51
+ readonly kinds?: ReadonlyArray<EventKind>;
52
+ readonly categories?: ReadonlyArray<EventCategory>;
53
+ readonly flagKeys?: ReadonlyArray<string>;
54
+ readonly timeRange?: {
55
+ readonly start: number;
56
+ readonly end: number;
57
+ };
58
+ }
59
+ /**
60
+ * Type guards for event validation
61
+ */
62
+ export declare function isValidEventKind(kind: string): kind is EventKind;
63
+ export declare function isValidEventCategory(category: string): category is EventCategory;
64
+ export {};
@@ -1,4 +1,5 @@
1
1
  import type { LDClient, LDDebugOverride, LDFlagSet, LDFlagValue, LDPlugin } from 'launchdarkly-js-client-sdk';
2
+ import type { ProcessedEvent } from './events';
2
3
  /**
3
4
  * Interface for flag override plugins that can be used with the LaunchDarkly Toolbar
4
5
  */
@@ -29,3 +30,23 @@ export interface IFlagOverridePlugin extends LDPlugin, LDDebugOverride {
29
30
  */
30
31
  getClient(): LDClient | null;
31
32
  }
33
+ /**
34
+ * Interface for event interception plugins that can be used with the LaunchDarkly Toolbar
35
+ */
36
+ export interface IEventInterceptionPlugin extends LDPlugin {
37
+ /**
38
+ * Gets all intercepted events from the event store
39
+ * @returns Array of processed events
40
+ */
41
+ getEvents(): ProcessedEvent[];
42
+ /**
43
+ * Subscribes to event store changes
44
+ * @param listener - Callback function to be called when events change
45
+ * @returns Unsubscribe function
46
+ */
47
+ subscribe(listener: () => void): () => void;
48
+ /**
49
+ * Clears all events from the event store
50
+ */
51
+ clearEvents(): void;
52
+ }
@@ -1,14 +1,16 @@
1
1
  import { ToolbarMode, ToolbarPosition } from './types/toolbar';
2
- import type { IFlagOverridePlugin } from '../../types/plugin';
2
+ import type { IEventInterceptionPlugin, IFlagOverridePlugin } from '../../types/plugin';
3
3
  export interface LdToolbarProps {
4
- flagOverridePlugin?: IFlagOverridePlugin;
5
4
  mode: ToolbarMode;
5
+ flagOverridePlugin?: IFlagOverridePlugin;
6
+ eventInterceptionPlugin?: IEventInterceptionPlugin;
6
7
  }
7
8
  export declare function LdToolbar(props: LdToolbarProps): import("react/jsx-runtime").JSX.Element;
8
9
  export interface LaunchDarklyToolbarProps {
9
10
  devServerUrl?: string;
10
11
  projectKey?: string;
11
12
  flagOverridePlugin?: IFlagOverridePlugin;
13
+ eventInterceptionPlugin?: IEventInterceptionPlugin;
12
14
  pollIntervalInMs?: number;
13
15
  position?: ToolbarPosition;
14
16
  }
@@ -1,3 +1,21 @@
1
+ export declare const statsHeader: string;
2
+ export declare const statsText: string;
1
3
  export declare const eventInfo: string;
2
4
  export declare const eventName: string;
3
5
  export declare const eventMeta: string;
6
+ export declare const eventBadge: string;
7
+ export declare const eventBadgeFeature: string;
8
+ export declare const eventBadgeIdentify: string;
9
+ export declare const eventBadgeCustom: string;
10
+ export declare const eventBadgeDebug: string;
11
+ export declare const eventBadgeSummary: string;
12
+ export declare const eventBadgeDiagnostic: string;
13
+ export declare const eventBadgeDefault: string;
14
+ export declare const virtualContainer: string;
15
+ export declare const virtualInner: string;
16
+ export declare const virtualItem: string;
17
+ export declare const liveTailContainer: string;
18
+ export declare const liveTailIndicator: string;
19
+ export declare const liveTailDot: string;
20
+ export declare const liveTailText: string;
21
+ export declare const liveTailSubtext: string;
@@ -1 +1,6 @@
1
- export declare function EventsTabContent(): import("react/jsx-runtime").JSX.Element;
1
+ import type { IEventInterceptionPlugin } from '../../../types/plugin';
2
+ interface EventsTabContentProps {
3
+ eventInterceptionPlugin?: IEventInterceptionPlugin;
4
+ }
5
+ export declare function EventsTabContent(props: EventsTabContentProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare const warningContainer: string;
2
+ export declare const warningMessage: string;
3
+ export declare const warningTitle: string;
4
+ export declare const warningText: string;
5
+ export declare const warningHelp: string;
@@ -0,0 +1 @@
1
+ export declare function DoNotTrackWarning(): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { Dispatch, SetStateAction } from 'react';
2
2
  import { ActiveTabId, ToolbarMode } from '../types';
3
- import type { IFlagOverridePlugin } from '../../../types/plugin';
3
+ import type { IFlagOverridePlugin, IEventInterceptionPlugin } from '../../../types/plugin';
4
4
  interface ExpandedToolbarContentProps {
5
5
  isExpanded: boolean;
6
6
  activeTab: ActiveTabId;
@@ -11,8 +11,9 @@ interface ExpandedToolbarContentProps {
11
11
  onClose: () => void;
12
12
  onTabChange: (tabId: string) => void;
13
13
  setSearchIsExpanded: Dispatch<SetStateAction<boolean>>;
14
- flagOverridePlugin?: IFlagOverridePlugin;
15
14
  mode: ToolbarMode;
15
+ flagOverridePlugin?: IFlagOverridePlugin;
16
+ eventInterceptionPlugin?: IEventInterceptionPlugin;
16
17
  }
17
18
  export declare function ExpandedToolbarContent(props: ExpandedToolbarContentProps): import("react/jsx-runtime").JSX.Element;
18
19
  export {};
@@ -1,10 +1,11 @@
1
1
  import { TabId, ToolbarMode } from '../types';
2
- import type { IFlagOverridePlugin } from '../../../types/plugin';
2
+ import type { IFlagOverridePlugin, IEventInterceptionPlugin } from '../../../types/plugin';
3
3
  interface TabContentRendererProps {
4
4
  activeTab: TabId;
5
5
  slideDirection: number;
6
- flagOverridePlugin?: IFlagOverridePlugin;
7
6
  mode: ToolbarMode;
7
+ flagOverridePlugin?: IFlagOverridePlugin;
8
+ eventInterceptionPlugin?: IEventInterceptionPlugin;
8
9
  }
9
10
  export declare function TabContentRenderer(props: TabContentRendererProps): import("react/jsx-runtime").JSX.Element | null;
10
11
  export {};
@@ -1,6 +1,7 @@
1
1
  export { ActionButtonsContainer } from './ActionButtonsContainer';
2
2
  export { CircleLogo } from './CircleLogo';
3
3
  export { ConnectionStatus } from './ConnectionStatus';
4
+ export { DoNotTrackWarning } from './DoNotTrackWarning';
4
5
  export { ExpandedToolbarContent } from './ExpandedToolbarContent';
5
6
  export { LaunchDarklyIcon } from './icons/LaunchDarklyIcon';
6
7
  export { StatusDot } from './StatusDot';
@@ -75,6 +75,33 @@ export declare const ANIMATION_CONFIG: {
75
75
  };
76
76
  readonly delay: 0.3;
77
77
  };
78
+ readonly eventList: {
79
+ readonly liveTail: {
80
+ readonly dot: {
81
+ readonly scale: number[];
82
+ readonly opacity: number[];
83
+ readonly transition: {
84
+ readonly duration: 1.5;
85
+ readonly repeat: number;
86
+ readonly ease: "easeInOut";
87
+ };
88
+ };
89
+ readonly container: {
90
+ readonly initial: {
91
+ readonly opacity: 0;
92
+ readonly y: 20;
93
+ };
94
+ readonly animate: {
95
+ readonly opacity: 1;
96
+ readonly y: 0;
97
+ };
98
+ readonly transition: {
99
+ readonly duration: 0.4;
100
+ readonly ease: readonly [0.25, 0.46, 0.45, 0.94];
101
+ };
102
+ };
103
+ };
104
+ };
78
105
  };
79
106
  export declare const DIMENSIONS: {
80
107
  readonly collapsed: {
@@ -3,3 +3,5 @@ export { useToolbarAnimations } from './useToolbarAnimations';
3
3
  export { useToolbarVisibility } from './useToolbarVisibility';
4
4
  export { useToolbarDrag } from './useToolbarDrag';
5
5
  export { useKeyPressed } from './useKeyPressed';
6
+ export { useEvents } from './useEvents';
7
+ export { useCurrentDate } from './useCurrentDate';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Hook that provides the current date and updates it at a specified interval
3
+ * Useful for displaying relative timestamps that update in real-time
4
+ */
5
+ export declare function useCurrentDate(updateInterval?: number): Date;
@@ -0,0 +1,13 @@
1
+ import type { ProcessedEvent } from '../../../types/events';
2
+ import { IEventInterceptionPlugin } from '../../../types/plugin';
3
+ interface EventStats {
4
+ totalEvents: number;
5
+ eventsByKind: Record<string, number>;
6
+ eventsByFlag: Record<string, number>;
7
+ }
8
+ interface UseEventsReturn {
9
+ events: ProcessedEvent[];
10
+ eventStats: EventStats;
11
+ }
12
+ export declare function useEvents(eventInterceptionPlugin: IEventInterceptionPlugin | undefined, searchTerm?: string): UseEventsReturn;
13
+ export {};
@@ -1,12 +1,12 @@
1
- export type TabId = 'flag-sdk' | 'flag-dev-server' | 'settings';
1
+ export type TabId = 'flag-sdk' | 'flag-dev-server' | 'events' | 'settings';
2
2
  export type ActiveTabId = TabId | undefined;
3
3
  export declare const TAB_ORDER: readonly TabId[];
4
4
  export type ToolbarMode = 'dev-server' | 'sdk';
5
5
  export declare const DEV_SERVER_TABS: readonly TabId[];
6
6
  export declare const SDK_MODE_TABS: readonly TabId[];
7
7
  export declare function getToolbarMode(devServerUrl?: string): ToolbarMode;
8
- export declare function getTabsForMode(mode: ToolbarMode, hasFlagOverridePlugin: boolean): readonly TabId[];
9
- export declare function getDefaultActiveTab(mode: ToolbarMode): TabId;
8
+ export declare function getTabsForMode(mode: ToolbarMode, hasFlagOverridePlugin: boolean, hasEventInterceptionPlugin: boolean): readonly TabId[];
9
+ export declare function getDefaultActiveTab(mode: ToolbarMode, hasFlagOverridePlugin?: boolean, hasEventInterceptionPlugin?: boolean): TabId;
10
10
  export interface FeatureFlag {
11
11
  id: string;
12
12
  name: string;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Utility function to detect if Do Not Track is enabled
3
+ * Based on the same logic used in LaunchDarkly SDK
4
+ *
5
+ * @returns {boolean} true if Do Not Track is enabled, false otherwise
6
+ */
7
+ export declare function isDoNotTrackEnabled(): boolean;
@@ -1 +1,2 @@
1
1
  export { deepEqual } from './deepEqual';
2
+ export { isDoNotTrackEnabled } from './browser';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@launchdarkly/toolbar",
3
- "version": "0.11.1-beta.1",
3
+ "version": "0.13.0-beta.1",
4
4
  "description": "A React component that provides a developer-friendly toolbar for interacting with LaunchDarkly during development",
5
5
  "keywords": [
6
6
  "launchdarkly",
@@ -23,10 +23,23 @@
23
23
  "homepage": "https://github.com/launchdarkly/launchdarkly-toolbar#readme",
24
24
  "main": "./dist/js/index.js",
25
25
  "types": "./dist/index.d.ts",
26
+ "sideEffects": [
27
+ "./dist/js/index.js",
28
+ "./dist/static/**/*",
29
+ "*.css"
30
+ ],
26
31
  "exports": {
27
32
  ".": {
28
33
  "types": "./dist/index.d.ts",
29
34
  "import": "./dist/js/index.js"
35
+ },
36
+ "./plugins": {
37
+ "types": "./dist/plugins/index.d.ts",
38
+ "import": "./dist/js/plugins/index.js"
39
+ },
40
+ "./plugins/FlagOverridePlugin": {
41
+ "types": "./dist/plugins/FlagOverridePlugin.d.ts",
42
+ "import": "./dist/js/plugins/FlagOverridePlugin.js"
30
43
  }
31
44
  },
32
45
  "files": [
@@ -62,9 +75,9 @@
62
75
  },
63
76
  "devDependencies": {
64
77
  "@playwright/test": "^1.53.1",
65
- "@rsbuild/core": "1.4.12",
66
- "@rsbuild/plugin-react": "^1.3.4",
67
- "@rslib/core": "^0.11.1",
78
+ "@rsbuild/core": "1.5.4",
79
+ "@rsbuild/plugin-react": "^1.4.0",
80
+ "@rslib/core": "^0.13.0",
68
81
  "@storybook/addon-docs": "^9.0.5",
69
82
  "@storybook/addon-essentials": "^9.0.0-alpha.12",
70
83
  "@storybook/addon-interactions": "^9.0.0-alpha.10",
@@ -93,8 +106,7 @@
93
106
  },
94
107
  "peerDependencies": {
95
108
  "launchdarkly-js-client-sdk": "^3.9.0",
96
- "react": "^18.0.0 || ^19.0.0",
97
- "react-dom": "^18.0.0 || ^19.0.0"
109
+ "react": "^18.0.0 || ^19.0.0"
98
110
  },
99
111
  "private": false,
100
112
  "publishConfig": {