Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

fix: sentry metrics

Enno Gelhausac61be645465
diff --git a/apps/backend/src/api/routes/auth.controller.ts b/apps/backend/src/api/routes/auth.controller.ts
index 23ed163e9..0d8a839ef 100644
--- a/apps/backend/src/api/routes/auth.controller.ts
+++ b/apps/backend/src/api/routes/auth.controller.ts
@@ -171,7 +171,7 @@ export class AuthController {
response.header('reload', 'true');
try {
Sentry.metrics.count('auth.login.success', 1, {
- tags: { provider: body.provider || 'LOCAL', organizationId: (addedOrg as any)?.organizationId || 'unknown' },
+ attributes: { provider: body.provider || 'LOCAL' },
} as any);
} catch (e) {}
response.status(200).json({
@@ -180,7 +180,7 @@ export class AuthController {
} catch (e: any) {
try {
Sentry.metrics.count('auth.login.failure', 1, {
- tags: { provider: body?.provider || 'LOCAL' },
+ attributes: { provider: body?.provider || 'LOCAL' },
} as any);
} catch (er) {}
response.status(400).send(e.message);
@@ -271,7 +271,7 @@ export class AuthController {
if (token) {
try {
- Sentry.metrics.count('oauth.connects', 1, { tags: { provider } } as any);
+ Sentry.metrics.count('oauth.connects', 1, { attributes: { provider } } as any);
} catch (e) {}
return response.json({ token });
}
diff --git a/apps/backend/src/api/routes/posts.controller.ts b/apps/backend/src/api/routes/posts.controller.ts
index 70b754fdf..8f06b6a19 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: { provider } } as any);
+ Sentry.metrics.count('posts.created', 1, { attributes: { provider } } as any);
}
} catch (e) {}
@@ -219,8 +219,8 @@ export class PostsController {
return (async () => {
const res = await this._postsService.changeDate(org.id, id, date, action);
if (action === 'schedule') {
- try {
- Sentry.metrics.count('posts.scheduled', 1, { tags: { scheduleType: action } } as any);
+ try {
+ Sentry.metrics.count('posts.scheduled', 1, { attributes: { scheduleType: action } } as any);
} catch (e) {}
}
diff --git a/apps/orchestrator/src/activities/post.activity.ts b/apps/orchestrator/src/activities/post.activity.ts
index e4b38e4d4..2644946d3 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: { taskQueue: post.integration?.providerIdentifier?.split('-')[0] || 'main' } } as any);
+ Sentry.metrics.gauge('posts.queued', count, { attributes: { 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.ts
index 04410cef3..c0f8ae0a3 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: { provider: post.integration?.providerIdentifier } } as any);
- Sentry.metrics.distribution('posts.publish_latency_ms', latency, { tags: { provider: post.integration?.providerIdentifier } } as any);
+ Sentry.metrics.count('posts.published.success', 1, { attributes: { provider: post.integration?.providerIdentifier } } as any);
+ Sentry.metrics.distribution('posts.publish_latency_ms', latency, { attributes: { provider: post.integration?.providerIdentifier } } as any);
} catch (e) {}
}
@@ -219,12 +219,12 @@ 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: { provider: post.integration?.providerIdentifier, failure_reason } } as any);
+ Sentry.metrics.count('posts.published.failure', 1, { attributes: { provider: post.integration?.providerIdentifier, failure_reason } } as any);
} catch (e) {}
try {
const cause = (err as any)?.cause;
const reason = (cause && (cause as any).type) || (err as any)?.message || 'unknown';
- Sentry.metrics.count('task_failures_by_reason', 1, { tags: { reason } } as any);
+ Sentry.metrics.count('task_failures_by_reason', 1, { attributes: { reason } } as any);
} catch (e) {}
// specific case for bad body errors
@@ -253,10 +253,10 @@ export async function postWorkflowV101({
if (postsResults.length === before) {
// all retries exhausted without success
try {
- Sentry.metrics.count('temporal.retry_exhausted', 1, { tags: { workflow: 'postWorkflowV101' } } as any);
+ Sentry.metrics.count('temporal.retry_exhausted', 1, { attributes: { workflow: 'postWorkflowV101' } } as any);
} catch (e) {}
try {
- Sentry.metrics.count('posts.published.failure', 1, { tags: { provider: post.integration?.providerIdentifier, failure_reason: 'retry_exhausted' } } as any);
+ Sentry.metrics.count('posts.published.failure', 1, { attributes: { 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.ts
index 7216dc8d7..1870e1439 100644
--- a/apps/sdk/src/index.ts
+++ b/apps/sdk/src/index.ts
@@ -22,7 +22,7 @@ export default class Postiz {
async post(posts: CreatePostDto) {
try {
- Sentry.metrics.count('sdk.requests', 1, { tags: { method: 'post' } } as any);
+ Sentry.metrics.count('sdk.requests', 1, { attributes: { method: 'post' } } as any);
} catch (e) {}
return (
@@ -39,7 +39,7 @@ export default class Postiz {
async postList(filters: GetPostsDto) {
try {
- Sentry.metrics.count('sdk.requests', 1, { tags: { method: 'list' } } as any);
+ Sentry.metrics.count('sdk.requests', 1, { attributes: { method: 'list' } } as any);
} catch (e) {}
return (
@@ -55,7 +55,7 @@ export default class Postiz {
async upload(file: Buffer, extension: string) {
try {
- Sentry.metrics.count('sdk.requests', 1, { tags: { method: 'upload' } } as any);
+ Sentry.metrics.count('sdk.requests', 1, { attributes: { method: 'upload' } } as any);
} catch (e) {}
const formData = new FormData();
@@ -87,7 +87,7 @@ export default class Postiz {
async integrations() {
try {
- Sentry.metrics.count('sdk.requests', 1, { tags: { method: 'integrations' } } as any);
+ Sentry.metrics.count('sdk.requests', 1, { attributes: { method: 'integrations' } } as any);
} catch (e) {}
return (
@@ -103,7 +103,7 @@ export default class Postiz {
deletePost(id: string) {
try {
- Sentry.metrics.count('sdk.requests', 1, { tags: { method: 'delete' } } as any);
+ Sentry.metrics.count('sdk.requests', 1, { attributes: { 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.ts
index 3647748b2..c7a06da63 100644
--- a/libraries/nestjs-libraries/src/database/prisma/media/media.service.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/media/media.service.ts
@@ -44,8 +44,8 @@ export class MediaService {
async () => {
const start = Date.now();
try {
- try {
- Sentry.metrics.count('media.generate_attempt', 1, { tags: { media_type: 'image' } } as any);
+ try {
+ Sentry.metrics.count('media.generate_attempt', 1, { attributes: { 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: { media_type: 'image' } } as any);
- Sentry.metrics.distribution('media.generation_ms', Date.now() - start, { tags: { media_type: 'image' } } as any);
+ 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, { tags: { media_type: 'image' } } as any);
+ Sentry.metrics.count('media.generate_failure', 1, { attributes: { 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: { media_type: 'video' } } as any);
+ Sentry.metrics.count('media.generate_attempt', 1, { attributes: { 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: { media_type: 'video' } } as any);
- Sentry.metrics.distribution('media.generation_ms', Date.now() - start, { tags: { media_type: 'video' } } as any);
+ 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, { tags: { media_type: 'video' } } as any);
+ Sentry.metrics.count('media.generate_failure', 1, { attributes: { 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.ts
index e0de2f399..4be7c3d50 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: { taskQueue } } as any);
+ Sentry.metrics.gauge('posts.queued', count, { attributes: { taskQueue } } as any);
} catch (err) {}
} catch (err) {}
} catch (err) {}
diff --git a/libraries/nestjs-libraries/src/integrations/refresh.integration.service.ts b/libraries/nestjs-libraries/src/integrations/refresh.integration.service.ts
index defd99f5a..050885a1a 100644
--- a/libraries/nestjs-libraries/src/integrations/refresh.integration.service.ts
+++ b/libraries/nestjs-libraries/src/integrations/refresh.integration.service.ts
@@ -74,7 +74,7 @@ export class RefreshIntegrationService {
): Promise<AuthTokenDetails | false> {
try {
try {
- Sentry.metrics.count('provider.refresh_attempt', 1, { tags: { provider: socialProvider.identifier } } as any);
+ Sentry.metrics.count('provider.refresh_attempt', 1, { attributes: { provider: socialProvider.identifier } } as any);
} catch (e) {}
const refresh: false | AuthTokenDetails = await socialProvider
@@ -83,7 +83,7 @@ export class RefreshIntegrationService {
if (!refresh || !refresh.accessToken) {
try {
- Sentry.metrics.count('provider.refresh_fail', 1, { tags: { provider: socialProvider.identifier } } as any);
+ Sentry.metrics.count('provider.refresh_fail', 1, { attributes: { provider: socialProvider.identifier } } as any);
} catch (e) {}
await this._integrationService.refreshNeeded(
@@ -124,7 +124,7 @@ export class RefreshIntegrationService {
};
} catch (err) {
try {
- Sentry.metrics.count('provider.refresh_fail', 1, { tags: { provider: socialProvider.identifier } } as any);
+ Sentry.metrics.count('provider.refresh_fail', 1, { attributes: { provider: socialProvider.identifier } } as any);
} catch (e) {}
return false;
}
diff --git a/libraries/nestjs-libraries/src/integrations/social.abstract.ts b/libraries/nestjs-libraries/src/integrations/social.abstract.ts
index 183480066..0e6af5931 100644
--- a/libraries/nestjs-libraries/src/integrations/social.abstract.ts
+++ b/libraries/nestjs-libraries/src/integrations/social.abstract.ts
@@ -111,7 +111,7 @@ export abstract class SocialAbstract {
request = await fetch(url, options);
const latency = Date.now() - start;
try {
- Sentry.metrics.distribution('provider.api_latency_ms', latency, { tags: { provider: this.identifier, endpoint: url, status: 'success' } } as any);
+ Sentry.metrics.distribution('provider.api_latency_ms', latency, { attributes: { provider: this.identifier, endpoint: url, status: 'success' } } as any);
} catch (e) {}
if (request.status === 200 || request.status === 201) {
@@ -120,7 +120,7 @@ export abstract class SocialAbstract {
} catch (err) {
const latency = Date.now() - start;
try {
- Sentry.metrics.distribution('provider.api_latency_ms', latency, { tags: { provider: this.identifier, endpoint: url, status: 'failure' } } as any);
+ Sentry.metrics.distribution('provider.api_latency_ms', latency, { attributes: { provider: this.identifier, endpoint: url, status: 'failure' } } as any);
} catch (e) {}
throw err;
}
@@ -145,7 +145,7 @@ export abstract class SocialAbstract {
json.includes('Rate limit')
) {
try {
- Sentry.metrics.count('provider.rate_limited', 1, { tags: { provider: this.identifier } } as any);
+ Sentry.metrics.count('provider.rate_limited', 1, { attributes: { provider: this.identifier } } as any);
} catch (e) {}
await timer(5000);
return this.fetch(
diff --git a/libraries/nestjs-libraries/src/sentry/initialize.sentry.ts b/libraries/nestjs-libraries/src/sentry/initialize.sentry.ts
index ed37aa0b8..4ae228e45 100644
--- a/libraries/nestjs-libraries/src/sentry/initialize.sentry.ts
+++ b/libraries/nestjs-libraries/src/sentry/initialize.sentry.ts
@@ -45,13 +45,13 @@ export const initializeSentry = (appName: string, allowLogs = false) => {
try {
process.on('unhandledRejection', (reason) => {
try {
- Sentry.metrics.count('app.unhandled_errors', 1, { tags: { service: appName, route: 'unhandledRejection' } } as any);
+ 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, { tags: { service: appName, route: 'uncaughtException' } } as any);
+ Sentry.metrics.count('app.unhandled_errors', 1, { attributes: { service: appName, route: 'uncaughtException' } } as any);
} catch (e) {}
});
} catch (e) {}