@spotlightjs/overlay 2.0.0 → 2.2.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 (25) hide show
  1. package/dist/{index-5682ce90.js → index-2dea620f.js} +6676 -6479
  2. package/dist/index-2dea620f.js.map +1 -0
  3. package/dist/{main-3257b7fc.js → main-d5f617e5.js} +2 -2
  4. package/dist/{main-3257b7fc.js.map → main-d5f617e5.js.map} +1 -1
  5. package/dist/sentry-spotlight.js +20 -14
  6. package/dist/sentry-spotlight.umd.cjs +129 -129
  7. package/dist/sentry-spotlight.umd.cjs.map +1 -1
  8. package/dist/src/index.d.ts +7 -12
  9. package/dist/src/integrations/integration.d.ts +2 -1
  10. package/dist/src/integrations/sentry/components/traces/spans/SpanItem.d.ts +2 -1
  11. package/dist/src/integrations/sentry/components/traces/spans/SpanTree.d.ts +2 -1
  12. package/dist/src/integrations/sentry/components/traces/traceDetail/TraceDetailHeader.d.ts +4 -0
  13. package/dist/src/integrations/sentry/components/traces/traceDetail/index.d.ts +1 -0
  14. package/dist/src/integrations/sentry/components/traces/traceInfo/TraceGeneralInfo.d.ts +6 -0
  15. package/dist/src/integrations/sentry/components/traces/traceInfo/TraceTags.d.ts +6 -0
  16. package/dist/src/integrations/sentry/components/traces/traceInfo/index.d.ts +6 -0
  17. package/dist/src/integrations/sentry/data/sentryDataCache.d.ts +11 -3
  18. package/dist/src/integrations/sentry/data/sentryEventsContext.d.ts +1 -1
  19. package/dist/src/integrations/sentry/hooks/useDebounce.d.ts +1 -0
  20. package/dist/src/integrations/sentry/index.d.ts +8 -0
  21. package/dist/src/integrations/sentry/sentry-integration.d.ts +2 -7
  22. package/dist/src/integrations/sentry/utils/fetch.d.ts +6 -0
  23. package/dist/src/lib/eventTarget.d.ts +11 -0
  24. package/package.json +4 -3
  25. package/dist/index-5682ce90.js.map +0 -1
@@ -1,10 +1,14 @@
1
+ import { CONTEXT_LINES_ENDPOINT } from '@spotlightjs/sidecar/constants';
2
+ import { DEFAULT_ANCHOR, DEFAULT_EXPERIMENTS, DEFAULT_SIDECAR_URL } from './constants.ts';
3
+ import { off, on, trigger } from './lib/eventTarget.ts';
1
4
  import { React, ReactDOM } from './react-instance.tsx';
2
5
  import { SpotlightOverlayOptions } from './types.ts';
3
6
  export { default as console } from './integrations/console/index.ts';
4
7
  export { default as hydrationError } from './integrations/hydration-error/index.ts';
5
8
  export { default as sentry } from './integrations/sentry/index.ts';
6
9
  export { default as viteInspect } from './integrations/vite-inspect/index.ts';
7
- export { React, ReactDOM };
10
+ export type { SpotlightOverlayOptions, WindowWithSpotlight } from './types.ts';
11
+ export { CONTEXT_LINES_ENDPOINT, DEFAULT_ANCHOR, DEFAULT_EXPERIMENTS, DEFAULT_SIDECAR_URL, React, ReactDOM, off, on, trigger, };
8
12
  /**
9
13
  * Open the Spotlight debugger Window
10
14
  */
@@ -16,24 +20,15 @@ export declare function closeSpotlight(): Promise<void>;
16
20
  /**
17
21
  * Invokes the passed in callback when the Spotlight debugger Window is closed
18
22
  */
19
- export declare function onClose(cb: () => void): Promise<void>;
23
+ export declare function onClose(cb: EventListener): Promise<void>;
20
24
  /**
21
25
  * Invokes the passed in callback when the Spotlight debugger Window is opened
22
26
  */
23
- export declare function onOpen(cb: () => void): Promise<void>;
27
+ export declare function onOpen(cb: EventListener): Promise<void>;
24
28
  /**
25
29
  * Register a callback that is invoked when a severe event is processed
26
30
  * by a Spotlight integration.
27
31
  * A count of the number of collected severe events is passed to the callback.
28
32
  */
29
33
  export declare function onSevereEvent(cb: (count: number) => void): Promise<void>;
30
- /**
31
- * Trigger an event in Spotlight.
32
- *
33
- * This is primarily useful for handling an uncaught error/crash, and forcing the debugger
34
- * to render vs a native error handler.
35
- *
36
- * e.g. trigger("sentry.showError", {eventId});
37
- */
38
- export declare function trigger(eventName: string, payload: unknown): Promise<void>;
39
34
  export declare function init({ openOnInit, showTriggerButton, injectImmediately, sidecarUrl, anchor, debug, integrations, experiments, fullPage, showClearEventsButton, }?: SpotlightOverlayOptions): Promise<void>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { type ComponentType } from 'react';
