feat: revert all the mod changes

This commit is contained in:
Nevo David 2026-03-22 10:23:52 +07:00
parent 40c443ba96
commit 1aa47351a4
15 changed files with 95 additions and 337 deletions

View file

@ -169,20 +169,10 @@ export class AuthController {
}
response.header('reload', 'true');
try {
Sentry.metrics.count('auth.login.success', 1, {
attributes: { provider: body.provider || 'LOCAL' },
} as any);
} catch (e) {}
response.status(200).json({
login: true,
});
} catch (e: any) {
try {
Sentry.metrics.count('auth.login.failure', 1, {
attributes: { provider: body?.provider || 'LOCAL' },
} as any);
} catch (er) {}
response.status(400).send(e.message);
}
}
@ -270,9 +260,6 @@ export class AuthController {
const { jwt, token } = await this._authService.checkExists(provider, code);
if (token) {
try {
Sentry.metrics.count('oauth.connects', 1, { attributes: { provider } } as any);
} catch (e) {}
return response.json({ token });
}

View file

@ -25,7 +25,6 @@ import { UploadFactory } from '@gitroom/nestjs-libraries/upload/upload.factory';
import { SaveMediaInformationDto } from '@gitroom/nestjs-libraries/dtos/media/save.media.information.dto';
import { VideoDto } from '@gitroom/nestjs-libraries/dtos/videos/video.dto';
import { VideoFunctionDto } from '@gitroom/nestjs-libraries/dtos/videos/video.function.dto';
import * as Sentry from '@sentry/nestjs';
@ApiTags('Media')
@Controller('/media')
@ -93,26 +92,13 @@ export class MediaController {
@UploadedFile() file: Express.Multer.File
) {
const originalName = file?.originalname || '';
try {
const uploadedFile = await this.storage.uploadFile(file);
try {
Sentry.metrics.count('uploads.total', 1);
Sentry.metrics.distribution('upload_size_bytes', file?.size || 0);
} catch (e) {}
return this._mediaService.saveFile(
org.id,
uploadedFile.originalname,
uploadedFile.path,
originalName
);
} catch (err) {
try {
Sentry.metrics.count('uploads.failure', 1);
} catch (e) {}
throw err;
}
const uploadedFile = await this.storage.uploadFile(file);
return this._mediaService.saveFile(
org.id,
uploadedFile.originalname,
uploadedFile.path,
originalName
);
}
@Post('/save-media')
@ -149,31 +135,19 @@ export class MediaController {
@Body('preventSave') preventSave: string = 'false'
) {
const originalName = file.originalname;
try {
const getFile = await this.storage.uploadFile(file);
const getFile = await this.storage.uploadFile(file);
try {
Sentry.metrics.count('uploads.total', 1);
Sentry.metrics.distribution('upload_size_bytes', file?.size || 0);
} catch (e) {}
if (preventSave === 'true') {
const { path } = getFile;
return { path };
}
return this._mediaService.saveFile(
org.id,
getFile.originalname,
getFile.path,
originalName
);
} catch (err) {
try {
Sentry.metrics.count('uploads.failure', 1);
} catch (e) {}
throw err;
if (preventSave === 'true') {
const { path } = getFile;
return { path };
}
return this._mediaService.saveFile(
org.id,
getFile.originalname,
getFile.path,
originalName
);
}
@Post('/:endpoint')
@ -192,27 +166,15 @@ export class MediaController {
const name = upload.Location.split('/').pop();
const originalName = req.body?.file?.name;
try {
const saveFile = await this._mediaService.saveFile(
org.id,
name,
// @ts-ignore
upload.Location,
originalName || undefined
);
const saveFile = await this._mediaService.saveFile(
org.id,
name,
// @ts-ignore
upload.Location,
originalName || undefined
);
try {
Sentry.metrics.count('uploads.total', 1);
Sentry.metrics.distribution('upload_size_bytes', (req.headers['content-length'] ? Number(req.headers['content-length']) : 0) || 0);
} catch (e) {}
res.status(200).json({ ...upload, saved: saveFile });
} catch (err) {
try {
Sentry.metrics.count('uploads.failure', 1);
} catch (e) {}
throw err;
}
res.status(200).json({ ...upload, saved: saveFile });
}
@Get('/')

View file

@ -16,7 +16,6 @@ import { GetPostsDto } from '@gitroom/nestjs-libraries/dtos/posts/get.posts.dto'
import { GetPostsListDto } from '@gitroom/nestjs-libraries/dtos/posts/get.posts.list.dto';
import { CheckPolicies } from '@gitroom/backend/services/auth/permissions/permissions.ability';
import { ApiTags } from '@nestjs/swagger';
import * as Sentry from '@sentry/nestjs';
import { GeneratorDto } from '@gitroom/nestjs-libraries/dtos/generator/generator.dto';
import { CreateGeneratedPostsDto } from '@gitroom/nestjs-libraries/dtos/generator/create.generated.posts.dto';
import { AgentGraphService } from '@gitroom/nestjs-libraries/agent/agent.graph.service';
@ -163,18 +162,7 @@ export class PostsController {
) {
console.log(JSON.stringify(rawBody, null, 2));
const body = await this._postsService.mapTypeToPost(rawBody, org.id);
const created = await this._postsService.createPost(org.id, body);
try {
for (const p of body.posts || []) {
const providerRaw = (p?.settings && p.settings.__type) || (p?.integration && p.integration.id) || '';
const provider = (typeof providerRaw === 'string' ? providerRaw.split('-')[0] : '')
.toLowerCase();
Sentry.metrics.count('posts.created', 1, { attributes: { provider } } as any);
}
} catch (e) {}
return created;
return this._postsService.createPost(org.id, body);
}
@Post('/generator/draft')
@ -216,11 +204,7 @@ export class PostsController {
@Body('date') date: string,
@Body('action') action: 'schedule' | 'update' = 'schedule'
) {
return (async () => {
const res = await this._postsService.changeDate(org.id, id, date, action);
return res;
})();
return this._postsService.changeDate(org.id, id, date, action);
}
@Post('/separate-posts')

View file

@ -2,8 +2,7 @@ import { useIntegration } from '@gitroom/frontend/components/launches/helpers/us
import { useMediaDirectory } from '@gitroom/react/helpers/use.media.directory';
import clsx from 'clsx';
import { VideoOrImage } from '@gitroom/react/helpers/video.or.image';
import { FC, useEffect } from 'react';
import * as Sentry from '@sentry/nextjs';
import { FC } from 'react';
import { textSlicer } from '@gitroom/helpers/utils/count.length';
import Image from 'next/image';
import { useLaunchStore } from '@gitroom/frontend/components/new-launch/store';
@ -12,11 +11,6 @@ import { stripHtmlValidation } from '@gitroom/helpers/utils/strip.html.validatio
export const GeneralPreviewComponent: FC<{
maximumCharacters?: number;
}> = (props) => {
useEffect(() => {
try {
Sentry.metrics.count('preview.render', 1);
} catch (e) {}
}, []);
const { value: topValue, integration } = useIntegration();
const current = useLaunchStore((state) => state.current);
const mediaDir = useMediaDirectory();

View file

@ -11,7 +11,6 @@ import React, {
forwardRef,
useImperativeHandle,
} from 'react';
import * as Sentry from '@sentry/nextjs';
import clsx from 'clsx';
import { makeId } from '@gitroom/nestjs-libraries/services/make.is';
import EmojiPicker from 'emoji-picker-react';
@ -184,12 +183,6 @@ export const EditorWrapper: FC<{
setLoaded(true);
}, [loaded, loadedState]);
useEffect(() => {
try {
Sentry.metrics.count('editor.open', 1);
} catch (e) {}
}, []);
const canEdit = useMemo(() => {
return current === 'global' || !!internal;
}, [current, internal]);

View file

@ -33,7 +33,6 @@ import { SelectCustomer } from '@gitroom/frontend/components/launches/select.cus
import { CopilotPopup } from '@copilotkit/react-ui';
import { DummyCodeComponent } from '@gitroom/frontend/components/new-launch/dummy.code.component';
import { stripHtmlValidation } from '@gitroom/helpers/utils/strip.html.validation';
import * as Sentry from '@sentry/nextjs';
import {
SettingsIcon,
ChevronDownIcon,
@ -414,10 +413,6 @@ export const ManageModal: FC<AddEditModalProps> = (props) => {
}
if (!dummy) {
try {
Sentry.metrics.count('post.submit', 1, { attributes: { action: type } });
} catch (e) {}
addEditSets
? addEditSets(data)
: await fetch('/posts', {

View file

@ -23,7 +23,6 @@ import {
postId as postIdSearchParam,
} from '@gitroom/nestjs-libraries/temporal/temporal.search.attribute';
import { SubscriptionService } from '@gitroom/nestjs-libraries/database/prisma/subscriptions/subscription.service';
import * as Sentry from '@sentry/nestjs';
@Injectable()
@Activity()
@ -81,31 +80,7 @@ export class PostActivity {
@ActivityMethod()
async updatePost(id: string, postId: string, releaseURL: string) {
const res = await this._postService.updatePost(id, postId, releaseURL);
try {
const posts = await this._postService.getPostByForWebhookId(postId);
const post = Array.isArray(posts) && posts.length ? (posts[0] as any) : (posts as any);
if (post && post.organizationId) {
try {
const running = this._temporalService.client
.getRawClient()
?.workflow.list({ query: `organizationId="${post.organizationId}" AND ExecutionStatus="Running"` });
let count = 0;
if (running) {
for await (const _ of running) {
count++;
}
}
try {
Sentry.metrics.gauge('posts.queued', count, { attributes: { taskQueue: post.integration?.providerIdentifier?.split('-')[0] || 'main' } } as any);
} catch (e) {}
} catch (e) {}
}
} catch (e) {}
return res;
return this._postService.updatePost(id, postId, releaseURL);
}
@ActivityMethod()

View file

@ -1,8 +1,6 @@
import { CreatePostDto } from '@gitroom/nestjs-libraries/dtos/posts/create.post.dto';
import { GetPostsDto } from '@gitroom/nestjs-libraries/dtos/posts/get.posts.dto';
import fetch, { FormData } from 'node-fetch';
import * as Sentry from '@sentry/node';
import crypto from 'crypto';
function toQueryString(obj: Record<string, any>): string {
const params = new URLSearchParams();
@ -21,10 +19,6 @@ export default class Postiz {
) {}
async post(posts: CreatePostDto) {
try {
Sentry.metrics.count('sdk.requests', 1, { attributes: { method: 'post' } } as any);
} catch (e) {}
return (
await fetch(`${this._path}/public/v1/posts`, {
method: 'POST',
@ -38,10 +32,6 @@ export default class Postiz {
}
async postList(filters: GetPostsDto) {
try {
Sentry.metrics.count('sdk.requests', 1, { attributes: { method: 'list' } } as any);
} catch (e) {}
return (
await fetch(`${this._path}/public/v1/posts?${toQueryString(filters)}`, {
method: 'GET',
@ -54,10 +44,6 @@ export default class Postiz {
}
async upload(file: Buffer, extension: string) {
try {
Sentry.metrics.count('sdk.requests', 1, { attributes: { method: 'upload' } } as any);
} catch (e) {}
const formData = new FormData();
const type =
extension === 'png'
@ -86,10 +72,6 @@ export default class Postiz {
}
async integrations() {
try {
Sentry.metrics.count('sdk.requests', 1, { attributes: { method: 'integrations' } } as any);
} catch (e) {}
return (
await fetch(`${this._path}/public/v1/integrations`, {
method: 'GET',
@ -102,10 +84,6 @@ export default class Postiz {
}
deletePost(id: string) {
try {
Sentry.metrics.count('sdk.requests', 1, { attributes: { method: 'delete' } } as any);
} catch (e) {}
return fetch(`${this._path}/public/v1/posts/${id}`, {
method: 'DELETE',
headers: {

View file

@ -7,7 +7,6 @@ import { SaveMediaInformationDto } from '@gitroom/nestjs-libraries/dtos/media/sa
import { VideoManager } from '@gitroom/nestjs-libraries/videos/video.manager';
import { VideoDto } from '@gitroom/nestjs-libraries/dtos/videos/video.dto';
import { UploadFactory } from '@gitroom/nestjs-libraries/upload/upload.factory';
import * as Sentry from '@sentry/nestjs';
import {
AuthorizationActions,
Sections,
@ -42,31 +41,11 @@ export class MediaService {
org,
'ai_images',
async () => {
const start = Date.now();
try {
try {
Sentry.metrics.count('media.generate_attempt', 1, { attributes: { media_type: 'image' } } as any);
} catch (e) {}
if (generatePromptFirst) {
prompt = await this._openAi.generatePromptForPicture(prompt);
console.log('Prompt:', prompt);
}
const res = await this._openAi.generateImage(prompt, !!generatePromptFirst);
try {
Sentry.metrics.count('media.generate_success', 1, { attributes: { media_type: 'image' } } as any);
Sentry.metrics.distribution('media.generation_ms', Date.now() - start, { attributes: { media_type: 'image' } } as any);
} catch (e) {}
return res;
} catch (err) {
try {
Sentry.metrics.count('media.generate_failure', 1, { attributes: { media_type: 'image' } } as any);
} catch (e) {}
throw err;
if (generatePromptFirst) {
prompt = await this._openAi.generatePromptForPicture(prompt);
console.log('Prompt:', prompt);
}
return this._openAi.generateImage(prompt, !!generatePromptFirst);
}
);
@ -126,39 +105,21 @@ export class MediaService {
console.log(body.customParams);
await video.instance.processAndValidate(body.customParams);
console.log('no err');
const start = Date.now();
try {
try {
Sentry.metrics.count('media.generate_attempt', 1, { attributes: { media_type: 'video' } } as any);
} catch (e) {}
return await this._subscriptionService.useCredit(
org,
'ai_videos',
async () => {
const loadedData = await video.instance.process(
body.output,
body.customParams
);
const result = await this._subscriptionService.useCredit(
org,
'ai_videos',
async () => {
const loadedData = await video.instance.process(
body.output,
body.customParams
);
const file = await this.storage.uploadSimple(loadedData);
return this.saveFile(org.id, file.split('/').pop(), file);
}
);
try {
Sentry.metrics.count('media.generate_success', 1, { attributes: { media_type: 'video' } } as any);
Sentry.metrics.distribution('media.generation_ms', Date.now() - start, { attributes: { media_type: 'video' } } as any);
} catch (e) {}
return result;
} catch (err) {
try {
Sentry.metrics.count('media.generate_failure', 1, { attributes: { media_type: 'video' } } as any);
} catch (e) {}
throw err;
}
const file = await this.storage.uploadSimple(loadedData);
return this.saveFile(org.id, file.split('/').pop(), file);
}
);
}
async videoFunction(identifier: string, functionName: string, body: any) {

View file

@ -681,25 +681,6 @@ export class PostsService {
},
]),
});
// update queued-per-org gauge (simple approach: count running workflows for org)
try {
const running = this._temporalService.client
.getRawClient()
?.workflow.list({
query: `organizationId="${orgId}" AND ExecutionStatus="Running"`,
});
let count = 0;
if (running) {
for await (const _ of running) {
count++;
}
}
try {
Sentry.metrics.gauge('posts.queued', count, { attributes: { taskQueue } } as any);
} catch (err) {}
} catch (err) {}
} catch (err) {}
}
@ -738,7 +719,7 @@ export class PostsService {
).catch((err) => {});
}
// metric moved: controller records `posts.created` with org/provider tags
Sentry.metrics.count('post_created', 1);
postList.push({
postId: posts[0].id,
integration: post.integration.id,

View file

@ -7,7 +7,6 @@ import {
SocialProvider,
} from '@gitroom/nestjs-libraries/integrations/social/social.integrations.interface';
import { TemporalService } from 'nestjs-temporal-core';
import * as Sentry from '@sentry/nestjs';
@Injectable()
export class RefreshIntegrationService {
@ -72,61 +71,45 @@ export class RefreshIntegrationService {
integration: Integration,
socialProvider: SocialProvider
): Promise<AuthTokenDetails | false> {
try {
try {
Sentry.metrics.count('provider.refresh_attempt', 1, { attributes: { provider: socialProvider.identifier } } as any);
} catch (e) {}
const refresh: false | AuthTokenDetails = await socialProvider
.refreshToken(integration.refreshToken)
.catch((err) => false);
const refresh: false | AuthTokenDetails = await socialProvider
.refreshToken(integration.refreshToken)
.catch((err) => false);
if (!refresh || !refresh.accessToken) {
try {
Sentry.metrics.count('provider.refresh_fail', 1, { attributes: { provider: socialProvider.identifier } } as any);
} catch (e) {}
await this._integrationService.refreshNeeded(
integration.organizationId,
integration.id
);
await this._integrationService.informAboutRefreshError(
integration.organizationId,
integration
);
await this._integrationService.disconnectChannel(
integration.organizationId,
integration
);
return false;
}
// proceed with reconnect handling below
if (
!socialProvider.reConnect ||
integration.rootInternalId === integration.internalId
) {
return refresh;
}
const reConnect = await socialProvider.reConnect(
integration.rootInternalId,
integration.internalId,
refresh.accessToken
if (!refresh || !refresh.accessToken) {
await this._integrationService.refreshNeeded(
integration.organizationId,
integration.id
);
await this._integrationService.informAboutRefreshError(
integration.organizationId,
integration
);
await this._integrationService.disconnectChannel(
integration.organizationId,
integration
);
return {
...refresh,
...reConnect,
};
} catch (err) {
try {
Sentry.metrics.count('provider.refresh_fail', 1, { attributes: { provider: socialProvider.identifier } } as any);
} catch (e) {}
return false;
}
if (
!socialProvider.reConnect ||
integration.rootInternalId === integration.internalId
) {
return refresh;
}
const reConnect = await socialProvider.reConnect(
integration.rootInternalId,
integration.internalId,
refresh.accessToken
);
return {
...refresh,
...reConnect,
};
}
}

View file

@ -1,7 +1,6 @@
import { timer } from '@gitroom/helpers/utils/timer';
import { Integration } from '@prisma/client';
import { ApplicationFailure } from '@temporalio/activity';
import * as Sentry from '@sentry/nestjs';
export class RefreshToken extends ApplicationFailure {
constructor(identifier: string, json: string, body: BodyInit, message = '') {
@ -105,24 +104,10 @@ export abstract class SocialAbstract {
totalRetries = 0,
ignoreConcurrency = false
): Promise<Response> {
const start = Date.now();
let request: Response;
try {
request = await fetch(url, options);
const latency = Date.now() - start;
try {
Sentry.metrics.distribution('provider.api_latency_ms', latency, { attributes: { provider: this.identifier, endpoint: url, status: 'success' } } as any);
} catch (e) {}
const request = await fetch(url, options);
if (request.status === 200 || request.status === 201) {
return request;
}
} catch (err) {
const latency = Date.now() - start;
try {
Sentry.metrics.distribution('provider.api_latency_ms', latency, { attributes: { provider: this.identifier, endpoint: url, status: 'failure' } } as any);
} catch (e) {}
throw err;
if (request.status === 200 || request.status === 201) {
return request;
}
if (totalRetries > 2) {
@ -144,9 +129,6 @@ export abstract class SocialAbstract {
json.includes('rate_limit_exceeded') ||
json.includes('Rate limit')
) {
try {
Sentry.metrics.count('provider.rate_limited', 1, { attributes: { provider: this.identifier } } as any);
} catch (e) {}
await timer(5000);
return this.fetch(
url,

View file

@ -31,10 +31,6 @@ export const initializeSentry = (appName: string, allowLogs = false) => {
recordInputs: true,
recordOutputs: true,
}),
Sentry.langChainIntegration({
recordInputs: true,
recordOutputs: true,
}),
],
tracesSampleRate: 1.0,
enableLogs: true,
@ -46,18 +42,5 @@ export const initializeSentry = (appName: string, allowLogs = false) => {
} catch (err) {
console.log(err);
}
try {
process.on('unhandledRejection', (reason) => {
try {
Sentry.metrics.count('app.unhandled_errors', 1, { attributes: { service: appName, route: 'unhandledRejection' } } as any);
} catch (e) {}
});
process.on('uncaughtException', (err) => {
try {
Sentry.metrics.count('app.unhandled_errors', 1, { attributes: { service: appName, route: 'uncaughtException' } } as any);
} catch (e) {}
});
} catch (e) {}
return true;
};

View file

@ -80,10 +80,10 @@
"@pigment-css/react": "^0.0.30",
"@postiz/wallets": "^0.0.1",
"@prisma/client": "6.5.0",
"@sentry/nestjs": "^10.45.0",
"@sentry/nextjs": "^10.45.0",
"@sentry/profiling-node": "^10.45.0",
"@sentry/react": "^10.45.0",
"@sentry/nestjs": "^10.26.0",
"@sentry/nextjs": "^10.26.0",
"@sentry/profiling-node": "^10.25.0",
"@sentry/react": "^10.25.0",
"@solana/wallet-adapter-react": "^0.15.35",
"@solana/wallet-adapter-react-ui": "^0.9.35",
"@stripe/react-stripe-js": "^5.4.1",

10
pnpm-lock.yaml generated
View file

@ -127,16 +127,16 @@ importers:
specifier: 6.5.0
version: 6.5.0(prisma@6.5.0(typescript@5.5.4))(typescript@5.5.4)
'@sentry/nestjs':
specifier: ^10.45.0
specifier: ^10.26.0
version: 10.45.0(@nestjs/common@10.4.22(class-transformer@0.5.1)(class-validator@0.14.4)(reflect-metadata@0.1.14)(rxjs@7.8.2))(@nestjs/core@10.4.22)
'@sentry/nextjs':
specifier: ^10.45.0
specifier: ^10.26.0
version: 10.45.0(@opentelemetry/context-async-hooks@2.6.0(@opentelemetry/api@1.9.0))(@opentelemetry/core@2.6.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.6.0(@opentelemetry/api@1.9.0))(next@14.2.35(@babel/core@7.29.0)(@opentelemetry/api@1.9.0)(@playwright/test@1.58.2)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.97.3))(react@18.3.1)(webpack@5.105.4(@swc/core@1.5.7(@swc/helpers@0.5.13))(esbuild@0.25.12))
'@sentry/profiling-node':
specifier: ^10.45.0
specifier: ^10.25.0
version: 10.45.0
'@sentry/react':
specifier: ^10.45.0
specifier: ^10.25.0
version: 10.45.0(react@18.3.1)
'@solana/wallet-adapter-react':
specifier: ^0.15.35
@ -26315,7 +26315,7 @@ snapshots:
'@types/pg-pool@2.0.6':
dependencies:
'@types/pg': 8.15.5
'@types/pg': 8.15.6
'@types/pg-pool@2.0.7':
dependencies: