Skip to content

Commit

Permalink
feat: Add Spotlight (#60523)
Browse files Browse the repository at this point in the history
Co-authored-by: Abhijeet Prasad <aprasad@sentry.io>
  • Loading branch information
HazAT and AbhiPrasad committed Dec 7, 2023
1 parent eeca4a5 commit dba826f
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
"@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
"@sentry/jest-environment": "^4.0.0",
"@sentry/profiling-node": "^1.2.1",
"@spotlightjs/spotlight": "^1.0.0",
"@styled/typescript-styled-plugin": "^1.0.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^12.1.2",
Expand Down Expand Up @@ -203,7 +204,8 @@
"terser": "5.16.9",
"tocbot": "^4.20.0",
"tsconfig-paths": "^4.2.0",
"webpack-dev-server": "^4.15.1"
"webpack-dev-server": "^4.15.1",
"webpack-hook-plugin": "^1.0.7"
},
"optionalDependencies": {
"fsevents": "^2.3.2"
Expand Down
1 change: 1 addition & 0 deletions src/sentry/conf/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ def env(
]
CSP_CONNECT_SRC += [
"ws://127.0.0.1:8000",
"http://localhost:8969/stream",
]

# Before enforcing Content Security Policy, we recommend creating a separate
Expand Down
1 change: 1 addition & 0 deletions src/sentry/utils/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ def flush(
ThreadingIntegration(propagate_hub=True),
OpenAiIntegration(capture_prompts=True),
],
spotlight=settings.IS_DEV,
**sdk_options,
)

Expand Down
7 changes: 7 additions & 0 deletions static/app/bootstrap/initializeSdk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import {browserHistory, createRoutes, match} from 'react-router';
import {ExtraErrorData} from '@sentry/integrations';
import * as Sentry from '@sentry/react';
import * as Spotlight from '@spotlightjs/spotlight';
import {BrowserTracing} from '@sentry/react';
import {_browserPerformanceTimeOriginMode} from '@sentry/utils';
import {Event} from '@sentry/types';
Expand Down Expand Up @@ -169,6 +170,12 @@ export function initializeSdk(config: Config, {routes}: {routes?: Function} = {}
},
});

if (process.env.NODE_ENV !== 'production') {
if (sentryConfig.environment === 'development') {
/* #__PURE__ */ Spotlight.init();
}
}

// Event processor to fill the debug_meta field with debug IDs based on the
// files the error touched. (files inside the stacktrace)
const debugIdPolyfillEventProcessor = async (event: Event, hint: Sentry.EventHint) => {
Expand Down
1 change: 1 addition & 0 deletions static/app/types/system.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export interface Config {
dsn: string;
release: string;
tracePropagationTargets: string[];
environment?: string;
profilesSampleRate?: number;
};
singleOrganization: boolean;
Expand Down
7 changes: 7 additions & 0 deletions webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import webpack from 'webpack';
import {Configuration as DevServerConfig} from 'webpack-dev-server';
import WebpackHookPlugin from 'webpack-hook-plugin';
import FixStyleOnlyEntriesPlugin from 'webpack-remove-empty-scripts';

import IntegrationDocsFetchPlugin from './build-utils/integration-docs-fetch-plugin';
Expand Down Expand Up @@ -610,6 +611,12 @@ if (
},
};
appConfig.output!.publicPath = '/_static/dist/sentry/';

appConfig.plugins?.push(
new WebpackHookPlugin({
onBuildStart: ['yarn run spotlight-sidecar'],
})
);
}
}

Expand Down
23 changes: 23 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2701,6 +2701,24 @@
dependencies:
"@sinonjs/commons" "^2.0.0"

"@spotlightjs/overlay@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@spotlightjs/overlay/-/overlay-1.0.0.tgz#1fa67d3a631fc87db63eda931681ed4ac8df4203"
integrity sha512-PAytV9acAqF8UHFD4236eAMlvOrh46T14508UuhM4fTRKSpJPktNpm+EO5wIa1Z1V+DtycJRi93tskbm6H4Faw==

"@spotlightjs/sidecar@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@spotlightjs/sidecar/-/sidecar-1.0.0.tgz#fe5ef4909c065e15dd7bc9deaac692ca54871cfb"
integrity sha512-OVyIetoyF8+POvfLbKuW6U3+STjiudxF4ugpxwCWCM+KIp9ZMJNmtQyXAsxkCrXTbWVtt88Pj2duZRPsQiYr7Q==

"@spotlightjs/spotlight@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@spotlightjs/spotlight/-/spotlight-1.0.0.tgz#9d89096c3de2ad95d712e77999cafd82e59c65a3"
integrity sha512-cYeKHUt6ntR6assWnwzm5NlEKF70bGlXJnzDAbpyGKgyE5wIawwEzSj5Jq80/c7BOx4NrETxhJX+mX3y9hztrA==
dependencies:
"@spotlightjs/overlay" "1.0.0"
"@spotlightjs/sidecar" "1.0.0"

"@styled/typescript-styled-plugin@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@styled/typescript-styled-plugin/-/typescript-styled-plugin-1.0.0.tgz#82723b57c2a49cfb4bb7ea456cd7350474ae423a"
Expand Down Expand Up @@ -11561,6 +11579,11 @@ webpack-dev-server@^4.15.1:
webpack-dev-middleware "^5.3.1"
ws "^8.13.0"

webpack-hook-plugin@^1.0.7:
version "1.0.7"
resolved "https://registry.yarnpkg.com/webpack-hook-plugin/-/webpack-hook-plugin-1.0.7.tgz#689c2a24e16df247be91d8649e9da048774308ec"
integrity sha512-8GJ+LiR+0rrShCSeeFMaKONX7xMMW3H9Hszmy5IsCereZUJ5AoLhJgn5BhySQChA4Q5lZ7/9KtidDypYHQDDmA==

webpack-merge@^5.7.3:
version "5.7.3"
resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-5.7.3.tgz#2a0754e1877a25a8bbab3d2475ca70a052708213"
Expand Down

0 comments on commit dba826f

Please sign in to comment.