Skip to content

Commit 03c22ed

Browse files
committed
feat: enable cloud Sentry Ref: KK-1474
chore: compose.yaml list all env files Ref: KK-1474 chore: vite.config.ts define process.env Ref: KK-1474 feat: generate sourcemaps Ref: KK-1474
1 parent 7f7530e commit 03c22ed

9 files changed

Lines changed: 117 additions & 115 deletions

File tree

.env.development.local.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ VITE_MATOMO_SRC_URL=https://webanalytics.digiaiiris.com/js/piwik.min.js
1717
VITE_MATOMO_TRACKER_URL=https://webanalytics.digiaiiris.com/js/tracker.php
1818
VITE_MATOMO_ENABLED=0
1919
VITE_IDLE_TIMEOUT_IN_MS=3600000
20+
VITE_SENTRY_ENVIRONMENT=local
21+
VITE_SENTRY_DSN=
22+
VITE_SENTRY_TRACES_SAMPLE_RATE=1.0
23+
VITE_SENTRY_TRACE_PROPAGATION_TARGETS=http://localhost:8081
24+
VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE=0
25+
VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE=0

CHANGELOG.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -403,29 +403,25 @@ See https://github.com/City-of-Helsinki/kukkuu-ui/milestone/6?closed=1
403403

404404
## [3.12.2](https://github.com/City-of-Helsinki/kukkuu-ui/compare/kukkuu-ui-v3.12.1...kukkuu-ui-v3.12.2) (2025-10-06)
405405

406-
407406
### Bug Fixes
408407

