From 0aea3b0b4c66ffb4e6d06e6389951781a10de49e Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sun, 7 May 2023 12:21:51 -0400 Subject: Add Faro observability to docs site Signed-off-by: Dave Henderson --- docs/static/js/faro.js | 35 +++++++++++++++++++++++++++++++++++ docs/static/js/search.js | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 docs/static/js/faro.js (limited to 'docs/static') diff --git a/docs/static/js/faro.js b/docs/static/js/faro.js new file mode 100644 index 00000000..662961a0 --- /dev/null +++ b/docs/static/js/faro.js @@ -0,0 +1,35 @@ +(function () { + var webSdkScript = document.createElement("script"); + + webSdkScript.src = "https://unpkg.com/@grafana/faro-web-sdk@^1.0.0/dist/bundle/faro-web-sdk.iife.js"; + + webSdkScript.onload = () => { + window.GrafanaFaroWebSdk.initializeFaro({ + url: "https://faro-collector-prod-us-central-0.grafana.net/collect/d8b5652f5dd57fb1cfec9a1c32970fe0", + app: { + name: "docs.gomplate.ca", + version: "1.0.0", + environment: "production", + }, + }); + + // Load instrumentations at the onLoad event of the web-SDK and after the above configuration. + // This is important because we need to ensure that the Web-SDK has been loaded and initialized before we add further instruments! + var webTracingScript = document.createElement("script"); + + webTracingScript.src = "https://unpkg.com/@grafana/faro-web-tracing@^1.0.0/dist/bundle/faro-web-tracing.iife.js"; + + // Initialize, configure (if necessary) and add the the new instrumentation to the already loaded and configured Web-SDK. + webTracingScript.onload = () => { + window.GrafanaFaroWebSdk.faro.instrumentations.add( + new window.GrafanaFaroWebTracing.TracingInstrumentation() + ); + }; + + // Append the Web Tracing script script tag to the HTML page + document.head.appendChild(webTracingScript); + }; + + // Append the Web-SDK script script tag to the HTML page + document.head.appendChild(webSdkScript); +})(); diff --git a/docs/static/js/search.js b/docs/static/js/search.js index 8bcea296..4f1bbdd9 100644 --- a/docs/static/js/search.js +++ b/docs/static/js/search.js @@ -63,7 +63,7 @@ function populateResults(result) { } let end = contents.length if (endIdx + summaryInclude < contents.length) { - endIdx + summaryInclude + endIdx + summaryInclude } snippet += contents.substring(start, end) snippetHighlights.push( -- cgit v1.2.3