Skip to content

Commit e2ae8b1

Browse files
authored
feat: Update app runner (#12)
1 parent 95ae34a commit e2ae8b1

20 files changed

+892
-41
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SENTRY_DSN=

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ web_modules/
7777
.env.development.local
7878
.env.test.local
7979
.env.production.local
80-
.env.local
8180

8281
# parcel-bundler cache (https://parceljs.org/)
8382
.cache

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ The main purpose of this repository is to visualize the differences between the
66
[Sentry JS SDK](https://github.com/getsentry/sentry-javascript) version 7 and version 8. Those
77
example applications can also be used as a reference for using the JS SDKs.
88

9+
## Setup
10+
11+
1. Clone the repository
12+
2. Copy the `.env.example` file to `.env` and set the `SENTRY_DSN` variable in it
13+
914
## How to test apps and save the payloads
1015

11-
1. Change the proxy-server options in `utils/event-proxy-server/start-event-proxy.ts`
12-
- `appName`: the app folder name you want to test (e.g. `apps/express` -> `appName: 'express'`)
13-
- `filenameOrigin`: where the filename comes from (usually `url` but sometimes `transactionName`)
14-
2. Make sure you have a folder named like the app in `payload-files`.
16+
1. Make sure you have a folder named like the app in `payload-files`.
1517
- Example: `apps/express` -> `payload-files/express`
16-
3. Add an env variable for `E2E_TEST_DSN`
17-
4. Run `yarn start:proxy-server`.
18-
5. Run `yarn start:[app]` like `start:express`.
19-
6. Check the "Disable Cache" option in the DevTools Network tab of your browser.
20-
7. Open the following URLs in your browser.
21-
8. The json file will be generated.
18+
2. Run `yarn start:[app]`, e.g. `yarn start:express`.
19+
3. Check the "Disable Cache" option in the DevTools Network tab of your browser.
20+
4. Open the following URLs in your browser.
21+
5. The json file will be generated.
2222

2323
### Test URLs (for servers like express, fastify)
2424

apps/express/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
},
1717
"dependencies": {
1818
"@sentry/node": "7.110.1",
19+
"dotenv": "^16.4.5",
1920
"express": "^4.19.2"
2021
},
2122
"devDependencies": {

apps/express/src/app.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import * as Sentry from '@sentry/node';
22
import express from 'express';
3+
import dotenv from 'dotenv';
4+
5+
dotenv.config({ path: './../../.env' });
36

47
declare global {
58
namespace globalThis {
@@ -12,7 +15,7 @@ const port = 3030;
1215

1316
Sentry.init({
1417
environment: 'qa', // dynamic sampling bias to keep transactions
15-
dsn: process.env.E2E_TEST_DSN,
18+
dsn: process.env.SENTRY_DSN,
1619
includeLocalVariables: true,
1720
debug: true,
1821
tunnel: `http://localhost:3031/`, // proxy server

apps/fastify/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
},
1616
"dependencies": {
1717
"@sentry/node": "7.110.1",
18+
"dotenv": "^16.4.5",
1819
"fastify": "4.26.2"
1920
}
2021
}

apps/fastify/src/app.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import * as Sentry from '@sentry/node';
22
import { fastify } from 'fastify';
3+
import dotenv from 'dotenv';
4+
5+
dotenv.config({ path: './../../.env' });
36

47
declare global {
58
namespace globalThis {
@@ -11,7 +14,7 @@ const app = fastify();
1114

1215
Sentry.init({
1316
environment: 'qa', // dynamic sampling bias to keep transactions
14-
dsn: process.env.E2E_TEST_DSN,
17+
dsn: process.env.SENTRY_DSN,
1518
includeLocalVariables: true,
1619
integrations: [],
1720
tracesSampleRate: 1,

apps/koa/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"dependencies": {
1818
"@koa/router": "12.0.1",
1919
"@sentry/node": "7.110.1",
20+
"dotenv": "^16.4.5",
2021
"koa": "2.15.3"
2122
},
2223
"devDependencies": {

apps/koa/src/app.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import Koa from 'koa';
22
import Router from '@koa/router';
33
import * as Sentry from '@sentry/node';
44
import { stripUrlQueryAndFragment } from '@sentry/utils';
5+
import dotenv from 'dotenv';
6+
7+
dotenv.config({ path: './../../.env' });
58

69
declare global {
710
namespace globalThis {
@@ -14,7 +17,7 @@ const app = new Koa();
1417

1518
Sentry.init({
1619
environment: 'qa', // dynamic sampling bias to keep transactions
17-
dsn: process.env.E2E_TEST_DSN,
20+
dsn: process.env.SENTRY_DSN,
1821
includeLocalVariables: true,
1922
debug: true,
2023
tunnel: `http://localhost:3031/`, // proxy server

apps/nestjs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@nestjs/platform-express": "10.3.7",
2121
"@sentry/node": "7.110.1",
2222
"@sentry/types": "7.110.1",
23+
"dotenv": "^16.4.5",
2324
"reflect-metadata": "0.2.2",
2425
"rxjs": "7.8.1"
2526
},

apps/nestjs/src/main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { NestFactory } from '@nestjs/core';
22
import * as Sentry from '@sentry/node';
33
import { AppModule } from './app.module';
4+
import dotenv from 'dotenv';
5+
6+
dotenv.config({ path: './../../.env' });
47

58
async function bootstrap() {
69
Sentry.init({
710
environment: 'qa', // dynamic sampling bias to keep transactions
8-
dsn: process.env.E2E_TEST_DSN,
11+
dsn: process.env.SENTRY_DSN,
912
includeLocalVariables: true,
1013
tunnel: `http://localhost:3031/`, // proxy server
1114
tracesSampleRate: 1,

apps/nextjs-13_2_0/sentry.client.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as Sentry from '@sentry/nextjs';
22

33
Sentry.init({
44
environment: 'qa', // dynamic sampling bias to keep transactions
5-
dsn: process.env.E2E_TEST_DSN,
5+
dsn: process.env.SENTRY_DSN,
66
includeLocalVariables: true,
77
tunnel: `http://localhost:3031/`, // proxy server
88
tracesSampleRate: 1,

apps/nextjs-13_2_0/sentry.edge.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as Sentry from '@sentry/nextjs';
22

33
Sentry.init({
44
environment: 'qa', // dynamic sampling bias to keep transactions
5-
dsn: process.env.E2E_TEST_DSN,
5+
dsn: process.env.SENTRY_DSN,
66
includeLocalVariables: true,
77
tunnel: `http://localhost:3031/`, // proxy server
88
tracesSampleRate: 1,

apps/nextjs-13_2_0/sentry.server.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as Sentry from '@sentry/nextjs';
22

33
Sentry.init({
44
environment: 'qa', // dynamic sampling bias to keep transactions
5-
dsn: process.env.E2E_TEST_DSN,
5+
dsn: process.env.SENTRY_DSN,
66
includeLocalVariables: true,
77
tunnel: `http://localhost:3031/`, // proxy server
88
tracesSampleRate: 1,

apps/nextjs-14_2_1/sentry.client.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as Sentry from '@sentry/nextjs';
22

33
Sentry.init({
44
environment: 'qa', // dynamic sampling bias to keep transactions
5-
dsn: process.env.E2E_TEST_DSN,
5+
dsn: process.env.SENTRY_DSN,
66
includeLocalVariables: true,
77
tunnel: `http://localhost:3031/`, // proxy server
88
tracesSampleRate: 1,

apps/nextjs-14_2_1/sentry.edge.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as Sentry from '@sentry/nextjs';
22

33
Sentry.init({
44
environment: 'qa', // dynamic sampling bias to keep transactions
5-
dsn: process.env.E2E_TEST_DSN,
5+
dsn: process.env.SENTRY_DSN,
66
includeLocalVariables: true,
77
tunnel: `http://localhost:3031/`, // proxy server
88
tracesSampleRate: 1,

apps/nextjs-14_2_1/sentry.server.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as Sentry from '@sentry/nextjs';
22

33
Sentry.init({
44
environment: 'qa', // dynamic sampling bias to keep transactions
5-
dsn: process.env.E2E_TEST_DSN,
5+
dsn: process.env.SENTRY_DSN,
66
includeLocalVariables: true,
77
tunnel: `http://localhost:3031/`, // proxy server
88
tracesSampleRate: 1,

package.json

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,24 @@
99
"packageManager": "[email protected]",
1010
"scripts": {
1111
"start:proxy-server": "yarn workspace event-proxy-server run start",
12-
"start:express": "yarn workspace express-test-application run start",
13-
"start:fastify": "yarn workspace fastify-test-application run start",
14-
"start:nestjs": "yarn workspace nestjs-test-application run start",
15-
"start:koa": "yarn workspace koa-test-application run start",
16-
"start:nextjs-14_2_1": "yarn workspace nextjs-14_2_1-test-application run dev",
17-
"start:nextjs-13_2_0": "yarn workspace nextjs-13_2_0-test-application run dev",
12+
"start:proxy-server:express": "APP_NAME=express yarn workspace event-proxy-server run start",
13+
"start:proxy-server:fastify": "APP_NAME=fastify yarn workspace event-proxy-server run start",
14+
"start:proxy-server:nestjs": "APP_NAME=nestjs yarn workspace event-proxy-server run start",
15+
"start:proxy-server:koa": "APP_NAME=koa yarn workspace event-proxy-server run start",
16+
"start:proxy-server:nextjs-13_2_0": "APP_NAME=nextjs-13_2_0 yarn workspace event-proxy-server run start",
17+
"start:proxy-server:nextjs-14_2_1": "APP_NAME=nextjs-14_2_1 yarn workspace event-proxy-server run start",
18+
"start:app:express": "yarn workspace express-test-application run start",
19+
"start:app:fastify": "yarn workspace fastify-test-application run start",
20+
"start:app:nestjs": "yarn workspace nestjs-test-application run start",
21+
"start:app:koa": "yarn workspace koa-test-application run start",
22+
"start:app:nextjs-14_2_1": "yarn workspace nextjs-14_2_1-test-application run dev",
23+
"start:app:nextjs-13_2_0": "yarn workspace nextjs-13_2_0-test-application run dev",
24+
"start:express": "run-p start:proxy-server:express start:app:express",
25+
"start:fastify": "run-p start:proxy-server:fastify start:app:fastify",
26+
"start:nestjs": "run-p start:proxy-server:nestjs start:app:nestjs",
27+
"start:koa": "run-p start:proxy-server:koa start:app:koa",
28+
"start:nextjs-13_2_0": "run-p start:proxy-server:nextjs-13_2_0 start:app:nextjs-13_2_0",
29+
"start:nextjs-14_2_1": "run-p start:proxy-server:nextjs-14_2_1 start:app:nextjs-14_2_1",
1830
"fix:prettier": "prettier . --write",
1931
"fix:lint": "yarn run eslint --fix",
2032
"lint": "yarn run eslint"
@@ -37,6 +49,7 @@
3749
"eslint": "^9.0.0",
3850
"globals": "^15.0.0",
3951
"nodemon": "^3.1.0",
52+
"npm-run-all": "^4.1.5",
4053
"prettier": "^3.2.5",
4154
"ts-node": "10.9.2",
4255
"typescript": "5.4.4",
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
import { startEventProxyServer } from './src/event-proxy-server';
22

3+
const appName = process.env.APP_NAME;
4+
const filenameOrigin = process.env.FILENAME_ORIGIN || 'url';
5+
6+
if (!appName) {
7+
throw new Error('You have to provide an APP_NAME environment variable.');
8+
}
9+
10+
if (filenameOrigin !== 'url' && filenameOrigin !== 'transactionName') {
11+
throw new Error(
12+
"FILENAME_ORIGIN environment variable must be either 'url' or 'transactionName'.",
13+
);
14+
}
15+
316
startEventProxyServer({
417
port: 3031,
5-
appName: 'express',
6-
filenameOrigin: 'url',
18+
appName,
19+
filenameOrigin,
720
});

0 commit comments

Comments
 (0)