Skip to main content

Unity Backtrace and HelpShift SDK integration

By combining error and exception capturing from Backtrace with first-class in-app customer support using HelpShift in Unity games, you can collect error information without requiring additional details from the player and have rich in-app communication with individual users or user groups.

1. Integrating Both SDKs​

Integrate the respective SDKs for Backtrace and HelpShift first.

Backtrace SDK​

HelpShift SDK​

2. Linking HelpShift And Backtrace​

iOS And Android​

For details on controlling the display of the HelpShift UI, refer to the HelpShift SDK for Android documentation.

Linking Backtrace and HelpShift is not tricky. Add the backtraceClient["guid"] to a customer issue field with the ID device_id, as shown in the code example below:

var configMap = new Dictionary<string, object>();
// Add Backtrace GUID to link HelpShift and Backtrace
Dictionary<string, string> backtraceid = new Dictionary<string, string>();
backtraceid.Add("type", "singleline");
backtraceid.Add("value", backtraceClient["guid"]);

// Add to CIF (custom issue fields) key
Dictionary<string, object> cifDictionary = new Dictionary<string, object>();
cifDictionary.Add("device_id", backtraceid);

configMap.Add("customIssueFields", cifDictionary);

// Show in-app conversation UI
HelpshiftSdk.ShowConversation(configMap);

WebGL (Web Chat)​

Make sure to add the Backtrace GUID to the jslib file in your Plugins folder (Unity documentation).

mergeInto(LibraryManager.library, {

EnableHelpshift: function (guid) {
var PLATFORM_ID = <your platform id>,
DOMAIN = <your domain>,
LANGUAGE = "en";

window.helpshiftConfig = {
platformId: PLATFORM_ID,
domain: DOMAIN,
language: LANGUAGE,
userId: Pointer_stringify(guid),
userEmail: "Backtrace@Backtrace.io",
userName: "John Doe"
};

!function(t,e){if("function"!=typeof window.Helpshift){var n=function(){n.q.push(arguments)};n.q=[],window.Helpshift=n;var i,a=t.getElementsByTagName("script")[0];if(t.getElementById(e))return;i=t.createElement("script"),i.async=!0,i.id=e,i.src="https://webchat.helpshift.com/webChat.js";var o=function(){window.Helpshift("init")};window.attachEvent?i.attachEvent("onload",o):i.addEventListener("load",o,!1),a.parentNode.insertBefore(i,a)}else window.Helpshift("update")}(document,"hs-chat");

Helpshift("setCustomIssueFields", {
// Key of the Backtrace GUID Custom Issue Field
"device_id": {
// Type of Custom Issue Field
type: "singleline",
// Value to set for Custom Issue Field
value: Pointer_stringify(guid)
}
});
}

});

Import it in C# in your game class:

#if (UNITY_WEBGL)
[DllImport("__Internal")]
private static extern void EnableHelpshift(string guid);
#endif

Call it where appropriate (you need a reference to the Backtrace client):

<YourGameClass>.EnableHelpshift(backtraceClient["guid"]);

Also, refer to the source in our example game for JavaScript and for C# bridge (take note of the DLL Import).