mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #12644 from Atlante45/feat/ga-installer
Add Google Analytics to installer
This commit is contained in:
commit
afcfbfe721
4 changed files with 133 additions and 18 deletions
|
@ -17,6 +17,8 @@ To produce an executable installer on Windows, the following are required:
|
|||
- [Nullsoft Scriptable Install System](http://nsis.sourceforge.net/Download) - 3.0b3
|
||||
- [UAC Plug-in for Nullsoft](http://nsis.sourceforge.net/UAC_plug-in) - 0.2.4c
|
||||
- [nsProcess Plug-in for Nullsoft](http://nsis.sourceforge.net/NsProcess_plugin) - 1.6
|
||||
- [Inetc Plug-in for Nullsoft](http://nsis.sourceforge.net/Inetc_plug-in) - 1.0
|
||||
- [NSISpcre Plug-in for Nullsoft](http://nsis.sourceforge.net/NSISpcre_plug-in) - 1.0
|
||||
|
||||
Run the `package` target to create an executable installer using the Nullsoft Scriptable Install System.
|
||||
|
||||
|
|
|
@ -149,6 +149,8 @@ macro(SET_PACKAGING_PARAMETERS)
|
|||
set(CLIENT_LAUNCH_NOW_REG_KEY "ClientLaunchAfterInstall")
|
||||
set(SERVER_LAUNCH_NOW_REG_KEY "ServerLaunchAfterInstall")
|
||||
set(CUSTOM_INSTALL_REG_KEY "CustomInstall")
|
||||
set(CLIENT_ID_REG_KEY "ClientGUID")
|
||||
set(GA_TRACKING_ID $ENV{GA_TRACKING_ID})
|
||||
endif ()
|
||||
|
||||
# setup component categories for installer
|
||||
|
|
|
@ -41,6 +41,8 @@ set(CONSOLE_STARTUP_REG_KEY "@CONSOLE_STARTUP_REG_KEY@")
|
|||
set(SERVER_LAUNCH_NOW_REG_KEY "@SERVER_LAUNCH_NOW_REG_KEY@")
|
||||
set(CLIENT_LAUNCH_NOW_REG_KEY "@CLIENT_LAUNCH_NOW_REG_KEY@")
|
||||
set(CUSTOM_INSTALL_REG_KEY "@CUSTOM_INSTALL_REG_KEY@")
|
||||
set(GA_TRACKING_ID "@GA_TRACKING_ID@")
|
||||
set(CLIENT_ID_REG_KEY "@CLIENT_ID_REG_KEY@")
|
||||
set(INSTALLER_HEADER_IMAGE "@INSTALLER_HEADER_IMAGE@")
|
||||
set(UNINSTALLER_HEADER_IMAGE "@UNINSTALLER_HEADER_IMAGE@")
|
||||
set(ADD_REMOVE_ICON_PATH "@ADD_REMOVE_ICON_PATH@")
|
||||
|
|
|
@ -319,6 +319,78 @@ Function DownloadFile
|
|||
FunctionEnd
|
||||
!endif
|
||||
|
||||
|
||||
!include NSISpcre.nsh
|
||||
!insertmacro REMatches
|
||||
|
||||
Var CampaignName
|
||||
|
||||
!macro GetCampaignName RetVar
|
||||
Call GetCampaignName
|
||||
Pop ${RetVar}
|
||||
!macroend
|
||||
|
||||
Function GetCampaignName
|
||||
Push $0 ; Stash $0
|
||||
|
||||
; Parse filename out of the path
|
||||
${RECaptureMatches} $0 "([^\\]*\\)*(.*)\.exe" $EXEPATH 0
|
||||
${If} $0 == 2
|
||||
Pop $0 ; Discard Path
|
||||
Pop $0 ; Recover filename
|
||||
; Parse campaign out of the filename
|
||||
${RECaptureMatches} $0 "HighFidelity-([^-]*-)Beta-.*" $0 0
|
||||
${If} $0 == 1
|
||||
Pop $0 ; Recover campaign name
|
||||
StrCpy $0 $0 -1 0 ; Remove trailing - and copy to _RetVar
|
||||
${Else}
|
||||
StrCpy $0 ""
|
||||
${EndIf}
|
||||
${Else}
|
||||
StrCpy $0 ""
|
||||
${EndIf}
|
||||
|
||||
Exch $0 ; Restore $0 and push result
|
||||
FunctionEnd
|
||||
|
||||
!macro CreateGUID RetVar
|
||||
System::Call 'ole32::CoCreateGuid(g .s)'
|
||||
Pop ${RetVar}
|
||||
; Strip opening and closing braces
|
||||
StrCpy ${RetVar} ${RetVar} -1 1
|
||||
!macroend
|
||||
|
||||
Var GAClientID
|
||||
|
||||
!macro InitGAClientID
|
||||
; Generate a new GUID on every run for now
|
||||
!insertmacro CreateGUID $GAClientID
|
||||
!macroend
|
||||
|
||||
!macro GoogleAnalytics Category Action Label Value
|
||||
${If} "@GA_TRACKING_ID@" != ""
|
||||
Push $0
|
||||
Push $1
|
||||
|
||||
StrCpy $0 "https://google-analytics.com/collect?v=1&tid=@GA_TRACKING_ID@"
|
||||
StrCpy $0 "$0&cid=$GAClientID&t=event&ec=${Category}&ea=${Action}"
|
||||
|
||||
${If} "${Label}" != ""
|
||||
StrCpy $0 "$0&el=${Label}"
|
||||
${EndIf}
|
||||
${If} "${Value}" != ""
|
||||
StrCpy $0 "$0&ev=${Value}"
|
||||
${EndIf}
|
||||
|
||||
GetTempFileName $1
|
||||
inetc::get /SILENT $0 $1 /END
|
||||
Delete $1
|
||||
|
||||
Pop $1
|
||||
Pop $0
|
||||
${EndIf}
|
||||
!macroend
|
||||
|
||||
;--------------------------------
|
||||
; Installation types
|
||||
|
||||
|
@ -342,28 +414,32 @@ SectionEnd
|
|||
|
||||
;--------------------------------
|
||||
;Pages
|
||||
!define MUI_CUSTOMFUNCTION_ABORT OnUserAbort
|
||||
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE PageWelcomePre
|
||||
!insertmacro MUI_PAGE_WELCOME
|
||||
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE PageLicensePre
|
||||
!insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@"
|
||||
|
||||
Page custom InstallTypesPage ReadInstallTypes
|
||||
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE AbortFunction
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE PageDirectoryPre
|
||||
!insertmacro MUI_PAGE_DIRECTORY
|
||||
|
||||
;Start Menu Folder Page Configuration
|
||||
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
|
||||
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
|
||||
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
|
||||
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE AbortFunction
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE PageStartMenuPre
|
||||
!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
|
||||
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE AbortFunction
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE PageComponentsPre
|
||||
@CPACK_NSIS_PAGE_COMPONENTS@
|
||||
|
||||
Page custom PostInstallOptionsPage ReadPostInstallOptions
|
||||
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE PageInstallFilesPre
|
||||
!insertmacro MUI_PAGE_INSTFILES
|
||||
|
||||
!insertmacro MUI_UNPAGE_CONFIRM
|
||||
|
@ -452,8 +528,40 @@ Var CopyFromProductionCheckbox
|
|||
Var ExpressInstallRadioButton
|
||||
Var CustomInstallRadioButton
|
||||
Var InstallTypeDialog
|
||||
Var Express
|
||||
Var CustomInstallTemporaryState
|
||||
Var Express
|
||||
|
||||
!macro MaybeSkipPage
|
||||
; Check if Express is set, if so, abort the post install options page
|
||||
${If} $Express == "1"
|
||||
Abort
|
||||
${EndIf}
|
||||
!macroend
|
||||
|
||||
Function OnUserAbort
|
||||
!insertmacro GoogleAnalytics "Installer" "Abort" "User Abort" ""
|
||||
FunctionEnd
|
||||
Function PageWelcomePre
|
||||
!insertmacro GoogleAnalytics "Installer" "Welcome" "" ""
|
||||
FunctionEnd
|
||||
Function PageLicensePre
|
||||
!insertmacro GoogleAnalytics "Installer" "License" "" ""
|
||||
FunctionEnd
|
||||
Function PageDirectoryPre
|
||||
!insertmacro MaybeSkipPage
|
||||
!insertmacro GoogleAnalytics "Installer" "Directory" "" ""
|
||||
FunctionEnd
|
||||
Function PageStartMenuPre
|
||||
!insertmacro MaybeSkipPage
|
||||
!insertmacro GoogleAnalytics "Installer" "StartMenu" "" ""
|
||||
FunctionEnd
|
||||
Function PageComponentsPre
|
||||
!insertmacro MaybeSkipPage
|
||||
!insertmacro GoogleAnalytics "Installer" "Components" "" ""
|
||||
FunctionEnd
|
||||
Function PageInstallFilesPre
|
||||
!insertmacro GoogleAnalytics "Installer" "Install" "" ""
|
||||
FunctionEnd
|
||||
|
||||
!macro SetInstallOption Checkbox OptionName Default
|
||||
; reads the value for the given install option to the registry
|
||||
|
@ -472,6 +580,8 @@ Var CustomInstallTemporaryState
|
|||
!macroend
|
||||
|
||||
Function InstallTypesPage
|
||||
!insertmacro GoogleAnalytics "Installer" "Install Types" "" ""
|
||||
|
||||
!insertmacro MUI_HEADER_TEXT "Choose Installation Type" "Express or Custom Install"
|
||||
|
||||
nsDialogs::Create 1018
|
||||
|
@ -523,14 +633,10 @@ Function ChangeCustomLabel
|
|||
Pop $R1
|
||||
FunctionEnd
|
||||
|
||||
Function AbortFunction
|
||||
; Check if Express is set, if so, abort the post install options page
|
||||
StrCmp $Express "1" 0 end
|
||||
Abort
|
||||
end:
|
||||
FunctionEnd
|
||||
|
||||
Function PostInstallOptionsPage
|
||||
!insertmacro MaybeSkipPage
|
||||
!insertmacro GoogleAnalytics "Installer" "Post Install Options" "" ""
|
||||
|
||||
!insertmacro MUI_HEADER_TEXT "Setup Options" ""
|
||||
|
||||
nsDialogs::Create 1018
|
||||
|
@ -540,11 +646,6 @@ Function PostInstallOptionsPage
|
|||
Abort
|
||||
${EndIf}
|
||||
|
||||
; Check if Express is set, if so, abort the post install options page
|
||||
StrCmp $Express "1" 0 end
|
||||
Abort
|
||||
end:
|
||||
|
||||
StrCpy $CurrentOffset 0
|
||||
StrCpy $OffsetUnits u
|
||||
|
||||
|
@ -965,6 +1066,7 @@ Section "-Core installation"
|
|||
; Handle whichever post install options were set
|
||||
Call HandlePostInstallOptions
|
||||
|
||||
!insertmacro GoogleAnalytics "Installer" "Done" "" ""
|
||||
SectionEnd
|
||||
|
||||
!include nsProcess.nsh
|
||||
|
@ -979,7 +1081,7 @@ SectionEnd
|
|||
${If} $R0 == 0
|
||||
|
||||
; the process is running, ask the user to close it
|
||||
|
||||
|
||||
${If} "${displayName}" == "@CONSOLE_DISPLAY_NAME@"
|
||||
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION \
|
||||
"${displayName} cannot be ${action} while ${displayName} is running.$\r$\nPlease close it in the system tray and click Retry to continue." \
|
||||
|
@ -992,6 +1094,8 @@ SectionEnd
|
|||
/SD IDCANCEL IDRETRY Prompt_${UniqueID} IDCANCEL 0
|
||||
${EndIf}
|
||||
|
||||
!insertmacro GoogleAnalytics "Installer" "Abort" "${displayName} Running" ""
|
||||
|
||||
; If the user decided to cancel, stop the current installer/uninstaller
|
||||
Abort
|
||||
|
||||
|
@ -1219,6 +1323,11 @@ Function .onInit
|
|||
Quit
|
||||
!endif
|
||||
|
||||
!insertmacro InitGAClientID
|
||||
!insertmacro GetCampaignName $CampaignName
|
||||
|
||||
!insertmacro GoogleAnalytics "Installer" "Start" "$CampaignName" ""
|
||||
|
||||
; make sure none of the installed applications are still running
|
||||
!insertmacro CheckForRunningApplications "installed" "Installer"
|
||||
${nsProcess::Unload}
|
||||
|
|
Loading…
Reference in a new issue