@buoy-gg/events 7.0.40 → 7.0.42

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 (126) hide show
  1. package/README.md +11 -60
  2. package/lib/commonjs/components/EventsCopySettingsView.js +1 -581
  3. package/lib/commonjs/components/EventsModal.js +1 -387
  4. package/lib/commonjs/components/ReactQueryEventDetail.js +1 -433
  5. package/lib/commonjs/components/UnifiedEventDetail.js +1 -556
  6. package/lib/commonjs/components/UnifiedEventFilters.js +1 -160
  7. package/lib/commonjs/components/UnifiedEventItem.js +1 -417
  8. package/lib/commonjs/components/UnifiedEventList.js +1 -187
  9. package/lib/commonjs/components/UnifiedEventViewer.js +1 -130
  10. package/lib/commonjs/hooks/useUnifiedEvents.js +1 -419
  11. package/lib/commonjs/index.js +1 -282
  12. package/lib/commonjs/preset.js +1 -60
  13. package/lib/commonjs/sources/sourceIds.js +1 -30
  14. package/lib/commonjs/stores/unifiedEventStore.js +1 -712
  15. package/lib/commonjs/sync/eventsSyncAdapter.js +1 -358
  16. package/lib/commonjs/types/copySettings.js +1 -249
  17. package/lib/commonjs/types/index.js +1 -17
  18. package/lib/commonjs/utils/autoDiscoverEventSources.js +1 -1065
  19. package/lib/commonjs/utils/badgeSelectionStorage.js +1 -126
  20. package/lib/commonjs/utils/copySettingsStorage.js +1 -43
  21. package/lib/commonjs/utils/correlationUtils.js +1 -130
  22. package/lib/commonjs/utils/eventExportFormatter.js +1 -1912
  23. package/lib/commonjs/utils/eventTransformers.js +1 -496
  24. package/lib/commonjs/utils/eventVisibility.js +1 -76
  25. package/lib/commonjs/utils/testIDs.js +1 -91
  26. package/lib/module/components/EventsCopySettingsView.js +1 -577
  27. package/lib/module/components/EventsModal.js +1 -383
  28. package/lib/module/components/ReactQueryEventDetail.js +1 -429
  29. package/lib/module/components/UnifiedEventDetail.js +1 -552
  30. package/lib/module/components/UnifiedEventFilters.js +1 -156
  31. package/lib/module/components/UnifiedEventItem.js +1 -413
  32. package/lib/module/components/UnifiedEventList.js +1 -183
  33. package/lib/module/components/UnifiedEventViewer.js +1 -126
  34. package/lib/module/hooks/useUnifiedEvents.js +1 -416
  35. package/lib/module/index.js +1 -102
  36. package/lib/module/preset.js +1 -57
  37. package/lib/module/sources/sourceIds.js +1 -26
  38. package/lib/module/stores/unifiedEventStore.js +1 -678
  39. package/lib/module/sync/eventsSyncAdapter.js +1 -354
  40. package/lib/module/types/copySettings.js +1 -244
  41. package/lib/module/types/index.js +1 -37
  42. package/lib/module/utils/autoDiscoverEventSources.js +1 -1057
  43. package/lib/module/utils/badgeSelectionStorage.js +1 -116
  44. package/lib/module/utils/copySettingsStorage.js +1 -37
  45. package/lib/module/utils/correlationUtils.js +1 -120
  46. package/lib/module/utils/eventExportFormatter.js +1 -1901
  47. package/lib/module/utils/eventTransformers.js +1 -487
  48. package/lib/module/utils/eventVisibility.js +1 -70
  49. package/lib/module/utils/testIDs.js +1 -83
  50. package/lib/typescript/components/EventsModal.d.ts +1 -7
  51. package/lib/typescript/components/UnifiedEventDetail.d.ts +2 -9
  52. package/lib/typescript/components/UnifiedEventItem.d.ts +0 -7
  53. package/lib/web/index.mjs +12 -0
  54. package/package.json +31 -11
  55. package/lib/commonjs/components/EventsCopySettingsView.js.map +0 -1
  56. package/lib/commonjs/components/EventsModal.js.map +0 -1
  57. package/lib/commonjs/components/ReactQueryEventDetail.js.map +0 -1
  58. package/lib/commonjs/components/UnifiedEventDetail.js.map +0 -1
  59. package/lib/commonjs/components/UnifiedEventFilters.js.map +0 -1
  60. package/lib/commonjs/components/UnifiedEventItem.js.map +0 -1
  61. package/lib/commonjs/components/UnifiedEventList.js.map +0 -1
  62. package/lib/commonjs/components/UnifiedEventViewer.js.map +0 -1
  63. package/lib/commonjs/hooks/useUnifiedEvents.js.map +0 -1
  64. package/lib/commonjs/index.js.map +0 -1
  65. package/lib/commonjs/preset.js.map +0 -1
  66. package/lib/commonjs/sources/sourceIds.js.map +0 -1
  67. package/lib/commonjs/stores/unifiedEventStore.js.map +0 -1
  68. package/lib/commonjs/sync/eventsSyncAdapter.js.map +0 -1
  69. package/lib/commonjs/types/copySettings.js.map +0 -1
  70. package/lib/commonjs/types/index.js.map +0 -1
  71. package/lib/commonjs/utils/autoDiscoverEventSources.js.map +0 -1
  72. package/lib/commonjs/utils/badgeSelectionStorage.js.map +0 -1
  73. package/lib/commonjs/utils/copySettingsStorage.js.map +0 -1
  74. package/lib/commonjs/utils/correlationUtils.js.map +0 -1
  75. package/lib/commonjs/utils/eventExportFormatter.js.map +0 -1
  76. package/lib/commonjs/utils/eventTransformers.js.map +0 -1
  77. package/lib/commonjs/utils/eventVisibility.js.map +0 -1
  78. package/lib/commonjs/utils/testIDs.js.map +0 -1
  79. package/lib/module/components/EventsCopySettingsView.js.map +0 -1
  80. package/lib/module/components/EventsModal.js.map +0 -1
  81. package/lib/module/components/ReactQueryEventDetail.js.map +0 -1
  82. package/lib/module/components/UnifiedEventDetail.js.map +0 -1
  83. package/lib/module/components/UnifiedEventFilters.js.map +0 -1
  84. package/lib/module/components/UnifiedEventItem.js.map +0 -1
  85. package/lib/module/components/UnifiedEventList.js.map +0 -1
  86. package/lib/module/components/UnifiedEventViewer.js.map +0 -1
  87. package/lib/module/hooks/useUnifiedEvents.js.map +0 -1
  88. package/lib/module/index.js.map +0 -1
  89. package/lib/module/preset.js.map +0 -1
  90. package/lib/module/sources/sourceIds.js.map +0 -1
  91. package/lib/module/stores/unifiedEventStore.js.map +0 -1
  92. package/lib/module/sync/eventsSyncAdapter.js.map +0 -1
  93. package/lib/module/types/copySettings.js.map +0 -1
  94. package/lib/module/types/index.js.map +0 -1
  95. package/lib/module/utils/autoDiscoverEventSources.js.map +0 -1
  96. package/lib/module/utils/badgeSelectionStorage.js.map +0 -1
  97. package/lib/module/utils/copySettingsStorage.js.map +0 -1
  98. package/lib/module/utils/correlationUtils.js.map +0 -1
  99. package/lib/module/utils/eventExportFormatter.js.map +0 -1
  100. package/lib/module/utils/eventTransformers.js.map +0 -1
  101. package/lib/module/utils/eventVisibility.js.map +0 -1
  102. package/lib/module/utils/testIDs.js.map +0 -1
  103. package/lib/typescript/components/EventsCopySettingsView.d.ts.map +0 -1
  104. package/lib/typescript/components/EventsModal.d.ts.map +0 -1
  105. package/lib/typescript/components/ReactQueryEventDetail.d.ts.map +0 -1
  106. package/lib/typescript/components/UnifiedEventDetail.d.ts.map +0 -1
  107. package/lib/typescript/components/UnifiedEventFilters.d.ts.map +0 -1
  108. package/lib/typescript/components/UnifiedEventItem.d.ts.map +0 -1
  109. package/lib/typescript/components/UnifiedEventList.d.ts.map +0 -1
  110. package/lib/typescript/components/UnifiedEventViewer.d.ts.map +0 -1
  111. package/lib/typescript/hooks/useUnifiedEvents.d.ts.map +0 -1
  112. package/lib/typescript/index.d.ts.map +0 -1
  113. package/lib/typescript/preset.d.ts.map +0 -1
  114. package/lib/typescript/sources/sourceIds.d.ts.map +0 -1
  115. package/lib/typescript/stores/unifiedEventStore.d.ts.map +0 -1
  116. package/lib/typescript/sync/eventsSyncAdapter.d.ts.map +0 -1
  117. package/lib/typescript/types/copySettings.d.ts.map +0 -1
  118. package/lib/typescript/types/index.d.ts.map +0 -1
  119. package/lib/typescript/utils/autoDiscoverEventSources.d.ts.map +0 -1
  120. package/lib/typescript/utils/badgeSelectionStorage.d.ts.map +0 -1
  121. package/lib/typescript/utils/copySettingsStorage.d.ts.map +0 -1
  122. package/lib/typescript/utils/correlationUtils.d.ts.map +0 -1
  123. package/lib/typescript/utils/eventExportFormatter.d.ts.map +0 -1
  124. package/lib/typescript/utils/eventTransformers.d.ts.map +0 -1
  125. package/lib/typescript/utils/eventVisibility.d.ts.map +0 -1
  126. package/lib/typescript/utils/testIDs.d.ts.map +0 -1
@@ -1,577 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * EventsCopySettingsView
5
- *
6
- * Settings UI for configuring event export format and content.
7
- * Based on NetworkCopySettingsView pattern.
8
- */
9
-
10
- import { useCallback, useEffect, useMemo, useState } from "react";
11
- import { Text, StyleSheet, ScrollView, View } from "react-native";
12
- import { DynamicFilterView, macOSColors, night, FileText, FileCode, Hash, Zap, AlertTriangle, Settings, Eye, XCircle, GitBranch, ToolbarCopyButton, useFeatureGate, ProFeatureBanner, ExportPreview, monoFont } from "@buoy-gg/shared-ui";
13
- import { DataViewer } from "@buoy-gg/shared-ui/dataViewer";
14
- import { DEFAULT_COPY_SETTINGS, COPY_PRESETS, PRESET_METADATA, detectActivePreset } from "../types/copySettings";
15
- import { generateExport, estimateExportSize, getExportSummary } from "../utils/eventExportFormatter";
16
- import { loadCopySettings, saveCopySettings } from "../utils/copySettingsStorage";
17
- import { EVENTS_TEST_ID } from "../utils/testIDs";
18
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
19
- // Size thresholds for warnings
20
- const SIZE_WARNING_THRESHOLD = 50 * 1024; // 50KB
21
- const SIZE_DANGER_THRESHOLD = 200 * 1024; // 200KB
22
-
23
- // Helper to format bytes
24
- function formatBytes(bytes) {
25
- if (bytes < 1024) return `${bytes} B`;
26
- if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
27
- return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
28
- }
29
-
30
- // Mock events for preview when no real events exist
31
- function createMockEvents() {
32
- const now = Date.now();
33
- return [{
34
- id: "mock-1",
35
- source: "storage-async",
36
- timestamp: now - 2000,
37
- title: "Set Item",
38
- subtitle: "user_cart",
39
- status: "success",
40
- originalEvent: {
41
- action: "setItem",
42
- key: "user_cart",
43
- value: {
44
- items: 2
45
- }
46
- }
47
- }, {
48
- id: "mock-2",
49
- source: "react-query-query",
50
- timestamp: now - 1500,
51
- title: "cart \u203A items",
52
- subtitle: "Fetching...",
53
- status: "pending",
54
- originalEvent: {
55
- type: "query-fetch-start",
56
- queryKey: ["cart", "items"]
57
- },
58
- correlationId: "rq-query-cart",
59
- sequenceInGroup: 1
60
- }, {
61
- id: "mock-3",
62
- source: "react-query-query",
63
- timestamp: now - 1000,
64
- title: "cart \u203A items",
65
- subtitle: "Success \u00B7 500ms",
66
- status: "success",
67
- originalEvent: {
68
- type: "query-fetch-success",
69
- queryKey: ["cart", "items"],
70
- data: {
71
- items: []
72
- }
73
- },
74
- correlationId: "rq-query-cart",
75
- sequenceInGroup: 2
76
- }, {
77
- id: "mock-4",
78
- source: "network",
79
- timestamp: now - 500,
80
- title: "POST /api/checkout",
81
- subtitle: "402 \u00B7 450ms",
82
- status: "error",
83
- originalEvent: {
84
- method: "POST",
85
- url: "/api/checkout",
86
- status: 402,
87
- error: "Payment required"
88
- }
89
- }];
90
- }
91
- export function EventsCopySettingsView({
92
- events = [],
93
- initialSettings = DEFAULT_COPY_SETTINGS,
94
- onSettingsChange
95
- }) {
96
- const {
97
- isPro
98
- } = useFeatureGate();
99
- const [settings, setSettings] = useState(initialSettings);
100
- const [isPreviewExpanded, setIsPreviewExpanded] = useState(false);
101
- const [isLoaded, setIsLoaded] = useState(false);
102
-
103
- // Load persisted settings on mount
104
- useEffect(() => {
105
- let mounted = true;
106
- loadCopySettings().then(savedSettings => {
107
- if (mounted && savedSettings) {
108
- setSettings(savedSettings);
109
- onSettingsChange?.(savedSettings);
110
- }
111
- if (mounted) {
112
- setIsLoaded(true);
113
- }
114
- });
115
- return () => {
116
- mounted = false;
117
- };
118
- }, [onSettingsChange]);
119
-
120
- // Update internal state, notify parent, and persist
121
- const updateSettings = useCallback(newSettings => {
122
- setSettings(newSettings);
123
- onSettingsChange?.(newSettings);
124
- // Persist to storage
125
- saveCopySettings(newSettings);
126
- }, [onSettingsChange]);
127
-
128
- // Use mock events if no real events
129
- const hasLiveData = events.length > 0;
130
- const previewEvents = hasLiveData ? events : createMockEvents();
131
-
132
- // Detect active preset
133
- const activePreset = useMemo(() => detectActivePreset(settings), [settings]);
134
-
135
- // Estimate size
136
- const estimatedSize = useMemo(() => estimateExportSize(previewEvents, settings), [previewEvents, settings]);
137
-
138
- // Size warning level
139
- const sizeWarningLevel = useMemo(() => {
140
- if (estimatedSize >= SIZE_DANGER_THRESHOLD) return "danger";
141
- if (estimatedSize >= SIZE_WARNING_THRESHOLD) return "warning";
142
- return "none";
143
- }, [estimatedSize]);
144
-
145
- // Generate copy text
146
- const generateCopyText = useCallback(() => {
147
- return generateExport(previewEvents, settings);
148
- }, [previewEvents, settings]);
149
-
150
- // Handle preset selection
151
- const applyPreset = useCallback(presetName => {
152
- const preset = COPY_PRESETS[presetName];
153
- updateSettings({
154
- ...preset,
155
- // Convert readonly array to mutable array
156
- filterSources: [...preset.filterSources]
157
- });
158
- }, [updateSettings]);
159
-
160
- // Handle option changes
161
- const handleOptionChange = useCallback((optionId, value) => {
162
- const [group, key] = optionId.split("::");
163
- if (group === "preset") {
164
- applyPreset(key);
165
- return;
166
- }
167
- if (group === "include") {
168
- updateSettings({
169
- ...settings,
170
- [key]: !settings[key]
171
- });
172
- return;
173
- }
174
- if (group === "format") {
175
- updateSettings({
176
- ...settings,
177
- format: value
178
- });
179
- return;
180
- }
181
- if (group === "timestamp") {
182
- updateSettings({
183
- ...settings,
184
- timestampFormat: value
185
- });
186
- return;
187
- }
188
- if (group === "filter") {
189
- updateSettings({
190
- ...settings,
191
- filterMode: value
192
- });
193
- return;
194
- }
195
- if (group === "threshold") {
196
- updateSettings({
197
- ...settings,
198
- dataSizeThreshold: value
199
- });
200
- return;
201
- }
202
- }, [settings, updateSettings, applyPreset]);
203
-
204
- // Render preview content
205
- const renderPreviewContent = useCallback(() => {
206
- const eventCount = previewEvents.length;
207
- return /*#__PURE__*/_jsx(ExportPreview, {
208
- expanded: isPreviewExpanded,
209
- onExpandedChange: setIsPreviewExpanded,
210
- summary: `${eventCount} event${eventCount !== 1 ? "s" : ""} \u00B7 ~${formatBytes(estimatedSize)}${!hasLiveData ? " (mock data)" : ""}`,
211
- warningLevel: sizeWarningLevel,
212
- warningText: {
213
- warning: "Large payload - preview may be slow",
214
- danger: "Very large payload - may cause performance issues"
215
- },
216
- testIDs: {
217
- expand: `${EVENTS_TEST_ID}-preview-expand`,
218
- collapse: `${EVENTS_TEST_ID}-preview-collapse`,
219
- summary: `${EVENTS_TEST_ID}-preview-summary`,
220
- warning: `${EVENTS_TEST_ID}-preview-size-warning`
221
- },
222
- renderBody: () => {
223
- const exportText = generateCopyText();
224
- return settings.format === "json" ? /*#__PURE__*/_jsx(DataViewer, {
225
- testIDPrefix: `${EVENTS_TEST_ID}-preview-json`,
226
- data: JSON.parse(exportText),
227
- title: "",
228
- showTypeFilter: true,
229
- rawMode: true,
230
- initialExpanded: true
231
- }) : /*#__PURE__*/_jsxs(View, {
232
- children: [settings.format === "mermaid" && /*#__PURE__*/_jsx(Text, {
233
- style: styles.mermaidHint,
234
- children: "\uD83D\uDCA1 Paste into mermaid.live to visualize"
235
- }), /*#__PURE__*/_jsx(ScrollView, {
236
- style: styles.previewScroll,
237
- nestedScrollEnabled: true,
238
- testID: `${EVENTS_TEST_ID}-preview-scroll`,
239
- children: /*#__PURE__*/_jsx(Text, {
240
- style: styles.previewText,
241
- selectable: isPro,
242
- testID: `${EVENTS_TEST_ID}-preview-text`,
243
- children: exportText
244
- })
245
- })]
246
- });
247
- }
248
- });
249
- }, [isPreviewExpanded, previewEvents, settings, estimatedSize, sizeWarningLevel, hasLiveData, generateCopyText, isPro]);
250
-
251
- // Render preview header actions
252
- const renderPreviewHeaderActions = useCallback(() => {
253
- const summary = getExportSummary(previewEvents);
254
- const statusLabel = hasLiveData ? `${summary.totalEvents} events` : "Mock data (no events captured)";
255
- return /*#__PURE__*/_jsxs(_Fragment, {
256
- children: [/*#__PURE__*/_jsx(Text, {
257
- style: styles.statusLabel,
258
- testID: `${EVENTS_TEST_ID}-export-status`,
259
- children: statusLabel
260
- }), /*#__PURE__*/_jsx(ToolbarCopyButton, {
261
- value: generateCopyText()
262
- })]
263
- });
264
- }, [hasLiveData, previewEvents, generateCopyText]);
265
-
266
- // Build filter config
267
- const dynamicFilterConfig = useMemo(() => ({
268
- sections: [
269
- // Presets Section
270
- {
271
- id: "presets",
272
- title: "Presets",
273
- type: "custom",
274
- data: [{
275
- id: "preset::llm",
276
- label: PRESET_METADATA.llm.label,
277
- icon: Zap,
278
- color: PRESET_METADATA.llm.color,
279
- value: "llm",
280
- isActive: activePreset === "llm",
281
- description: PRESET_METADATA.llm.description
282
- }, {
283
- id: "preset::bugReport",
284
- label: PRESET_METADATA.bugReport.label,
285
- icon: AlertTriangle,
286
- color: PRESET_METADATA.bugReport.color,
287
- value: "bugReport",
288
- isActive: activePreset === "bugReport",
289
- description: PRESET_METADATA.bugReport.description
290
- }, {
291
- id: "preset::json",
292
- label: PRESET_METADATA.json.label,
293
- icon: FileCode,
294
- color: PRESET_METADATA.json.color,
295
- value: "json",
296
- isActive: activePreset === "json",
297
- description: PRESET_METADATA.json.description
298
- }, {
299
- id: "preset::errors",
300
- label: PRESET_METADATA.errors.label,
301
- icon: XCircle,
302
- color: PRESET_METADATA.errors.color,
303
- value: "errors",
304
- isActive: activePreset === "errors",
305
- description: PRESET_METADATA.errors.description
306
- }, {
307
- id: "preset::minimal",
308
- label: PRESET_METADATA.minimal.label,
309
- icon: FileText,
310
- color: PRESET_METADATA.minimal.color,
311
- value: "minimal",
312
- isActive: activePreset === "minimal",
313
- description: PRESET_METADATA.minimal.description
314
- }, {
315
- id: "preset::mermaid",
316
- label: PRESET_METADATA.mermaid.label,
317
- icon: GitBranch,
318
- color: PRESET_METADATA.mermaid.color,
319
- value: "mermaid",
320
- isActive: activePreset === "mermaid",
321
- description: PRESET_METADATA.mermaid.description
322
- }, {
323
- id: "preset::custom",
324
- label: "Custom",
325
- icon: Settings,
326
- color: night.color.textSecondary,
327
- value: "custom",
328
- isActive: activePreset === null,
329
- description: "User-configured"
330
- }]
331
- },
332
- // Include Section
333
- {
334
- id: "include",
335
- title: "Include",
336
- type: "custom",
337
- data: [{
338
- id: "include::includeSource",
339
- label: "Source",
340
- value: "includeSource",
341
- isActive: settings.includeSource
342
- }, {
343
- id: "include::includeStatus",
344
- label: "Status",
345
- value: "includeStatus",
346
- isActive: settings.includeStatus
347
- }, {
348
- id: "include::includeTitle",
349
- label: "Title",
350
- value: "includeTitle",
351
- isActive: settings.includeTitle
352
- }, {
353
- id: "include::includeSubtitle",
354
- label: "Subtitle",
355
- value: "includeSubtitle",
356
- isActive: settings.includeSubtitle
357
- }, {
358
- id: "include::includeCorrelation",
359
- label: "Correlation",
360
- value: "includeCorrelation",
361
- isActive: settings.includeCorrelation
362
- }, {
363
- id: "include::includeDuration",
364
- label: "Duration",
365
- value: "includeDuration",
366
- isActive: settings.includeDuration
367
- }, {
368
- id: "include::includeSummaryHeader",
369
- label: "Summary",
370
- value: "includeSummaryHeader",
371
- isActive: settings.includeSummaryHeader
372
- }, {
373
- id: "include::includeEventData",
374
- label: "Data",
375
- value: "includeEventData",
376
- isActive: settings.includeEventData
377
- }]
378
- },
379
- // Format Section
380
- {
381
- id: "format",
382
- title: "Format",
383
- type: "custom",
384
- data: [{
385
- id: "format::markdown",
386
- label: "Markdown",
387
- icon: FileText,
388
- color: macOSColors.semantic.info,
389
- value: "markdown",
390
- isActive: settings.format === "markdown"
391
- }, {
392
- id: "format::json",
393
- label: "JSON",
394
- icon: FileCode,
395
- color: macOSColors.semantic.warning,
396
- value: "json",
397
- isActive: settings.format === "json"
398
- }, {
399
- id: "format::plaintext",
400
- label: "Text",
401
- icon: Hash,
402
- color: night.color.textSecondary,
403
- value: "plaintext",
404
- isActive: settings.format === "plaintext"
405
- }, {
406
- id: "format::mermaid",
407
- label: "Diagram",
408
- icon: GitBranch,
409
- color: "#A855F7",
410
- value: "mermaid",
411
- isActive: settings.format === "mermaid",
412
- description: "Mermaid sequence diagram"
413
- }]
414
- },
415
- // Timestamp Section
416
- {
417
- id: "timestamp",
418
- title: "Timestamps",
419
- type: "custom",
420
- data: [{
421
- id: "timestamp::relative",
422
- label: "Relative",
423
- value: "relative",
424
- isActive: settings.timestampFormat === "relative",
425
- description: "+0ms, +150ms"
426
- }, {
427
- id: "timestamp::absolute",
428
- label: "Absolute",
429
- value: "absolute",
430
- isActive: settings.timestampFormat === "absolute",
431
- description: "ISO format"
432
- }, {
433
- id: "timestamp::both",
434
- label: "Both",
435
- value: "both",
436
- isActive: settings.timestampFormat === "both",
437
- description: "Both formats"
438
- }]
439
- },
440
- // Filter Section
441
- {
442
- id: "filter",
443
- title: "Filter Events",
444
- type: "custom",
445
- data: [{
446
- id: "filter::all",
447
- label: "All",
448
- value: "all",
449
- isActive: settings.filterMode === "all"
450
- }, {
451
- id: "filter::errors",
452
- label: "Errors",
453
- icon: XCircle,
454
- color: macOSColors.semantic.error,
455
- value: "errors",
456
- isActive: settings.filterMode === "errors"
457
- }, {
458
- id: "filter::success",
459
- label: "Success",
460
- color: macOSColors.semantic.success,
461
- value: "success",
462
- isActive: settings.filterMode === "success"
463
- }, {
464
- id: "filter::pending",
465
- label: "Pending",
466
- color: macOSColors.semantic.warning,
467
- value: "pending",
468
- isActive: settings.filterMode === "pending"
469
- }]
470
- },
471
- // LLM Optimization Section
472
- {
473
- id: "llmOptimization",
474
- title: "LLM Optimization",
475
- type: "custom",
476
- data: [{
477
- id: "include::compactMode",
478
- label: "Compact",
479
- value: "compactMode",
480
- isActive: settings.compactMode,
481
- description: "One line per event"
482
- }, {
483
- id: "include::smartJsonParsing",
484
- label: "Smart JSON",
485
- value: "smartJsonParsing",
486
- isActive: settings.smartJsonParsing,
487
- description: "Parse nested JSON"
488
- }, {
489
- id: "include::reduxChangedOnly",
490
- label: "Redux Diff",
491
- value: "reduxChangedOnly",
492
- isActive: settings.reduxChangedOnly,
493
- description: "Only show changes"
494
- }, {
495
- id: "include::showStorageDiff",
496
- label: "Storage Diff",
497
- value: "showStorageDiff",
498
- isActive: settings.showStorageDiff,
499
- description: "Show what changed"
500
- }, {
501
- id: "include::stripVerboseFields",
502
- label: "Strip Noise",
503
- value: "stripVerboseFields",
504
- isActive: settings.stripVerboseFields,
505
- description: "Remove images/descriptions"
506
- }]
507
- }],
508
- previewSection: {
509
- enabled: true,
510
- title: "PREVIEW",
511
- icon: Eye,
512
- content: renderPreviewContent,
513
- headerActions: renderPreviewHeaderActions
514
- },
515
- onFilterChange: handleOptionChange
516
- }), [settings, activePreset, handleOptionChange, renderPreviewContent, renderPreviewHeaderActions]);
517
-
518
- // Pro gating - show banner at top with preview below (no floating)
519
- if (!isPro) {
520
- return /*#__PURE__*/_jsxs(ScrollView, {
521
- style: styles.gatedContainer,
522
- contentContainerStyle: styles.gatedContent,
523
- testID: `${EVENTS_TEST_ID}-copy-settings-gated`,
524
- children: [/*#__PURE__*/_jsx(ProFeatureBanner, {
525
- featureName: "Events Export",
526
- description: "Export event flows to share with your team, debug issues, or feed into AI tools.",
527
- benefits: ["Export to Markdown, JSON, or plain text", "Customizable presets (LLM-ready, Bug Report, JSON)", "Share event flows with teammates", "Feed event context directly to AI assistants"]
528
- }), /*#__PURE__*/_jsx(View, {
529
- style: styles.gatedPreview,
530
- children: /*#__PURE__*/_jsx(DynamicFilterView, {
531
- ...dynamicFilterConfig
532
- })
533
- })]
534
- });
535
- }
536
- return /*#__PURE__*/_jsx(DynamicFilterView, {
537
- ...dynamicFilterConfig
538
- });
539
- }
540
- const styles = StyleSheet.create({
541
- previewScroll: {
542
- maxHeight: 300
543
- },
544
- previewText: {
545
- fontFamily: monoFont,
546
- fontSize: 11,
547
- color: night.color.text,
548
- lineHeight: 18
549
- },
550
- mermaidHint: {
551
- fontSize: 11,
552
- color: night.color.textSecondary,
553
- marginBottom: 8,
554
- paddingHorizontal: 8,
555
- paddingVertical: 6,
556
- backgroundColor: "#A855F7" + "15",
557
- borderRadius: 6,
558
- overflow: "hidden"
559
- },
560
- statusLabel: {
561
- fontSize: 11,
562
- fontWeight: "600",
563
- color: night.color.textTertiary,
564
- marginRight: 8
565
- },
566
- gatedContainer: {
567
- flex: 1
568
- },
569
- gatedContent: {
570
- padding: 12,
571
- gap: 12
572
- },
573
- gatedPreview: {
574
- // No flex: 1 so it doesn't try to fill remaining space
575
- }
576
- });
577
- //# sourceMappingURL=EventsCopySettingsView.js.map
1
+ "use strict";import{useCallback as m,useEffect as N,useMemo as S,useState as A}from"react";import{Text as x,StyleSheet as V,ScrollView as M,View as R}from"react-native";import{DynamicFilterView as $,macOSColors as f,night as g,FileText as q,FileCode as L,Hash as J,Zap as G,AlertTriangle as W,Settings as K,Eye as Z,XCircle as j,GitBranch as B,ToolbarCopyButton as U,useFeatureGate as Y,ProFeatureBanner as X,ExportPreview as Q,monoFont as ee}from"@buoy-gg/shared-ui";import{DataViewer as te}from"@buoy-gg/shared-ui/dataViewer";import{DEFAULT_COPY_SETTINGS as ie,COPY_PRESETS as re,PRESET_METADATA as t,detectActivePreset as oe}from"../types/copySettings";import{generateExport as ae,estimateExportSize as le,getExportSummary as se}from"../utils/eventExportFormatter";import{loadCopySettings as ne,saveCopySettings as ce}from"../utils/copySettingsStorage";import{EVENTS_TEST_ID as l}from"../utils/testIDs";import{jsx as a,jsxs as E,Fragment as de}from"react/jsx-runtime";const ue=50*1024;const me=200*1024;function pe(o){if(o<1024)return`${o} B`;if(o<1024*1024)return`${(o/1024).toFixed(1)} KB`;return`${(o/(1024*1024)).toFixed(1)} MB`}function ve(){const o=Date.now();return[{id:"mock-1",source:"storage-async",timestamp:o-2e3,title:"Set Item",subtitle:"user_cart",status:"success",originalEvent:{action:"setItem",key:"user_cart",value:{items:2}}},{id:"mock-2",source:"react-query-query",timestamp:o-1500,title:"cart \u203A items",subtitle:"Fetching...",status:"pending",originalEvent:{type:"query-fetch-start",queryKey:["cart","items"]},correlationId:"rq-query-cart",sequenceInGroup:1},{id:"mock-3",source:"react-query-query",timestamp:o-1e3,title:"cart \u203A items",subtitle:"Success \xB7 500ms",status:"success",originalEvent:{type:"query-fetch-success",queryKey:["cart","items"],data:{items:[]}},correlationId:"rq-query-cart",sequenceInGroup:2},{id:"mock-4",source:"network",timestamp:o-500,title:"POST /api/checkout",subtitle:"402 \xB7 450ms",status:"error",originalEvent:{method:"POST",url:"/api/checkout",status:402,error:"Payment required"}}]}export function EventsCopySettingsView({events:o=[],initialSettings:_=ie,onSettingsChange:b}){const{isPro:h}=Y();const[e,D]=A(_);const[T,H]=A(false);const[fe,z]=A(false);N(()=>{let i=true;ne().then(r=>{if(i&&r){D(r);b?.(r)}if(i){z(true)}});return()=>{i=false}},[b]);const s=m(i=>{D(i);b?.(i);ce(i)},[b]);const p=o.length>0;const n=p?o:ve();const c=S(()=>oe(e),[e]);const v=S(()=>le(n,e),[n,e]);const C=S(()=>{if(v>=me)return"danger";if(v>=ue)return"warning";return"none"},[v]);const y=m(()=>{return ae(n,e)},[n,e]);const F=m(i=>{const r=re[i];s({...r,filterSources:[...r.filterSources]})},[s]);const P=m((i,r)=>{const[u,w]=i.split("::");if(u==="preset"){F(w);return}if(u==="include"){s({...e,[w]:!e[w]});return}if(u==="format"){s({...e,format:r});return}if(u==="timestamp"){s({...e,timestampFormat:r});return}if(u==="filter"){s({...e,filterMode:r});return}if(u==="threshold"){s({...e,dataSizeThreshold:r});return}},[e,s,F]);const I=m(()=>{const i=n.length;return a(Q,{expanded:T,onExpandedChange:H,summary:`${i} event${i!==1?"s":""} \xB7 ~${pe(v)}${!p?" (mock data)":""}`,warningLevel:C,warningText:{warning:"Large payload - preview may be slow",danger:"Very large payload - may cause performance issues"},testIDs:{expand:`${l}-preview-expand`,collapse:`${l}-preview-collapse`,summary:`${l}-preview-summary`,warning:`${l}-preview-size-warning`},renderBody:()=>{const r=y();return e.format==="json"?a(te,{testIDPrefix:`${l}-preview-json`,data:JSON.parse(r),title:"",showTypeFilter:true,rawMode:true,initialExpanded:true}):E(R,{children:[e.format==="mermaid"&&a(x,{style:d.mermaidHint,children:"\u{1F4A1} Paste into mermaid.live to visualize"}),a(M,{style:d.previewScroll,nestedScrollEnabled:true,testID:`${l}-preview-scroll`,children:a(x,{style:d.previewText,selectable:h,testID:`${l}-preview-text`,children:r})})]})}})},[T,n,e,v,C,p,y,h]);const O=m(()=>{const i=se(n);const r=p?`${i.totalEvents} events`:"Mock data (no events captured)";return E(de,{children:[a(x,{style:d.statusLabel,testID:`${l}-export-status`,children:r}),a(U,{value:y()})]})},[p,n,y]);const k=S(()=>({sections:[{id:"presets",title:"Presets",type:"custom",data:[{id:"preset::llm",label:t.llm.label,icon:G,color:t.llm.color,value:"llm",isActive:c==="llm",description:t.llm.description},{id:"preset::bugReport",label:t.bugReport.label,icon:W,color:t.bugReport.color,value:"bugReport",isActive:c==="bugReport",description:t.bugReport.description},{id:"preset::json",label:t.json.label,icon:L,color:t.json.color,value:"json",isActive:c==="json",description:t.json.description},{id:"preset::errors",label:t.errors.label,icon:j,color:t.errors.color,value:"errors",isActive:c==="errors",description:t.errors.description},{id:"preset::minimal",label:t.minimal.label,icon:q,color:t.minimal.color,value:"minimal",isActive:c==="minimal",description:t.minimal.description},{id:"preset::mermaid",label:t.mermaid.label,icon:B,color:t.mermaid.color,value:"mermaid",isActive:c==="mermaid",description:t.mermaid.description},{id:"preset::custom",label:"Custom",icon:K,color:g.color.textSecondary,value:"custom",isActive:c===null,description:"User-configured"}]},{id:"include",title:"Include",type:"custom",data:[{id:"include::includeSource",label:"Source",value:"includeSource",isActive:e.includeSource},{id:"include::includeStatus",label:"Status",value:"includeStatus",isActive:e.includeStatus},{id:"include::includeTitle",label:"Title",value:"includeTitle",isActive:e.includeTitle},{id:"include::includeSubtitle",label:"Subtitle",value:"includeSubtitle",isActive:e.includeSubtitle},{id:"include::includeCorrelation",label:"Correlation",value:"includeCorrelation",isActive:e.includeCorrelation},{id:"include::includeDuration",label:"Duration",value:"includeDuration",isActive:e.includeDuration},{id:"include::includeSummaryHeader",label:"Summary",value:"includeSummaryHeader",isActive:e.includeSummaryHeader},{id:"include::includeEventData",label:"Data",value:"includeEventData",isActive:e.includeEventData}]},{id:"format",title:"Format",type:"custom",data:[{id:"format::markdown",label:"Markdown",icon:q,color:f.semantic.info,value:"markdown",isActive:e.format==="markdown"},{id:"format::json",label:"JSON",icon:L,color:f.semantic.warning,value:"json",isActive:e.format==="json"},{id:"format::plaintext",label:"Text",icon:J,color:g.color.textSecondary,value:"plaintext",isActive:e.format==="plaintext"},{id:"format::mermaid",label:"Diagram",icon:B,color:"#A855F7",value:"mermaid",isActive:e.format==="mermaid",description:"Mermaid sequence diagram"}]},{id:"timestamp",title:"Timestamps",type:"custom",data:[{id:"timestamp::relative",label:"Relative",value:"relative",isActive:e.timestampFormat==="relative",description:"+0ms, +150ms"},{id:"timestamp::absolute",label:"Absolute",value:"absolute",isActive:e.timestampFormat==="absolute",description:"ISO format"},{id:"timestamp::both",label:"Both",value:"both",isActive:e.timestampFormat==="both",description:"Both formats"}]},{id:"filter",title:"Filter Events",type:"custom",data:[{id:"filter::all",label:"All",value:"all",isActive:e.filterMode==="all"},{id:"filter::errors",label:"Errors",icon:j,color:f.semantic.error,value:"errors",isActive:e.filterMode==="errors"},{id:"filter::success",label:"Success",color:f.semantic.success,value:"success",isActive:e.filterMode==="success"},{id:"filter::pending",label:"Pending",color:f.semantic.warning,value:"pending",isActive:e.filterMode==="pending"}]},{id:"llmOptimization",title:"LLM Optimization",type:"custom",data:[{id:"include::compactMode",label:"Compact",value:"compactMode",isActive:e.compactMode,description:"One line per event"},{id:"include::smartJsonParsing",label:"Smart JSON",value:"smartJsonParsing",isActive:e.smartJsonParsing,description:"Parse nested JSON"},{id:"include::reduxChangedOnly",label:"Redux Diff",value:"reduxChangedOnly",isActive:e.reduxChangedOnly,description:"Only show changes"},{id:"include::showStorageDiff",label:"Storage Diff",value:"showStorageDiff",isActive:e.showStorageDiff,description:"Show what changed"},{id:"include::stripVerboseFields",label:"Strip Noise",value:"stripVerboseFields",isActive:e.stripVerboseFields,description:"Remove images/descriptions"}]}],previewSection:{enabled:true,title:"PREVIEW",icon:Z,content:I,headerActions:O},onFilterChange:P}),[e,c,P,I,O]);if(!h){return E(M,{style:d.gatedContainer,contentContainerStyle:d.gatedContent,testID:`${l}-copy-settings-gated`,children:[a(X,{featureName:"Events Export",description:"Export event flows to share with your team, debug issues, or feed into AI tools.",benefits:["Export to Markdown, JSON, or plain text","Customizable presets (LLM-ready, Bug Report, JSON)","Share event flows with teammates","Feed event context directly to AI assistants"]}),a(R,{style:d.gatedPreview,children:a($,{...k})})]})}return a($,{...k})}const d=V.create({previewScroll:{maxHeight:300},previewText:{fontFamily:ee,fontSize:11,color:g.color.text,lineHeight:18},mermaidHint:{fontSize:11,color:g.color.textSecondary,marginBottom:8,paddingHorizontal:8,paddingVertical:6,backgroundColor:"#A855F715",borderRadius:6,overflow:"hidden"},statusLabel:{fontSize:11,fontWeight:"600",color:g.color.textTertiary,marginRight:8},gatedContainer:{flex:1},gatedContent:{padding:12,gap:12},gatedPreview:{}});