### Install Dependencies and Start Server Source: https://docs.bugsplat.com/introduction/getting-started/integrations/web/javascript Install project dependencies using npm and start the local development server for the BugSplat JavaScript example. ```sh cd my-javascript-crasher npm i npm start ``` -------------------------------- ### BugSplat .NET SDK Integration Steps Source: https://docs.bugsplat.com/introduction/getting-started/integrations/desktop/windows-dot-net-framework Steps to integrate the BugSplat .NET SDK into your application. This involves adding DLL references, initializing the crash reporter with database and application details, and including necessary executables and DLLs in your installer. ```text 1. Add a reference to "BugSplatDotNet.dll". 2. Add a call to BugSplat.CrashReporter.Init with BugSplat database, application name, and version. 3. Add BsSndRpt.exe, BugSplatDotNet.dll, and BugSplatRC.dll to your application's installer. 4. Edit BugSplatRC.dll with Visual Studio to change the banner. 5. Add symbolic debug information (pdb, dll, executable files) to your release build and upload them. ``` -------------------------------- ### Initialize BugSplat in Objective-C Source: https://docs.bugsplat.com/introduction/getting-started/integrations/desktop/macos Provides an example of initializing the BugSplat SDK in an Objective-C application for macOS. It covers setting the delegate, configuring auto-submission, and starting the crash reporting service. ```Objective-C #import "BugSplatMac/BugSplatMac.h" @interface AppDelegate () @end @implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Initialize BugSplat [[BugSplat shared] setDelegate:self]; [[BugSplat shared] setAutoSubmitCrashReport:NO]; [[BugSplat shared] start]; } #pragma mark - BugSplatDelegate - (void)bugSplatWillSendCrashReport:(BugSplat *)bugSplat { NSLog(@"bugSplatWillSendCrashReport called"); } - (void)bugSplatWillSendCrashReportsAlways:(BugSplat *)bugSplat { NSLog(@"bugSplatWillSendCrashReportsAlways called"); } - (void)bugSplatDidFinishSendingCrashReport:(BugSplat *)bugSplat { NSLog(@"bugSplatDidFinishSendingCrashReport called"); } - (void)bugSplatWillCancelSendingCrashReport:(BugSplat *)bugSplat { NSLog(@"bugSplatWillCancelSendingCrashReport called"); } - (void)bugSplatWillShowSubmitCrashReportAlert:(BugSplat *)bugSplat { NSLog(@"bugSplatWillShowSubmitCrashReportAlert called"); } - (void)bugSplat:(BugSplat *)bugSplat didFailWithError:(NSError *)error { NSLog(@"bugSplat:didFailWithError: %@", [error localizedDescription]); } @end ``` -------------------------------- ### Install depot_tools for Windows Source: https://docs.bugsplat.com/introduction/getting-started/integrations/cross-platform/crashpad/how-to-build-google-crashpad Installs the Chromium depot_tools on Windows. This involves cloning the repository and updating the system's PATH environment variable using the setx command. ```bash git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git setx path "%path%;C:\path\to\depot_tools" ``` -------------------------------- ### Clone BugSplat JavaScript Crasher Example Source: https://docs.bugsplat.com/introduction/getting-started/integrations/web/javascript Clone the example repository to set up a local environment for testing BugSplat error reporting. ```sh git clone https://github.com/BugSplat-Git/my-javascript-crasher ``` -------------------------------- ### BugSplat Crashpad Initialization Parameters (C++) Source: https://docs.bugsplat.com/introduction/getting-started/integrations/cross-platform/crashpad Provides an example of how to call the `initializeCrashpad` function with preprocessor macros defining BugSplat database, application name, and version. ```cpp #define BUGSPLAT_DATABASE "your-database-here" #define BUGSPLAT_APP_NAME "your-application-here" #define BUGSPLAT_APP_VERSION "1.2.3-etc" initializeCrashpad(BUGSPLAT_DATABASE, BUGSPLAT_APP_NAME, BUGSPLAT_APP_VERSION); ``` -------------------------------- ### Linux Crashpad Setup with QMake Source: https://docs.bugsplat.com/introduction/getting-started/integrations/cross-platform/qt Provides QMake configuration for Linux to link Crashpad static libraries with the correct linking order and copies the `crashpad_handler` executable to the build directory. It specifies the library paths for Linux. ```QMake linux { # Crashpad libraries LIBS += -L$$PWD/Crashpad/Libraries/Linux/ -lcommon LIBS += -L$$PWD/Crashpad/Libraries/Linux/ -lclient LIBS += -L$$PWD/Crashpad/Libraries/Linux/ -lutil LIBS += -L$$PWD/Crashpad/Libraries/Linux/ -lbase # Copy crashpad_handler to build directory QMAKE_POST_LINK += "cp $$PWD/Crashpad/Bin/Linux/crashpad_handler $$OUT_PWD/crashpad" } ``` -------------------------------- ### Install BugSplat Node.js Package Source: https://docs.bugsplat.com/introduction/getting-started/integrations/cross-platform/node.js Installs the bugsplat-node package using npm. This command should be run at the root of your Node.js project directory. ```bash npm i bugsplat-node --save ``` -------------------------------- ### Install bugsplat-ng Package Source: https://docs.bugsplat.com/introduction/getting-started/integrations/web/angular Installs the bugsplat-ng package into your Angular project using npm. This package provides the necessary tools to integrate BugSplat error reporting. ```shell npm i bugsplat-ng --save ``` -------------------------------- ### Windows Crashpad Setup with QMake Source: https://docs.bugsplat.com/introduction/getting-started/integrations/cross-platform/qt Sets up QMake for Windows to link Crashpad static libraries and copy the `crashpad_handler.exe` to the output directory. It includes linking against the `Advapi32` system library and defines an output directory based on build configuration. ```QMake win32 { # Crashpad libraries LIBS += -L$$PWD/Crashpad/Libraries/Windows/ -lbase LIBS += -L$$PWD/Crashpad/Libraries/Windows/ -lcommon LIBS += -L$$PWD/Crashpad/Libraries/Windows/ -lclient LIBS += -L$$PWD/Crashpad/Libraries/Windows/ -lutil # System libraries LIBS += -lAdvapi32 # Build variables CONFIG(debug, debug|release) { EXEDIR = $$OUT_PWD\debug } CONFIG(release, debug|release) { EXEDIR = $$OUT_PWD\release } # Copy crashpad_handler.exe to output directory QMAKE_POST_LINK += "copy /y $$shell_path($$PWD)\Crashpad\Bin\Windows\crashpad_handler.exe $$shell_path($$OUT_PWD)\crashpad" } ``` -------------------------------- ### Install BugSplat Symbol Upload Package Source: https://docs.bugsplat.com/introduction/getting-started/integrations/web/angular Installs the `@bugsplat/symbol-upload` package as a development dependency using npm. This package provides the necessary tools for uploading symbols to BugSplat. ```bash npm i -D @bugsplat/symbol-upload ``` -------------------------------- ### Fetch and Build Breakpad Tools Source: https://docs.bugsplat.com/introduction/getting-started/integrations/cross-platform/crashpad/how-to-build-google-crashpad This snippet shows how to fetch the Breakpad repository and build the necessary tools like `dump_syms` and `symupload`. It requires cloning the repository and running standard build commands. ```bash mkdir ~/breakpad cd breakpad fetch breakpad ``` -------------------------------- ### BugSplat API: Get Versions (Example) Source: https://docs.bugsplat.com/introduction/development/web-services/api/versions Example of retrieving version information from the BugSplat API, typically used to list or check existing versions. Requires an authorization token. ```APIDOC GET https://app.bugsplat.com/api/versions?database=fred Curl Example: curl --location 'https://app.bugsplat.com/api/versions?database=fred' \ --header 'Authorization: Bearer ••••••' ``` -------------------------------- ### Application Entry Point Calling Crashpad Initialization (C++) Source: https://docs.bugsplat.com/introduction/getting-started/integrations/cross-platform/crashpad/how-to-build-google-crashpad The main function of the application, demonstrating how to call the `initializeCrashpad` function. This ensures that crash reporting is set up when the application starts. ```cpp int main(int argc, char *argv[]) { initializeCrashpad(); } ``` -------------------------------- ### Get Crash Details API Request Example Source: https://docs.bugsplat.com/introduction/development/web-services/api/crash Example of how to use curl to call the BugSplat API to retrieve crash details. It includes the endpoint, query parameters for database and ID, and an authorization header. ```bash curl --location 'https://app.bugsplat.com/api/crash/details?database=fred&id=132547' \ --header 'Authorization: Bearer ••••••' ``` -------------------------------- ### Import BugSplat Class Source: https://docs.bugsplat.com/introduction/getting-started/integrations/cross-platform/python Imports the necessary BugSplat class from the installed library to begin exception reporting setup. ```Python from bugsplat import BugSplat ``` -------------------------------- ### Build Minidump_stackwalk on Windows Source: https://docs.bugsplat.com/introduction/getting-started/integrations/cross-platform/crashpad/how-to-build-google-crashpad Instructions for building Minidump_stackwalk on Windows using MinGW-w64 and TDM-GCC. It details installing TDM-GCC, using a MinGW64 shell, configuring the build with specific flags, and making the project. Includes a workaround for potential 'make' failures. ```bash cd ~/breakpad/src && ./configure --disable-dependency-tracking && make # If make fails, try removing all instances of '/usr/bin' from Makefile. ``` -------------------------------- ### Get BugSplat Instance Source: https://docs.bugsplat.com/introduction/getting-started/integrations/game-development/unity Retrieves an instance of the BugSplat object from the BugSplatManager. This is the primary way to access BugSplat functionalities within your application. ```csharp var bugsplat = FindObjectOfType().BugSplat; ``` -------------------------------- ### Download Symbol-Upload Binaries Source: https://docs.bugsplat.com/education/faq/how-to-upload-symbol-files-with-symbol-upload Provides commands to download prebuilt binaries for the symbol-upload tool on different operating systems. These commands fetch the executable and, for macOS and Linux, make it executable. ```powershell Invoke-WebRequest -Uri "https://app.bugsplat.com/download/symbol-upload-windows.exe" -OutFile "symbol-upload-windows.exe" ``` ```bash curl -sL -O "https://app.bugsplat.com/download/symbol-upload-macos" && chmod +x symbol-upload-macos ``` ```bash curl -sL -O "https://app.bugsplat.com/download/symbol-upload-linux" && chmod +x symbol-upload-linux ``` -------------------------------- ### Require BugSplatNode Module Source: https://docs.bugsplat.com/introduction/getting-started/integrations/cross-platform/node.js Imports the BugSplatNode class from the installed package. This should be added at the entry point of your application, typically main.js. ```typescript const { BugSplatNode } = require('bugsplat-node'); ``` -------------------------------- ### Set Custom Attributes Source: https://docs.bugsplat.com/introduction/getting-started/integrations/desktop/macos Demonstrates how to add custom key-value attributes to crash reports, enhancing searchability in the BugSplat dashboard. Examples are provided for both Swift and Objective-C. ```Swift BugSplat.shared().setValue("Value of Attribute", forAttribute: "AttributeName") ``` ```Objective-C [[BugSplat shared] setValue:@"Value of Attribute" forAttribute:@"AttributeName"]; ``` -------------------------------- ### Initialize Crashpad Handler and Settings (C++) Source: https://docs.bugsplat.com/introduction/getting-started/integrations/cross-platform/crashpad/how-to-build-google-crashpad Implements the core Crashpad initialization logic. This function sets up the handler path, report directories, metrics directories, upload URL, and crash annotations. It also configures settings like enabling uploads and disabling rate limiting, returning a boolean status indicating success or failure. ```cpp bool initializeCrashpad() { // Get directory where the exe lives so we can pass a full path to handler, reportsDir, metricsDir and attachments StringType exeDir = getExecutableDir(); // Ensure that handler is shipped with your application FilePath handler(exeDir + "/path/to/crashpad_handler"); // Directory where reports will be saved. Important! Must be writable or crashpad_handler will crash. FilePath reportsDir(exeDir + "/path/to/crashpad"); // Directory where metrics will be saved. Important! Must be writable or crashpad_handler will crash. FilePath metricsDir(exeDir + "/path/to/crashpad"); // Configure url with BugSplat’s public fred database. Replace 'fred' with the name of your BugSplat database. StringType url = "https://fred.bugsplat.com/post/bp/crash/crashpad.php"; // Metadata that will be posted to the server with the crash report map map annotations; annotations["format"] = "minidump"; // Required: Crashpad setting to save crash as a minidump annotations["database"] = "fred"; // Required: BugSplat appName annotations["product"] = "myCrashpadCrasher"; // Required: BugSplat appName annotations["version"] = "1.0.0"; // Required: BugSplat appVersion annotations["key"] = "Sample key"; // Optional: BugSplat key field annotations["user"] = "fred@bugsplat.com"; // Optional: BugSplat user email annotations["list_annotations"] = "Sample comment"; // Optional: BugSplat crash description // Disable crashpad rate limiting so that all crashes have dmp files vector arguments; arguments.push_back("--no-rate-limit"); // Initialize Crashpad database unique_ptr database = CrashReportDatabase::Initialize(reportsDir); if (database == NULL) return false; // File paths of attachments to be uploaded with the minidump file at crash time - default upload limit is 2MB vector attachments; FilePath attachment(exeDir + "/path/to/attachment.txt"); attachments.push_back(attachment); // Enable automated crash uploads Settings *settings = database->GetSettings(); if (settings == NULL) return false; settings->SetUploadsEnabled(true); // Start crash handler CrashpadClient *client = new CrashpadClient(); bool status = client->StartHandler(handler, reportsDir, metricsDir, url, annotations, arguments, true, true, attachments); return status; } ``` -------------------------------- ### Build Crashpad with Ninja Source: https://docs.bugsplat.com/introduction/getting-started/integrations/cross-platform/crashpad/how-to-build-google-crashpad Compiles the Crashpad project using the Ninja build tool. This command executes the build process based on the configuration generated by GN in the 'out/Default' directory. ```bash ninja -C out/Default ``` -------------------------------- ### Initialize BugSplat in Objective-C Source: https://docs.bugsplat.com/introduction/getting-started/integrations/mobile/ios Provides an example of initializing the BugSplat SDK in an Objective-C application for macOS. It covers setting the delegate, configuring auto-submission, and starting the crash reporting service. ```Objective-C #import "BugSplatMac/BugSplatMac.h" @interface AppDelegate () @end @implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Initialize BugSplat [[BugSplat shared] setDelegate:self]; [[BugSplat shared] setAutoSubmitCrashReport:NO]; [[BugSplat shared] start]; } #pragma mark - BugSplatDelegate - (void)bugSplatWillSendCrashReport:(BugSplat *)bugSplat { NSLog(@"bugSplatWillSendCrashReport called"); } - (void)bugSplatWillSendCrashReportsAlways:(BugSplat *)bugSplat { NSLog(@"bugSplatWillSendCrashReportsAlways called"); } - (void)bugSplatDidFinishSendingCrashReport:(BugSplat *)bugSplat { NSLog(@"bugSplatDidFinishSendingCrashReport called"); } - (void)bugSplatWillCancelSendingCrashReport:(BugSplat *)bugSplat { NSLog(@"bugSplatWillCancelSendingCrashReport called"); } - (void)bugSplatWillShowSubmitCrashReportAlert:(BugSplat *)bugSplat { NSLog(@"bugSplatWillShowSubmitCrashReportAlert called"); } - (void)bugSplat:(BugSplat *)bugSplat didFailWithError:(NSError *)error { NSLog(@"bugSplat:didFailWithError: %@", [error localizedDescription]); } @end ``` -------------------------------- ### Initialize BugSplat in Swift (UIKit) Source: https://docs.bugsplat.com/introduction/getting-started/integrations/desktop/macos Demonstrates the initialization of the BugSplat SDK within a UIKit application using Swift. It configures the shared instance, sets the delegate, disables auto-submission, and starts the SDK. ```Swift import BugSplat @main class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Initialize BugSplat BugSplat.shared().delegate = self BugSplat.shared().autoSubmitCrashReport = false BugSplat.shared().start() return true } } extension AppDelegate: BugSplatDelegate { // MARK: BugSplatDelegate func bugSplatWillSendCrashReport(_ bugSplat: BugSplat) { print("\(#file) - \(#function)") } func bugSplatWillSendCrashReportsAlways(_ bugSplat: BugSplat) { print("\(#file) - \(#function)") } func bugSplatDidFinishSendingCrashReport(_ bugSplat: BugSplat) { print("\(#file) - \(#function)") } func bugSplatWillCancelSendingCrashReport(_ bugSplat: BugSplat) { print("\(#file) - \(#function)") } func bugSplatWillShowSubmitCrashReportAlert(_ bugSplat: BugSplat) { print("\(#file) - \(#function)") } func bugSplat(_ bugSplat: BugSplat, didFailWithError error: Error) { print("\(#file) - \(#function)") } } ``` -------------------------------- ### Run Deno Sample Application Source: https://docs.bugsplat.com/introduction/getting-started/integrations/cross-platform/deno Execute a Deno application that integrates BugSplat. The `--allow-net` flag is required for BugSplat to send reports to its backend, and `--allow-read` is needed if the application reads local files (e.g., log files). ```bash deno run --allow-net --allow-read main.ts ``` -------------------------------- ### Initialize BugSplat in Swift (SwiftUI) Source: https://docs.bugsplat.com/introduction/getting-started/integrations/desktop/macos Shows how to integrate and initialize the BugSplat SDK in a SwiftUI application using Swift. It utilizes an NSObject subclass to manage the delegate and start the SDK, ensuring proper lifecycle management. ```Swift import BugSplat @main struct BugSplatTestSwiftUIApp: App { private let bugSplat = BugSplatInitializer() var body: some Scene { WindowGroup { ContentView() } } } @objc class BugSplatInitializer: NSObject, BugSplatDelegate { override init() { super.init() BugSplat.shared().delegate = self BugSplat.shared().autoSubmitCrashReport = false BugSplat.shared().start() } // MARK: BugSplatDelegate func bugSplatWillSendCrashReport(_ bugSplat: BugSplat) { print("\(#file) - \(#function)") } func bugSplatWillSendCrashReportsAlways(_ bugSplat: BugSplat) { print("\(#file) - \(#function)") } func bugSplatDidFinishSendingCrashReport(_ bugSplat: BugSplat) { print("\(#file) - \(#function)") } func bugSplatWillCancelSendingCrashReport(_ bugSplat: BugSplat) { print("\(#file) - \(#function)") } func bugSplatWillShowSubmitCrashReportAlert(_ bugSplat: BugSplat) { print("\(#file) - \(#function)") } func bugSplat(_ bugSplat: BugSplat, didFailWithError error: Error) { print("\(#file) - \(#function)") } } ``` -------------------------------- ### Initialize BugSplat Crashpad Source: https://docs.bugsplat.com/introduction/getting-started/integrations/cross-platform/qt Demonstrates the essential call to `initializeCrashpad` within the application's entry point (`main` function). This function is crucial for setting up the crash reporting mechanism. ```cpp int main(int argc, char *argv[]) { QString dbName = "Fred"; QString appName = "myQtCrasher"; QString appVersion = "1.0"; initializeCrashpad(dbName, appName, appVersion); // ... rest of your application code } ``` -------------------------------- ### Implement Custom Exception Report Throttling Source: https://docs.bugsplat.com/introduction/getting-started/integrations/game-development/unity Overrides the default BugSplat crash report throttling by assigning a custom `Func` to `ShouldPostException`. This example implements a time-based throttling mechanism to limit reports to one every 3 seconds. ```csharp var lastPost = new DateTime(0); bugsplat.ShouldPostException = (ex) => { var now = DateTime.Now; if (now - lastPost < TimeSpan.FromSeconds(3)) { Debug.LogWarning("ShouldPostException returns false. Skipping BugSplat report..."); return false; } Debug.Log("ShouldPostException returns true. Posting BugSplat report..."); lastPost = now; return true; }; ```