409-
* Stricter yarn configuration ([2f3a899](https://github.com/City-of-Helsinki/kukkuu-ui/commit/2f3a8994a5b46c39a44c63ef14a43b84a5225f55))
410-
408+
- Stricter yarn configuration ([2f3a899](https://github.com/City-of-Helsinki/kukkuu-ui/commit/2f3a8994a5b46c39a44c63ef14a43b84a5225f55))
411409

412410
### Dependencies
413411

414-
* Bump vite from 6.0.14 to 6.3.6 ([#697](https://github.com/City-of-Helsinki/kukkuu-ui/issues/697)) ([087a1b6](https://github.com/City-of-Helsinki/kukkuu-ui/commit/087a1b68bac2926b92b103908686fd76f04bdf51))
412+
- Bump vite from 6.0.14 to 6.3.6 ([#697](https://github.com/City-of-Helsinki/kukkuu-ui/issues/697)) ([087a1b6](https://github.com/City-of-Helsinki/kukkuu-ui/commit/087a1b68bac2926b92b103908686fd76f04bdf51))
415413

416414
## [3.12.1](https://github.com/City-of-Helsinki/kukkuu-ui/compare/kukkuu-ui-v3.12.0...kukkuu-ui-v3.12.1) (2025-09-12)
417415

418-
419416
### Bug Fixes
420417

421-
* React-router 7.5.2 fix imports ([b051f33](https://github.com/City-of-Helsinki/kukkuu-ui/commit/b051f33d6aec5309a95cd5415258c9ec821b0499))
422-
418+
- React-router 7.5.2 fix imports ([b051f33](https://github.com/City-of-Helsinki/kukkuu-ui/commit/b051f33d6aec5309a95cd5415258c9ec821b0499))
423419

424420
### Dependencies
425421

426-
* Bump form-data from 4.0.1 to 4.0.4 ([c759d10](https://github.com/City-of-Helsinki/kukkuu-ui/commit/c759d10025b734ec7cd1fbc2fb1bb1f2bead991a))
427-
* Bump react-router from 7.1.3 to 7.5.2 ([af5fb12](https://github.com/City-of-Helsinki/kukkuu-ui/commit/af5fb12998e1aa1616965b2b415349ca03727c5b))
428-
* Jsdom to 26.1.0 ([0ff4460](https://github.com/City-of-Helsinki/kukkuu-ui/commit/0ff44606080d4845dacd777cb59da0d64e6f1337))
422+
- Bump form-data from 4.0.1 to 4.0.4 ([c759d10](https://github.com/City-of-Helsinki/kukkuu-ui/commit/c759d10025b734ec7cd1fbc2fb1bb1f2bead991a))
423+
- Bump react-router from 7.1.3 to 7.5.2 ([af5fb12](https://github.com/City-of-Helsinki/kukkuu-ui/commit/af5fb12998e1aa1616965b2b415349ca03727c5b))
424+
- Jsdom to 26.1.0 ([0ff4460](https://github.com/City-of-Helsinki/kukkuu-ui/commit/0ff44606080d4845dacd777cb59da0d64e6f1337))
429425

430426
## [3.12.0](https://github.com/City-of-Helsinki/kukkuu-ui/compare/kukkuu-ui-v3.11.2...kukkuu-ui-v3.12.0) (2025-06-05)
431427

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ ARG VITE_OIDC_AUTOMATIC_SILENT_RENEW_ENABLED
7272
ARG VITE_OIDC_SESSION_POLLING_INTERVAL_MS
7373
ARG VITE_OIDC_AUDIENCES
7474
ARG VITE_FEATURE_FLAG_SHOW_CORONAVIRUS_INFO
75+
ARG VITE_SENTRY_ENVIRONMENT
7576
ARG VITE_SENTRY_DSN
77+
ARG VITE_SENTRY_TRACES_SAMPLE_RATE
78+
ARG VITE_SENTRY_TRACE_PROPAGATION_TARGETS
79+
ARG VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE
80+
ARG VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE
7681
ARG VITE_BUILDTIME
7782
ARG VITE_RELEASE
7883
ARG VITE_COMMITHASH

compose.yaml

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,18 @@ services:
66
build:
77
context: .
88
target: ${DOCKER_TARGET:-development} # select the docker container from dockerFile
9-
args:
10-
# NOTE: Build args hardcoded because Docker compose can't read build args
11-
# from other env files beside .env, even if env_file parameter is used, see
12-
# https://stackoverflow.com/questions/50592531/setting-build-args-in-docker-compose-yml-using-env-file
13-
VITE_ORIGIN: http://localhost:3000
14-
VITE_API_URI: https://kukkuu.api.test.hel.ninja/graphql
15-
VITE_OIDC_SERVER_TYPE: KEYCLOAK
16-
VITE_OIDC_RETURN_TYPE: 'code'
17-
VITE_OIDC_AUTHORITY: https://tunnistus.test.hel.ninja/auth/realms/helsinki-tunnistus/
18-
VITE_OIDC_CLIENT_ID: 'kukkuu-ui-test'
19-
VITE_OIDC_KUKKUU_API_CLIENT_ID: 'kukkuu-api-test'
20-
VITE_OIDC_SCOPE: 'openid profile email'
21-
VITE_OIDC_AUDIENCES: kukkuu-api-test,profile-api-test
22-
VITE_ADMIN_TICKET_VALIDATION_URL: https://kukkuu-admin.test.hel.ninja/check-ticket-validity
23-
VITE_CMS_URI: https://kukkuu.app-staging.hkih.hion.dev/graphql
24-
VITE_HELSINKI_PROFILE_URL: https://profiili.test.hel.ninja/loginsso
25-
VITE_MATOMO_URL_BASE: https://webanalytics.digiaiiris.com/js/
26-
VITE_MATOMO_SITE_ID: 813
27-
VITE_MATOMO_ENABLED: 0
28-
VITE_IDLE_TIMEOUT_IN_MS: 3600000 # 60 * 60 * 1000ms = 60min
299
environment:
3010
NODE_ENV: ${DOCKER_TARGET:-development} # which node env the build uses. NOTE: Usually same as the ${DOCKER_TARGET}.
3111
VITE_ENVIRONMENT: ${DOCKER_TARGET:-development}
32-
# Environment variables (not build args) for using the public test environment backend,
33-
# must contain same values than the build args:
34-
env_file: '.env.development'
12+
# Load environment variables from base .env and environment-specific files
13+
# Files are processed in order, with later files overriding earlier ones
14+
env_file:
15+
- ".env"
16+
- ".env.development"
17+
- ".env.development.local"
3518
volumes:
36-
- '.:/app'
37-
- '/app/node_modules'
19+
- ".:/app"
20+
- "/app/node_modules"
3821
ports:
39-
- '3000:3000' # for development mode
40-
- '8082:8080' # for production mode
22+
- "3000:3000" # for development mode
23+
- "8082:8080" # for production mode

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"@ffmpeg-installer/ffmpeg": "^1.1.0",
7171
"@jonkoops/matomo-tracker-react": "^0.7.0",
7272
"@reduxjs/toolkit": "^2.5.1",
73-
"@sentry/browser": "^8.51.0",
73+
"@sentry/browser": "^10.25.0",
7474
"@stylistic/eslint-plugin-js": "^3.0.0",
7575
"@testing-library/jest-dom": "^6.6.3",
7676
"@testing-library/react": "^16.2.0",

src/index.tsx

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,54 @@ import 'hds-core/lib/base.css';
33
import Modal from 'react-modal';
44
import { createRoot } from 'react-dom/client';
55
import React from 'react';
6+
import * as Sentry from '@sentry/browser';
67

78
import BrowserApp from './domain/app/BrowserApp';
89
import { initI18next } from './common/translation/i18n/i18nInit';
910
import AppConfig from './domain/app/AppConfig';
10-
import { initSentry } from './utils/sentry';
11-
1211
initI18next();
1312
Modal.setAppElement('#root');
1413

15-
if (AppConfig.isAppInProductionMode) {
16-
initSentry();
14+
if (import.meta.env.VITE_SENTRY_DSN) {
15+
Sentry.init({
16+
beforeSend(event) {
17+
// Check if the event contains a PERMISSION_DENIED error
18+
if (event.exception && event.exception.values) {
19+
const isPermissionDenied = event.exception.values.some(
20+
(exception) =>
21+
exception.type === 'GraphQLError' &&
22+
exception.value?.includes('PERMISSION_DENIED')
23+
);
24+
if (isPermissionDenied) {
25+
// Return null to ignore the event
26+
return null;
27+
}
28+
}
29+
// Otherwise, send the event to Sentry
30+
return event;
31+
},
32+
dsn: import.meta.env.VITE_SENTRY_DSN,
33+
environment: import.meta.env.VITE_SENTRY_ENVIRONMENT,
34+
release: import.meta.env.VITE_SENTRY_RELEASE,
35+
integrations: [
36+
Sentry.browserTracingIntegration(),
37+
Sentry.replayIntegration(),
38+
],
39+
tracesSampleRate: parseFloat(
40+
import.meta.env.VITE_SENTRY_TRACES_SAMPLE_RATE || '0'
41+
),
42+
tracePropagationTargets: (
43+
import.meta.env.VITE_SENTRY_TRACE_PROPAGATION_TARGETS || ''
44+
).split(','),
45+
replaysSessionSampleRate: parseFloat(
46+
import.meta.env.VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE || '0'
47+
),
48+
replaysOnErrorSampleRate: parseFloat(
49+
import.meta.env.VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE || '0'
50+
),
51+
});
1752
}
53+
1854
const container = document.getElementById('root') as Element;
1955
const root = createRoot(container);
2056

src/utils/sentry.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

vite.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export default defineConfig(() => {
1616
},
1717
},
1818
},
19+
define: {
20+
'process.env': '{}',
21+
},
1922
envPrefix: 'VITE_',
2023
resolve: {
2124
alias: {
@@ -28,6 +31,7 @@ export default defineConfig(() => {
2831
},
2932
build: {
3033
outDir: 'build',
34+
sourcemap: true,
3135
},
3236
server: {
3337
port: parseInt(process.env.PORT) || 3000,

yarn.lock

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,51 +2665,51 @@
26652665
resolved "https://registry.yarnpkg.com/@rtsao/scc/-/scc-1.1.0.tgz#927dd2fae9bc3361403ac2c7a00c32ddce9ad7e8"
26662666
integrity sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==
26672667

2668-
"@sentry-internal/browser-utils@8.51.0":
2669-
version "8.51.0"
2670-
resolved "https://registry.yarnpkg.com/@sentry-internal/browser-utils/-/browser-utils-8.51.0.tgz#eaa245aefad8b3d893516ffe9535b1907f049094"
2671-
integrity sha512-r94yfRK17zNJER0hgQE4qOSy5pWzsnFcGTJQSqhSEKUcC4KK37qSfoPrPejFxtIqXhqlkd/dTWKvrMwXWcn0MQ==
2672-
dependencies:
2673-
"@sentry/core" "8.51.0"
2674-
2675-
"@sentry-internal/feedback@8.51.0":
2676-
version "8.51.0"
2677-
resolved "https://registry.yarnpkg.com/@sentry-internal/feedback/-/feedback-8.51.0.tgz#58e1de053b175e6fe5896e9b1282d754ea4e12d5"
2678-
integrity sha512-VgfxSZWLYUPKDnkt2zG+Oe5ccv8U3WPM6Mo4kfABIJT3Ai4VbZB7+vb2a4pm6lUCF9DeOPXHb5o9Tg17SHDAHw==
2679-
dependencies:
2680-
"@sentry/core" "8.51.0"
2681-
2682-
"@sentry-internal/replay-canvas@8.51.0":
2683-
version "8.51.0"
2684-
resolved "https://registry.yarnpkg.com/@sentry-internal/replay-canvas/-/replay-canvas-8.51.0.tgz#c896448d456290f8f4eb99df924d1bcc07908947"
2685-
integrity sha512-ERXIbwdULkdtIQnfkMLRVfpoGV2rClwySGRlTPepFKeLxlcXo9o09cPu+qbukiDnGK0cgEgRnrV961hMg21Bmw==
2686-
dependencies:
2687-
"@sentry-internal/replay" "8.51.0"
2688-
"@sentry/core" "8.51.0"
2689-
2690-
"@sentry-internal/replay@8.51.0":
2691-
version "8.51.0"
2692-
resolved "https://registry.yarnpkg.com/@sentry-internal/replay/-/replay-8.51.0.tgz#c121518ef493afcf38c900d37e12af68787351d5"
2693-
integrity sha512-lkm7id3a2n3yMZeF5socCVQUeEeShNOGr7Wtsmb5RORacEnld0z+NfbMTilo1mDwiWBzI5OYBjm62eglm1HFsQ==
2694-
dependencies:
2695-
"@sentry-internal/browser-utils" "8.51.0"
2696-
"@sentry/core" "8.51.0"
2697-
2698-
"@sentry/browser@^8.51.0":
2699-
version "8.51.0"
2700-
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-8.51.0.tgz#1d208785a432f4a4aee616da459e118994c8661f"
2701-
integrity sha512-1kbbyVfBBAx5Xyynp+lC5lLnAHo0qJ2r4mtmdT6koPjesvoOocEK0QQnouQBmdUbm3L0L/bPI1SgXjbeJyhzHQ==
2702-
dependencies:
2703-
"@sentry-internal/browser-utils" "8.51.0"
2704-
"@sentry-internal/feedback" "8.51.0"
2705-
"@sentry-internal/replay" "8.51.0"
2706-
"@sentry-internal/replay-canvas" "8.51.0"
2707-
"@sentry/core" "8.51.0"
2708-
2709-
"@sentry/core@8.51.0":
2710-
version "8.51.0"
2711-
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-8.51.0.tgz#d0c73dfe3489788911b7ce784d3ef8458344482c"
2712-
integrity sha512-Go0KxCYLw+OBIlLSv5YsYX+x9NW43fNVcyB6rhkSp2Q5Zme3tAE6KtZFvyu4SO7G/903wisW5Q6qV6UuK/ee4A==
2668+
"@sentry-internal/browser-utils@10.25.0":
2669+
version "10.25.0"
2670+
resolved "https://registry.yarnpkg.com/@sentry-internal/browser-utils/-/browser-utils-10.25.0.tgz#3ef1c2e6044fdf80dba75a9ce18c8133184e57da"
2671+
integrity sha512-wzg1ITZxrRtQouHPCgpt3tl1GiNAWFVy2RYK2KstFEhpYBAOUn9BAdP7KU9UyHBFKqbAvV4oGtAT8H2/Y4+leA==
2672+
dependencies:
2673+
"@sentry/core" "10.25.0"
2674+
2675+
"@sentry-internal/feedback@10.25.0":
2676+
version "10.25.0"
2677+
resolved "https://registry.yarnpkg.com/@sentry-internal/feedback/-/feedback-10.25.0.tgz#9a335f11bada42bde307e3fa58b0aaf764aea40e"
2678+
integrity sha512-qlbT4tOd+WRyKpLdsbi26rkynGBoVabnY8/9rFnTxZ0WIUG5EFhJFqEeRLMyv+uk0uRFF3H0I9+u+qP/BKxIcQ==
2679+
dependencies:
2680+
"@sentry/core" "10.25.0"
2681+
2682+
"@sentry-internal/replay-canvas@10.25.0":
2683+
version "10.25.0"
2684+
resolved "https://registry.yarnpkg.com/@sentry-internal/replay-canvas/-/replay-canvas-10.25.0.tgz#cd3a5f953b9b3cbc1fc3fbdfb6ac0bdbfa1f7cc3"
2685+
integrity sha512-zuj5jVNswZ/aA1nPPbU+VIFkQG0695lbyIfS1Skq+5o2FdRIS3MGnBXw1abI9h4pft8GLQWcKiBxISM7UpSz6w==
2686+
dependencies:
2687+
"@sentry-internal/replay" "10.25.0"
2688+
"@sentry/core" "10.25.0"
2689+
2690+
"@sentry-internal/replay@10.25.0":
2691+
version "10.25.0"
2692+
resolved "https://registry.yarnpkg.com/@sentry-internal/replay/-/replay-10.25.0.tgz#5aa936c551bcac5ce0825550ec382e83e9774142"
2693+
integrity sha512-V/kKQn9T46HBTiP0bIThmpVr94K4vXwYM3/EHVpGSq4P9RynX06cgps8GLHq94+A0kX/DbK9igEMZmIuzS1q3A==
2694+
dependencies:
2695+
"@sentry-internal/browser-utils" "10.25.0"
2696+
"@sentry/core" "10.25.0"
2697+
2698+
"@sentry/browser@^10.25.0":
2699+
version "10.25.0"
2700+
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-10.25.0.tgz#d97fffc53f955ed75369f781bf458d0a47d286ac"
2701+
integrity sha512-UgSVT3RTM3vsK914TPuHVJQsjq5ooXVmjMtsWP3Ep+6f7N+1UVX4ZXsyyj5lDOcWdc79FgproD+MrEf9Cj6uBg==
2702+
dependencies:
2703+
"@sentry-internal/browser-utils" "10.25.0"
2704+
"@sentry-internal/feedback" "10.25.0"
2705+
"@sentry-internal/replay" "10.25.0"
2706+
"@sentry-internal/replay-canvas" "10.25.0"
2707+
"@sentry/core" "10.25.0"
2708+
2709+
"@sentry/core@10.25.0":
2710+
version "10.25.0"
2711+
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-10.25.0.tgz#99e5253a1a5e52f7e8972c89dcf3e710700e4059"
2712+
integrity sha512-mGi4BYIPwZjWdOXHrPoXz1AW4/cQbFoiuW/m+OOATmtSoGTDnWYwP+qZU7VLlL+v8ZEzxfPi2C1NPfJtPj7QWA==
27132713

27142714
"@sinclair/typebox@^0.27.8":
27152715
version "0.27.8"

0 commit comments

Comments
 (0)