Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init Sentry at service side #4419

Merged
merged 50 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
0b6f9b5
feat(condo): INFRA-229 init sentry
sitozzz Feb 20, 2024
8f923a8
feat(condo): INFRA-229 downgrade sentry package version for compatibi…
sitozzz Feb 20, 2024
3050d10
fix(condo): INFRA-229 move dsn url to runtime config
sitozzz Feb 21, 2024
c337a16
fix(condo): INFRA-229 set sentry to latest version & simplify config
sitozzz Feb 21, 2024
544fbe0
fix(condo): INFRA-229 move sentry related values to a single config r…
sitozzz Feb 22, 2024
97ba49e
feat(condo): INFRA-229 add sentry apollo logger & profiler
sitozzz Feb 27, 2024
7330f2d
fix(condo): INFRA-229 disable debug mode by default
sitozzz Feb 28, 2024
bfc0825
fix(condo): INFRA-229 rebase & little sentry config optimisation
sitozzz Mar 6, 2024
68397a9
chore(condo): INFRA-229 add sentry config
sitozzz Mar 6, 2024
7b5f9cf
chore(condo): INFRA-229 sentry client side config adjustments
sitozzz Mar 7, 2024
edb6930
fix(global): INFRA-229 add sentry config inside build stage
sitozzz Mar 7, 2024
fc47976
chore(condo): INFRA-229 temp changes for debug proposes
sitozzz Mar 7, 2024
26e1b4a
chore(condo): INFRA-229 temp changes for debug proposes
sitozzz Mar 7, 2024
98a0f0a
chore(condo): INFRA-229 temp changes for debug proposes
sitozzz Mar 7, 2024
f9c5d83
chore(condo): INFRA-229 temp changes for debug proposes
sitozzz Mar 7, 2024
94eb486
chore(condo): INFRA-229 temp changes for debug proposes
sitozzz Mar 7, 2024
7ed8935
chore(condo): INFRA-229 temp changes for debug proposes
sitozzz Mar 7, 2024
24ddfa8
chore(condo): INFRA-229 temp changes for debug proposes
sitozzz Mar 7, 2024
cc370f2
chore(condo): INFRA-229 temp changes for debug proposes
sitozzz Mar 7, 2024
0e8b827
chore(condo): INFRA-229 temp changes for debug proposes
sitozzz Mar 7, 2024
be2bbb3
fix(condo): INFRA-229 revert werf env changes & try set vars only at …
sitozzz Mar 11, 2024
d05c0ab
chore(condo): INFRA-229 remove unused log
sitozzz Mar 11, 2024
5762efa
fix(keystone): INFRA-229 disable sentry apollo plugin when no config …
sitozzz Mar 11, 2024
6ec23ca
chore(condo): INFRA-229 second try to pass gh env to werf setup stage
sitozzz Mar 11, 2024
4866cc9
chore(condo): INFRA-229 second try to pass gh env to werf setup stage
sitozzz Mar 11, 2024
af4999c
chore(condo): INFRA-229 second try to pass gh env to werf setup stage
sitozzz Mar 11, 2024
bb1a6ed
chore(condo): INFRA-229 second try to pass gh env to werf setup stage
sitozzz Mar 11, 2024
13dab51
chore(condo): INFRA-229 second try to pass gh env to werf setup stage
sitozzz Mar 11, 2024
1dfd71d
chore(condo): INFRA-229 second try to pass gh env to werf setup stage
sitozzz Mar 11, 2024
c66c3c0
chore(condo): INFRA-229 second try to pass gh env to werf setup stage
sitozzz Mar 11, 2024
675c663
fix(condo): INFRA-229 disable sentry debug mode
sitozzz Mar 12, 2024
3ddb2e3
fix(condo): INFRA-229 try to integrate with sentry release gh action …
sitozzz Mar 12, 2024
bbfbd7d
fix(condo): INFRA-229 try to integrate with sentry release gh action …
sitozzz Mar 12, 2024
b3f6dc0
fix(condo): INFRA-229 try to integrate with sentry release gh action …
sitozzz Mar 12, 2024
8c03024
fix(condo): INFRA-229 try to integrate with sentry release gh action …
sitozzz Mar 12, 2024
603c98a
fix(condo): INFRA-229 try to integrate with sentry release gh action …
sitozzz Mar 12, 2024
ed894e0
fix(condo): INFRA-229 try to integrate with sentry release gh action …
sitozzz Mar 12, 2024
8f8fd09
fix(condo): INFRA-229 try to integrate with sentry release gh action …
sitozzz Mar 12, 2024
a88dfb9
fix(condo): INFRA-229 try to integrate with sentry release gh action …
sitozzz Mar 12, 2024
cc0bc9b
fix(condo): INFRA-229 try to integrate with sentry release gh action …
sitozzz Mar 12, 2024
1b086d1
fix(condo): INFRA-229 try to integrate with sentry release gh action …
sitozzz Mar 12, 2024
5d24994
fix(condo): INFRA-229 try to integrate with sentry release gh action …
sitozzz Mar 12, 2024
d5f4551
fix(condo): INFRA-229 try to integrate with sentry release gh action …
sitozzz Mar 12, 2024
9b480ed
fix(condo): INFRA-229 try to integrate with sentry release gh action …
sitozzz Mar 12, 2024
5561ae5
fix(condo): INFRA-229 add release name for review env
sitozzz Mar 13, 2024
058aa33
fix(condo): INFRA-229 set commit sha as release anchor at both sides …
sitozzz Mar 13, 2024
1c64d25
chore(condo): INFRA-229 update values at helm
sitozzz Mar 13, 2024
efd1c8a
fix(condo): INFRA-229 update config at helm & point submodule to master
sitozzz Mar 13, 2024
f710b9b
fix(keystone): INFRA-229 remove comment lines
sitozzz Mar 14, 2024
c60eff8
chore(condo): INFRA-229 simplify wrapper logic at next.config
sitozzz Mar 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(condo): INFRA-229 set commit sha as release anchor at both sides …
…of condo application
  • Loading branch information