2
3
  import { type ExperimentsConfig, type NotificationCount } from '../types';
3
4
  export type SpotlightContext = {
@@ -94,7 +95,7 @@ export type RawEventContext = {
94
95
  *
95
96
  * Return the processed object or undefined if the event should be ignored.
96
97
  */
97
- data: string;
98
+ data: string | Buffer;
98
99
  };
99
100
  type TeardownFunction = () => void | Promise<() => void>;
100
101
  export declare function initIntegrations(integrations: Integration<any>[] | undefined, context: SpotlightContext): Promise<[Integration[], TeardownFunction[]]>;
@@ -1,5 +1,5 @@
1
1
  import { Span, TraceContext } from '../../../types';
2
- declare const SpanItem: ({ span, startTimestamp, totalDuration, depth, traceContext, totalTransactions, spanNodeWidth, setSpanNodeWidth, }: {
2
+ declare const SpanItem: ({ span, startTimestamp, totalDuration, depth, traceContext, totalTransactions, spanNodeWidth, setSpanNodeWidth, query, }: {
3
3
  span: Span;
4
4
  startTimestamp: number;
5
5
  totalDuration: number;
@@ -8,5 +8,6 @@ declare const SpanItem: ({ span, startTimestamp, totalDuration, depth, traceCont
8
8
  totalTransactions?: number | undefined;
9
9
  spanNodeWidth: number;
10
10
  setSpanNodeWidth?: ((val: number) => void) | undefined;
11
+ query?: string | undefined;
11
12
  }) => import("react/jsx-runtime").JSX.Element;
12
13
  export default SpanItem;
@@ -1,5 +1,5 @@
1
1
  import { Span, TraceContext } from '../../../types';
2
- export default function SpanTree({ traceContext, tree, startTimestamp, totalDuration, depth, totalTransactions, spanNodeWidth, setSpanNodeWidth, }: {
2
+ export default function SpanTree({ traceContext, tree, startTimestamp, totalDuration, depth, totalTransactions, spanNodeWidth, setSpanNodeWidth, query, }: {
3
3
  traceContext: TraceContext;
4
4
  tree: Span[];
5
5
  startTimestamp: number;
@@ -8,4 +8,5 @@ export default function SpanTree({ traceContext, tree, startTimestamp, totalDura
8
8
  totalTransactions?: number;
9
9
  spanNodeWidth: number;
10
10
  setSpanNodeWidth?: (val: number) => void;
11
+ query?: string;
11
12
  }): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,4 @@
1
+ import { Trace } from '../../../../../integrations/sentry/types';
2
+ export default function TraceDetailHeader({ trace }: {
3
+ trace: Trace;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function TraceDetails(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { Trace } from '../../../../../integrations/sentry/types';
2
+ type TraceGeneralInfoProps = {
3
+ trace: Trace;
4
+ };
5
+ export default function TraceGeneralInfo({ trace }: TraceGeneralInfoProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,6 @@
1
+ import { Trace } from '../../../../../integrations/sentry/types';
2
+ type TraceTagsProps = {
3
+ trace: Trace;
4
+ };
5
+ export default function TraceTags({ trace }: TraceTagsProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,6 @@
1
+ import { TraceContext } from '../../../types';
2
+ type TraceInfoProps = {
3
+ traceContext: TraceContext;
4
+ };
5
+ export default function TraceInfo({ traceContext }: TraceInfoProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { Envelope } from '@sentry/types';
2
2
  import { RawEventContext } from '../../../integrations/integration';
3
- import { Sdk, SentryEvent, Span, Trace } from '../types';
3
+ import { Sdk, SentryErrorEvent, SentryEvent, Span, Trace } from '../types';
4
4
  type OnlineSubscription = ['online', (status: boolean) => void];
5
5
  type EventSubscription = ['event', (event: SentryEvent) => void];
6
6
  type TraceSubscription = ['trace', (trace: Trace) => void];
@@ -19,17 +19,19 @@ declare class SentryDataCache {
19
19
  rawEnvelope: RawEventContext;
20
20
  }[];
21
21
  protected subscribers: Map<string, Subscription>;
22
+ protected contextLinesProvider: string;
22
23
  constructor(initial?: (SentryEvent & {
23
24
  event_id?: string;
24
25
  })[]);
26
+ setSidecarUrl(url: string): void;
25
27
  inferSdkFromEvent(event: SentryEvent): Sdk;
26
28
  pushEnvelope({ envelope, rawEnvelope }: {
27
29
  envelope: Envelope;
28
30
  rawEnvelope: RawEventContext;
29
- }): void;
31
+ }): number;
30
32
  pushEvent(event: SentryEvent & {
31
33
  event_id?: string;
32
- }): void;
34
+ }): Promise<void>;
33
35
  getEvents(): SentryEvent[];
34
36
  getTraces(): Trace[];
35
37
  getSdks(): Sdk[];
@@ -56,6 +58,12 @@ declare class SentryDataCache {
56
58
  * information about any session-initiated traces.
57
59
  */
58
60
  isTraceLocal(traceId: string): boolean | null;
61
+ /**
62
+ * Reverses the stack trace and tries to fill missing context lines
63
+ * @param errorEvent
64
+ * @returns
65
+ */
66
+ processStacktrace(errorEvent: SentryErrorEvent): Promise<void[]>;
59
67
  }
60
68
  declare const _default: SentryDataCache;
61
69
  export default _default;
@@ -1,6 +1,6 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import React from 'react';
3
- import { SentryEvent } from '../types';
3
+ import type { SentryEvent } from '../types';
4
4
  interface SetEventsAction {
5
5
  e: SentryEvent | SentryEvent[];
6
6
  action: string;
@@ -0,0 +1 @@
1
+ export default function useDebounce<T extends (...args: any[]) => void>(callback: T, delay: number): (...args: Parameters<T>) => void;
@@ -6,6 +6,8 @@ import TracesTab from './tabs/TracesTab';
6
6
  type SentryIntegrationOptions = {
7
7
  sidecarUrl?: string;
8
8
  injectIntoSDK?: boolean;
9
+ openLastError?: boolean;
10
+ retries?: number;
9
11
  };
10
12
  export default function sentryIntegration(options?: SentryIntegrationOptions): {
11
13
  name: string;
@@ -39,6 +41,12 @@ export default function sentryIntegration(options?: SentryIntegrationOptions): {
39
41
  })[];
40
42
  reset: () => void;
41
43
  };
44
+ /**
45
+ * Implements parser for
46
+ * @see https://develop.sentry.dev/sdk/envelopes/#serialization-format
47
+ * @param rawEvent Envelope data
48
+ * @returns parsed envelope
49
+ */
42
50
  export declare function processEnvelope(rawEvent: RawEventContext): {
43
51
  event: Envelope;
44
52
  rawEvent: RawEventContext;
@@ -2,9 +2,9 @@ import { Client, Event } from '@sentry/types';
2
2
  type SpotlightBrowserIntegrationOptions = {
3
3
  /**
4
4
  * The URL of the Sidecar instance to connect and forward events to.
5
- * If not set, Spotlight will try to connect to the Sidecar running on localhost:8969.
5
+ * If not set, Spotlight will try to connect to the Sidecar running on DEFAULT_SIDECAR_URL.
6
6
  *
7
- * @default "http://localhost:8969/stream"
7
+ * @default DEFAULT_SIDECAR_URL
8
8
  */
9
9
  sidecarUrl?: string;
10
10
  };
@@ -29,9 +29,4 @@ export declare const spotlightIntegration: (options?: SpotlightBrowserIntegratio
29
29
  processEvent: (event: Event) => Promise<Event | null>;
30
30
  afterAllSetup: (client: Client) => void;
31
31
  };
32
- type FetchImpl = typeof fetch;
33
- /**
34
- * We want to get an unpatched fetch implementation to avoid capturing our own calls.
35
- */
36
- export declare function getNativeFetchImplementation(): FetchImpl;
37
32
  export {};
@@ -0,0 +1,6 @@
1
+ type FetchImpl = typeof fetch;
2
+ /**
3
+ * We want to get an unpatched fetch implementation to avoid capturing our own calls.
4
+ */
5
+ export declare function getNativeFetchImplementation(): FetchImpl;
6
+ export {};
@@ -11,3 +11,14 @@
11
11
  * which is local to one spotlight code instance.
12
12
  */
13
13
  export declare function getSpotlightEventTarget(): EventTarget;
14
+ /**
15
+ * Trigger an event in Spotlight.
16
+ *
17
+ * This is primarily useful for handling an uncaught error/crash, and forcing the debugger
18
+ * to render vs a native error handler.
19
+ *
20
+ * e.g. trigger("sentry.showError", {eventId});
21
+ */
22
+ export declare function trigger(eventName: string, payload?: unknown): Promise<void>;
23
+ export declare function on(eventName: string, cb: EventListener): Promise<void>;
24
+ export declare function off(eventName: string, cb: EventListener): Promise<void>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spotlightjs/overlay",
3
3
  "description": "The overlay of Spotlight to add debug interface to your web app.",
4
- "version": "2.0.0",
4
+ "version": "2.2.0",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "files": [
@@ -30,7 +30,7 @@
30
30
  "eslint-plugin-react-hooks": "^4.6.0",
31
31
  "eslint-plugin-react-refresh": "^0.4.3",
32
32
  "typescript": "^5.0.2",
33
- "vite": "^4.5.2",
33
+ "vite": "^4.5.3",
34
34
  "vite-plugin-dts": "^3.5.2",
35
35
  "vite-plugin-svgr": "^3.2.0",
36
36
  "vitest": "^0.34.6",
@@ -50,7 +50,8 @@
50
50
  "react-diff-viewer-continued": "^3.4.0",
51
51
  "@types/beautify": "^0.0.3",
52
52
  "react-json-view": "^1.21.3",
53
- "@spotlightjs/tsconfig": "1.0.0"
53
+ "@spotlightjs/tsconfig": "1.0.0",
54
+ "@spotlightjs/sidecar": "1.6.0"
54
55
  },
55
56
  "volta": {
56
57
  "extends": "../../package.json"