From b9d9b8f8ca3fd583c056a62a3cad4b2a078c1998 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Sat, 4 Oct 2025 11:47:18 -0400 Subject: [PATCH] Add client session id --- playlet-lib/src/components/Telemetry/Sentry.bs | 11 +---------- playlet-lib/src/components/Telemetry/Telemetry.bs | 7 +++++++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/playlet-lib/src/components/Telemetry/Sentry.bs b/playlet-lib/src/components/Telemetry/Sentry.bs index ca198955..1adb4d5a 100644 --- a/playlet-lib/src/components/Telemetry/Sentry.bs +++ b/playlet-lib/src/components/Telemetry/Sentry.bs @@ -21,7 +21,7 @@ namespace Sentry payload += `{"type":"event"}` + `\n` if StringUtils.IsNullOrEmpty(event.event_id) - event.event_id = GenerateEventId() + event.event_id = m.deviceInfo.GetRandomUUID().Replace("-", "") end if if StringUtils.IsNullOrEmpty(event.timestamp) @@ -116,15 +116,6 @@ namespace Sentry return 0 end function - function GenerateEventId() as string - hexChars = "0123456789abcdef" - eventId = "" - for i = 0 to 31 - eventId = eventId + hexChars.Mid(rnd(16) - 1, 1) - end for - return eventId - end function - function GetFingerprint(message as dynamic) as dynamic if StringUtils.IsNullOrEmpty(message) return invalid diff --git a/playlet-lib/src/components/Telemetry/Telemetry.bs b/playlet-lib/src/components/Telemetry/Telemetry.bs index 1bcbe769..a75379f7 100644 --- a/playlet-lib/src/components/Telemetry/Telemetry.bs +++ b/playlet-lib/src/components/Telemetry/Telemetry.bs @@ -13,6 +13,7 @@ function Init() as void end function function OnNodeReady() as void + m.deviceInfo = CreateObject("roDeviceInfo") m.tags = GetTags() m.release = GetRelease(m.tags) m.dist = GetDist(m.tags) @@ -160,6 +161,12 @@ function GetTags() as object tags[key] = ToString(tags[key]) end if end for + + ' A session ID in this case acts as single trace ID for all events sent during a single app session + ' For example, to understand why a requested hit a 403, it could be explained by a previous + ' refresh token failure event that happened earlier in the same session + tags["session_id"] = m.deviceInfo.GetRandomUUID() + return tags end function