Skip to content

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
}

}

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