{"id":10950,"library":"gleap","title":"Gleap JavaScript SDK","description":"The Gleap JavaScript SDK, currently at version 15.2.8, offers an AI-native platform for comprehensive customer support, feedback collection, and bug reporting within web applications. It integrates a range of features including an autonomous AI agent (Kai) designed for resolving customer inquiries and automating workflows, a built-in Help Center, outbound messaging, product roadmapping tools, and a unified multichannel inbox. The package maintains an active development pace with frequent minor releases, addressing features like video calling capabilities, improved platform/device detection, and updates to cookie management defaults. Its key differentiators lie in its holistic approach to customer engagement, extending beyond basic feedback forms to include advanced AI assistance and a full suite of support tools.","status":"active","version":"15.2.8","language":"javascript","source_language":"en","source_url":"https://github.com/GleapSDK/JavaScript-SDK","tags":["javascript","bug-reporting","bug-reporting-tool","customer-surveys","surveys","customer-feedback","customer-feedback-sdk","javascript-bug-reporting","crash-reporting","typescript"],"install":[{"cmd":"npm install gleap","lang":"bash","label":"npm"},{"cmd":"yarn add gleap","lang":"bash","label":"yarn"},{"cmd":"pnpm add gleap","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Gleap is exported as a default module. CommonJS require() is not the primary way to import in modern applications.","wrong":"const Gleap = require('gleap');","symbol":"Gleap","correct":"import Gleap from 'gleap';"},{"note":"The initialize method is a static method of the default exported Gleap object, not a named export.","wrong":"import { initialize } from 'gleap';","symbol":"initialize","correct":"import Gleap from 'gleap'; Gleap.initialize('YOUR_SDK_TOKEN');"},{"note":"The package ships with TypeScript types. The default export 'Gleap' itself represents the main API surface.","symbol":"Gleap (type)","correct":"import Gleap from 'gleap'; type GleapInstance = typeof Gleap;"}],"quickstart":{"code":"import Gleap from 'gleap';\n\n// Replace 'YOUR_SDK_TOKEN' with your actual token from the Gleap dashboard.\n// For production, consider using environment variables for security.\nconst SDK_TOKEN = process.env.GLEAP_SDK_TOKEN || 'YOUR_SDK_TOKEN_HERE';\n\nif (SDK_TOKEN === 'YOUR_SDK_TOKEN_HERE') {\n  console.warn('Gleap SDK: SDK_TOKEN is a placeholder. Please replace it with your actual token.');\n}\n\ntry {\n  Gleap.initialize(SDK_TOKEN);\n  console.log('Gleap SDK initialized successfully.');\n  \n  // Example of identifying a user (optional, but common practice)\n  Gleap.identify('user-123', {\n    name: 'John Doe',\n    email: 'john.doe@example.com',\n    plan: 'premium'\n  });\n\n  // To open the Gleap widget programmatically (e.g., from a custom button)\n  // Gleap.open();\n\n} catch (error) {\n  console.error('Failed to initialize Gleap SDK:', error);\n}","lang":"typescript","description":"Demonstrates how to install, import, and initialize the Gleap SDK with an SDK token, including an example of user identification."},"warnings":[{"fix":"Review your session management and subdomain strategies if you were relying on previous non-cookie-based defaults. Consult Gleap documentation for explicit control over cookie behavior if needed.","message":"As of v15.2.2, Gleap enabled cookie mode by default. This change affects session management, particularly on shared subdomains, potentially altering existing behavior if you had specific cookie configurations.","severity":"gotcha","affected_versions":">=15.2.2"},{"fix":"Ensure you replace 'SDK-TOKEN' with the actual token obtained from your Gleap dashboard during initialization. Verify the token is correct and that `Gleap.initialize()` is called once, early in your application's lifecycle.","message":"Failing to initialize the SDK with a valid `SDK-TOKEN` will prevent the Gleap widget and associated functionality from appearing or working correctly.","severity":"gotcha","affected_versions":">=15.0.0"},{"fix":"Ensure Gleap is only initialized and used within browser contexts. For server-rendered applications (SSR), use conditional checks like `if (typeof window !== 'undefined')` before initializing Gleap.","message":"The Gleap SDK is designed for client-side environments (browsers). Attempting to run its initialization or core functionality directly in a Node.js server-side environment without proper mocking or conditional loading can lead to errors.","severity":"gotcha","affected_versions":">=15.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure `import Gleap from 'gleap';` is at the top of your module, or if using a script tag, place it before any code that references `Gleap`.","cause":"The Gleap SDK was not imported correctly, or the script tag for the SDK was not loaded before its usage in a non-module context.","error":"ReferenceError: Gleap is not defined"},{"fix":"Verify that you are using `import Gleap from 'gleap';` and then calling `Gleap.initialize(...)` directly on the default-imported object.","cause":"This usually indicates that `Gleap` was imported incorrectly (e.g., as a named import instead of default) or that the imported object does not expose an `initialize` method.","error":"Gleap.initialize is not a function"},{"fix":"Check if `Gleap.initialize('YOUR_SDK_TOKEN')` is called with the correct token. Confirm the Gleap dashboard settings don't have the widget disabled or restricted by page rules.","cause":"The SDK might not have been initialized or the provided SDK token is incorrect/inactive, or the widget is hidden by configuration.","error":"No Gleap feedback button or widget is visible on the page."}],"ecosystem":"npm"}