Skip to content

Commit

Permalink
feat: #157 config for sentry log support source mapp (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
duong-se authored Feb 11, 2020
1 parent 44aa104 commit d1405fa
Show file tree
Hide file tree
Showing 24 changed files with 136 additions and 48 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pull-request-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ env:
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
AWS_REGION: ${{secrets.AWS_REGION}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
SENTRY_AUTH_TOKEN: ${{secrets.SENTRY_AUTH_TOKEN}}
REAPIT_ENV: DEV
CI: true

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ env:
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
AWS_REGION: ${{secrets.AWS_REGION}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
SENTRY_AUTH_TOKEN: ${{secrets.SENTRY_AUTH_TOKEN}}
REAPIT_ENV: DEV
CI: true

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ env:
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
AWS_REGION: ${{secrets.AWS_REGION}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
SENTRY_AUTH_TOKEN: ${{secrets.SENTRY_AUTH_TOKEN}}
REAPIT_ENV: PROD
CI: true

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"@cypress/webpack-preprocessor": "^4.1.1",
"@octokit/rest": "^16.38.1",
"@redux-saga/testing-utils": "^1.0.5",
"@sentry/webpack-plugin": "^1.10.0",
"@storybook/addon-actions": "^5.2.6",
"@storybook/addon-docs": "^5.2.6",
"@storybook/addon-info": "^5.2.6",
Expand Down
5 changes: 4 additions & 1 deletion packages/aml-checklist/src/core/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import store from './store'
import '../styles/index.scss'

if (process.env.NODE_ENV === 'production') {
Sentry.init({ dsn: process.env.SENTRY_PROJECT_URL_AML_APP })
Sentry.init({
release: process.env.APP_VERSION,
dsn: process.env.SENTRY_PROJECT_URL_AML_APP,
})
}

const rootElement = document.querySelector('#root') as Element
Expand Down
1 change: 1 addition & 0 deletions packages/aml-checklist/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": "./",
"sourceRoot": "/",
"paths": {
"@/*": ["src/*"],
"@reapit/cognito-auth": ["../cognito-auth/src"],
Expand Down
1 change: 1 addition & 0 deletions packages/cognito-auth/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"typeRoots": ["./src/core/definitions.d.ts", "node_modules/@types", "../../node_modules/@types"],
"baseUrl": "./",
"sourceRoot": "/",
"paths": {
"@/*": ["src/*"],
"@reapit/cognito-auth": ["../cognito-auth/src"],
Expand Down
3 changes: 2 additions & 1 deletion packages/cognito-custom-mail-lambda/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"target": "es6",
"module": "commonjs",
"noEmit": false,
"outDir": "dist"
"outDir": "dist",
"sourceRoot": "/"
},
"include": ["src"]
}
3 changes: 2 additions & 1 deletion packages/elements/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"baseUrl": "./",
"lib": ["es2015", "es2017", "dom", "es5", "es6", "esnext"],
"outDir": "public",
"rootDir": "src"
"rootDir": "src",
"sourceRoot": "/"
},
"include": ["src"]
}
6 changes: 5 additions & 1 deletion packages/foundations-ts-definitions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": "./"
"baseUrl": "./",
"sourceRoot": "/",
"paths": {
"@/*": ["src/*"]
}
},
"include": ["types"],
"exclude": ["node_modules"]
Expand Down
5 changes: 4 additions & 1 deletion packages/geo-diary/src/core/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import store from './store'
import { register } from './service-worker'

if (process.env.NODE_ENV === 'production') {
Sentry.init({ dsn: process.env.SENTRY_PROJECT_URL_GEO_DIARY })
Sentry.init({
release: process.env.APP_VERSION,
dsn: process.env.SENTRY_PROJECT_URL_GEO_DIARY,
})
}

