DEV Community

Roberto Luna
Roberto Luna

Posted on

Implementing Automatic Suspension for Maintenance Expiration in Access Control

Implementing Automatic Suspension for Maintenance Expiration in Access Control

TL;DR: I implemented automatic suspension for maintenance expiration in the Access Control module, addressing a critical issue with error reporting and noisy logs. This change involves updating the Sentry configuration, fixing errors in the condominios dashboard, and adding a new feature for automatic suspension.

The Problem

The initial problem was related to error reporting and noisy logs in the development environment. Specifically, Sentry was reporting hydration errors and other issues that were not relevant to the production environment. Additionally, there was an issue with the reduce function not being recognized in the presupuesto page.

The error messages were:

  • NODE-G hydration error
  • NODE-H dev noise
  • u.reduce is not a function

What I Tried First

Initially, I tried to address the issue by modifying the Sentry configuration to only report errors in production. However, this required updating the sentry.client.config.ts file to include a conditional statement for reporting errors.

// apps/web/sentry.client.config.ts
Sentry.init({
  // ...
  // Solo reportar errores de producción 
  environment: process.env.NODE_ENV === 'production' ? 'production' : 'development',
});
Enter fullscreen mode Exit fullscreen mode

The Implementation

To fix the issues, I made the following changes:

Update Sentry Configuration

I updated the Sentry configuration to only report errors in production.

// apps/web/sentry.client.config.ts
Sentry.init({
  // ...
  environment: process.env.NODE_ENV === 'production' ? 'production' : 'development',
  tracesSampleRate: 1,
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 1.0,
});
Enter fullscreen mode Exit fullscreen mode

Fix Condominios Dashboard Errors

I fixed the errors in the condominios dashboard by updating the page.tsx file.

// apps/web/src/app/condominios/dashboard/hoy/page.tsx
export default function CondosHoyPage() {
  // ...
  const [saludo, setSaludo] = useState("");
  // ...
}
Enter fullscreen mode Exit fullscreen mode

Add Automatic Suspension Feature

I added a new feature for automatic suspension by updating the access-control.controller.ts file.

// apps/api/src/access-control/access-control.controller.ts
import { Injectable } from '@nestjs/common';
import { CronService } from './access-control.cron';

@Injectable()
export class AccessControlController {
  constructor(private readonly cronService: CronService) {}

  async suspendMaintenance() {
    // ...
  }
}
Enter fullscreen mode Exit fullscreen mode

Update Package.json

I updated the package.json file to reflect the new version.

// package.json
{
  "name": "playamxcrm",
  "version": "1.7.0",
  // ...
}
Enter fullscreen mode Exit fullscreen mode

Key Takeaway

The key takeaway from this experience is the importance of properly configuring Sentry to report errors in production. Additionally, I learned that it's essential to handle errors and exceptions properly to avoid noisy logs and ensure a smooth user experience.

What's Next

Next, I plan to implement additional features for the Access Control module, such as integrating with the ZKTeco system. I will also continue to monitor and optimize the performance of the application to ensure it meets the requirements of the users.

vibecoding #buildinpublic #accesscontrol #sentry #nodejs #nestjs


Part of my Build in Public series — sharing the real process of building Building PlayaMXCRM from Playa del Carmen, México.

Repo: zaerohell/VS · 2026-07-08

#playadev #buildinpublic

Top comments (0)