Skip to content

Commit c9b8223

Browse files
authored
feat(error-tracking): add sentry (#2)
* chore: generate sourcemaps * feat: add sentry
1 parent 755886c commit c9b8223

File tree

7 files changed

+83
-2
lines changed

7 files changed

+83
-2
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "dat-song-bot",
3+
"sideEffects": false,
34
"version": "0.1.0",
45
"main": "dist/index.js",
56
"typings": "dist/index.d.ts",
@@ -68,6 +69,7 @@
6869
},
6970
"dependencies": {
7071
"@ffmpeg-installer/ffmpeg": "^1.0.18",
72+
"@sentry/node": "5.4.3",
7173
"axios": "^0.19.0",
7274
"chrome-aws-lambda": "^1.17.1",
7375
"date-fns": "^1.30.1",

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const config = {
66
YOUTUBE_CLIENT_SECRET: process.env.YOUTUBE_CLIENT_SECRET,
77
YOUTUBE_REFRESH_TOKEN: process.env.YOUTUBE_REFRESH_TOKEN,
88
UNSPLASH_ACCESS_KEY: process.env.UNSPLASH_ACCESS_KEY,
9+
SENTRY_DSN: process.env.SENTRY_DSN,
910
};
1011

1112
export default config;

src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,20 @@ import { getUnsplashPhoto } from './image';
1010
import { videoLogger } from './lib/utils';
1111
import { Handler } from 'aws-lambda';
1212
import { uploadVideo, connectToYoutube } from './upload';
13+
import { init as initSentry } from '@sentry/node';
14+
import config from './config';
1315

1416
const IMAGE_OUTPUT = '/tmp/out.png';
1517
const VIDEO_OUTPUT = '/tmp/out.mp4';
1618

19+
if (process.env.NODE_ENV === 'production') {
20+
global.__rootdir__ = __dirname || process.cwd();
21+
22+
initSentry({
23+
dsn: config.SENTRY_DSN,
24+
});
25+
}
26+
1727
export const main: Handler = async () => {
1828
try {
1929
await launchPage();

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"include": ["src", "types", "test"],
33
"compilerOptions": {
44
"target": "es2015",
5-
"module": "esnext",
5+
"module": "es6",
66
"lib": ["dom", "esnext"],
77
"importHelpers": true,
88
"declaration": false,

types/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ declare module '@ffmpeg-installer/ffmpeg' {
99

1010
export = installer;
1111
}
12+
13+
declare module NodeJS {
14+
interface Global {
15+
__rootdir__: string;
16+
}
17+
}

webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ module.exports = {
3535
},
3636
],
3737
},
38+
devtool: 'inline-source-map',
3839
externals: {
3940
'chrome-aws-lambda': 'chrome-aws-lambda',
4041
'aws-sdk': 'aws-sdk',

yarn.lock

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,62 @@
923923
into-stream "^5.0.0"
924924
lodash "^4.17.4"
925925

926+
"@sentry/core@5.4.3":
927+
version "5.4.3"
928+
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.4.3.tgz#c9e3a6cc9f5e296c5a5e19a7a925d9ee9125a95f"
929+
integrity sha512-VjRv9BXip2BtCSohi/WQra+Ep4B8ajer1nU1VpKy5tUCjpVfXRpitY23EdEl+MVJH7h6YPZ45JsuFiKGgrtaFQ==
930+
dependencies:
931+
"@sentry/hub" "5.4.3"
932+
"@sentry/minimal" "5.4.3"
933+
"@sentry/types" "5.4.2"
934+
"@sentry/utils" "5.4.2"
935+
tslib "^1.9.3"
936+
937+
"@sentry/hub@5.4.3":
938+
version "5.4.3"
939+
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.4.3.tgz#d6936f976435dd552e06a6a3e9f8cd643e9b9b3f"
940+
integrity sha512-97bnk2dDuCdFv2xhujogqPiDDpKOsHxBXH1jOJ5ezr3/uZNsMRr450FDxxJJYDLuSx+qZ/+vUFfdVNjprBsuSg==
941+
dependencies:
942+
"@sentry/types" "5.4.2"
943+
"@sentry/utils" "5.4.2"
944+
tslib "^1.9.3"
945+
946+
"@sentry/minimal@5.4.3":
947+
version "5.4.3"
948+
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.4.3.tgz#afaa8f7a3b5074efa8d70a2edac920b2e0cdbe15"
949+
integrity sha512-xSCcKDtVtlmJIGmnlNH2fL++4l7iORJ+pOOfTz1Yjm/Il7Tz9wLVodbEfplXmAbOvgG/x9oilbW0MBSnrwKPfQ==
950+
dependencies:
951+
"@sentry/hub" "5.4.3"
952+
"@sentry/types" "5.4.2"
953+
tslib "^1.9.3"
954+
955+
"@sentry/node@5.4.3":
956+
version "5.4.3"
957+
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-5.4.3.tgz#3de5b050b8c7ca44d25e3b1d6b0cf9b76833d937"
958+
integrity sha512-QdLj1Po+94Ns9y5Z4orvA/febJV8i1uwSVK/cj61FISdb2DXlCWRFV9OYvm0I0EIHr9xAORpOCmyy0JbO1lE8w==
959+
dependencies:
960+
"@sentry/core" "5.4.3"
961+
"@sentry/hub" "5.4.3"
962+
"@sentry/types" "5.4.2"
963+
"@sentry/utils" "5.4.2"
964+
cookie "0.3.1"
965+
https-proxy-agent "2.2.1"
966+
lru_map "0.3.3"
967+
tslib "^1.9.3"
968+
969+
"@sentry/types@5.4.2":
970+
version "5.4.2"
971+
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.4.2.tgz#4ab327bced2cfd961dc7a29f0ff43398f913f6a6"
972+
integrity sha512-yh1fd7x5lLOIZ8W3A1I792B3jowJVCWp4HcTRikjTsjbF8lcURY62m+hiLYUFPTIX99AlFRIPiApDkWiwMGYMA==
973+
974+
"@sentry/utils@5.4.2":
975+
version "5.4.2"
976+
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.4.2.tgz#c88c6c08d635e1744a443cfefe9e2ed7fa250e4e"
977+
integrity sha512-AW7/TGt2HiPQB8lJ8NgMgaFAIDQpKDF+wV8nENRbC1CP1zzcvb1QBF4zBL2auDT4fhkhVa817064s7vlDiJVLQ==
978+
dependencies:
979+
"@sentry/types" "5.4.2"
980+
tslib "^1.9.3"
981+
926982
"@serverless/enterprise-plugin@^1.0.3":
927983
version "1.0.7"
928984
resolved "https://registry.yarnpkg.com/@serverless/enterprise-plugin/-/enterprise-plugin-1.0.7.tgz#0c99b5845f964552ab92b864d1320acd7c56bc05"
@@ -4672,7 +4728,7 @@ https-browserify@^1.0.0:
46724728
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
46734729
integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=
46744730

4675-
https-proxy-agent@^2.2.1:
4731+
https-proxy-agent@2.2.1, https-proxy-agent@^2.2.1:
46764732
version "2.2.1"
46774733
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz#51552970fa04d723e04c56d04178c3f92592bbc0"
46784734
integrity sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==
@@ -6450,6 +6506,11 @@ lru-cache@^5.0.0, lru-cache@^5.1.1:
64506506
dependencies:
64516507
yallist "^3.0.2"
64526508

6509+
lru_map@0.3.3:
6510+
version "0.3.3"
6511+
resolved "https://registry.yarnpkg.com/lru_map/-/lru_map-0.3.3.tgz#b5c8351b9464cbd750335a79650a0ec0e56118dd"
6512+
integrity sha1-tcg1G5Rky9dQM1p5ZQoOwOVhGN0=
6513+
64536514
lsmod@1.0.0:
64546515
version "1.0.0"
64556516
resolved "https://registry.yarnpkg.com/lsmod/-/lsmod-1.0.0.tgz#9a00f76dca36eb23fa05350afe1b585d4299e64b"

0 commit comments

Comments
 (0)