diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js
index a0c97b6b..2b7a4397 100644
--- a/docs/docusaurus.config.js
+++ b/docs/docusaurus.config.js
@@ -1,3 +1,5 @@
+const path = require('path');
+
module.exports = {
title: "Oh My Posh",
tagline: "A prompt theme engine for any shell.",
@@ -7,6 +9,7 @@ module.exports = {
organizationName: "jandedobbeleer",
projectName: "oh-my-posh",
onBrokenLinks: "ignore",
+ plugins: [path.resolve(__dirname, 'plugins', 'appinsights')],
themeConfig: {
sidebarCollapsible: false,
prism: {
@@ -92,6 +95,9 @@ module.exports = {
],
copyright: `Copyright © ${new Date().getFullYear()} Jan De Dobbeleer and contributors.`,
},
+ appInsights: {
+ instrumentationKey: "72804848-dc30-4856-8245-4fa1450b041f",
+ }
},
presets: [
[
diff --git a/docs/package.json b/docs/package.json
index 1a0c0b32..1724162a 100644
--- a/docs/package.json
+++ b/docs/package.json
@@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"scripts": {
- "start": "docusaurus start",
+ "start": "NODE_ENV=development docusaurus start",
"build": "docusaurus build",
"themes": "node export_themes.js"
},
diff --git a/docs/plugins/appinsights/analytics.js b/docs/plugins/appinsights/analytics.js
new file mode 100644
index 00000000..9f2d831b
--- /dev/null
+++ b/docs/plugins/appinsights/analytics.js
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
+
+export default (function () {
+ if (!ExecutionEnvironment.canUseDOM) {
+ return null;
+ }
+
+ return {
+ onRouteUpdate({ location }) {
+ window.setTimeout(() => {
+ if (window.appInsights) {
+ window.appInsights.trackPageView({name: location.pathname});
+ }
+ }, 0);
+ },
+ };
+})();
diff --git a/docs/plugins/appinsights/index.js b/docs/plugins/appinsights/index.js
new file mode 100644
index 00000000..25683e78
--- /dev/null
+++ b/docs/plugins/appinsights/index.js
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+const { Console } = require('console');
+const path = require('path');
+
+module.exports = function (context) {
+ const { siteConfig } = context;
+ const { themeConfig } = siteConfig;
+ const { appInsights } = themeConfig || {};
+
+ if (!appInsights) {
+ throw new Error(
+ `You need to specify "appInsights" object in "themeConfig" with "instrumentationKey" field in it to use appinsights.`,
+ );
+ }
+
+ const { instrumentationKey } = appInsights;
+
+ if (!instrumentationKey) {
+ throw new Error(
+ 'You specified the "appInsights" object in "themeConfig" but the "trackingID" field was missing. ' +
+ 'Please ensure this is not a mistake.',
+ );
+ }
+
+ const isProd = process.env.NODE_ENV !== 'development';
+
+ return {
+ name: 'docusaurus-plugin-app-insights',
+
+ getClientModules() {
+ return isProd ? [path.resolve(__dirname, './analytics')] : [];
+ },
+
+ injectHtmlTags() {
+ if (!isProd) {
+ return {};
+ }
+ return {
+ headTags: [
+ {
+ tagName: 'script',
+ attributes: {
+ type: 'text/javascript'
+ },
+ innerHTML: `
+!function(T,l,y){var S=T.location,k="script",D="instrumentationKey",C="ingestionendpoint",I="disableExceptionTracking",E="ai.device.",b="toLowerCase",w="crossOrigin",N="POST",e="appInsightsSDK",t=y.name||"appInsights";(y.name||T[e])&&(T[e]=t);var n=T[t]||function(d){var g=!1,f=!1,m={initialize:!0,queue:[],sv:"5",version:2,config:d};function v(e,t){var n={},a="Browser";return n[E+"id"]=a[b](),n[E+"type"]=a,n["ai.operation.name"]=S&&S.pathname||"_unknown_",n["ai.internal.sdkVersion"]="javascript:snippet_"+(m.sv||m.version),{time:function(){var e=new Date;function t(e){var t=""+e;return 1===t.length&&(t="0"+t),t}return e.getUTCFullYear()+"-"+t(1+e.getUTCMonth())+"-"+t(e.getUTCDate())+"T"+t(e.getUTCHours())+":"+t(e.getUTCMinutes())+":"+t(e.getUTCSeconds())+"."+((e.getUTCMilliseconds()/1e3).toFixed(3)+"").slice(2,5)+"Z"}(),iKey:e,name:"Microsoft.ApplicationInsights."+e.replace(/-/g,"")+"."+t,sampleRate:100,tags:n,data:{baseData:{ver:2}}}}var h=d.url||y.src;if(h){function a(e){var t,n,a,i,r,o,s,c,u,p,l;g=!0,m.queue=[],f||(f=!0,t=h,s=function(){var e={},t=d.connectionString;if(t)for(var n=t.split(";"),a=0;a