Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

feat(web): add support for sentry and pylon (#11495)

Vikrant Guptac6b2fe47d51e
diff --git a/conf/example.yaml b/conf/example.yaml
index 01de105c5c..c6a3b7dbc8 100644
--- a/conf/example.yaml
+++ b/conf/example.yaml
@@ -68,6 +68,12 @@ web:
appcues:
# Whether to enable Appcues in web.
enabled: true
+ sentry:
+ # Whether to enable Sentry in web.
+ enabled: true
+ pylon:
+ # Whether to enable Pylon in web.
+ enabled: true
##################### Cache #####################
cache:
diff --git a/docs/config/web-settings.json b/docs/config/web-settings.json
index 4ae155c359..ae7ad166c1 100644
--- a/docs/config/web-settings.json
+++ b/docs/config/web-settings.json
@@ -1,7 +1,9 @@
{
"required": [
"posthog",
- "appcues"
+ "appcues",
+ "sentry",
+ "pylon"
],
"additionalProperties": false,
"definitions": {
@@ -28,6 +30,30 @@
}
},
"type": "object"
+ },
+ "Pylon": {
+ "required": [
+ "enabled"
+ ],
+ "additionalProperties": false,
+ "properties": {
+ "enabled": {
+ "type": "boolean"
+ }
+ },
+ "type": "object"
+ },
+ "Sentry": {
+ "required": [
+ "enabled"
+ ],
+ "additionalProperties": false,
+ "properties": {
+ "enabled": {
+ "type": "boolean"
+ }
+ },
+ "type": "object"
}
},
"properties": {
@@ -36,6 +62,12 @@
},
"posthog": {
"$ref": "#/definitions/Posthog"
+ },
+ "pylon": {
+ "$ref": "#/definitions/Pylon"
+ },
+ "sentry": {
+ "$ref": "#/definitions/Sentry"
}
},
"type": "object"
diff --git a/frontend/src/AppRoutes/index.tsx b/frontend/src/AppRoutes/index.tsx
index ea8172c565..ca290d291d 100644
--- a/frontend/src/AppRoutes/index.tsx
+++ b/frontend/src/AppRoutes/index.tsx
@@ -35,7 +35,6 @@ import { PreferenceContextProvider } from 'providers/preferences/context/Prefere
import { QueryBuilderProvider } from 'providers/QueryBuilder';
import { LicenseStatus } from 'types/api/licensesV3/getActive';
import { extractDomain } from 'utils/app';
-import { bootSettings } from 'utils/bootData';
import { Home } from './pageComponents';
import PrivateRoute from './Private';
@@ -334,7 +333,10 @@ function App(): JSX.Element {
useEffect(() => {
if (isCloudUser || isEnterpriseSelfHostedUser) {
- if (bootSettings.posthog.enabled && process.env.POSTHOG_KEY) {
+ if (
+ (window.signozBootData?.settings?.posthog.enabled ?? true) &&
+ process.env.POSTHOG_KEY
+ ) {
posthog.init(process.env.POSTHOG_KEY, {
api_host: 'https://us.i.posthog.com',
person_profiles: 'identified_only', // or 'always' to create profiles for anonymous users as well
diff --git a/frontend/src/types/generated/webSettings.ts b/frontend/src/types/generated/webSettings.ts
index 52125098cd..fd73568d9f 100644
--- a/frontend/src/types/generated/webSettings.ts
+++ b/frontend/src/types/generated/webSettings.ts
@@ -3,6 +3,8 @@
export interface WebSettings {
appcues: Appcues;
posthog: Posthog;
+ pylon: Pylon;
+ sentry: Sentry;
}
export interface Appcues {
enabled: boolean;
@@ -10,3 +12,9 @@ export interface Appcues {
export interface Posthog {
enabled: boolean;
}
+export interface Pylon {
+ enabled: boolean;
+}
+export interface Sentry {
+ enabled: boolean;
+}
diff --git a/frontend/src/utils/__tests__/bootData.test.ts b/frontend/src/utils/__tests__/bootData.test.ts
deleted file mode 100644
index e9b6b47346..0000000000
--- a/frontend/src/utils/__tests__/bootData.test.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-export {};
-
-type BootData = typeof import('../bootData');
-
-function loadModule(settings?: object | null): BootData {
- (window as any).signozBootData =
- settings !== undefined ? { settings } : undefined;
- let mod!: BootData;
- jest.isolateModules(() => {
- // oxlint-disable-next-line typescript-eslint/no-require-imports, typescript-eslint/no-var-requires
- mod = require('../bootData');
- });
- return mod;
-}
-
-afterEach(() => {
- delete (window as any).signozBootData;
-});
-
-describe('when window.signozBootData is absent', () => {
- it('defaults posthog and appcues to enabled', () => {
- const { bootSettings } = loadModule();
- expect(bootSettings.posthog.enabled).toBe(true);
- expect(bootSettings.appcues.enabled).toBe(true);
- });
-});
-
-describe('when window.signozBootData.settings is null (injection failed)', () => {
- it('defaults posthog and appcues to enabled', () => {
- const { bootSettings } = loadModule(null);
- expect(bootSettings.posthog.enabled).toBe(true);
- expect(bootSettings.appcues.enabled).toBe(true);
- });
-});
-
-describe('when window.signozBootData.settings is populated', () => {
- it('reads posthog enabled: true', () => {
- const { bootSettings } = loadModule({ posthog: { enabled: true } });
- expect(bootSettings.posthog.enabled).toBe(true);
- });
-
- it('reads posthog enabled: false', () => {
- const { bootSettings } = loadModule({ posthog: { enabled: false } });
- expect(bootSettings.posthog.enabled).toBe(false);
- });
-
- it('reads appcues enabled: true', () => {
- const { bootSettings } = loadModule({ appcues: { enabled: true } });
- expect(bootSettings.appcues.enabled).toBe(true);
- });
-
- it('reads appcues enabled: false', () => {
- const { bootSettings } = loadModule({ appcues: { enabled: false } });
- expect(bootSettings.appcues.enabled).toBe(false);
- });
-
- it('missing sub-namespace defaults to enabled', () => {
- const { bootSettings } = loadModule({ posthog: { enabled: false } });
- expect(bootSettings.appcues.enabled).toBe(true);
- });
-});
-
-describe('when window.signozBootData exists but settings is undefined', () => {
- it('defaults posthog and appcues to enabled', () => {
- (window as any).signozBootData = {};
- let mod!: BootData;
- jest.isolateModules(() => {
- // oxlint-disable-next-line typescript-eslint/no-require-imports, typescript-eslint/no-var-requires
- mod = require('../bootData');
- });
- expect(mod.bootSettings.posthog.enabled).toBe(true);
- expect(mod.bootSettings.appcues.enabled).toBe(true);
- });
-});
diff --git a/frontend/src/utils/bootData.ts b/frontend/src/utils/bootData.ts
deleted file mode 100644
index eaef1320b6..0000000000
--- a/frontend/src/utils/bootData.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import type { WebSettings } from 'types/generated/webSettings';
-
-const raw = window.signozBootData?.settings as
- | Partial<WebSettings>
- | null
- | undefined;
-
-export const bootSettings: Readonly<WebSettings> = {
- posthog: { enabled: raw?.posthog?.enabled ?? true },
- appcues: { enabled: raw?.appcues?.enabled ?? true },
-};
diff --git a/pkg/web/config.go b/pkg/web/config.go
index d0fa45600b..0a3f710918 100644
--- a/pkg/web/config.go
+++ b/pkg/web/config.go
@@ -23,6 +23,8 @@ type Config struct {
type SettingsConfig struct {
Posthog PosthogConfig `mapstructure:"posthog"`
Appcues AppcuesConfig `mapstructure:"appcues"`
+ Sentry SentryConfig `mapstructure:"sentry"`
+ Pylon PylonConfig `mapstructure:"sentry"`
}
type PosthogConfig struct {
@@ -33,6 +35,14 @@ type AppcuesConfig struct {
Enabled bool `mapstructure:"enabled"`
}
+type SentryConfig struct {
+ Enabled bool `mapstructure:"enabled"`
+}
+
+type PylonConfig struct {
+ Enabled bool `mapstructure:"enabled"`
+}
+
func NewConfigFactory() factory.ConfigFactory {
return factory.NewConfigFactory(factory.MustNewName("web"), newConfig)
}
@@ -49,6 +59,12 @@ func newConfig() factory.Config {
Appcues: AppcuesConfig{
Enabled: true,
},
+ Sentry: SentryConfig{
+ Enabled: true,
+ },
+ Pylon: PylonConfig{
+ Enabled: true,
+ },
},
}
}
diff --git a/pkg/web/settings.go b/pkg/web/settings.go
index 5c60eae8d5..9195eae32d 100644
--- a/pkg/web/settings.go
+++ b/pkg/web/settings.go
@@ -3,6 +3,8 @@ package web
type Settings struct {
Posthog Posthog `json:"posthog" required:"true"`
Appcues Appcues `json:"appcues" required:"true"`
+ Sentry Sentry `json:"sentry" required:"true"`
+ Pylon Pylon `json:"pylon" required:"true"`
}
type Posthog struct {
@@ -13,6 +15,14 @@ type Appcues struct {
Enabled bool `json:"enabled" required:"true"`
}
+type Sentry struct {
+ Enabled bool `json:"enabled" required:"true"`
+}
+
+type Pylon struct {
+ Enabled bool `json:"enabled" required:"true"`
+}
+
func NewSettings(config Config) Settings {
return Settings{
Posthog: Posthog{
@@ -21,5 +31,11 @@ func NewSettings(config Config) Settings {
Appcues: Appcues{
Enabled: config.Settings.Appcues.Enabled,
},
+ Sentry: Sentry{
+ Enabled: config.Settings.Sentry.Enabled,
+ },
+ Pylon: Pylon{
+ Enabled: config.Settings.Pylon.Enabled,
+ },
}
}