Introduction
Combining error and exception capturing from Backtrace with first class in-app customer support with HelpShift in Unity games gives you the ability to collect error information without asking the player for additional details and have rich in-app communication with a user or a group of users.
1. Integrate both SDKs
Both Backtrace and HelpShift require you to integrate their respective SDKs first.
Backtrace SDK
HelpShift SDK
- iOS
- Android
- WebGL (web chat)
- Helpshift WebChat
- Unity documentation on how to embed a JavaScript library
- Find the source code in our example game here
2. Link HelpShift and Backtrace
iOS and Android
For details on how to control showing the HelpShift UI, see here.
Linking Backtrace and Helpshift is easy, just add the backtraceClient["guid"] to a customer issue field with id device_id, as you can see in the code example below:
var configMap = new Dictionary<string, object>(); // Add backtrace GUID so Helpshift and Backtrace are linked 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 you add the Backtrace GUID to the jslib file in your Plugins folder (Unity doc).
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
And call it where appropriate (note, you need a reference to the Backtrace client):
<YourGameClass>.EnableHelpshift(backtraceClient["guid"]);
Also, see the source in our example game here (JavaScript) and here (C# bridge, take note of the DLL Import.