Windows Platform Integration Guidelines
This article is a detailed document introducing the use of the PC SDK, containing a basic integration process and an advanced introduction to the use of the interface. This document applies to version 2.2.1 and above, if you are using a lower version, it is recommended to upgrade as soon as possible. See View dll version number for the method to view the version.
If you want to quickly integrate and verify the platform and SDK functionality, it is recommended to check the "Tutorial" in the project menu. The initialization code for this project has been generated by project specific information (platform, engine, local(China)/international, AppID) in the guide, which can be copied and used directly. The following figure shows:
Project creation: External projects support self-service project creation, but there is a free trial period. For internal projects, contact "CrashSight Assistant" on corporate WeChat to open them.
1 Instructions for use
When integrating to CrashSight SDK PC version, the game client needs to load the exception catching dll by itself and pass in the user id and game version parameters. The following table lists the web addresses and reporting addresses of local(China) and international services. Users can choose qq login or enterprise WeChat login:
Server Type | Website URL | Upload URL(used in config file) |
---|---|---|
Local Server | https://crashsight.qq.com | pc.crashsight.qq.com |
International Server | https://crashsight.wetest.net | pc.crashsight.wetest.net |
PS: The international version and the local version are exactly the same, you only need to modify the different reporting address to report to the specified region (note that the corresponding appid and key also need to do the corresponding changes, otherwise the server will reject)
2 CrashSight component download
The new version of CrashSight mainly provides 64-bit version, compared with 32-bit version and 64-bit version, except for different file names, the functions and usage are the same.
After successfully creating a project in the platform, you can download the corresponding SDK from the "Tutorial" in the sidebar, as shown in the figure below:
3 CrashSight integration
As this SDK adopts the way of loading dll directly from the client, the specific integration is as follows:
-
Login to the web side and register the project, select PC as the project type, the appid (e.g. 0620edc732)
-
Put the provided files to the specified location according to the instructions, the client will load the CrashSight64.dll in the same level directory after startup
-
C++ through HINSTANCE dllDemo = LoadLibraryA("CrashSight64.dll"); load the dll, other languages use the language corresponding to the dll loading method can be.
-
Set the APP Version before initializing CrashSight.
typedef void(*CS_SetAppVersion)(const char *app_version);
- Configure uploading URL (Reference code) Call the following function to pass the reported URL to CrashSight. Local(China) server URL:pc.crashsight.qq.com International server URL:pc.crashsight.wetest.net
typedef void(*CS_ConfigCrashServerUrl)(const char* crash_server_url);
- Initialize CrashSight. call the following function to set the CrashSight appid and initialize it.
typedef void(*CS_InitWithAppId)(const char* app_id);
- When the client configuration is finished, start the game normally and find that there is CrashSight64.dll in the game process, which means that CrashSight is loaded and started successfully.
4 CrashSight reporting data fields
After the game client loads the dll and calls the export function:
- The dll will read the domain name in the configuration file to report networking data.
- It is used to report the minidmp generated by the dll to the server when the dll catches a crash exception.
The current data fields reported by CrashSight are as follows:
Field | Description |
---|---|
userId | user id |
appId | project's registration id |
Mac | Mac address |
osName | operating system name |
displayCard | Display card name |
Cpu | Cpu type |
phyMemAll | Machine memory |
osBit | machine bit count |
resolution | resolution |
pidName | process name |
bootTime | boot time |
Ip | Ip address |
5 Interfaces
5.1 Error Reporting
// declare the export function
typedef void(*CS_ReportException)(int type, const char* name, const char* message, const char* stackTrace, const char * extras, bool is_async, const char *error_attach_path);
CS_ReportException theReportException = (CS_ReportException)GetProcAddress(dllDemo, "CS_ReportException");
// call the function
theReportException(1, "name", "message", "stack", "{\"k1\":\"v1111\",\"k2\":\"v2222\",\"k3\":\"v3333\"}", true, "/path/to/your/attach/file");
// declare the export function
typedef void(*CS_ReportExceptionW)(int type, const char* name, const char* message, const char* stackTrace, const char * extras, bool is_async, const wchar_t *error_attach_path);
CS_ReportExceptionW theReportExceptionW = (CS_ReportExceptionW)GetProcAddress(dllDemo, "CS_ReportExceptionW");
// call the function
theReportExceptionW(1, "name", "message", "stack", "{\"k1\":\"v1111\",\"k2\":\"v2222\",\"k3\":\"v3333\"}", true, L"/path/to/your/attach/file");
parameter | explanation |
---|---|
type | Deprecated, fill in with 1 is ok |
expName | Name of the problem, please limit it to 128 bytes. (In particular, if you use UE engine and transcode it by UTF8, please limit it to 96 characters if possible) |
expMessage | A brief description of the problem, please limit it to 128 bytes. (In particular, if you use UE engine and transcode it by UTF8, please limit it to 96 characters if possible) |
stackTrace | The stack of the current error, limit to 2M only |
extras | additional information, need to pass key-value pairs in json format, such as no additional information can be filled with "" |
is_async | Synchronous/asynchronous reporting, generally fill in true (asynchronous) |
error_attach_path | The absolute path of the attachment, you can specify a 5M attachment |
If you need to pass in a path with Unicode characters, please use the wide character version (CS_ReportExceptionW).
5.2 Setting callbacks
// declare the export function
typedef void(*CS_SetCrashCallback)(CrashCallbackFuncPtr callback);
CS_SetCrashCallback theSetCrashCallback = (CS_SetCrashCallback)GetProcAddress(dllDemo, "CS_SetCrashCallback");
// call the function
theSetCrashCallback(myCallback);
parameter | explanation |
---|---|
callback | Pointer to callback function |
The CrashCallbackFuncPtr callback can be any of the user's own function implementations (see Callback functions), as long as the parameters match, the declaration cycle always exists, and it will not become a null pointer.Note here that the callback function cannot be a non-static function of a class member, because the default first argument of a non-static function of a class member is 'this'
5.3 Callback function
typedef void(*CrashCallbackFuncPtr)(int type, const char* guid);
parameter | explanation |
---|---|
type | Type of callback, currently there are only crash callbacks, always be 1 |
guid | Unique identifier string of length 64, each report has a separate string |
Splice https://{website_domain}/crash-reporting/client-report-id/{APP_ID}/{GUID}?pid={platform_ID}
to get the relevant report URL.
5.4 Custom Interface Log
// declare the export function
enum LogSeverity { LogSilent, LogError, LogWarning, LogInfo, LogDebug, LogVerbose };
typedef void(*CS_PrintLog)(LogSeverity level, const char* tag, const char *format, ...);
CS_PrintLog thePrintLog = (CS_PrintLog)GetProcAddress(dllDemo, "CS_PrintLog");
// call the function
thePrintLog(LogSeverity.LogError, "MyTag", "%s", "myMessage");
parameter | explanation |
---|---|
level | Log level |
tag | Log tag |
format | Log format |
args | Variable parameters |
This function can be called to write a log to the SDK during the program runtime, and this log will be reported together with the error report and crash report. The log content is a 30KB circular queue.
5.5 Custom KV
// declare the export function
typedef void(*CS_SetUserValue)(const char* key, const char* value);
CS_SetUserValue theSetUserValue = (CS_SetUserValue)GetProcAddress(dllDemo, "CS_SetUserValue");
// call the function
theSetUserValue("key", "value");
parameter | explanation |
---|---|
key | custom key |
value | custom value |
This function can be called to write custom KV to SDK during program operation to save some key properties, which will be reported together with the error report and crash report. It is recommended that the KV be set according to the specification in the custom data format document.
5.6 Turn on VEH exceptions
// declare the export function
typedef void (*CS_SetVehEnable)(bool enable);
CS_SetVehEnable theSetVehEnable = (CS_SetVehEnable)GetProcAddress(dllDemo, "CS_SetVehEnable");
// call the function
theSetVehEnable(true);
Set VEH exception handling state, default is off. When turned off, only unhandled exceptions are reported. This scheme optimizes the catching of some exceptions, e.g. when turned off, crashes caused by THROW are reported (when turned on, they are not), bad memory accesses that have been handled are not reported by mistake, etc. Note that since UE catches all exceptions at the engine level via __try __except (macro PLATFORM_SEH_EXCEPTIONS_DISABLED related area), there are no 'unhandled exceptions'. Therefore, turn on this option until this catch is turned off by modifying the engine code, as this will result in a large number of exceptions not being reported.
5.7 Enabling additional exception catching
// declare the export function
typedef void (*CS_SetExtraHandler)(bool extra_handle_enable);
CS_SetExtraHandler theSetExtraHandler = (CS_SetExtraHandler)GetProcAddress(dllDemo, "CS_SetExtraHandler");
// call the function
theSetExtraHandler(true);
Set additional exception handling mechanism, default is off. When turned on, it can catch crashes caused by illegal arguments thrown by safety functions like strcpy_s and, crashes caused by false function call purecall errors.
5.8 Custom file data
Crashes/errors carry the contents of a file in the specified directory, usually the file contents are logs, so this feature is also called custom file logging. Unlike the interface log, the file log reads the specified file and does not restrict the content of the written file or the method. This feature does not need to be actively enabled, as long as in the corresponding reporting trigger is, the specified directory has files will be reported.
Specifically:
On crash, the file specified by the CS_SetCustomLogDir interface is reported.
On error, the file specified by the CS_ReportException interface is reported.
5.9 Proactive reporting of crashes
This function can be called in some cases where active dump reporting is expected. It is mainly used to report UE Fatal errors.
// declare the export function
typedef void (*CS_ReportCrash)();
CS_ReportCrash theReportCrash = (CS_ReportCrash)GetProcAddress(dllDemo, "CS_ReportCrash");
// call the function
theReportCrash();