Skip to content

feat: make logs sharing API public #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

evsaev
Copy link

@evsaev evsaev commented Jun 5, 2025

This PR enables developers to export Pulse logs through a low-level API. Specifically, it changes the access level of ShareItems and ShareService from package -> public.

Context

I’m using Pulse in my app and want to allow end users to export device logs by tapping a button on the troubleshooting screen. To make this process as seamless as possible - and to avoid the overhead of integrating PulseUI views for export - I’d prefer a lightweight, low-level way to access the logs.

Usage

let store = LoggerStore.shared
let context = store.backgroundContext

let entitiesToExport = try await context.perform {
    let fetchRequest = NSFetchRequest<LoggerSessionEntity>(entityName: "LoggerSessionEntity")
    fetchRequest.predicate = ... // required filters go here
    fetchRequest.sortDescriptors  = ... // required sorting goes there
    return try context.fetch(fetchRequest)
}

let logs = try await ShareService.share(
  entitiesToExport,
  store: store,
  as: .html
)

if let logsFileURL = logs.items.first as? URL else {
  // show share sheet for logs file
}

@@ -41,10 +41,8 @@ package struct ShareItems: Identifiable {
}
}

package enum ShareService {
private static var task: ShareStoreTask?
Copy link
Author

@evsaev evsaev Jun 5, 2025

Choose a reason for hiding this comment

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

This doesn’t have to be part of the PR, but I noticed it’s unused -> can safely be removed

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.

1 participant