Skip to content

feat: Update app runner #12

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

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SENTRY_DSN=
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ web_modules/
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ The main purpose of this repository is to visualize the differences between the
[Sentry JS SDK](https://github.com/getsentry/sentry-javascript) version 7 and version 8. Those
example applications can also be used as a reference for using the JS SDKs.

## Setup

1. Clone the repository
2. Copy the `.env.example` file to `.env` and set the `SENTRY_DSN` variable in it

## How to test apps and save the payloads

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

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

Expand Down
1 change: 1 addition & 0 deletions apps/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"dependencies": {
"@sentry/node": "7.110.1",
"dotenv": "^16.4.5",
"express": "^4.19.2"
},
"devDependencies": {
Expand Down
5 changes: 4 additions & 1 deletion apps/express/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import * as Sentry from '@sentry/node';
import express from 'express';
import dotenv from 'dotenv';

dotenv.config({ path: './../../.env' });

declare global {
namespace globalThis {
Expand All @@ -12,7 +15,7 @@ const port = 3030;

Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: process.env.E2E_TEST_DSN,
dsn: process.env.SENTRY_DSN,
includeLocalVariables: true,
debug: true,
tunnel: `http://localhost:3031/`, // proxy server
Expand Down
1 change: 1 addition & 0 deletions apps/fastify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"dependencies": {
"@sentry/node": "7.110.1",
"dotenv": "^16.4.5",
"fastify": "4.26.2"
}
}
5 changes: 4 additions & 1 deletion apps/fastify/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import * as Sentry from '@sentry/node';
import { fastify } from 'fastify';
import dotenv from 'dotenv';

dotenv.config({ path: './../../.env' });

declare global {
namespace globalThis {
Expand All @@ -11,7 +14,7 @@ const app = fastify();

Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: process.env.E2E_TEST_DSN,
dsn: process.env.SENTRY_DSN,
includeLocalVariables: true,
integrations: [],
tracesSampleRate: 1,
Expand Down
1 change: 1 addition & 0 deletions apps/koa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"dependencies": {
"@koa/router": "12.0.1",
"@sentry/node": "7.110.1",
"dotenv": "^16.4.5",
"koa": "2.15.3"
},
"devDependencies": {
Expand Down
5 changes: 4 additions & 1 deletion apps/koa/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import Koa from 'koa';
import Router from '@koa/router';
import * as Sentry from '@sentry/node';
import { stripUrlQueryAndFragment } from '@sentry/utils';
import dotenv from 'dotenv';

dotenv.config({ path: './../../.env' });

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

Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: process.env.E2E_TEST_DSN,
dsn: process.env.SENTRY_DSN,
includeLocalVariables: true,
debug: true,
tunnel: `http://localhost:3031/`, // proxy server
Expand Down
1 change: 1 addition & 0 deletions apps/nestjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@nestjs/platform-express": "10.3.7",
"@sentry/node": "7.110.1",
"@sentry/types": "7.110.1",
"dotenv": "^16.4.5",
"reflect-metadata": "0.2.2",
"rxjs": "7.8.1"
},
Expand Down
5 changes: 4 additions & 1 deletion apps/nestjs/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { NestFactory } from '@nestjs/core';
import * as Sentry from '@sentry/node';
import { AppModule } from './app.module';
import dotenv from 'dotenv';

dotenv.config({ path: './../../.env' });

async function bootstrap() {
Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: process.env.E2E_TEST_DSN,
dsn: process.env.SENTRY_DSN,
includeLocalVariables: true,
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1,
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs-13_2_0/sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as Sentry from '@sentry/nextjs';

Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: process.env.E2E_TEST_DSN,
dsn: process.env.SENTRY_DSN,
includeLocalVariables: true,
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1,
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs-13_2_0/sentry.edge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as Sentry from '@sentry/nextjs';

Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: process.env.E2E_TEST_DSN,
dsn: process.env.SENTRY_DSN,
includeLocalVariables: true,
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1,
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs-13_2_0/sentry.server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as Sentry from '@sentry/nextjs';

Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: process.env.E2E_TEST_DSN,
dsn: process.env.SENTRY_DSN,
includeLocalVariables: true,
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1,
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs-14_2_1/sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as Sentry from '@sentry/nextjs';

Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: process.env.E2E_TEST_DSN,
dsn: process.env.SENTRY_DSN,
includeLocalVariables: true,
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1,
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs-14_2_1/sentry.edge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as Sentry from '@sentry/nextjs';

Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: process.env.E2E_TEST_DSN,
dsn: process.env.SENTRY_DSN,
includeLocalVariables: true,
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1,
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs-14_2_1/sentry.server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as Sentry from '@sentry/nextjs';

Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: process.env.E2E_TEST_DSN,
dsn: process.env.SENTRY_DSN,
includeLocalVariables: true,
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1,
Expand Down
25 changes: 19 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,24 @@
"packageManager": "[email protected]",
"scripts": {
"start:proxy-server": "yarn workspace event-proxy-server run start",
"start:express": "yarn workspace express-test-application run start",
"start:fastify": "yarn workspace fastify-test-application run start",
"start:nestjs": "yarn workspace nestjs-test-application run start",
"start:koa": "yarn workspace koa-test-application run start",
"start:nextjs-14_2_1": "yarn workspace nextjs-14_2_1-test-application run dev",
"start:nextjs-13_2_0": "yarn workspace nextjs-13_2_0-test-application run dev",
"start:proxy-server:express": "APP_NAME=express yarn workspace event-proxy-server run start",
"start:proxy-server:fastify": "APP_NAME=fastify yarn workspace event-proxy-server run start",
"start:proxy-server:nestjs": "APP_NAME=nestjs yarn workspace event-proxy-server run start",
"start:proxy-server:koa": "APP_NAME=koa yarn workspace event-proxy-server run start",
"start:proxy-server:nextjs-13_2_0": "APP_NAME=nextjs-13_2_0 yarn workspace event-proxy-server run start",
"start:proxy-server:nextjs-14_2_1": "APP_NAME=nextjs-14_2_1 yarn workspace event-proxy-server run start",
"start:app:express": "yarn workspace express-test-application run start",
"start:app:fastify": "yarn workspace fastify-test-application run start",
"start:app:nestjs": "yarn workspace nestjs-test-application run start",
"start:app:koa": "yarn workspace koa-test-application run start",
"start:app:nextjs-14_2_1": "yarn workspace nextjs-14_2_1-test-application run dev",
"start:app:nextjs-13_2_0": "yarn workspace nextjs-13_2_0-test-application run dev",
"start:express": "run-p start:proxy-server:express start:app:express",
"start:fastify": "run-p start:proxy-server:fastify start:app:fastify",
"start:nestjs": "run-p start:proxy-server:nestjs start:app:nestjs",
"start:koa": "run-p start:proxy-server:koa start:app:koa",
"start:nextjs-13_2_0": "run-p start:proxy-server:nextjs-13_2_0 start:app:nextjs-13_2_0",
"start:nextjs-14_2_1": "run-p start:proxy-server:nextjs-14_2_1 start:app:nextjs-14_2_1",
"fix:prettier": "prettier . --write",
"fix:lint": "yarn run eslint --fix",
"lint": "yarn run eslint"
Expand All @@ -37,6 +49,7 @@
"eslint": "^9.0.0",
"globals": "^15.0.0",
"nodemon": "^3.1.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.5",
"ts-node": "10.9.2",
"typescript": "5.4.4",
Expand Down
17 changes: 15 additions & 2 deletions utils/event-proxy-server/start-event-proxy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import { startEventProxyServer } from './src/event-proxy-server';

const appName = process.env.APP_NAME;
const filenameOrigin = process.env.FILENAME_ORIGIN || 'url';

if (!appName) {
throw new Error('You have to provide an APP_NAME environment variable.');
}

if (filenameOrigin !== 'url' && filenameOrigin !== 'transactionName') {
throw new Error(
"FILENAME_ORIGIN environment variable must be either 'url' or 'transactionName'.",
);
}

startEventProxyServer({
port: 3031,
appName: 'express',
filenameOrigin: 'url',
appName,
filenameOrigin,
});
Loading