const rootElement = document.querySelector('#root') as Element
Expand Down
1 change: 1 addition & 0 deletions packages/geo-diary/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": "./",
"sourceRoot": "/",
"paths": {
"@/*": ["src/*"],
"@reapit/cognito-auth": ["../cognito-auth/src"],
Expand Down
1 change: 1 addition & 0 deletions packages/graphql-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": "./",
"sourceRoot": "/",
"paths": {
"@/*": ["src/*"],
"@reapit/cognito-auth": ["../cognito-auth/src"],
Expand Down
5 changes: 4 additions & 1 deletion packages/lifetime-legal/src/core/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import store from './store'
import '../styles/index.scss'

if (process.env.NODE_ENV === 'production') {
Sentry.init({ dsn: process.env.SENTRY_PROJECT_URL_LTL_APP })
Sentry.init({
release: process.env.APP_VERSION,
dsn: process.env.SENTRY_PROJECT_URL_LTL_APP,
})
}

const rootElement = document.querySelector('#root') as Element
Expand Down
1 change: 1 addition & 0 deletions packages/lifetime-legal/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": "./",
"sourceRoot": "/",
"paths": {
"@/*": ["src/*"],
"@reapit/cognito-auth": ["../cognito-auth/src"],
Expand Down
7 changes: 5 additions & 2 deletions packages/marketplace/src/core/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import ToastMessage from '../components/ui/toast-message'
import { PortalProvider } from '@reapit/elements'
import ReactGA from 'react-ga'

if (process.env.NODE_ENV !== 'development' && process.env.SENTRY_PROJECT_URL_MARKETPLACE) {
Sentry.init({ dsn: process.env.SENTRY_PROJECT_URL_MARKETPLACE })
if (process.env.NODE_ENV === 'production') {
Sentry.init({
release: process.env.APP_VERSION,
dsn: process.env.SENTRY_PROJECT_URL_MARKETPLACE,
})
}

if (process.env.NODE_ENV !== 'development' && process.env.MARKETPLACE_GOOGLE_ANALYTICS_KEY) {
Expand Down
1 change: 1 addition & 0 deletions packages/marketplace/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": "./",
"sourceRoot": "/",
"paths": {
"@/*": ["src/*"],
"@reapit/cognito-auth": ["../cognito-auth/src"],
Expand Down
1 change: 1 addition & 0 deletions packages/smb/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": "./",
"sourceRoot": "/",
"paths": {
"@/*": ["src/*"],
"@reapit/cognito-auth": ["../cognito-auth/src"],
Expand Down
1 change: 1 addition & 0 deletions packages/web-components/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"baseUrl": "./",
"outDir": "dist-npm",
"declaration": true,
"sourceRoot": "/",
"declarationDir": "dist-npm",
"moduleResolution": "node",
"paths": {
Expand Down
39 changes: 30 additions & 9 deletions scripts/release/utils.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,42 @@
#!/usr/bin/env node
const { execSync } = require('child_process')
const spawn = require('child_process').spawnSync
const Octokit = require('@octokit/rest')

const removeUnuseChar = value => {
return value.replace(/(\r\n\t|\n|\r\t)/gm, '')
}

function runCommand(cmd, args) {
const resultObj = spawn(cmd, args)
const { stdout, stderr } = resultObj

if (stderr.length !== 0) {
throw new Error(stderr.toString().trim())
}

return stdout.toString().trim()
}

const getRef = () => {
return runCommand('git', ['rev-parse', '--short', 'HEAD'])
}

const getHashOfCommitTagged = () => {
return runCommand('git', ['rev-list', '--tags', '--max-count=1'])
}

const getVersionTag = () => {
const tagName = execSync('git describe --always --tags $(git rev-list --tags --max-count=1)').toString()
const tagNameArr = removeUnuseChar(tagName).split('_')
const PACKAGE_NAME_INDEX = 0
const VERSION_INDEX = 1
const packageName = tagNameArr[PACKAGE_NAME_INDEX]
const version = tagNameArr[VERSION_INDEX]
return {
packageName,
version,
try {
const tagName = runCommand('git', ['describe', '--tags', getHashOfCommitTagged()])
const tagNameArr = removeUnuseChar(tagName).split('_')
const PACKAGE_NAME_INDEX = 0
const VERSION_INDEX = 1
const packageName = tagNameArr[PACKAGE_NAME_INDEX]
const version = tagNameArr[VERSION_INDEX]
return { packageName, version }
} catch (e) {
return { packageName: '', version: getRef() }
}
}

Expand Down
7 changes: 6 additions & 1 deletion scripts/webpack/webpack.base.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const FaviconsWebpackPlugin = require('favicons-webpack-plugin')
const { EnvironmentPlugin } = require('webpack')
const ResolveTSPathsToWebpackAlias = require('ts-paths-to-webpack-alias')
const { PATHS } = require('./constants')
const { getVersionTag } = require('../release/utils')
const config = require(PATHS.config)

module.exports = {
Expand All @@ -26,7 +27,11 @@ module.exports = {
title: 'TypeScript',
excludeWarnings: false,
}),
new EnvironmentPlugin(config[process.env.REAPIT_ENV || 'LOCAL']),
new EnvironmentPlugin({
...config[process.env.REAPIT_ENV || 'LOCAL'],
APP_VERSION:
process.env.REAPIT_ENV === 'LOCAL' ? JSON.stringify('LOCAL') : JSON.stringify(getVersionTag().version),
}),
new HtmlWebpackPlugin({
inject: true,
template: PATHS.template,
Expand Down
14 changes: 13 additions & 1 deletion scripts/webpack/webpack.base.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ const ResolveTSPathsToWebpackAlias = require('ts-paths-to-webpack-alias')
const { GenerateSW } = require('workbox-webpack-plugin')
const HashedModuleIdsPlugin = require('webpack').HashedModuleIdsPlugin
const { EnvironmentPlugin } = require('webpack')
const SentryWebpackPlugin = require('@sentry/webpack-plugin')
const { PATHS } = require('./constants')
const { getVersionTag } = require('../release/utils')
const config = require(PATHS.config)

module.exports = {
Expand Down Expand Up @@ -61,7 +63,11 @@ module.exports = {
windows: false,
},
}),
new EnvironmentPlugin(config[process.env.REAPIT_ENV || 'DEV']),
new EnvironmentPlugin({
...config[process.env.REAPIT_ENV || 'DEV'],
APP_VERSION:
process.env.REAPIT_ENV === 'LOCAL' ? JSON.stringify('LOCAL') : JSON.stringify(getVersionTag().version),
}),
new HashedModuleIdsPlugin(),
new GenerateSW({
clientsClaim: true,
Expand All @@ -70,6 +76,12 @@ module.exports = {
cacheId: process.cwd(),
cleanupOutdatedCaches: true,
}),
new SentryWebpackPlugin({
include: '.',
ignoreFile: '.sentrycliignore',
ignore: ['node_modules', 'webpack.config.js'],
configFile: 'sentry.properties',
}),
],
module: {
rules: [
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"strict": true,
"target": "es2020",
"typeRoots": ["./node_modules/@types"],
"types": ["jest", "node", "react"]
"types": ["jest", "node", "react"],
"sourceMap": true,
"inlineSources": true
},
"exclude": ["public", "dist", "scripts", "node_modules", "coverage"]
}
Loading

0 comments on commit d1405fa

Please sign in to comment.