Skip to main content
Glama

playwright-mcp

user-id.ts1.13 kB
import { createHash } from 'crypto'; import { hostname, userInfo } from 'os'; let cachedUserId: string | null = null; /** * Gets a unique user ID for PostHog analytics based on machine hostname and username. * This is deterministic and requires no file system permissions. */ export function getUserId(): string { if (cachedUserId) { return cachedUserId; } try { const host = hostname(); const username = userInfo().username; // Create a stable hash from hostname + username const hash = createHash('sha256') .update(`${host}-${username}`) .digest('hex') .substring(0, 16); cachedUserId = `user_${hash}`; return cachedUserId; } catch (err) { // Fallback to just hostname if userInfo fails try { const host = hostname(); const hash = createHash('sha256') .update(host) .digest('hex') .substring(0, 16); cachedUserId = `user_${hash}`; return cachedUserId; } catch { // Ultimate fallback - use a session-based ID cachedUserId = `user_${Date.now().toString(36)}`; return cachedUserId; } } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Ashish-Bansal/playwright-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server