sitozzz committed Mar 14, 2024
commit 058aa332038ee25ce9b602935f312fa198c12697
5 changes: 4 additions & 1 deletion .github/workflows/deploy_development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
username: ${{ secrets.SBERCLOUD_CR_USERNAME }}
password: ${{ secrets.SBERCLOUD_CR_PASSWORD }}
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
Expand Down Expand Up @@ -70,3 +70,6 @@ jobs:
WERF_SET_CI_REF: "ci.werf.io/ref=${GITHUB_REF_NAME}"
WERF_REPO: swr.ru-moscow-1.hc.sbercloud.ru/condo/condo
WERF_REPO_CONTAINER_REGISTRY: default
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_RELEASE: "development-${{ github.sha }}"
SENTRY_ENVIRONMENT: "development"
5 changes: 4 additions & 1 deletion .github/workflows/deploy_production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
username: ${{ secrets.SBERCLOUD_CR_USERNAME }}
password: ${{ secrets.SBERCLOUD_CR_PASSWORD }}
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
Expand Down Expand Up @@ -75,3 +75,6 @@ jobs:
WERF_SET_CI_REF: "ci.werf.io/ref=${GITHUB_REF_NAME}"
WERF_REPO: swr.ru-moscow-1.hc.sbercloud.ru/condo/condo
WERF_REPO_CONTAINER_REGISTRY: default
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_RELEASE: "production-${{ github.sha }}"
SENTRY_ENVIRONMENT: "production"
3 changes: 2 additions & 1 deletion .github/workflows/deploy_review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ jobs:
WERF_REPO: swr.ru-moscow-1.hc.sbercloud.ru/condo/condo
WERF_REPO_CONTAINER_REGISTRY: default
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_RELEASE: "review-${{ env.REVIEW_URL_PREFIX }}"
SENTRY_RELEASE: "review-${{ github.sha }}"
SENTRY_ENVIRONMENT: "review"
- name: Urls output
run: |
echo "condo: https://review-${{ env.REVIEW_URL_PREFIX }}-condo.r.doma.ai"
Expand Down
5 changes: 4 additions & 1 deletion apps/condo/domains/common/utils/VersioningMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ const packageJson = require('@app/condo/package.json')
const express = require('express')
const { get } = require('lodash')

const getCurrentVersion = () => get(process.env, 'WERF_COMMIT_HASH', packageJson.version)

class VersioningMiddleware {
async prepareMiddleware () {
// this route can not be used for csrf attack (because no cookies and tokens are used in a public route)
// nosemgrep: javascript.express.security.audit.express-check-csurf-middleware-usage.express-check-csurf-middleware-usage
const app = express()
app.use('/api/version', (req, res) => {
res.status(200).json({
build: get(process.env, 'WERF_COMMIT_HASH', packageJson.version),
build: getCurrentVersion(),
})
})

Expand All @@ -19,4 +21,5 @@ class VersioningMiddleware {

module.exports = {
VersioningMiddleware,
getCurrentVersion,
}
5 changes: 3 additions & 2 deletions apps/condo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const { getWebhookModels } = require('@open-condo/webhooks/schema')

const { PaymentLinkMiddleware } = require('@condo/domains/acquiring/PaymentLinkMiddleware')
const FileAdapter = require('@condo/domains/common/utils/fileAdapter')
const { VersioningMiddleware } = require('@condo/domains/common/utils/VersioningMiddleware')
const { VersioningMiddleware, getCurrentVersion } = require('@condo/domains/common/utils/VersioningMiddleware')
const { UnsubscribeMiddleware } = require('@condo/domains/notification/UnsubscribeMiddleware')
const { UserExternalIdentityMiddleware } = require('@condo/domains/user/integration/UserExternalIdentityMiddleware')
const { OIDCMiddleware } = require('@condo/domains/user/oidc')
Expand Down Expand Up @@ -109,7 +109,7 @@ const tasks = () => [
if (!IS_BUILD_PHASE && SENTRY_CONFIG['server']) {
Sentry.init({
dsn: SENTRY_CONFIG['server']['dsn'],
debug: false,
debug: SENTRY_CONFIG['server']['environment'] === 'review',
tracesSampleRate: SENTRY_CONFIG['server']['sampleRate'],
integrations: [
new Sentry.Integrations.Http({ tracing: true }),
Expand All @@ -118,6 +118,7 @@ if (!IS_BUILD_PHASE && SENTRY_CONFIG['server']) {
environment: SENTRY_CONFIG['server']['environment'],
organization: SENTRY_CONFIG['server']['organization'],
project: SENTRY_CONFIG['server']['project'],
release: `${SENTRY_CONFIG['server']['environment']}-${getCurrentVersion()}`,
})
}

Expand Down
6 changes: 4 additions & 2 deletions apps/condo/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const withTMModule = require('next-transpile-modules')
const conf = require('@open-condo/config')

const { antGlobalVariables } = require('@condo/domains/common/constants/style')
const { getCurrentVersion } = require('@condo/domains/common/utils/VersioningMiddleware')

// Tell webpack to compile the "@open-condo/next" package, necessary
// https://www.npmjs.com/package/next-transpile-modules
Expand Down Expand Up @@ -79,6 +80,7 @@ module.exports = withTM(withLess(withCSS({
condoRBDomain,
sentryConfig,
apolloBatchingEnabled,
currentVersion: getCurrentVersion(),
},
lessLoaderOptions: {
javascriptEnabled: true,
Expand Down Expand Up @@ -115,14 +117,14 @@ if (sentryConfig['client']) {
module.exports,
sitozzz marked this conversation as resolved.
Show resolved Hide resolved
{
dryRun: false,
silent: true,
silent: false,
org: sentryConfig['client']['organization'],
project: sentryConfig['client']['project'],
validate: true,
widenClientFileUpload: true,
transpileClientSDK: false,
hideSourceMaps: true,
disableLogger: false,
disableLogger: true,
automaticVercelMonitors: true,
autoInstrumentServerFunctions: true,
autoInstrumentMiddleware: true,
Expand Down
3 changes: 2 additions & 1 deletion apps/condo/sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import * as Sentry from '@sentry/nextjs'
import getConfig from 'next/config'

const { publicRuntimeConfig: { sentryConfig } } = getConfig()
const { publicRuntimeConfig: { sentryConfig, currentVersion } } = getConfig()

if (sentryConfig['client']) {
Sentry.init({
Expand All @@ -16,5 +16,6 @@ if (sentryConfig['client']) {
debug: false,
autoSessionTracking: true,
environment: sentryConfig['client']['environment'],
release: `${sentryConfig['client']['environment']}-${currentVersion}`,
})
}
3 changes: 2 additions & 1 deletion apps/condo/sentry.server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import * as Sentry from '@sentry/nextjs'
import getConfig from 'next/config'

const { publicRuntimeConfig: { sentryConfig } } = getConfig()
const { publicRuntimeConfig: { sentryConfig, currentVersion } } = getConfig()

if (sentryConfig['client']) {
Sentry.init({
Expand All @@ -16,5 +16,6 @@ if (sentryConfig['client']) {
sendClientReports: true,
autoSessionTracking: true,
environment: sentryConfig['client']['environment'],
release: `${sentryConfig['client']['environment']}-${currentVersion}`,
})
}
1 change: 1 addition & 0 deletions werf-giterminism.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ config:
- PULL_PERSONAL_ACCESS_KEY
- SENTRY_AUTH_TOKEN
- SENTRY_RELEASE
- SENTRY_ENVIRONMENT
1 change: 1 addition & 0 deletions werf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ shell:
- "echo 'SENTRY_CONFIG={\"client\":{\"organization\":\"condo\",\"project\":\"javascript-nextjs\"},\"server\":{}}' >> /app/.env"
- echo 'SENTRY_AUTH_TOKEN={{ env "SENTRY_AUTH_TOKEN" }}' >> /app/.env
- echo 'SENTRY_RELEASE={{ env "SENTRY_RELEASE" }}' >> /app/.env
- echo 'SENTRY_ENVIRONMENT={{ env "SENTRY_ENVIRONMENT" }}' >> /app/.env
- "echo 'SENTRY_ORG=condo' >> /app/.env"
- "echo 'SENTRY_PROJECT=javascript-nextjs' >> /app/.env"
- "yarn workspace @app/condo next telemetry disable"
Expand Down