mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Implement optional usage statistics call:
* Disabled by default, can be checked in preferences dialog * If enabled, reports HeidiSQL revision and versions of recently used servers
This commit is contained in:
@ -169,6 +169,11 @@ const
|
|||||||
REGNAME_COPYTABLE_ALLFIELDS = 'CopyTable_Option_WithAllFields';
|
REGNAME_COPYTABLE_ALLFIELDS = 'CopyTable_Option_WithAllFields';
|
||||||
REGNAME_DEFAULTVIEW = 'DefaultView';
|
REGNAME_DEFAULTVIEW = 'DefaultView';
|
||||||
REGNAME_FILTERS = 'RecentFilters';
|
REGNAME_FILTERS = 'RecentFilters';
|
||||||
|
REGNAME_SERVERVERSION = 'ServerVersion';
|
||||||
|
REGNAME_LASTCONNECT = 'LastConnect';
|
||||||
|
REGNAME_DO_STATISTICS = 'DoUsageStatistics';
|
||||||
|
DEFAULT_DO_STATISTICS = False;
|
||||||
|
REGNAME_LAST_STATSCALL = 'LastUsageStatisticCall';
|
||||||
|
|
||||||
REGNAME_FIELDCOLOR_NUMERIC = 'FieldColor_Numeric';
|
REGNAME_FIELDCOLOR_NUMERIC = 'FieldColor_Numeric';
|
||||||
REGNAME_FIELDCOLOR_TEXT = 'FieldColor_Text';
|
REGNAME_FIELDCOLOR_TEXT = 'FieldColor_Text';
|
||||||
|
@ -1406,17 +1406,20 @@ var
|
|||||||
sValue,
|
sValue,
|
||||||
parHost, parPort, parUser, parPass, parDatabase,
|
parHost, parPort, parUser, parPass, parDatabase,
|
||||||
parTimeout, parCompress, parDescription : String;
|
parTimeout, parCompress, parDescription : String;
|
||||||
LastUpdatecheck : TDateTime;
|
LastUpdatecheck, LastStatsCall, LastConnect: TDateTime;
|
||||||
UpdatecheckInterval : Integer;
|
UpdatecheckInterval, i: Integer;
|
||||||
DefaultLastrunDate, LastSession: String;
|
DefaultLastrunDate, LastSession, StatsURL: String;
|
||||||
frm : TfrmUpdateCheck;
|
frm : TfrmUpdateCheck;
|
||||||
dlgResult: Integer;
|
dlgResult: Integer;
|
||||||
Connected, CommandLineMode: Boolean;
|
Connected, CommandLineMode: Boolean;
|
||||||
ConnForm: TConnForm;
|
ConnForm: TConnForm;
|
||||||
|
StatsCall: TDownloadUrl2;
|
||||||
|
SessionNames: TStringlist;
|
||||||
begin
|
begin
|
||||||
|
DefaultLastrunDate := '2000-01-01';
|
||||||
|
|
||||||
// Do an updatecheck if checked in settings
|
// Do an updatecheck if checked in settings
|
||||||
if GetRegValue(REGNAME_DO_UPDATECHECK, DEFAULT_DO_UPDATECHECK) then begin
|
if GetRegValue(REGNAME_DO_UPDATECHECK, DEFAULT_DO_UPDATECHECK) then begin
|
||||||
DefaultLastrunDate := '2000-01-01';
|
|
||||||
try
|
try
|
||||||
LastUpdatecheck := StrToDateTime( GetRegValue(REGNAME_LAST_UPDATECHECK, DefaultLastrunDate) );
|
LastUpdatecheck := StrToDateTime( GetRegValue(REGNAME_LAST_UPDATECHECK, DefaultLastrunDate) );
|
||||||
except
|
except
|
||||||
@ -1432,6 +1435,44 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// Call user statistics if checked in settings
|
||||||
|
if GetRegValue(REGNAME_DO_STATISTICS, DEFAULT_DO_STATISTICS) then begin
|
||||||
|
try
|
||||||
|
LastStatsCall := StrToDateTime( GetRegValue(REGNAME_LAST_STATSCALL, DefaultLastrunDate) );
|
||||||
|
except
|
||||||
|
LastStatsCall := StrToDateTime( DefaultLastrunDate );
|
||||||
|
end;
|
||||||
|
if DaysBetween(Now, LastStatsCall) >= 30 then begin
|
||||||
|
// Report used SVN revision
|
||||||
|
StatsURL := APPDOMAIN + 'savestats.php?c=' + AppRevision;
|
||||||
|
// Enumerate actively used server versions
|
||||||
|
SessionNames := TStringlist.Create;
|
||||||
|
if MainReg.OpenKey(REGPATH + REGKEY_SESSIONS, true) then
|
||||||
|
MainReg.GetKeyNames(SessionNames);
|
||||||
|
for i:=0 to SessionNames.Count-1 do begin
|
||||||
|
try
|
||||||
|
LastConnect := StrToDateTime(GetRegValue(REGNAME_LASTCONNECT, DefaultLastrunDate, SessionNames[i]));
|
||||||
|
except
|
||||||
|
LastConnect := StrToDateTime(DefaultLastrunDate);
|
||||||
|
end;
|
||||||
|
if LastConnect > LastStatsCall then begin
|
||||||
|
StatsURL := StatsURL + '&s[]=' + IntToStr(GetRegValue(REGNAME_SERVERVERSION, 0, SessionNames[i]));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
StatsCall := TDownloadUrl2.Create(Self);
|
||||||
|
StatsCall.URL := StatsURL;
|
||||||
|
StatsCall.SetUserAgent(APPNAME + ' ' + FullAppVersion);
|
||||||
|
try
|
||||||
|
StatsCall.ExecuteTarget(nil);
|
||||||
|
OpenRegistry;
|
||||||
|
MainReg.WriteString(REGNAME_LAST_STATSCALL, DateTimeToStr(Now));
|
||||||
|
except
|
||||||
|
// Silently ignore it when the url could not be called over the network.
|
||||||
|
end;
|
||||||
|
FreeAndNil(StatsCall);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
Connected := False;
|
Connected := False;
|
||||||
|
|
||||||
// Check commandline if parameters were passed. Otherwise show connections windows
|
// Check commandline if parameters were passed. Otherwise show connections windows
|
||||||
@ -1573,6 +1614,11 @@ begin
|
|||||||
tabHost.Caption := 'Host: '+MySQLConn.Connection.HostName;
|
tabHost.Caption := 'Host: '+MySQLConn.Connection.HostName;
|
||||||
showstatus('MySQL '+v1+'.'+v2+'.'+v3, 3);
|
showstatus('MySQL '+v1+'.'+v2+'.'+v3, 3);
|
||||||
|
|
||||||
|
// Save server version
|
||||||
|
OpenRegistry(SessionName);
|
||||||
|
Mainreg.WriteInteger(REGNAME_SERVERVERSION, mysql_version);
|
||||||
|
Mainreg.WriteString(REGNAME_LASTCONNECT, DateTimeToStr(Now));
|
||||||
|
|
||||||
DatabasesWanted := explode(';', FConn.DatabaseList);
|
DatabasesWanted := explode(';', FConn.DatabaseList);
|
||||||
if FConn.DatabaseListSort then
|
if FConn.DatabaseListSort then
|
||||||
DatabasesWanted.Sort;
|
DatabasesWanted.Sort;
|
||||||
|
@ -185,6 +185,19 @@ object optionsform: Toptionsform
|
|||||||
TabOrder = 11
|
TabOrder = 11
|
||||||
OnClick = Modified
|
OnClick = Modified
|
||||||
end
|
end
|
||||||
|
object chkDoStatistics: TCheckBox
|
||||||
|
Left = 16
|
||||||
|
Top = 233
|
||||||
|
Width = 379
|
||||||
|
Height = 48
|
||||||
|
Caption =
|
||||||
|
'Count in usage statistics. This option, if enabled, will cause H' +
|
||||||
|
'eidiSQL to ping heidisql.com at most once every month. This is ' +
|
||||||
|
'used to count the used HeidiSQL and MySQL versions.'
|
||||||
|
TabOrder = 12
|
||||||
|
WordWrap = True
|
||||||
|
OnClick = Modified
|
||||||
|
end
|
||||||
end
|
end
|
||||||
object tabSQL: TTabSheet
|
object tabSQL: TTabSheet
|
||||||
BorderWidth = 5
|
BorderWidth = 5
|
||||||
|
@ -100,6 +100,7 @@ type
|
|||||||
btnRestoreDefaults: TButton;
|
btnRestoreDefaults: TButton;
|
||||||
lblMaxTotalRows: TLabel;
|
lblMaxTotalRows: TLabel;
|
||||||
editMaxTotalRows: TEdit;
|
editMaxTotalRows: TEdit;
|
||||||
|
chkDoStatistics: TCheckBox;
|
||||||
procedure FormShow(Sender: TObject);
|
procedure FormShow(Sender: TObject);
|
||||||
procedure Modified(Sender: TObject);
|
procedure Modified(Sender: TObject);
|
||||||
procedure Apply(Sender: TObject);
|
procedure Apply(Sender: TObject);
|
||||||
@ -196,6 +197,7 @@ begin
|
|||||||
MainReg.WriteBool(REGNAME_DO_UPDATECHECK, chkUpdatecheck.Checked);
|
MainReg.WriteBool(REGNAME_DO_UPDATECHECK, chkUpdatecheck.Checked);
|
||||||
MainReg.WriteBool(REGNAME_DO_UPDATECHECK_BUILDS, chkUpdatecheckBuilds.Checked);
|
MainReg.WriteBool(REGNAME_DO_UPDATECHECK_BUILDS, chkUpdatecheckBuilds.Checked);
|
||||||
MainReg.WriteInteger(REGNAME_UPDATECHECK_INTERVAL, updownUpdatecheckInterval.Position);
|
MainReg.WriteInteger(REGNAME_UPDATECHECK_INTERVAL, updownUpdatecheckInterval.Position);
|
||||||
|
MainReg.WriteBool(REGNAME_DO_STATISTICS, chkDoStatistics.Checked);
|
||||||
// Save color settings
|
// Save color settings
|
||||||
MainReg.WriteInteger(REGNAME_FIELDCOLOR_NUMERIC, cboxNumeric.Selected);
|
MainReg.WriteInteger(REGNAME_FIELDCOLOR_NUMERIC, cboxNumeric.Selected);
|
||||||
MainReg.WriteInteger(REGNAME_FIELDCOLOR_TEXT, cboxText.Selected);
|
MainReg.WriteInteger(REGNAME_FIELDCOLOR_TEXT, cboxText.Selected);
|
||||||
@ -313,6 +315,7 @@ begin
|
|||||||
chkUpdatecheckBuilds.Checked := GetRegValue(REGNAME_DO_UPDATECHECK_BUILDS, DEFAULT_DO_UPDATECHECK_BUILDS);
|
chkUpdatecheckBuilds.Checked := GetRegValue(REGNAME_DO_UPDATECHECK_BUILDS, DEFAULT_DO_UPDATECHECK_BUILDS);
|
||||||
updownUpdatecheckInterval.Position := GetRegValue(REGNAME_UPDATECHECK_INTERVAL, DEFAULT_UPDATECHECK_INTERVAL);
|
updownUpdatecheckInterval.Position := GetRegValue(REGNAME_UPDATECHECK_INTERVAL, DEFAULT_UPDATECHECK_INTERVAL);
|
||||||
chkUpdatecheckClick(Sender);
|
chkUpdatecheckClick(Sender);
|
||||||
|
chkDoStatistics.Checked := GetRegValue(REGNAME_DO_STATISTICS, DEFAULT_DO_STATISTICS);
|
||||||
|
|
||||||
// Default Column-Width in DBGrids:
|
// Default Column-Width in DBGrids:
|
||||||
updownMaxColWidth.Position := GetRegValue(REGNAME_MAXCOLWIDTH, DEFAULT_MAXCOLWIDTH);
|
updownMaxColWidth.Position := GetRegValue(REGNAME_MAXCOLWIDTH, DEFAULT_MAXCOLWIDTH);
|
||||||
|
Reference in New Issue
Block a user