@launchdarkly/toolbar 0.14.0-beta.1 → 0.16.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.
package/README.md CHANGED
@@ -27,10 +27,11 @@ pnpm add @launchdarkly/toolbar@next
27
27
  ```tsx
28
28
  import { useEffect, useState } from 'react';
29
29
  import { asyncWithLDProvider } from 'launchdarkly-react-client-sdk';
30
- import { LaunchDarklyToolbar, FlagOverridePlugin } from '@launchdarkly/toolbar';
30
+ import { LaunchDarklyToolbar, FlagOverridePlugin, EventInterceptionPlugin } from '@launchdarkly/toolbar';
31
31
 
32
- // Create the plugin instance
32
+ // Create the plugin instances
33
33
  const flagOverridePlugin = new FlagOverridePlugin();
34
+ const eventInterceptionPlugin = new EventInterceptionPlugin();
34
35
 
35
36
  function App() {
36
37
  const [LDProvider, setLDProvider] = useState(null);
@@ -41,8 +42,8 @@ function App() {
41
42
  clientSideID: 'your-client-side-id',
42
43
  context: { key: 'user-key', name: 'User Name' },
43
44
  options: {
44
- // Pass the plugin to the SDK
45
- plugins: [flagOverridePlugin],
45
+ // Pass the plugins to the SDK
46
+ plugins: [flagOverridePlugin, eventInterceptionPlugin],
46
47
  },
47
48
  });
48
49
  setLDProvider(() => Provider);
@@ -59,7 +60,7 @@ function App() {
59
60
  <LDProvider>
60
61
  <div>
61
62
  <h1>My App</h1>
62
- {/* Pass the same plugin instance to the toolbar */}
63
+ {/* Pass the same plugin instances to the toolbar */}
63
64
  <LaunchDarklyToolbar
64
65
  flagOverridePlugin={flagOverridePlugin}
65
66
  eventInterceptionPlugin={eventInterceptionPlugin}
@@ -169,6 +170,31 @@ function App() {
169
170
  }
170
171
  ```
171
172
 
173
+ #### Event Interception Plugin
174
+
175
+ To track and display LaunchDarkly events (flag evaluations, custom events, etc.), add the `EventInterceptionPlugin`:
176
+
177
+ ```tsx
178
+ import { EventInterceptionPlugin } from '@launchdarkly/toolbar';
179
+
180
+ // Create plugin with optional configuration
181
+ const eventInterceptionPlugin = new EventInterceptionPlugin({
182
+ eventCapacity: 250, // Maximum events to store (default: 100)
183
+ enableLogging: true, // Console logging for debugging (default: false)
184
+ });
185
+
186
+ // Add to both SDK and toolbar
187
+ const Provider = await asyncWithLDProvider({
188
+ // ... other config
189
+ options: {
190
+ plugins: [flagOverridePlugin, eventInterceptionPlugin],
191
+ },
192
+ });
193
+
194
+ // Pass to toolbar
195
+ <LaunchDarklyToolbar flagOverridePlugin={flagOverridePlugin} eventInterceptionPlugin={eventInterceptionPlugin} />;
196
+ ```
197
+
172
198
  ### Dev Server Mode
173
199
 
174
200
  For teams using the LaunchDarkly CLI dev server, start it with CORS enabled:
@@ -1,7 +1,13 @@
1
1
  import type { ProcessedEvent } from '../types/events';
2
+ export interface EventStoreConfig {
3
+ /** Maximum number of events to store */
4
+ maxEvents?: number;
5
+ }
2
6
  export declare class EventStore {
3
7
  private events;
4
8
  private listeners;
9
+ private maxEvents;
10
+ constructor(config?: EventStoreConfig);
5
11
  addEvent(event: ProcessedEvent): void;
6
12
  getEvents(): ProcessedEvent[];
7
13
  subscribe(listener: () => void): () => void;