mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-08 09:53:20 +02:00
Sentry updates
This commit is contained in:
@@ -358,7 +358,7 @@ export class Dashboard {
|
||||
version.usedVersion ? '' : `data-showWelcome="true"`
|
||||
} ${
|
||||
experimental ? `data-experimental="${experimental}"` : ''
|
||||
} data-webview-url="${webviewUrl}" ></div>
|
||||
} data-webview-url="${webviewUrl}" data-is-crash-disabled="${!Telemetry.isVscodeEnabled()}" ></div>
|
||||
|
||||
${(scriptsToLoad || [])
|
||||
.map((script) => {
|
||||
|
||||
@@ -3,8 +3,6 @@ import { render } from 'react-dom';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
import { App } from './components/App';
|
||||
import * as Sentry from '@sentry/react';
|
||||
import { Integrations } from '@sentry/tracing';
|
||||
import { SENTRY_LINK, SentryIgnore } from '../constants';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import './styles.css';
|
||||
import { Preview } from './components/Preview';
|
||||
@@ -13,6 +11,7 @@ import { CustomPanelViewResult } from '../models';
|
||||
import { Chatbot } from './components/Chatbot/Chatbot';
|
||||
import { updateCssVariables } from './utils';
|
||||
import { I10nProvider } from './providers/I10nProvider';
|
||||
import { SentryInit } from '../utils/sentryInit';
|
||||
|
||||
declare const acquireVsCodeApi: <T = unknown>() => {
|
||||
getState: () => T;
|
||||
@@ -65,19 +64,13 @@ if (elm) {
|
||||
const url = elm?.getAttribute('data-url');
|
||||
const experimental = elm?.getAttribute('data-experimental');
|
||||
const webviewUrl = elm?.getAttribute('data-webview-url');
|
||||
const isCrashDisabled = elm?.getAttribute('data-is-crash-disabled');
|
||||
|
||||
updateCssVariables();
|
||||
mutationObserver.observe(document.body, { childList: false, attributes: true });
|
||||
|
||||
if (isProd === 'true') {
|
||||
Sentry.init({
|
||||
dsn: SENTRY_LINK,
|
||||
integrations: [new Integrations.BrowserTracing()],
|
||||
tracesSampleRate: 0, // No performance tracing required
|
||||
release: version || '',
|
||||
environment: environment || '',
|
||||
ignoreErrors: SentryIgnore
|
||||
});
|
||||
if (isProd === 'true' && isCrashDisabled === 'false') {
|
||||
Sentry.init(SentryInit(version, environment));
|
||||
|
||||
Sentry.setTag("type", "dashboard");
|
||||
if (document.body.getAttribute(`data-vscode-theme-id`)) {
|
||||
|
||||
@@ -24,6 +24,24 @@ export class Telemetry {
|
||||
return Telemetry.instance;
|
||||
}
|
||||
|
||||
public static isVscodeEnabled(): boolean {
|
||||
const config = workspace.getConfiguration('telemetry');
|
||||
const isVscodeEnable = config.get<'off' | undefined>('enableTelemetry');
|
||||
return isVscodeEnable === 'off' ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if telemetry is enabled.
|
||||
* @returns {boolean} Returns true if telemetry is enabled, false otherwise.
|
||||
*/
|
||||
public static isEnabled(): boolean {
|
||||
const isVscodeEnable = Telemetry.isVscodeEnabled();
|
||||
|
||||
const isDisabled = Settings.get<boolean>(SETTING_TELEMETRY_DISABLE);
|
||||
|
||||
return isDisabled || isVscodeEnable ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send metrics to our own database
|
||||
* @param eventName
|
||||
@@ -31,11 +49,7 @@ export class Telemetry {
|
||||
* @returns
|
||||
*/
|
||||
public static send(eventName: string, properties?: any) {
|
||||
const config = workspace.getConfiguration('telemetry');
|
||||
const isVscodeEnable = config.get<'off' | undefined>('enableTelemetry');
|
||||
|
||||
const isDisabled = Settings.get<boolean>(SETTING_TELEMETRY_DISABLE);
|
||||
if (isDisabled || isVscodeEnable === 'off') {
|
||||
if (!Telemetry.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -286,7 +286,9 @@ export class PanelProvider implements WebviewViewProvider, Disposable {
|
||||
<body>
|
||||
<div id="app" data-isProd="${isProd}" data-environment="${
|
||||
isBeta ? 'BETA' : 'main'
|
||||
}" data-version="${version.usedVersion}"></div>
|
||||
}" data-version="${
|
||||
version.usedVersion
|
||||
}" data-is-crash-disabled="${!Telemetry.isVscodeEnabled()}"></div>
|
||||
|
||||
${(scriptsToLoad || [])
|
||||
.map((script) => {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import * as React from 'react';
|
||||
import * as Sentry from '@sentry/react';
|
||||
import { render } from 'react-dom';
|
||||
import { ViewPanel } from './ViewPanel';
|
||||
import * as Sentry from '@sentry/react';
|
||||
import { Integrations } from '@sentry/tracing';
|
||||
import { SENTRY_LINK, SentryIgnore } from '../constants';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
import { I10nProvider } from '../dashboardWebView/providers/I10nProvider';
|
||||
import { SentryInit } from '../utils/sentryInit';
|
||||
|
||||
import './styles.css';
|
||||
|
||||
@@ -17,7 +17,6 @@ import '@bendera/vscode-webview-elements/dist/vscode-table-row.js';
|
||||
import '@bendera/vscode-webview-elements/dist/vscode-table-cell.js';
|
||||
import '@bendera/vscode-webview-elements/dist/vscode-collapsible.js';
|
||||
import '@bendera/vscode-webview-elements/dist/vscode-label.js';
|
||||
import { I10nProvider } from '../dashboardWebView/providers/I10nProvider';
|
||||
// import '@bendera/vscode-webview-elements/dist/vscode-checkbox.js';
|
||||
|
||||
// import '@vscode/webview-ui-toolkit/dist/esm/checkbox';
|
||||
@@ -34,16 +33,10 @@ if (elm) {
|
||||
const version = elm?.getAttribute('data-version');
|
||||
const environment = elm?.getAttribute('data-environment');
|
||||
const isProd = elm?.getAttribute('data-isProd');
|
||||
const isCrashDisabled = elm?.getAttribute('data-is-crash-disabled');
|
||||
|
||||
if (isProd === 'true') {
|
||||
Sentry.init({
|
||||
dsn: SENTRY_LINK,
|
||||
integrations: [new Integrations.BrowserTracing()],
|
||||
tracesSampleRate: 0, // No performance tracing required
|
||||
release: version || '',
|
||||
environment: environment || '',
|
||||
ignoreErrors: SentryIgnore
|
||||
});
|
||||
if (isProd === 'true' && isCrashDisabled === 'false') {
|
||||
Sentry.init(SentryInit(version, environment));
|
||||
|
||||
Sentry.setTag("type", "panel");
|
||||
if (document.body.getAttribute(`data-vscode-theme-id`)) {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import * as Sentry from '@sentry/react';
|
||||
import { Integrations } from '@sentry/tracing';
|
||||
import { SENTRY_LINK, SentryIgnore } from '../constants';
|
||||
|
||||
export const SentryInit = (
|
||||
version: string | null,
|
||||
environment: string | null
|
||||
): Sentry.BrowserOptions => ({
|
||||
dsn: SENTRY_LINK,
|
||||
integrations: [new Integrations.BrowserTracing()],
|
||||
tracesSampleRate: 0, // No performance tracing required
|
||||
release: version || '',
|
||||
environment: environment || '',
|
||||
ignoreErrors: SentryIgnore,
|
||||
beforeSend(event) {
|
||||
if (event.user) {
|
||||
delete event.user.ip_address;
|
||||
}
|
||||
return event;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user