Skip to content
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

Get 'hashedDefaultUser' working even without a custom user set #214

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sources/TelemetryDeck/Signals/SignalManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import TVUIKit
protocol SignalManageable {
func processSignal(_ signalName: String, parameters: [String: String], floatValue: Double?, customUserID: String?, configuration: TelemetryManagerConfiguration)
func attemptToSendNextBatchOfCachedSignals()

@MainActor var defaultUserIdentifier: String { get }
}

final class SignalManager: SignalManageable, @unchecked Sendable {
Expand Down Expand Up @@ -237,7 +239,7 @@ private extension SignalManager {

// MARK: - Helpers

private extension SignalManager {
extension SignalManager {
#if os(macOS)
/// A custom ``UserDefaults`` instance specific to TelemetryDeck and the current application.
private var customDefaults: UserDefaults? {
Expand Down
5 changes: 3 additions & 2 deletions Sources/TelemetryDeck/TelemetryClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,9 @@ public final class TelemetryManager: @unchecked Sendable {
TelemetryDeck.updateDefaultUserID(to: newDefaultUser)
}

public var hashedDefaultUser: String? {
guard let defaultUser = configuration.defaultUser else { return nil }
@MainActor
public var hashedDefaultUser: String {
let defaultUser = self.signalManager.defaultUserIdentifier
return CryptoHashing.sha256(string: defaultUser, salt: configuration.salt)
}

Expand Down
Loading