remove sentry
This commit is contained in:
parent
4d74e55265
commit
8005d7192e
1738
package-lock.json
generated
1738
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -98,7 +98,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.556.0",
|
"@aws-sdk/client-s3": "^3.556.0",
|
||||||
"@sentry/sveltekit": "^8.30.0",
|
|
||||||
"greeks": "^1.0.0",
|
"greeks": "^1.0.0",
|
||||||
"html2canvas": "^1.4.1",
|
"html2canvas": "^1.4.1",
|
||||||
"https": "^1.0.0",
|
"https": "^1.0.0",
|
||||||
|
|||||||
@ -1,11 +0,0 @@
|
|||||||
import { handleErrorWithSentry, replayIntegration } from "@sentry/sveltekit";
|
|
||||||
import * as Sentry from "@sentry/sveltekit";
|
|
||||||
|
|
||||||
Sentry.init({
|
|
||||||
dsn: import.meta.env.VITE_SENTRY,
|
|
||||||
|
|
||||||
tracesSampleRate: 1.0,
|
|
||||||
});
|
|
||||||
|
|
||||||
// If you have a custom error handler, pass it to `handleErrorWithSentry`
|
|
||||||
export const handleError = handleErrorWithSentry();
|
|
||||||
@ -1,86 +1,76 @@
|
|||||||
import { sequence } from "@sveltejs/kit/hooks";
|
import { sequence } from "@sveltejs/kit/hooks";
|
||||||
import * as Sentry from "@sentry/sveltekit";
|
|
||||||
import PocketBase from "pocketbase";
|
import PocketBase from "pocketbase";
|
||||||
import { serializeNonPOJOs } from "$lib/utils";
|
import { serializeNonPOJOs } from "$lib/utils";
|
||||||
|
|
||||||
Sentry.init({
|
export const handle = sequence(async ({ event, resolve }) => {
|
||||||
dsn: import.meta.env.VITE_SENTRY,
|
// Use optional chaining and nullish coalescing for safer property access
|
||||||
tracesSampleRate: 1,
|
const regionHeader =
|
||||||
});
|
event?.request?.headers?.get("x-vercel-id") ??
|
||||||
|
"fra1::fra1::8t4xg-1700258428633-157d82fdfcc7";
|
||||||
|
|
||||||
export const handle = sequence(
|
const ip =
|
||||||
Sentry.sentryHandle(),
|
event.request.headers.get("x-forwarded-for") ||
|
||||||
async ({ event, resolve }) => {
|
event.request.headers.get("remote-address");
|
||||||
// Use optional chaining and nullish coalescing for safer property access
|
|
||||||
const regionHeader =
|
|
||||||
event?.request?.headers?.get("x-vercel-id") ??
|
|
||||||
"fra1::fra1::8t4xg-1700258428633-157d82fdfcc7";
|
|
||||||
|
|
||||||
const ip =
|
let isUS = false;
|
||||||
event.request.headers.get("x-forwarded-for") ||
|
|
||||||
event.request.headers.get("remote-address");
|
|
||||||
|
|
||||||
let isUS = false;
|
if (ip) {
|
||||||
|
const geoResponse = await fetch(`https://ipinfo.io/${ip}/geo`);
|
||||||
if (ip) {
|
const geoData = await geoResponse.json();
|
||||||
const geoResponse = await fetch(`https://ipinfo.io/${ip}/geo`);
|
if (geoData.country === "US") {
|
||||||
const geoData = await geoResponse.json();
|
isUS = true;
|
||||||
if (geoData.country === "US") {
|
//console.log("yelllo", geoData);
|
||||||
isUS = true;
|
|
||||||
//console.log("yelllo", geoData);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use a ternary operator instead of the logical OR for better compatibility
|
|
||||||
const pbURL = isUS
|
|
||||||
? import.meta.env.VITE_USEAST_POCKETBASE_URL
|
|
||||||
: import.meta.env.VITE_EU_POCKETBASE_URL;
|
|
||||||
const apiURL = isUS
|
|
||||||
? import.meta.env.VITE_USEAST_API_URL
|
|
||||||
: import.meta.env.VITE_EU_API_URL;
|
|
||||||
const fastifyURL = isUS
|
|
||||||
? import.meta.env.VITE_USEAST_FASTIFY_URL
|
|
||||||
: import.meta.env.VITE_EU_FASTIFY_URL;
|
|
||||||
const wsURL = isUS
|
|
||||||
? import.meta.env.VITE_USEAST_WS_URL
|
|
||||||
: import.meta.env.VITE_EU_WS_URL;
|
|
||||||
|
|
||||||
event.locals = {
|
|
||||||
region: decodeURIComponent(regionHeader),
|
|
||||||
pb: new PocketBase(pbURL),
|
|
||||||
apiURL,
|
|
||||||
fastifyURL,
|
|
||||||
wsURL,
|
|
||||||
apiKey: import.meta.env.VITE_STOCKNEAR_API_KEY,
|
|
||||||
};
|
|
||||||
|
|
||||||
const authCookie = event?.request?.headers?.get("cookie") || "";
|
|
||||||
event.locals.pb.authStore.loadFromCookie(authCookie);
|
|
||||||
|
|
||||||
if (event?.locals?.pb?.authStore?.isValid) {
|
|
||||||
try {
|
|
||||||
await event.locals.pb.collection("users").authRefresh();
|
|
||||||
event.locals.user = serializeNonPOJOs(event.locals.pb.authStore.model);
|
|
||||||
} catch (_) {
|
|
||||||
event.locals.pb.authStore.clear();
|
|
||||||
event.locals.user = undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await resolve(event);
|
|
||||||
|
|
||||||
// Use a more compatible way to set the cookie
|
|
||||||
const cookieString = event.locals.pb.authStore.exportToCookie({
|
|
||||||
httpOnly: true,
|
|
||||||
path: "/",
|
|
||||||
sameSite: "lax",
|
|
||||||
secure: true,
|
|
||||||
maxAge: 60 * 60 * 24 * 365,
|
|
||||||
});
|
|
||||||
|
|
||||||
response.headers.append("set-cookie", cookieString);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
export const handleError = Sentry.handleErrorWithSentry();
|
// Use a ternary operator instead of the logical OR for better compatibility
|
||||||
|
const pbURL = isUS
|
||||||
|
? import.meta.env.VITE_USEAST_POCKETBASE_URL
|
||||||
|
: import.meta.env.VITE_EU_POCKETBASE_URL;
|
||||||
|
const apiURL = isUS
|
||||||
|
? import.meta.env.VITE_USEAST_API_URL
|
||||||
|
: import.meta.env.VITE_EU_API_URL;
|
||||||
|
const fastifyURL = isUS
|
||||||
|
? import.meta.env.VITE_USEAST_FASTIFY_URL
|
||||||
|
: import.meta.env.VITE_EU_FASTIFY_URL;
|
||||||
|
const wsURL = isUS
|
||||||
|
? import.meta.env.VITE_USEAST_WS_URL
|
||||||
|
: import.meta.env.VITE_EU_WS_URL;
|
||||||
|
|
||||||
|
event.locals = {
|
||||||
|
region: decodeURIComponent(regionHeader),
|
||||||
|
pb: new PocketBase(pbURL),
|
||||||
|
apiURL,
|
||||||
|
fastifyURL,
|
||||||
|
wsURL,
|
||||||
|
apiKey: import.meta.env.VITE_STOCKNEAR_API_KEY,
|
||||||
|
};
|
||||||
|
|
||||||
|
const authCookie = event?.request?.headers?.get("cookie") || "";
|
||||||
|
event.locals.pb.authStore.loadFromCookie(authCookie);
|
||||||
|
|
||||||
|
if (event?.locals?.pb?.authStore?.isValid) {
|
||||||
|
try {
|
||||||
|
await event.locals.pb.collection("users").authRefresh();
|
||||||
|
event.locals.user = serializeNonPOJOs(event.locals.pb.authStore.model);
|
||||||
|
} catch (_) {
|
||||||
|
event.locals.pb.authStore.clear();
|
||||||
|
event.locals.user = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await resolve(event);
|
||||||
|
|
||||||
|
// Use a more compatible way to set the cookie
|
||||||
|
const cookieString = event.locals.pb.authStore.exportToCookie({
|
||||||
|
httpOnly: true,
|
||||||
|
path: "/",
|
||||||
|
sameSite: "lax",
|
||||||
|
secure: true,
|
||||||
|
maxAge: 60 * 60 * 24 * 365,
|
||||||
|
});
|
||||||
|
|
||||||
|
response.headers.append("set-cookie", cookieString);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
});
|
||||||
|
|||||||
@ -1,16 +1,10 @@
|
|||||||
import { sentrySvelteKit } from "@sentry/sveltekit";
|
|
||||||
import { sveltekit } from "@sveltejs/kit/vite";
|
import { sveltekit } from "@sveltejs/kit/vite";
|
||||||
import { visualizer } from "rollup-plugin-visualizer";
|
//import { visualizer } from "rollup-plugin-visualizer";
|
||||||
|
|
||||||
/** @type {import('vite').UserConfig} */
|
/** @type {import('vite').UserConfig} */
|
||||||
const config = {
|
const config = {
|
||||||
plugins: [
|
plugins: [
|
||||||
sentrySvelteKit({
|
//visualizer({ open: true }) // Plugin to visualize the bundle
|
||||||
sourceMapsUploadOptions: {
|
|
||||||
org: "stocknear",
|
|
||||||
project: "stocknear",
|
|
||||||
},
|
|
||||||
}), //visualizer({ open: true }) // Plugin to visualize the bundle
|
|
||||||
sveltekit(),
|
sveltekit(),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user