@@ -31,6 +31,11 @@ public class BacktraceClient : MonoBehaviour, IBacktraceClient
3131
3232 internal readonly Stack < BacktraceReport > BackgroundExceptions = new Stack < BacktraceReport > ( ) ;
3333
34+ /// <summary>
35+ /// Client report attachments
36+ /// </summary>
37+ private List < string > _clientReportAttachments ;
38+
3439 /// <summary>
3540 /// Attribute object accessor
3641 /// </summary>
@@ -50,6 +55,26 @@ public string this[string index]
5055 }
5156 }
5257
58+ /// <summary>
59+ /// Add attachment to managed reports.
60+ /// Note: this option won't add attachment to your native reports. You can add attachments to
61+ /// native reports only on BacktraceClient initialization.
62+ /// </summary>
63+ /// <param name="pathToAttachment">Path to attachment</param>
64+ public void AddAttachment ( string pathToAttachment )
65+ {
66+ _clientReportAttachments . Add ( pathToAttachment ) ;
67+ }
68+
69+ /// <summary>
70+ /// Returns list of defined path to attachments stored by Backtrace client.
71+ /// </summary>
72+ /// <returns>List of client attachments</returns>
73+ public List < string > GetAttachments ( )
74+ {
75+ return _clientReportAttachments ;
76+ }
77+
5378 /// <summary>
5479 /// Set client attributes that will be included in every report
5580 /// </summary>
@@ -271,6 +296,7 @@ internal ReportLimitWatcher ReportLimitWatcher
271296 /// </summary>
272297 /// <param name="configuration">Backtrace configuration scriptable object</param>
273298 /// <param name="attributes">Client side attributes</param>
299+ /// param name="attachments">List of attachments </param>
274300 /// <param name="gameObjectName">game object name</param>
275301 /// <returns>Backtrace client</returns>
276302 public static BacktraceClient Initialize ( BacktraceConfiguration configuration , Dictionary < string , string > attributes = null , string gameObjectName = "BacktraceClient" )
@@ -313,9 +339,24 @@ public static BacktraceClient Initialize(BacktraceConfiguration configuration, D
313339 /// <param name="gameObjectName">game object name</param>
314340 /// <returns>Backtrace client</returns>
315341 public static BacktraceClient Initialize ( string url , string databasePath , Dictionary < string , string > attributes = null , string gameObjectName = "BacktraceClient" )
342+ {
343+ return Initialize ( url , databasePath , attributes , null , gameObjectName ) ;
344+ }
345+
346+ /// <summary>
347+ /// Initialize new Backtrace integration with database path. Note - database path will be auto created by Backtrace Unity plugin
348+ /// </summary>
349+ /// <param name="url">Server url</param>
350+ /// <param name="databasePath">Database path</param>
351+ /// <param name="attributes">Client side attributes</param>
352+ /// <param name="attachments">Paths to attachments that Backtrace client will include in managed/native reports</param>
353+ /// <param name="gameObjectName">game object name</param>
354+ /// <returns>Backtrace client</returns>
355+ public static BacktraceClient Initialize ( string url , string databasePath , Dictionary < string , string > attributes = null , string [ ] attachments = null , string gameObjectName = "BacktraceClient" )
316356 {
317357 var configuration = ScriptableObject . CreateInstance < BacktraceConfiguration > ( ) ;
318358 configuration . ServerUrl = url ;
359+ configuration . AttachmentPaths = attachments ;
319360 configuration . Enabled = true ;
320361 configuration . DatabasePath = databasePath ;
321362 configuration . CreateDatabase = true ;
@@ -330,9 +371,23 @@ public static BacktraceClient Initialize(string url, string databasePath, Dictio
330371 /// <param name="gameObjectName">game object name</param>
331372 /// <returns>Backtrace client</returns>
332373 public static BacktraceClient Initialize ( string url , Dictionary < string , string > attributes = null , string gameObjectName = "BacktraceClient" )
374+ {
375+ return Initialize ( url , attributes , new string [ 0 ] , gameObjectName ) ;
376+ }
377+
378+ /// <summary>
379+ /// Initialize new Backtrace integration
380+ /// </summary>
381+ /// <param name="url">Server url</param>
382+ /// <param name="attributes">Client side attributes</param>
383+ /// <param name="attachments">Paths to attachments that Backtrace client will include in managed/native reports</param>
384+ /// <param name="gameObjectName">game object name</param>
385+ /// <returns>Backtrace client</returns>
386+ public static BacktraceClient Initialize ( string url , Dictionary < string , string > attributes = null , string [ ] attachments = null , string gameObjectName = "BacktraceClient" )
333387 {
334388 var configuration = ScriptableObject . CreateInstance < BacktraceConfiguration > ( ) ;
335389 configuration . ServerUrl = url ;
390+ configuration . AttachmentPaths = attachments ;
336391 configuration . Enabled = false ;
337392 return Initialize ( configuration , attributes , gameObjectName ) ;
338393 }
@@ -358,7 +413,7 @@ public void Refresh()
358413 _current = Thread . CurrentThread ;
359414 CaptureUnityMessages ( ) ;
360415 _reportLimitWatcher = new ReportLimitWatcher ( Convert . ToUInt32 ( Configuration . ReportPerMin ) ) ;
361-
416+ _clientReportAttachments = Configuration . GetAttachmentPaths ( ) ;
362417
363418 BacktraceApi = new BacktraceApi (
364419 credentials : new BacktraceCredentials ( Configuration . GetValidServerUrl ( ) ) ,
@@ -668,6 +723,7 @@ private BacktraceData SetupBacktraceData(BacktraceReport report)
668723 : _backtraceLogManager . ToSourceCode ( ) ;
669724
670725 report . AssignSourceCodeToReport ( sourceCode ) ;
726+ report . AttachmentPaths . AddRange ( _clientReportAttachments ) ;
671727
672728 // pass copy of dictionary to prevent overriding client attributes
673729 var result = report . ToBacktraceData ( null , GameObjectDepth ) ;
0 commit comments