Skip to content

Commit 79bd11a

Browse files
committed
env sentry props ara available vis static config
1 parent c8cfd4f commit 79bd11a

5 files changed

Lines changed: 30 additions & 7 deletions

File tree

src/container.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { SentryConfigs } from 'src/util/sentryConfig';
12
import { v4 } from 'uuid';
23
import { env, ExtensionContext, languages, UIKind } from 'vscode';
34
import * as vscode from 'vscode';
@@ -266,18 +267,16 @@ export class Container {
266267
// Initialize Sentry for error tracking
267268

268269
const sentryConfig: SentryConfig = {
269-
enabled: process.env.SENTRY_ENABLED === 'true',
270+
enabled: SentryConfigs.enabled === 'true',
270271
featureFlagEnabled: this.featureFlagClient.checkGate(Features.SentryLogging),
271-
dsn: process.env.SENTRY_DSN,
272-
environment: process.env.SENTRY_ENVIRONMENT || 'development',
273-
sampleRate: parseFloat(process.env.SENTRY_SAMPLE_RATE || '1.0'),
272+
dsn: SentryConfigs.dsn,
273+
environment: SentryConfigs.environment || 'development',
274+
sampleRate: SentryConfigs.sampleRate || 1.0,
274275
atlasCodeVersion: version,
275276
};
276-
277277
await SentryService.getInstance().initialize(sentryConfig, (error: string) => {
278278
this.analyticsApi.fireSentryCapturedExceptionFailedEvent({ error });
279279
});
280-
Logger.info('Sentry initialized successfully');
281280
}
282281

283282
private static async initializeFeatureFlagClient() {

src/logger.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ export class Logger {
160160
params,
161161
},
162162
});
163+
Logger.info('Error reported to Sentry successfully', ex);
163164
} catch (err) {
164165
console.error('Error reporting to Sentry:', err);
165166
}

src/sentry.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as Sentry from '@sentry/node';
99
import { extensions } from 'vscode';
1010

1111
import { ExtensionId } from './constants';
12+
import { Logger } from './logger';
1213
import { RovodevStaticConfig } from './rovo-dev/api/rovodevStaticConfig';
1314

1415
export interface SentryConfig {
@@ -49,11 +50,16 @@ export class SentryService {
4950
* @param config - Sentry configuration
5051
*/
5152
public async initialize(config: SentryConfig, analyticsCallback?: (error: string) => void): Promise<void> {
53+
Logger.info('Sentry trying to be initialized for Node.js environment.');
54+
5255
// If not enabled, silently return without initializing
5356
if (!config.enabled || !config.dsn || !config.featureFlagEnabled) {
57+
Logger.info(
58+
'Sentry not enabled or missing configuration, skipping initialization.',
59+
JSON.stringify(config),
60+
);
5461
return;
5562
}
56-
5763
this.analyticsCallback = analyticsCallback;
5864

5965
try {
@@ -67,10 +73,12 @@ export class SentryService {
6773
tracesSampleRate: 0, // Disable transaction tracing
6874
});
6975
this.sentryClient = Sentry;
76+
Logger.info('Sentry initialized for Node.js environment.');
7077

7178
this.initialized = true;
7279
} catch (error) {
7380
// Silently fail - don't break extension startup
81+
Logger.info(new Error('Failed to initialize Sentry:'), error);
7482
console.error('Failed to initialize Sentry:', error);
7583
this.initialized = false;
7684
}

src/util/sentryConfig.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Sentry static configuration for AtlasCode.
3+
*/
4+
export const SentryConfigs = {
5+
enabled: process.env.SENTRY_ENABLED || '',
6+
dsn: process.env.SENTRY_DSN || '',
7+
environment: process.env.SENTRY_ENVIRONMENT || '',
8+
sampleRate: Number(process.env.SENTRY_SAMPLE_RATE) || 1000,
9+
} as const;

webpack.env.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ const ENV_VARS = [
1818

1919
// Is this BBY? (set to "true" if this is a special internal build)
2020
'ROVODEV_BBY',
21+
22+
// Sentry configuration
23+
'SENTRY_ENABLED',
24+
'SENTRY_DSN',
25+
'SENTRY_ENVIRONMENT',
26+
'SENTRY_SAMPLE_RATE',
2127
];
2228

2329
function createEnvPlugin({ nodeEnv, isBrowser = false }) {

0 commit comments

Comments
 (0)