Compare commits

...

2 commits

Author SHA1 Message Date
4a0f3ab7ef fix: sentry tracing 2025-06-23 00:07:49 +02:00
8ba4056187 fix: sentry tracing 2025-06-22 23:58:34 +02:00
5 changed files with 266 additions and 215 deletions

View file

@ -93,6 +93,7 @@
"@react-navigation/native": "^6.0.8",
"@react-navigation/stack": "^6.3.21",
"@sentry/react-native": "~6.10.0",
"@sentry/tracing": "^7.120.3",
"@turf/along": "^7.1.0",
"@turf/boolean-equal": "^7.1.0",
"@turf/distance": "^7.1.0",

View file

@ -346,11 +346,12 @@ export default async function trackLocation() {
if (count > 0) {
locationLogger.info(`Found ${count} pending records, forcing sync`);
const transaction = Sentry.startTransaction({
await Sentry.startSpan(
{
name: "force-sync-pending-records",
op: "geolocation-sync",
});
},
async (span) => {
try {
const { userToken } = getAuthState();
const state = await BackgroundGeolocation.getState();
@ -371,7 +372,7 @@ export default async function trackLocation() {
},
});
transaction.setStatus("ok");
span.setStatus("ok");
} else {
Sentry.addBreadcrumb({
message: "Forced sync skipped",
@ -383,7 +384,7 @@ export default async function trackLocation() {
},
});
transaction.setStatus("cancelled");
span.setStatus("cancelled");
}
} catch (error) {
locationLogger.error("Forced sync failed", {
@ -401,10 +402,11 @@ export default async function trackLocation() {
},
});
transaction.setStatus("internal_error");
} finally {
transaction.finish();
span.setStatus("internal_error");
throw error; // Re-throw to ensure span captures the error
}
},
);
}
} catch (error) {
locationLogger.error("Failed to get pending records count", {

View file

@ -12,13 +12,12 @@ const logger = createLogger({
// Background task to cancel expired notifications
const backgroundTask = async () => {
const transaction = Sentry.startTransaction({
await Sentry.startSpan(
{
name: "auto-cancel-expired-notifications",
op: "background-task",
});
Sentry.getCurrentScope().setSpan(transaction);
},
async (span) => {
try {
logger.info("Starting auto-cancel expired notifications task");
@ -29,12 +28,13 @@ const backgroundTask = async () => {
});
// Get displayed notifications with timeout protection
const getNotificationsSpan = transaction.startChild({
let notifications;
await Sentry.startSpan(
{
op: "get-displayed-notifications",
description: "Getting displayed notifications",
});
let notifications;
},
async (getNotificationsSpan) => {
try {
// Add timeout protection for the API call
notifications = await Promise.race([
@ -50,9 +50,9 @@ const backgroundTask = async () => {
} catch (error) {
getNotificationsSpan.setStatus("internal_error");
throw error;
} finally {
getNotificationsSpan.finish();
}
},
);
if (!Array.isArray(notifications)) {
logger.warn("No notifications array received", { notifications });
@ -166,7 +166,7 @@ const backgroundTask = async () => {
},
});
transaction.setStatus("ok");
span.setStatus("ok");
} catch (error) {
logger.error("Auto-cancel task failed", { error });
@ -177,11 +177,11 @@ const backgroundTask = async () => {
},
});
transaction.setStatus("internal_error");
span.setStatus("internal_error");
throw error; // Re-throw to be handled by caller
} finally {
transaction.finish();
}
},
);
};
export const useAutoCancelExpired = () => {

View file

@ -1,4 +1,5 @@
import * as Sentry from "@sentry/react-native";
import "@sentry/tracing";
import { Platform } from "react-native";
import env from "~/env";

View file

@ -5735,6 +5735,17 @@ __metadata:
languageName: node
linkType: hard
"@sentry-internal/tracing@npm:7.120.3":
version: 7.120.3
resolution: "@sentry-internal/tracing@npm:7.120.3"
dependencies:
"@sentry/core": "npm:7.120.3"
"@sentry/types": "npm:7.120.3"
"@sentry/utils": "npm:7.120.3"
checksum: 10/bd6adcced941c651596de9b2c8a35f1492c5557bda36c3283b0ef0386e72586481d4288704d0cc71eb78fd2675715488ebc4239e001a571abc44dd3363022401
languageName: node
linkType: hard
"@sentry/babel-plugin-component-annotate@npm:3.2.2":
version: 3.2.2
resolution: "@sentry/babel-plugin-component-annotate@npm:3.2.2"
@ -5841,6 +5852,16 @@ __metadata:
languageName: node
linkType: hard
"@sentry/core@npm:7.120.3":
version: 7.120.3
resolution: "@sentry/core@npm:7.120.3"
dependencies:
"@sentry/types": "npm:7.120.3"
"@sentry/utils": "npm:7.120.3"
checksum: 10/fee971b8e0bbb5b499cd1161e18c6495f9d5472c286f5de5f84dc183dcfa739d31b7b57379f1fa01eb02b67f55c8ec008c1bcdb4f8da75144efd700592099602
languageName: node
linkType: hard
"@sentry/core@npm:8.54.0":
version: 8.54.0
resolution: "@sentry/core@npm:8.54.0"
@ -5885,6 +5906,22 @@ __metadata:
languageName: node
linkType: hard
"@sentry/tracing@npm:^7.120.3":
version: 7.120.3
resolution: "@sentry/tracing@npm:7.120.3"
dependencies:
"@sentry-internal/tracing": "npm:7.120.3"
checksum: 10/6d5e673a5cd4276bd717392d5da92c9977058a2b7a6d732718b16f088a335b8c4ab8a29662781cb658010bdcac4191950cc87edf4e3fd805b48626ed2afb8994
languageName: node
linkType: hard
"@sentry/types@npm:7.120.3":
version: 7.120.3
resolution: "@sentry/types@npm:7.120.3"
checksum: 10/56b9f32393b506e5e7250713fd764d755decae827ee545399dc66653eff2ddeb2f03a9c98ba5a0a846546dc37ab3af8d3535cf57ed01d9a7d00cd9dc72a55a36
languageName: node
linkType: hard
"@sentry/types@npm:8.54.0":
version: 8.54.0
resolution: "@sentry/types@npm:8.54.0"
@ -5894,6 +5931,15 @@ __metadata:
languageName: node
linkType: hard
"@sentry/utils@npm:7.120.3":
version: 7.120.3
resolution: "@sentry/utils@npm:7.120.3"
dependencies:
"@sentry/types": "npm:7.120.3"
checksum: 10/c50fa4b7334898c0db7840899b2fd1da1bc47a097ecbc433bc835b6e90d3e76b1761ef926cd5e9f0c15e9b00c1f091dd763862f4c98468f9628214be83fe5426
languageName: node
linkType: hard
"@sentry/utils@npm:8.54.0":
version: 8.54.0
resolution: "@sentry/utils@npm:8.54.0"
@ -6883,6 +6929,7 @@ __metadata:
"@react-navigation/native": "npm:^6.0.8"
"@react-navigation/stack": "npm:^6.3.21"
"@sentry/react-native": "npm:~6.10.0"
"@sentry/tracing": "npm:^7.120.3"
"@turf/along": "npm:^7.1.0"
"@turf/boolean-equal": "npm:^7.1.0"
"@turf/distance": "npm:^7.1.0"