### Google Tag Manager Setup Source: https://backmesh.com/blog Initializes Google Tag Manager (GTM) and configures it with an analytics ID. It also dynamically loads the GTM script into the page, ensuring proper tracking and event management. ```javascript window.dataLayer=window.dataLayer||[]; gtag("js",new Date); gtag("config","AW-941232918",{}); window.dataLayer=window.dataLayer||[]; !function(e,t,a,n){e[n]=e[n]||[];e[n].push({"gtm.start":(new Date).getTime(),event:"gtm.js"});var g=t.getElementsByTagName(a)[0],m=t.createElement(a);m.async=!0,m.src="https://www.googletagmanager.com/gtm.js?id=GTM-5DZ7WT5X",g.parentNode.insertBefore(m,g)}(window,document,"script","dataLayer") ``` -------------------------------- ### OpenAI API Integration Mistakes Source: https://backmesh.com/blog Discusses common security mistakes when integrating the OpenAI API into client-side applications. It highlights risks like API key exposure, unexpected charges, and policy violations, offering guidance to maintain simplicity and safety. ```APIDOC OpenAI API Integration Best Practices: Key concerns when building apps with OpenAI models: 1. Protecting your private API key. 2. Avoiding complexity by not setting up a full backend solely for API key safeguarding. Common mistakes and their consequences: - Overlooking security pitfalls can lead to: - Unexpected or excessive charges on your OpenAI account. - Violation of OpenAI’s Acceptable Use Policy and Terms of Service. - Potential exposure of your project to spam or abusive behavior. Guidance: - Learn how to avoid common security mistakes when integrating the OpenAI API into a client-side app. - Maintain simplicity and safety without sacrificing security. ``` -------------------------------- ### Docusaurus Data Attributes Handling Source: https://backmesh.com/blog Processes URL query parameters that start with 'docusaurus-data-'. It extracts these parameters and sets corresponding data attributes on the document's root element. ```javascript function(){try{const n=new URLSearchParams(window.location.search).entries();for(var[t,e]of n)if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}() ``` -------------------------------- ### Google Analytics gtag Function Source: https://backmesh.com/blog Defines the `gtag` function for Google Analytics, which pushes arguments to the `dataLayer`. This is a standard setup for integrating Google Analytics with a website. ```javascript function gtag(){dataLayer.push(arguments)}window.dataLayer=window ``` -------------------------------- ### Docusaurus Data Attributes Source: https://backmesh.com/pricing Processes URL query parameters that start with 'docusaurus-data-'. For each matching parameter, it extracts the value and sets a corresponding 'data-*' attribute on the document's root element, allowing for dynamic attribute configuration. ```javascript !function() { try { const n = new URLSearchParams(window.location.search).entries(); for (var [t, e] of n) if (t.startsWith("docusaurus-data-")) { var a = t.replace("docusaurus-data-", "data-"); document.documentElement.setAttribute(a, e) } } catch (t) {} }() ``` -------------------------------- ### OpenAI Integration with Backmesh Source: https://backmesh.com/docs Demonstrates how to integrate Backmesh with the OpenAI SDK. It shows replacing the default OpenAI API URL with the Backmesh Gatekeeper URL and using the user's JWT as the API key for authentication. This setup allows secure browser-based access to LLM APIs. ```typescript import OpenAI from "openai"; import supabase from "supabase-js"; const BACKMESH_URL = "https://edge.backmesh.com/v1/proxy/gbBbHCDBxqb8zwMk6dCio63jhOP2/wjlwRswvSXp4FBXwYLZ1/v1"; const jwt = supabase.auth.session().access_token; const client = new OpenAI({ httpAgent: new HttpsProxyAgent(BACKMESH_URL), dangerouslyAllowBrowser: true, // no longer dangerous apiKey: jwt, }); ``` -------------------------------- ### LLM Cost and Performance Comparator Source: https://backmesh.com/blog Introduces LLMcomp, a straightforward site for comparing popular LLMs like Claude Sonnet, Deep Seek, and GPT-4o on cost, latency, and performance. It utilizes a port of AgentOps' tokencost for web-based cost estimation. ```APIDOC LLM Comparator (LLMcomp): Purpose: To provide a quick comparison of cost, results, and performance across different Large Language Models (LLMs) for various tasks and prompts. Features: - Compares popular LLMs: Claude Sonnet, Deep Seek, GPT-4o (as of initial release). - Estimates LLM usage costs using a web port of AgentOps' tokencost. - Displays cost, latency, and other performance details. Technical Details: - Website code is open source, approximately 400 lines of code. Live Site: - URL: https://llmcomp.backmesh.com ``` -------------------------------- ### Initialize PostHog Analytics Source: https://backmesh.com/pricing Initializes the PostHog analytics service. It requires an API key and configuration for the API host. This script enables event tracking and user analytics for the application. ```javascript window.posthog = window.posthog || []; window.posthog.init = function(i, n, p) { function c(t, e) { var o = e.split("."); 2 == o.length && (t = t[o[0]], e = o[1]), t[e] = function() { t.push([e].concat(Array.prototype.slice.call(arguments, 0))) } } var r = document.createElement("script"); r.type = "text/javascript", r.async = !0, r.src = n.api_host.replace(".i.posthog.com", "-assets.i.posthog.com") + "/static/array.js"; var a = document.getElementsByTagName("script")[0]; a.parentNode.insertBefore(r, a); var g = window.posthog; void 0 !== p ? g = window.posthog[p] = [] : p = "posthog", g.people = g.people || [], g.toString = function(t) { var e = "posthog"; return "posthog" !== p && (e += "." + p), t || (e += " (stub)"), e }, g.people.toString = function() { return g.toString(1) + ".people (stub)" }, o = "capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys onSessionId".split(" "), s = 0; s < o.length; s++) c(g, o[s]); window.posthog._i.push([i, n, p]) }, window.posthog.__SV = 1); posthog.init("phc_fZ3tyt5smshwvm17JYlrU8PbxUVlOoakvH2M5b6ktdO", {api_host: "https://us.i.posthog.com", id: "default"}) ``` -------------------------------- ### ChatGPT-like App with Flutter and Firebase Source: https://backmesh.com/blog Showcases a ChatGPT-like application built using Flutter, Firebase Authentication, and Firestore. The app is approximately 1k lines of code, requires no backend server or cloud functions, and runs on the web, with potential for mobile and desktop deployment. ```APIDOC Flutter ChatGPT-like App: Description: A demonstration of building a conversational AI application similar to ChatGPT. Technology Stack: - Frontend: Flutter - Authentication: Firebase Authentication - Database: Firestore Key Features: - Approximately 1,000 lines of code. - No backend server or cloud functions required. - Cross-platform compatibility (Web, potential for Mobile/Desktop). Source Code: - Repository: https://github.com/backmesh/flutter-chatgpt Live Demo: - URL: https://flutter-chatgpt.pages.dev ``` -------------------------------- ### Initialize PostHog Analytics Source: https://backmesh.com/blog Initializes the PostHog analytics service with configuration details including the API host and ID. This script is used for tracking user events and application usage. ```javascript !function(t,e){var o,s,r,a;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,n,p){function c(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(r=t.createElement("script")).type="text/javascript",r.async=!0,r.src=n.api_host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",(a=t.getElementsByTagName("script")[0]).parentNode.insertBefore(r,a);var g=e;void 0!==p?g=e[p]=[]:p="posthog",g.people=g.people||[],g.toString=function(t){var e="posthog";return"posthog"!==p&&(e+="."+p),t||(e+=" (stub)"),e},g.people.toString=function(){return g.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys onSessionId".split(" "),s=0;s