π¨ The ultimate agentic social media scheduling tool π€
TypeScript nextjsopen-sourceopen-source-social-media-scheduling-toolosspostiz-cloudpostiz-hostedredisscheduling-toolsocial-media-scheduling-tooltypescript
feat: security
Enno Gelhausda995de88fbd
diff --git a/apps/backend/src/api/routes/media.controller.ts b/apps/backend/src/api/routes/media.controller.tsindex f0838c891..cdd751141 100644--- a/apps/backend/src/api/routes/media.controller.ts+++ b/apps/backend/src/api/routes/media.controller.ts@@ -97,8 +97,8 @@ export class MediaController {const uploadedFile = await this.storage.uploadFile(file);try {- Sentry.metrics.count('uploads.total', 1, { tags: { organizationId: org.id, storage_backend: process.env.STORAGE_PROVIDER || 'local' } } as any);- Sentry.metrics.distribution('upload_size_bytes', file?.size || 0, { tags: { organizationId: org.id, storage_backend: process.env.STORAGE_PROVIDER || 'local' } } as any);+ Sentry.metrics.count('uploads.total', 1);+ Sentry.metrics.distribution('upload_size_bytes', file?.size || 0);} catch (e) {}return this._mediaService.saveFile(@@ -109,7 +109,7 @@ export class MediaController {);} catch (err) {try {- Sentry.metrics.count('uploads.failure', 1, { tags: { organizationId: org.id, storage_backend: process.env.STORAGE_PROVIDER || 'local' } } as any);+ Sentry.metrics.count('uploads.failure', 1);} catch (e) {}throw err;}@@ -153,8 +153,8 @@ export class MediaController {const getFile = await this.storage.uploadFile(file);try {- Sentry.metrics.count('uploads.total', 1, { tags: { organizationId: org.id, storage_backend: process.env.STORAGE_PROVIDER || 'local' } } as any);- Sentry.metrics.distribution('upload_size_bytes', file?.size || 0, { tags: { organizationId: org.id, storage_backend: process.env.STORAGE_PROVIDER || 'local' } } as any);+ Sentry.metrics.count('uploads.total', 1);+ Sentry.metrics.distribution('upload_size_bytes', file?.size || 0);} catch (e) {}if (preventSave === 'true') {@@ -170,7 +170,7 @@ export class MediaController {);} catch (err) {try {- Sentry.metrics.count('uploads.failure', 1, { tags: { organizationId: org.id, storage_backend: process.env.STORAGE_PROVIDER || 'local' } } as any);+ Sentry.metrics.count('uploads.failure', 1);} catch (e) {}throw err;}@@ -202,14 +202,14 @@ export class MediaController {);try {- Sentry.metrics.count('uploads.total', 1, { tags: { organizationId: org.id, storage_backend: process.env.STORAGE_PROVIDER || 'local' } } as any);- Sentry.metrics.distribution('upload_size_bytes', (req.headers['content-length'] ? Number(req.headers['content-length']) : 0) || 0, { tags: { organizationId: org.id, storage_backend: process.env.STORAGE_PROVIDER || 'local' } } as any);+ 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, { tags: { organizationId: org.id, storage_backend: process.env.STORAGE_PROVIDER || 'local' } } as any);+ Sentry.metrics.count('uploads.failure', 1);} catch (e) {}throw err;}diff --git a/apps/backend/src/api/routes/posts.controller.ts b/apps/backend/src/api/routes/posts.controller.tsindex 4a17785ef..70b754fdf 100644--- a/apps/backend/src/api/routes/posts.controller.ts+++ b/apps/backend/src/api/routes/posts.controller.ts@@ -170,7 +170,7 @@ export class PostsController {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, { tags: { organizationId: org.id, provider } } as any);+ Sentry.metrics.count('posts.created', 1, { tags: { provider } } as any);}} catch (e) {}@@ -220,7 +220,7 @@ export class PostsController {const res = await this._postsService.changeDate(org.id, id, date, action);if (action === 'schedule') {try {- Sentry.metrics.count('posts.scheduled', 1, { tags: { organizationId: org.id, scheduleType: action } } as any);+ Sentry.metrics.count('posts.scheduled', 1, { tags: { scheduleType: action } } as any);} catch (e) {}}diff --git a/apps/orchestrator/src/activities/post.activity.ts b/apps/orchestrator/src/activities/post.activity.tsindex 78e66224f..e4b38e4d4 100644--- a/apps/orchestrator/src/activities/post.activity.ts+++ b/apps/orchestrator/src/activities/post.activity.ts@@ -99,7 +99,7 @@ export class PostActivity {}try {- Sentry.metrics.gauge('posts.queued_per_org', count, { tags: { organizationId: post.organizationId, taskQueue: post.integration?.providerIdentifier?.split('-')[0] || 'main' } } as any);+ Sentry.metrics.gauge('posts.queued_per_org', count, { tags: { taskQueue: post.integration?.providerIdentifier?.split('-')[0] || 'main' } } as any);} catch (e) {}} catch (e) {}}diff --git a/apps/orchestrator/src/workflows/post-workflows/post.workflow.v1.0.1.ts b/apps/orchestrator/src/workflows/post-workflows/post.workflow.v1.0.1.tsindex 76416950a..04410cef3 100644--- a/apps/orchestrator/src/workflows/post-workflows/post.workflow.v1.0.1.ts+++ b/apps/orchestrator/src/workflows/post-workflows/post.workflow.v1.0.1.ts@@ -175,8 +175,8 @@ export async function postWorkflowV101({if (i === 0) {try {const latency = Date.now() - startTime.getTime();- Sentry.metrics.count('posts.published.success', 1, { tags: { organizationId: post.organizationId, provider: post.integration?.providerIdentifier } } as any);- Sentry.metrics.distribution('posts.publish_latency_ms', latency, { tags: { organizationId: post.organizationId, provider: post.integration?.providerIdentifier } } as any);+ Sentry.metrics.count('posts.published.success', 1, { tags: { provider: post.integration?.providerIdentifier } } as any);+ Sentry.metrics.distribution('posts.publish_latency_ms', latency, { tags: { provider: post.integration?.providerIdentifier } } as any);} catch (e) {}}@@ -219,7 +219,7 @@ export async function postWorkflowV101({try {const cause = (err as any)?.cause;const failure_reason = (cause && (cause as any).type) || (err as any)?.message || 'unknown';- Sentry.metrics.count('posts.published.failure', 1, { tags: { organizationId: post.organizationId, provider: post.integration?.providerIdentifier, failure_reason } } as any);+ Sentry.metrics.count('posts.published.failure', 1, { tags: { provider: post.integration?.providerIdentifier, failure_reason } } as any);} catch (e) {}try {const cause = (err as any)?.cause;@@ -253,10 +253,10 @@ export async function postWorkflowV101({if (postsResults.length === before) {// all retries exhausted without successtry {- Sentry.metrics.count('temporal.retry_exhausted', 1, { tags: { workflow: 'postWorkflowV101', organizationId: post.organizationId } } as any);+ Sentry.metrics.count('temporal.retry_exhausted', 1, { tags: { workflow: 'postWorkflowV101' } } as any);} catch (e) {}try {- Sentry.metrics.count('posts.published.failure', 1, { tags: { organizationId: post.organizationId, provider: post.integration?.providerIdentifier, failure_reason: 'retry_exhausted' } } as any);+ Sentry.metrics.count('posts.published.failure', 1, { tags: { provider: post.integration?.providerIdentifier, failure_reason: 'retry_exhausted' } } as any);} catch (e) {}return false;diff --git a/apps/sdk/src/index.ts b/apps/sdk/src/index.tsindex e6cd69d48..7216dc8d7 100644--- a/apps/sdk/src/index.ts+++ b/apps/sdk/src/index.ts@@ -22,10 +22,7 @@ export default class Postiz {async post(posts: CreatePostDto) {try {- const apiHash = crypto.createHash('sha256').update(this._apiKey).digest('hex').slice(0, 8);- try {- Sentry.metrics.count('sdk.requests', 1, { tags: { method: 'post', api_key_hash: apiHash } } as any);- } catch (e) {}+ Sentry.metrics.count('sdk.requests', 1, { tags: { method: 'post' } } as any);} catch (e) {}return (@@ -42,10 +39,7 @@ export default class Postiz {async postList(filters: GetPostsDto) {try {- const apiHash = crypto.createHash('sha256').update(this._apiKey).digest('hex').slice(0, 8);- try {- Sentry.metrics.count('sdk.requests', 1, { tags: { method: 'list', api_key_hash: apiHash } } as any);- } catch (e) {}+ Sentry.metrics.count('sdk.requests', 1, { tags: { method: 'list' } } as any);} catch (e) {}return (@@ -61,10 +55,7 @@ export default class Postiz {async upload(file: Buffer, extension: string) {try {- const apiHash = crypto.createHash('sha256').update(this._apiKey).digest('hex').slice(0, 8);- try {- Sentry.metrics.count('sdk.requests', 1, { tags: { method: 'upload', api_key_hash: apiHash } } as any);- } catch (e) {}+ Sentry.metrics.count('sdk.requests', 1, { tags: { method: 'upload' } } as any);} catch (e) {}const formData = new FormData();@@ -96,10 +87,7 @@ export default class Postiz {async integrations() {try {- const apiHash = crypto.createHash('sha256').update(this._apiKey).digest('hex').slice(0, 8);- try {- Sentry.metrics.count('sdk.requests', 1, { tags: { method: 'integrations', api_key_hash: apiHash } } as any);- } catch (e) {}+ Sentry.metrics.count('sdk.requests', 1, { tags: { method: 'integrations' } } as any);} catch (e) {}return (@@ -115,10 +103,7 @@ export default class Postiz {deletePost(id: string) {try {- const apiHash = crypto.createHash('sha256').update(this._apiKey).digest('hex').slice(0, 8);- try {- Sentry.metrics.count('sdk.requests', 1, { tags: { method: 'delete', api_key_hash: apiHash } } as any);- } catch (e) {}+ Sentry.metrics.count('sdk.requests', 1, { tags: { method: 'delete' } } as any);} catch (e) {}return fetch(`${this._path}/public/v1/posts/${id}`, {diff --git a/libraries/nestjs-libraries/src/database/prisma/media/media.service.ts b/libraries/nestjs-libraries/src/database/prisma/media/media.service.tsindex 26bbca971..3647748b2 100644--- a/libraries/nestjs-libraries/src/database/prisma/media/media.service.ts+++ b/libraries/nestjs-libraries/src/database/prisma/media/media.service.ts@@ -45,7 +45,7 @@ export class MediaService {const start = Date.now();try {try {- Sentry.metrics.count('media.generate_attempt', 1, { tags: { organizationId: org.id, media_type: 'image' } } as any);+ Sentry.metrics.count('media.generate_attempt', 1, { tags: { media_type: 'image' } } as any);} catch (e) {}if (generatePromptFirst) {@@ -56,14 +56,14 @@ export class MediaService {const res = await this._openAi.generateImage(prompt, !!generatePromptFirst);try {- Sentry.metrics.count('media.generate_success', 1, { tags: { organizationId: org.id, media_type: 'image' } } as any);- Sentry.metrics.distribution('media.generation_ms', Date.now() - start, { tags: { organizationId: org.id, media_type: 'image' } } as any);+ Sentry.metrics.count('media.generate_success', 1, { tags: { media_type: 'image' } } as any);+ Sentry.metrics.distribution('media.generation_ms', Date.now() - start, { tags: { media_type: 'image' } } as any);} catch (e) {}return res;} catch (err) {try {- Sentry.metrics.count('media.generate_failure', 1, { tags: { organizationId: org.id, media_type: 'image' } } as any);+ Sentry.metrics.count('media.generate_failure', 1, { tags: { media_type: 'image' } } as any);} catch (e) {}throw err;}@@ -130,7 +130,7 @@ export class MediaService {const start = Date.now();try {try {- Sentry.metrics.count('media.generate_attempt', 1, { tags: { organizationId: org.id, media_type: 'video' } } as any);+ Sentry.metrics.count('media.generate_attempt', 1, { tags: { media_type: 'video' } } as any);} catch (e) {}const result = await this._subscriptionService.useCredit(@@ -148,14 +148,14 @@ export class MediaService {);try {- Sentry.metrics.count('media.generate_success', 1, { tags: { organizationId: org.id, media_type: 'video' } } as any);- Sentry.metrics.distribution('media.generation_ms', Date.now() - start, { tags: { organizationId: org.id, media_type: 'video' } } as any);+ Sentry.metrics.count('media.generate_success', 1, { tags: { media_type: 'video' } } as any);+ Sentry.metrics.distribution('media.generation_ms', Date.now() - start, { tags: { media_type: 'video' } } as any);} catch (e) {}return result;} catch (err) {try {- Sentry.metrics.count('media.generate_failure', 1, { tags: { organizationId: org.id, media_type: 'video' } } as any);+ Sentry.metrics.count('media.generate_failure', 1, { tags: { media_type: 'video' } } as any);} catch (e) {}throw err;}diff --git a/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts b/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.tsindex 4cb6d584b..e0de2f399 100644--- a/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts+++ b/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts@@ -697,7 +697,7 @@ export class PostsService {}try {- Sentry.metrics.gauge('posts.queued_per_org', count, { tags: { organizationId: orgId, taskQueue } } as any);+ Sentry.metrics.gauge('posts.queued_per_org', count, { tags: { taskQueue } } as any);} catch (err) {}} catch (err) {}} catch (err) {}