refactor: update service worker generation timestamp and cache version in sw.js; improve protobuf handling in OpenTelemetryRequestMiddleware

This commit is contained in:
Nawaz Dhandala
2026-03-05 18:10:31 +00:00
parent 2e07165c27
commit 7b468cc431
3 changed files with 10 additions and 7 deletions

1
.gitignore vendored
View File

@@ -140,3 +140,4 @@ terraform.tfstate.backup
.terraform/
.terraform.lock.hcl
.claude/worktrees/**
App/FeatureSet/Dashboard/public/sw.js

View File

@@ -1,9 +1,9 @@
/*
* Generated Service Worker for OneUptime Dashboard
*
* Generated at: 2026-03-04T18:04:01.216Z
* Generated at: 2026-03-05T14:58:16.272Z
* App Version: 0.1.0
* Git SHA: fda87057
* Git SHA: b592a7c5
*
* DO NOT EDIT THIS FILE DIRECTLY
* Edit the template file instead and run the generator script
@@ -19,7 +19,7 @@ console.log('[ServiceWorker] OneUptime PWA Service Worker Loaded');
// Cache configuration - Updated dynamically during build
// Version format: oneuptime-v{APP_VERSION}-{GIT_SHA}
// This ensures cache invalidation on every deployment
const CACHE_VERSION = 'oneuptime-v0.1.0-fda87057'; // Auto-generated version
const CACHE_VERSION = 'oneuptime-v0.1.0-b592a7c5'; // Auto-generated version
const STATIC_CACHE = `${CACHE_VERSION}-static`;
const DYNAMIC_CACHE = `${CACHE_VERSION}-dynamic`;

View File

@@ -43,20 +43,22 @@ export default class OpenTelemetryRequestMiddleware {
const contentType: string | undefined = req.headers["content-type"];
const isProtobuf: boolean =
req.body instanceof Uint8Array &&
(!contentType || contentType.includes("application/x-protobuf") || contentType.includes("application/protobuf"));
(!contentType ||
contentType.includes("application/x-protobuf") ||
contentType.includes("application/protobuf"));
if (req.url.includes("/otlp/v1/traces")) {
if (isProtobuf) {
req.body = TracesData.decode(req.body);
} else if (req.body instanceof Uint8Array) {
req.body = JSON.parse(req.body.toString("utf-8"));
req.body = JSON.parse(Buffer.from(req.body).toString("utf-8"));
}
productType = ProductType.Traces;
} else if (req.url.includes("/otlp/v1/logs")) {
if (isProtobuf) {
req.body = LogsData.decode(req.body);
} else if (req.body instanceof Uint8Array) {
req.body = JSON.parse(req.body.toString("utf-8"));
req.body = JSON.parse(Buffer.from(req.body).toString("utf-8"));
}
productType = ProductType.Logs;
@@ -64,7 +66,7 @@ export default class OpenTelemetryRequestMiddleware {
if (isProtobuf) {
req.body = MetricsData.decode(req.body);
} else if (req.body instanceof Uint8Array) {
req.body = JSON.parse(req.body.toString("utf-8"));
req.body = JSON.parse(Buffer.from(req.body).toString("utf-8"));
}
productType = ProductType.Metrics;
} else {