Skip to content

Conversation

@denrase
Copy link
Collaborator

@denrase denrase commented Oct 23, 2025

📜 Description

  • Add sentry.replay_id to logs if replay id is set on scope
  • Add sentry.replay_id and sentry._internal.replay_is_buffering if replay id is set on integration (buffer mode)

💡 Motivation and Context

I tried this with our sample app, but always got no session, and therefore not replayId, from the integration. Was expecting that we have a buffered session, but i'm probably not familiar with how this is implemented on iOS. I assumed the flow is similar to what we have on Android. NVM, this was on iOS 26 where it's disable. Works as expected on iOS < 26.

Closes #6133

💚 How did you test it?

Unit tests. Sample app.

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 23, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 5fdf539

@denrase denrase changed the title Add sentry.replay_id to logs Add sentry.replay_id attribute to logs Oct 23, 2025
@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.515%. Comparing base (22af3fc) to head (5fdf539).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
Sources/Sentry/SentryHub.m 80.000% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #6515       +/-   ##
=============================================
+ Coverage   85.513%   85.515%   +0.002%     
=============================================
  Files          451       451               
  Lines        27328     27346       +18     
  Branches     11913     11922        +9     
=============================================
+ Hits         23369     23385       +16     
- Misses        3914      3915        +1     
- Partials        45        46        +1     
Files with missing lines Coverage Δ
SentryTestUtils/TestHub.swift 77.419% <100.000%> (+1.557%) ⬆️
Sources/Swift/Tools/SentryLogger.swift 99.253% <100.000%> (+0.066%) ⬆️
Sources/Sentry/SentryHub.m 96.533% <80.000%> (-0.224%) ⬇️

... and 6 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 22af3fc...5fdf539. Read the comment docs.

@denrase denrase marked this pull request as ready for review October 23, 2025 12:49
@cursor
Copy link

cursor bot commented Oct 23, 2025

Bug: Replay Headers Cause Compilation Issues

The SentrySessionReplayIntegration headers are unconditionally imported in SentryPrivate.h. This causes compilation errors on platforms without replay support (e.g., watchOS, macOS without UIKit), as these headers contain code guarded by SENTRY_TARGET_REPLAY_SUPPORTED.

Fix in Cursor Fix in Web

@cursor
Copy link

cursor bot commented Oct 23, 2025

Bug: Test Crashes Due to Force-Unwrapping Nullable Property

Tests force-unwrap the sessionReplay property, which is now nullable. This creates a potential for test crashes if sessionReplay is nil, despite its nullable type declaration.

Fix in Cursor Fix in Web

@denrase
Copy link
Collaborator Author

denrase commented Oct 23, 2025

Having some trouble with accessing SentrySessionReplayIntegration in swift. Moved the files to SentryPrivate.h, like described in SWIFT.md, but now it is clashing with some build configurations and with SentryHybrid explicit module. Would appreciate some guidance here. 🙇

@philipphofmann
Copy link
Member

Having some trouble with accessing SentrySessionReplayIntegration in swift. Moved the files to SentryPrivate.h, like described in SWIFT.md, but now it is clashing with some build configurations and with SentryHybrid explicit module. Would appreciate some guidance here. 🙇

@noahsmartin is good candidate to answer this ⬆️

@denrase denrase requested a review from itaybre October 27, 2025 09:41
cursor[bot]

This comment was marked as outdated.

@denrase
Copy link
Collaborator Author

denrase commented Oct 27, 2025

I was unsuccessful in exposing SentrySessionReplayIntegration/SentrySessionReplay to the Swift SDK, so I opted to add a helper to SentryHub+Private to access the integrations replayId.

}

private func addReplayAttributes(to attributes: inout [String: SentryLog.Attribute]) {
#if os(iOS) || os(tvOS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be

Suggested change
#if os(iOS) || os(tvOS)
#if (os(iOS) || os(tvOS)) && !SENTRY_NO_UIKIT


// MARK: - Replay Attributes Tests

#if os(iOS) || os(tvOS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the same here

Suggested change
#if os(iOS) || os(tvOS)
#if (os(iOS) || os(tvOS)) && !SENTRY_NO_UIKIT

Copy link
Contributor

@itaybre itaybre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, once the build issue is fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add sentry.replay_id attribute to ios logs

3 participants