Skip to content

Commit

Permalink
add replay
Browse files Browse the repository at this point in the history
.
  • Loading branch information
denysoblohin-okta committed Jun 30, 2023
1 parent c488701 commit d952f63
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
7 changes: 7 additions & 0 deletions scripts/buildtools/webpack/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const fs = require('fs-extra');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const EventHooksPlugin = require('event-hooks-webpack-plugin');
const { sentryWebpackPlugin } = require("@sentry/webpack-plugin");

function webpackBundleAnalyzer(reportFilename = 'okta-sign-in.analyzer') {
// OKTA-429162: webpack-bundle-analyzer does not report bundled modules stats after upgrade to webpack@5
Expand Down Expand Up @@ -88,6 +89,12 @@ function plugins(options = {}) {
list.push(webpackBundleAnalyzer(options.analyzerFile));
}

list.push(sentryWebpackPlugin({
org: "okta-24",
project: "siw-v2-demo-1",
authToken: process.env.SENTRY_AUTH_TOKEN,
}));

return list;
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/Logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
function log(level, args) {
// Only log statements in development mode or if
// throwing an error through console.error
if (DEBUG || level === 'error') {
if (level === 'error') {
window.console[level].apply(window.console, args);
}
}
Expand Down
42 changes: 37 additions & 5 deletions src/util/Sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import AppState from 'v2/models/AppState';
import omit from 'lodash/omit';
import pick from 'lodash/pick';

const SENTRY_DSN = 'https://3aeb188c43df4230921b7bf857b8ac83@o4505233867538432.ingest.sentry.io/4505268101120000';
//const SENTRY_DSN = 'https://3aeb188c43df4230921b7bf857b8ac83@o4505233867538432.ingest.sentry.io/4505268101120000'; // siw6
const SENTRY_DSN = 'https://0014e1b37cf7473d977b85aea504af70@o4505233867538432.ingest.sentry.io/4505448311816192'; // siw-v2-demo-1

// https://okta-24.sentry.io/settings/projects/siw6/security-and-privacy/
// Safe fields in project config:
// currentAuthenticator
// currentAuthenticatorEnrollment
Expand All @@ -26,15 +28,41 @@ export const initSentry = () => {
normalizeDepth: 10, // to view structured context data instead of "[Object]", "[Array]"
integrations: [
new Sentry.BrowserTracing(),
// Replay
new Sentry.Replay({
networkDetailAllowUrls: [
'http://localhost:3000/idp/idx/'
],
beforeAddRecordingEvent: (e) => {
if (e.data.tag == 'breadcrumb') {
console.log('@@@ [replay]', e?.data?.tag, e?.data?.payload?.category, e)
}
return e;
},
// https://github.com/denysoblohin-okta/sentry-javascript/pull/1
filterNetwork: (info: any) => {
if (info?.body?.stateHandle) {
info.body.stateHandle = '!!! Filtered';
}
if (info?.body?.identifier) {
info.body.identifier = '!!! Filtered';
}
if (info?.body?.credentials) {
info.body.credentials = '!!! Filtered';
}
console.log('@@@ [replay] fetch: ', info);
return info;
}
}),
],
// Performance Monitoring
tracesSampleRate: 0.0, // disable

// Replay
replaysSessionSampleRate: 1.0,
replaysOnErrorSampleRate: 1.0,

// Hooks
beforeSendTransaction(_event, _hint) {
// don't send session replay data
return null;
},
beforeBreadcrumb(breadcrumb, _hint) {
// Filter breadcrumbs
// - Filter out console logs, use `custom` breadcrumbs instead
Expand All @@ -45,10 +73,14 @@ export const initSentry = () => {
|| breadcrumb.category.startsWith('ui.')
|| breadcrumb.category.startsWith('sentry.')
|| breadcrumb.category === 'custom';
if (allow) {
console.log('>>> [sentry] breadcrumb: ', breadcrumb.type, breadcrumb.category, breadcrumb);
}
return allow ? breadcrumb : null;
},
beforeSend(event, _hint) {
// delete event.breadcrumbs;
console.log('>>> [sentry] event: ', event);
return event;
},
});
Expand Down

0 comments on commit d952f63

Please sign in to comment.