- 1 Unity C# Integration
- 2 Interfaces
Unity SDK Integration(Linux DS)
This document is to introduce the Linux DS platform Unity SDK, including the basic integration process, and how to use the interfaces.
1 Unity C# Integration
1.1 Download and Import Unity Plugin to Unity Project
CrashSight Linux DS SDK is currently not open for download, please contact "CrashSight Assistant" to get the SDK package.
Unzip the SDK package and copy the contents to the Assets directory of the project to complete the import.
1.2 Initialize CrashSight
Choose the first scene or the main scene, and call the following code in a script loaded as early as possible to initialize:
// Debug switch. In the debugging mode, more logs will be printed to locate issues.
#if DEBUG
CrashSightAgent.ConfigDebugMode (true);
#endif
CrashSightAgent.ConfigDebugMode (false);
// Set the target domain name to report to. Please fill in according to project requirements. (required)
CrashSightAgent.ConfigCrashServerUrl (CrashSightUploadUrl);
// Set the target APP ID, APP KEY and version for reporting and initialize. You can find the APP ID and APP KEY from More->Product Settings->Product Info of the management console.
CrashSightAgent.Init(CrashSightAppId, CrashSightAppKey, AppVersion);
Domain name for reporting
Domestic public cloud: pc.crashsight.qq.com
Overseas public cloud: pc.crashsight.wetest.net
2 Interfaces
2.1 Initialization
public static void Init(string appId, string appKey, string appVersion);
Note: Execute initialization. Initialize as early as possible to enable crash detection and reporting features.
The appid is CrashSight's unique identifier for the project, and can be viewed in Product Settings -> Product Information.
The appKey is CrashSight's reporting key for the project, and can be viewed in Product Settings -> Product Information.
Parameter | Type | Note |
---|---|---|
appId | string | APP ID of registered project |
appKey | string | APP Key of registered project |
appVersion | string | application version |
2.2 Reporting errors
public static void ReportException(System.Exception e, string message);
Note: Active C# exception reporting
Parameter | Type | Note |
---|---|---|
e | System.Exception | Caught exception |
message | string | Exception message |
public static void ReportException(string name, string message, string stackTrace);
Note: Proactively report error messages. Can be called manually when an error is caught or needs to be reported, multi-threaded calls are supported. name, message and stackTrace cannot be null.
Parameter | Type | Note |
---|---|---|
name | string | Exception Name |
message | string | Exception message |
stackTrace | string | Stack |
public static void ReportException(int type, string exceptionName, string exceptionMsg, string exceptionStack, Dictionary<string, string> extInfo);
Note: Proactively report error messages. Can be called manually when an error is caught or needs to be reported, multi-threaded calls are supported. exceptionName, exceptionMsg and exceptionStack cannot be null.
Parameter | Type | Note |
---|---|---|
type | int | Exception Type, C#: 4, js: 5, lua: 6 |
exceptionName | string | Exception Name |
exceptionMsg | string | Exception Info |
exceptionStack | string | Stack |
extInfo | Dictionary<string, string> | Other Info |
View page:
extras: Crash Details->Download Attachments->extraMessage.txt
2.3 Setting user ID
public static void SetUserId(string userId);
Note: Setting user ID. The user id defaults to unknown.
Parameter | Type | Note |
---|---|---|
userId | string | User ID |
2.4 Adding custom data
public static void AddSceneData(string key, string value);
Note: Set the Key-Value data customized by the user. It will be reported together with exception info when sending the crash. The total length supports up to 128k.
View page: Crash Details->Download Attachments->valueMapOthers.txt
Parameter | Type | Note |
---|---|---|
key | string | Key |
value | string | Value |
2.5 Setting the application version
public static void SetAppVersion(string appVersion);
Note: Set app version number
Parameter | Type | Note |
---|---|---|
appVersion | string | Version Number |
2.6 Reporting domain name settings
public static void ConfigCrashServerUrl(string crashServerUrl);
Note: Set domain name for reporting.
Note: Call it before the InitWithAppId interface.
Domain name for reporting
Domestic public cloud: pc.crashsight.qq.com
Overseas public cloud: pc.crashsight.wetest.net
A direct CrashSight domain name Integration is different from an indirect one using MSDK. Make sure you follow the above domain name to reconfigure. For other environment domain name, please consult the Integration contact.
Parameter | Type | Note |
---|---|---|
crashServerUrl | string | Target domain name of reporting |
2.7 Set upload log path
public static void SetLogPath(string logPath);
Note: Set an upload path for log after a crash. Read permission is required. The attachment is supported up to 8MB.
Parameter | Type | Note |
---|---|---|
logPath | string | Log absolute path |
2.8 Enable Debug
public static void ConfigDebugMode(bool enable);
Note: Whether to enable debugging mode. Off by default. After enabling, some logs will be printed, but it can help locate issues during tests.
Note: Call it before the InitWithAppId interface.
Parameter | Type | Note |
---|---|---|
enable | bool | Enabling switch for debugging |
2.9 Set device id
public static void SetDeviceId(string deviceId);
Note: Set the device ID, by default uuid is used as the device ID
Note: Call it before the InitWithAppId interface.
Parameter | Type | Note |
---|---|---|
deviceId | string | Device ID |
2.10 Customize logging
public static void PrintLog(CSLogSeverity level, string format, params object[] args);
Note: The custom log shouldn't exceed 30KB.
Parameter | Type | Note |
---|---|---|
level | CSLogSeverity | Log level |
format | string | Log format |
args | params object[] | variable arguments |
Custom log view: issue details -> custom log (from interface)
2.11 Set path to all log files
public static void SetRecordFileDir(string record_dir);
Note: Set the path to all log files, including SDK logs and dump files, defaults to the directory of the current executable.
Parameter | Type | Note |
---|---|---|
record_dir | string | Record file path |