Unverified Commit aa1af381 authored by confiks's avatar confiks Committed by GitHub
Browse files

Remove SentryDSN from preferences (#6)

* Add config -> preferences update function. Strip sentryDSN out of preferences and into a package variable.

* Typo
parent 9f8b0090
......@@ -7,7 +7,7 @@ import (
"time"
"github.com/credentials/go-go-gadget-paillier"
"github.com/getsentry/raven-go"
raven "github.com/getsentry/raven-go"
"github.com/go-errors/errors"
"github.com/mhe/gabi"
"github.com/privacybydesign/irmago"
......@@ -58,14 +58,16 @@ type Client struct {
state *issuanceState
}
// SentryDSN should be set in the init() function
// Setting it to an empty string means no crash reports
var SentryDSN = ""
type Preferences struct {
EnableCrashReporting bool
SentryDSN string
}
var defaultClientConfig = Preferences{
var defaultPreferences = Preferences{
EnableCrashReporting: true,
SentryDSN: "", // Set this in the init() function, empty string -> no crash reports
}
// KeyshareHandler is used for asking the user for his email address and PIN,
......@@ -139,7 +141,7 @@ func New(
return nil, err
}
if cm.Preferences, err = cm.storage.LoadClientConfig(); err != nil {
if cm.Preferences, err = cm.storage.LoadPreferences(); err != nil {
return nil, err
}
cm.applyPreferences()
......@@ -738,7 +740,7 @@ func (client *Client) Logs() ([]*LogEntry, error) {
return client.logs, nil
}
// SendCrashReports toggles whether or not crash reports should be sent to Sentry.
// SetCrashReportingPreference toggles whether or not crash reports should be sent to Sentry.
// Has effect only after restarting.
func (client *Client) SetCrashReportingPreference(enable bool) {
client.Preferences.EnableCrashReporting = enable
......@@ -748,7 +750,7 @@ func (client *Client) SetCrashReportingPreference(enable bool) {
func (client *Client) applyPreferences() {
if client.Preferences.EnableCrashReporting {
raven.SetDSN(client.Preferences.SentryDSN)
raven.SetDSN(SentryDSN)
} else {
raven.SetDSN("")
}
......
......@@ -211,7 +211,7 @@ func (s *storage) LoadUpdates() (updates []update, err error) {
return updates, nil
}
func (s *storage) LoadClientConfig() (Preferences, error) {
config := defaultClientConfig
func (s *storage) LoadPreferences() (Preferences, error) {
config := defaultPreferences
return config, s.load(&config, preferencesFile)
}
......@@ -8,10 +8,10 @@ import (
"math/big"
"time"
"github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/fs"
"github.com/go-errors/errors"
"github.com/mhe/gabi"
"github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/fs"
)
// This file contains the update mechanism for Client
......@@ -45,6 +45,20 @@ var clientUpdates = []func(client *Client) error{
}
return nil
},
func(client *Client) error {
oldStruct := &struct {
SendCrashReports bool
}{}
// Load old file, convert to new struct, and save
err := client.storage.load(oldStruct, "config")
if err != nil {
return err
}
client.Preferences = Preferences{
EnableCrashReporting: oldStruct.SendCrashReports,
}
return client.storage.StorePreferences(client.Preferences)
},
}
// update performs any function from clientUpdates that has not
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment