From ecc5de18bed8a9d95f5715975d2f070d71ac3f83 Mon Sep 17 00:00:00 2001 From: Fedor Korotkov Date: Thu, 2 Feb 2023 06:12:28 -0500 Subject: [PATCH] Collect installation information (#390) --- .goreleaser.yml | 5 ++++ .../tart/Commands/ReportInstallation.swift | 25 +++++++++++++++++++ Sources/tart/Root.swift | 1 + 3 files changed, 31 insertions(+) create mode 100644 Sources/tart/Commands/ReportInstallation.swift diff --git a/.goreleaser.yml b/.goreleaser.yml index 345453f..b526e3a 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -39,10 +39,15 @@ brews: name: homebrew-cli caveats: See the GitHub repository for more information homepage: https://github.com/cirruslabs/tart + license: "AGPL-3.0" description: Run macOS VMs on Apple Silicon skip_upload: auto dependencies: - "cirruslabs/cli/softnet" + post_install: | + ENV["SENTRY_DSN"] = "https://606fab64ced94f0991109ac5467e23da@o4504250314522624.ingest.sentry.io/4504606552424448" + system "#{bin}/tart report-installation" + ENV.delete("SENTRY_DSN") custom_block: | depends_on :macos => :monterey diff --git a/Sources/tart/Commands/ReportInstallation.swift b/Sources/tart/Commands/ReportInstallation.swift new file mode 100644 index 0000000..219958e --- /dev/null +++ b/Sources/tart/Commands/ReportInstallation.swift @@ -0,0 +1,25 @@ +import ArgumentParser +import Foundation +import Sentry + +struct ReportInstallation: AsyncParsableCommand { + static var configuration = CommandConfiguration( + commandName: "report-installation", + abstract: "Send installation event to Sentry if configured", + discussion: """ + Reports macOS version and device model for analytics purposes. + Helps Cirrus Labs team to prioritize testing on most popular devices. + """, + shouldDisplay: false + ) + + func run() async throws { + let installationEvent = Event() + installationEvent.message = SentryMessage(formatted: "installed") + installationEvent.level = SentryLevel.info + installationEvent.user = nil + installationEvent.stacktrace = nil + let id = SentrySDK.capture(event: installationEvent) + print("Captured installation event #\(id)!") + } +} diff --git a/Sources/tart/Root.swift b/Sources/tart/Root.swift index 5d70c07..e987b6f 100644 --- a/Sources/tart/Root.swift +++ b/Sources/tart/Root.swift @@ -33,6 +33,7 @@ struct Root: AsyncParsableCommand { Rename.self, Stop.self, Delete.self, + ReportInstallation.self, ]) public static func main() async throws {