diff --git a/.github/workflows/deploy-prod-static.yml b/.github/workflows/deploy-prod-static.yml index 7920c7ce065c..701a2ba4f24c 100644 --- a/.github/workflows/deploy-prod-static.yml +++ b/.github/workflows/deploy-prod-static.yml @@ -50,10 +50,3 @@ jobs: action: "upload" app_location: "site" skip_app_build: true - - # Update the site stats - - run: node packages/typescriptlang-org/scripts/updateAppInsightsGitHubIssue.js - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_BOT_TOKEN }} - APP_INSIGHTS_API_KEY: ${{ secrets.APP_INSIGHTS_API_KEY }} - APP_INSIGHTS_ID: ${{ secrets.APP_INSIGHTS_ID }} diff --git a/.github/workflows/weekly-stats.yml b/.github/workflows/weekly-stats.yml deleted file mode 100644 index 9db840281325..000000000000 --- a/.github/workflows/weekly-stats.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Push AI stats to Teams - -on: - schedule: - # https://crontab.guru/#0_12_*_*_1 - - cron: "0 12 * * 1" - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: "16.x" - cache: yarn - - # Build v2 - - name: Deps - run: | - yarn install - env: - YARN_CHECKSUM_BEHAVIOR: ignore - - # Update the site stats - - run: node packages/typescriptlang-org/scripts/pingTeamsWithAppInsightData.js - env: - APP_INSIGHTS_API_KEY: ${{ secrets.APP_INSIGHTS_API_KEY }} - APP_INSIGHTS_ID: ${{ secrets.APP_INSIGHTS_ID }} - STATS_WEBHOOK_INCOMING_URL: ${{ secrets.STATS_WEBHOOK_INCOMING_URL }} - - - name: Send a message to Microsoft Teams - if: ${{ failure() }} - uses: aliencube/microsoft-teams-actions@v0.8.0 - with: - webhook_uri: ${{ secrets.TEAMS_WEB_BOT_INCOMING_URL }} - title: Updating site stats failed - summary: Something failed in the GitHub Action workflow - actions: '[{ "@type": "OpenUri", "name": "View Logs", "targets": [{ "os": "default", "uri": "https://github.com/microsoft/TypeScript-Website/actions/runs/${{ github.run_id }}?check_suite_focus=true" }] }]' diff --git a/README.md b/README.md index 0f34b32219dc..3e71919980ef 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ### Meta - **URLs:** [production](https://www.typescriptlang.org), [staging](http://www.staging-typescript.org/) -- **Admin:** Prod: [Azure Portal](https://ms.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/99160d5b-9289-4b66-8074-ed268e739e8e/resourceGroups/Default-Web-WestUS/providers/Microsoft.Web/sites/TypeScript-1ebb3390-2634-4956-a955-eab987b7bb25/appServices), [Deploy logs](https://ms.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/99160d5b-9289-4b66-8074-ed268e739e8e/resourceGroups/Default-Web-WestUS/providers/Microsoft.Web/sites/TypeScript-1ebb3390-2634-4956-a955-eab987b7bb25/vstscd), [App Insights](https://ms.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/57bfeeed-c34a-4ffd-a06b-ccff27ac91b8/resourceGroups/typescriptlang-org/providers/microsoft.insights/components/TypeScriptLang-Prod-Ai/overview) +- **Admin:** Prod: [Azure Portal](https://ms.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/99160d5b-9289-4b66-8074-ed268e739e8e/resourceGroups/Default-Web-WestUS/providers/Microsoft.Web/sites/TypeScript-1ebb3390-2634-4956-a955-eab987b7bb25/appServices), [Deploy logs](https://ms.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/99160d5b-9289-4b66-8074-ed268e739e8e/resourceGroups/Default-Web-WestUS/providers/Microsoft.Web/sites/TypeScript-1ebb3390-2634-4956-a955-eab987b7bb25/vstscd) - **Translations:** [microsoft/TypeScript-Website-Localizations](https://github.com/microsoft/TypeScript-Website-Localizations) ### Getting Started diff --git a/packages/playground/src/getExample.ts b/packages/playground/src/getExample.ts index 3d0802f7d902..35cbeade0111 100644 --- a/packages/playground/src/getExample.ts +++ b/packages/playground/src/getExample.ts @@ -25,11 +25,6 @@ export const getExampleSourceCode = async (prefix: string, lang: string, example code = code.split("\n").slice(1).join("\n").trim() } - // @ts-ignore - window.appInsights && - // @ts-ignore - window.appInsights.trackEvent({ name: "Read Playground Example", properties: { id: exampleID, lang } }) - return { example, code, diff --git a/packages/playground/src/index.ts b/packages/playground/src/index.ts index 25e2a9f90cb9..3c12e1f86a6d 100644 --- a/packages/playground/src/index.ts +++ b/packages/playground/src/index.ts @@ -241,8 +241,6 @@ export const setupPlayground = ( // When any compiler flags are changed, trigger a potential change to the URL sandbox.setDidUpdateCompilerSettings(async () => { playgroundDebouncedMainFunction() - // @ts-ignore - window.appInsights && window.appInsights.trackEvent({ name: "Compiler Settings changed" }) const model = sandbox.editor.getModel() const plugin = getCurrentPlugin() diff --git a/packages/playground/src/sidebar/plugins.ts b/packages/playground/src/sidebar/plugins.ts index 5b5e35cecfdd..6468b828a03d 100644 --- a/packages/playground/src/sidebar/plugins.ts +++ b/packages/playground/src/sidebar/plugins.ts @@ -23,10 +23,6 @@ export const addCustomPlugin = (mod: string) => { const newPlugins = customPlugins() newPlugins.push(mod) localStorage.setItem("custom-plugins-playground", JSON.stringify(newPlugins)) - // @ts-ignore - window.appInsights && - // @ts-ignore - window.appInsights.trackEvent({ name: "Added Custom Module", properties: { id: mod } }) } const customPlugins = (): string[] => { @@ -147,10 +143,6 @@ export const optionsPlugin: PluginFactory = (i, utils) => { const ds = utils.createDesignSystem(div) ds.declareRestartRequired(i) if (input.checked) { - // @ts-ignore - window.appInsights && - // @ts-ignore - window.appInsights.trackEvent({ name: "Added Registry Plugin", properties: { id: key } }) localStorage.setItem(key, "true") } else { localStorage.removeItem(key) diff --git a/packages/typescriptlang-org/gatsby-browser.js b/packages/typescriptlang-org/gatsby-browser.js deleted file mode 100644 index 2ece05cf0b10..000000000000 --- a/packages/typescriptlang-org/gatsby-browser.js +++ /dev/null @@ -1,61 +0,0 @@ -// This hooks ups client-side app analytics -// it's based on how the google analytics plugin works for gatsby -// https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-google-analytics/src/gatsby-browser.js - -exports.onRouteUpdate = ({ location, prevLocation }) => { - // Run both clear and app insights for a bit, then drop app insights - - // prettier-ignore - // ;(function(c,l,a,r,i,t,y){ - // c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; - // t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; - // y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); - // })(window, document, "clarity", "script", "3w5kyel345"); - - var sdkInstance = "appInsightsSDK" - window[sdkInstance] = "appInsights" - const config = { - instrumentationKey: "78a8fb52-a225-4c66-ac08-92fad1c1ade1", - // loggingLevelConsole: 1 - } - - let hasLocalStorage = false - try { - hasLocalStorage = typeof localStorage !== `undefined` - } catch (error) {} - - try { - // prettier-ignore - // @ts-ignore - var aiName = window[sdkInstance], aisdk = window[aiName] || function (e) { function n(e) { t[e] = function () { var n = arguments; t.queue.push(function () { t[e].apply(t, n) }) } } var t = { config: e }; t.initialize = !0; var i = document, a = window; setTimeout(function () { var n = i.createElement("script"); n.async = true; n.src = e.url || "https://az416426.vo.msecnd.net/scripts/b/ai.2.min.js", i.getElementsByTagName("script")[0].parentNode.appendChild(n) }); try { t.cookie = i.cookie } catch (e) { } t.queue = [], t.version = 2; for (var r = ["Event", "PageView", "Exception", "Trace", "DependencyData", "Metric", "PageViewPerformance"]; r.length;)n("track" + r.pop()); n("startTrackPage"), n("stopTrackPage"); var s = "Track" + r[0]; if (n("start" + s), n("stop" + s), n("setAuthenticatedUserContext"), n("clearAuthenticatedUserContext"), n("flush"), !(!0 === e.disableExceptionTracking || e.extensionConfig && e.extensionConfig.ApplicationInsightsAnalytics && !0 === e.extensionConfig.ApplicationInsightsAnalytics.disableExceptionTracking)) { n("_" + (r = "onerror")); var o = a[r]; a[r] = function (e, n, i, a, s) { var c = o && o(e, n, i, a, s); return !0 !== c && t["_" + r]({ message: e, url: n, lineNumber: i, columnNumber: a, error: s }), c }, e.autoExceptionInstrumented = !0 } return t }(config); - window[aiName] = aisdk - - const locationWithoutPlaygroundCode = location.pathname - .split("#code")[0] - .split("#src")[0] - - const prevHref = (prevLocation && prevLocation.pathname) || "" - const previousLocationWithoutPlaygroundCode = prevHref - .split("#code")[0] - .split("#src")[0] - - const referrerWithoutPlaygroundCode = - document.referrer && document.referrer.split("#code")[0].split("#src")[0] - - // @ts-ignore - aisdk.trackPageView({ - uri: locationWithoutPlaygroundCode, - refUri: referrerWithoutPlaygroundCode, - properties: { - uri: locationWithoutPlaygroundCode, - prev: previousLocationWithoutPlaygroundCode, - lang: document.documentElement.lang, - visitedPlayground: - hasLocalStorage && localStorage.getItem("sandbox-history") !== null, - }, - }) - } catch (error) { - console.error("Error with Application Insights") - console.error(error) - } -} diff --git a/packages/typescriptlang-org/scripts/makeMarkdownForAppInsights.js b/packages/typescriptlang-org/scripts/makeMarkdownForAppInsights.js deleted file mode 100644 index b9b639ebc910..000000000000 --- a/packages/typescriptlang-org/scripts/makeMarkdownForAppInsights.js +++ /dev/null @@ -1,161 +0,0 @@ -// @ts-check - -/* Creates a markdown summary of the last week's worth of analytics, - * run with: - APP_INSIGHTS_ID="X" APP_INSIGHTS_API_KEY="Y" node packages/typescriptlang-org/scripts/makeMarkdownForAppInsights.js - */ - -const nodeFetch = require("node-fetch").default -const querystring = require("querystring") - -// Get these from: https://ms.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/57bfeeed-c34a-4ffd-a06b-ccff27ac91b8/resourceGroups/typescriptlang-org/providers/microsoft.insights/components/TypeScriptLang-Prod-Ai/apiKeys -if (!process.env.APP_INSIGHTS_ID) - throw new Error("No App Insights ID at process.env.APP_INSIGHTS_ID") - -if (!process.env.APP_INSIGHTS_API_KEY) - throw new Error("No App Insights ID at process.env.APP_INSIGHTS_API_KEY") - -const getJSON = async (query, params) => { - const headers = { - "x-api-key": process.env.APP_INSIGHTS_API_KEY, - } - - const queryParams = querystring.stringify(params) - const root = `https://api.applicationinsights.io/v1/apps/${process.env.APP_INSIGHTS_ID}` - const href = `${root}${query}?${queryParams}` - const response = await nodeFetch(href, { headers }) - - if (!response.ok) { - console.error("Error in API call to app insights") - console.error(response) - } - - const json = await response.json() - return json -} - -const makeQuery = query => getJSON("/query", { query }) - -const makeAToSitePath = path => - `${path}` - -const makeAToPlaygroundSample = path => - `${path}` - -const makeAnchorAsNPMModule = path => - `${path}` - -const toMDList = (rows, anchorFunc) => { - return rows - .sort((a, b) => b[1] - a[1]) - .map(e => "- " + anchorFunc(e[0]) + ` (${e[1]})`) - .join("\n") -} - -const makeMarkdownOfWeeklyAppInsightsInfo = async () => { - // You'll be looking at this stuff and think? Err how do I make these complex queries. - // - // It's actually pretty trivial, you do it all in the portal, then there is a button to get it: - // "Run last query in logs view" (it's like 9 dots, then a speech bubble above the bar graph) - // Which gives you the exact query for the data you see. - - const likedPages = await makeQuery( - `let mainTable = union pageViews,customEvents | where timestamp > ago(1d) | where iif('*' in ("Liked Page"), 1==1, name in ("Liked Page")) | where customDimensions["slug"] startswith "/" ; let byTable = mainTable; let queryTable = () {byTable | extend dimension = customDimensions["slug"] | extend dimension = iif(isempty(dimension), "", dimension)}; let byCohortTable = queryTable | project dimension, timestamp; let topSegments = byCohortTable | summarize Events = count() by dimension | top 10 by Events | summarize makelist(dimension); let topEventMetrics = byCohortTable | where dimension in (topSegments); let otherEventUsers = byCohortTable | where dimension !in (topSegments) | extend dimension = "Other"; otherEventUsers | union topEventMetrics | summarize Events = count() by dimension | order by dimension asc` - ) - - const dislikedPagesTable = await makeQuery( - `let mainTable = union pageViews,customEvents | where timestamp > ago(1d) | where iif('*' in ("Disliked Page"), 1==1, name in ("Disliked Page")) | where customDimensions["slug"] startswith "/" ; let byTable = mainTable; let queryTable = () {byTable | extend dimension = customDimensions["slug"] | extend dimension = iif(isempty(dimension), "", dimension)}; let byCohortTable = queryTable | project dimension, timestamp; let topSegments = byCohortTable | summarize Events = count() by dimension | top 10 by Events | summarize makelist(dimension); let topEventMetrics = byCohortTable | where dimension in (topSegments); let otherEventUsers = byCohortTable | where dimension !in (topSegments) | extend dimension = "Other"; otherEventUsers | union topEventMetrics | summarize Events = count() by dimension | order by dimension asc` - ) - - const usedExamples = await makeQuery( - `let mainTable = union pageViews,customEvents | where timestamp > ago(7d) | where iif('*' in ("Read Playground Example"), 1==1, name in ("Read Playground Example")) | where true; let byTable = mainTable; let queryTable = () {byTable | extend dimension = customDimensions["id"] | extend dimension = iif(isempty(dimension), "", dimension)}; let byCohortTable = queryTable | project dimension, timestamp; let topSegments = byCohortTable | summarize Events = count() by dimension | top 10 by Events | summarize makelist(dimension); let topEventMetrics = byCohortTable | where dimension in (topSegments); let otherEventUsers = byCohortTable | where dimension !in (topSegments) | extend dimension = "Other"; otherEventUsers | union topEventMetrics | summarize Events = count() by dimension | order by dimension asc` - ) - - const playgroundPluginsTable = await makeQuery(`let mainTable = union customEvents -| where timestamp > ago(7d) -| where iif('*' in ("Added Registry Plugin"), 1==1, name in ("Added Registry Plugin")) -| where true; -let byTable = mainTable; -let queryTable = () -{ - byTable - | extend dimension = customDimensions["id"] - | extend dimension = iif(isempty(dimension), "", dimension) -}; -let byCohortTable = queryTable -| project dimension, timestamp; -let topSegments = byCohortTable -| summarize Events = count() by dimension -| top 10 by Events -| summarize makelist(dimension); -let topEventMetrics = byCohortTable -| where dimension in (topSegments); -let otherEventUsers = byCohortTable -| where dimension !in (topSegments) -| extend dimension = "Other"; -otherEventUsers -| union topEventMetrics -| summarize Events = count() by dimension -| order by dimension asc`) - - const mds = [] - - mds.push( - `Hello! This is an always updating GitHub Issue which pulls out the last week of interesting eco-system analytics from the TypeScript website and makes it available for everyone. If you have ideas for things you'd like to see in here, feel free to comment. Microsoft staff can find the [PM focused version here](https://dev.azure.com/devdiv/DevDiv/_dashboards/dashboard/bf4dee3f-7c4b-42b0-805b-670de64052e5).` - ) - - const mostLikedPages = likedPages.tables[0].rows - mds.push(`#### Most liked/disliked pages`) - mds.push( - "All documentation pages have :+1: and :-1: next to them asking _'Is this page helpful?'_. This is the aggregate of the last week for the results." - ) - mds.push(`###### Most Helpful`) - mds.push(toMDList(mostLikedPages, makeAToSitePath)) - - const mostdisLikedPages = dislikedPagesTable.tables[0].rows - mds.push(`###### Least Helpful`) - mds.push(toMDList(mostdisLikedPages, makeAToSitePath)) - - const examples = usedExamples.tables[0].rows.filter(a => a[0] !== "Other") - - mds.push(`#### Playground Examples`) - mds.push("What code samples in the playground are getting used?") - mds.push(toMDList(examples, makeAToPlaygroundSample)) - - const plugins = playgroundPluginsTable.tables[0].rows - .sort((a, b) => b[1] - a[1]) - .filter(a => a[0] !== "Other") - - mds.push(`#### Playground Plugins`) - mds.push( - "What Playground Plugins are being used? This only counts folks clicking in the registry in the sidebar" - ) - mds.push(toMDList(plugins, makeAnchorAsNPMModule)) - - const today = new Date() - mds.push( - `This was last updated ${today.getDate()}/${today.getMonth()}/${today.getFullYear()}. Created with [this script](https://github.com/microsoft/TypeScript-website/blob/v2/packages/typescriptlang-org/scripts/makeMarkdownForAppInsights.js).` - ) - - return mds.join("\n\n") -} - -// @ts-ignore -if (!module.parent) { - makeMarkdownOfWeeklyAppInsightsInfo().then(console.log) -} - -module.exports = { makeMarkdownOfWeeklyAppInsightsInfo } - -// const requests = await getJSON("/metrics/requests/count", { -// timespan: "P7D", -// interval: "P1D", -// }) -// console.log(requests) - -// const liked = await getJSON("/events/customEvents", { -// timespan: "P7D", -// $search: "Liked Page", -// $count: true, -// }) -// console.log(liked) diff --git a/packages/typescriptlang-org/scripts/pingTeamsWithAppInsightData.js b/packages/typescriptlang-org/scripts/pingTeamsWithAppInsightData.js deleted file mode 100644 index afffde850a2b..000000000000 --- a/packages/typescriptlang-org/scripts/pingTeamsWithAppInsightData.js +++ /dev/null @@ -1,221 +0,0 @@ -// @ts-check -/* Creates a message of TypeScript website analytics into the TypeScript Team web channel - * - * run with: - APP_INSIGHTS_ID="X" APP_INSIGHTS_API_KEY="Y" node packages/typescriptlang-org/scripts/pingTeamsWithAppInsightData.js - - if process.env.STATS_WEBHOOK_INCOMING_URL is set, then the message will go into teams - */ - -const nodeFetch = require("node-fetch").default -const querystring = require("querystring") - -const go = async () => { - const dl = await getDetailsForDownloadIntention() - - // Sessions - const all = await getCountForSessions() - const index = await getCountForSessions("Typed JavaScript") - const playground = await getCountForSessions("Playground") - const handbook = await getCountForSessions("Handbook") - - const JSinTSPages = [ - "TypeScript: Documentation - JSDoc Reference", - "TypeScript: Documentation - Migrating from JavaScript", - "TypeScript: Documentation - Type Checking JavaScript Files", - "TypeScript: Documentation - Creating .d.ts Files from .js files", - ] - const jsInTS = await getCountForQuery(getSessionsInList(JSinTSPages)) - - // Users - const allUsers = await getCountForQuery(getUsersAllPrefixed()) - - // https://adaptivecards.io/designer - - const headline = { - type: "FactSet", - facts: [ - { - title: "Sessions", - value: comma(all), - }, - { - title: "Unique Users", - value: comma(allUsers), - }, - { - title: "Homepage Sessions", - value: comma(index), - }, - ], - } - - const homepageSection = makeColumn("Download", { - All: comma(dl), - }) - - const playgroundSection = makeColumn("Playground Usage", { - All: comma(playground), - }) - - const handbookSection = makeColumn("Handbook", { - All: comma(handbook), - }) - - const jsInTSSection = makeColumn("JS in TS", { - All: comma(jsInTS), - }) - - const card = { - $schema: "http://adaptivecards.io/schemas/adaptive-card.json", - type: "AdaptiveCard", - version: "1.2", - minHeight: "100px", - body: [ - headline, - { - type: "ColumnSet", - columns: [ - homepageSection, - playgroundSection, - handbookSection, - jsInTSSection, - ], - }, - ], - } - - if (!process.env.STATS_WEBHOOK_INCOMING_URL) { - console.log(JSON.stringify(card, null, " ")) - } else { - // https://learn.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using#send-adaptive-cards-using-an-incoming-webhook - - const outer = { - type: "message", - attachments: [ - { - contentType: "application/vnd.microsoft.card.adaptive", - contentUrl: null, - content: card, - }, - ], - } - - const r = await nodeFetch(process.env.STATS_WEBHOOK_INCOMING_URL, { - method: "post", - body: JSON.stringify(outer), - headers: { "Content-Type": "application/json" }, - }) - console.log(r) - } -} - -go() - -const makeColumn = (title, data) => { - const facts = Object.entries(data).map(e => ({ title: e[0], value: e[1] })) - return { - type: "Column", - width: "stretch", - items: [ - { - type: "TextBlock", - text: title, - wrap: true, - size: "Medium", - weight: "Bolder", - color: "Accent", - }, - { - type: "FactSet", - facts, - }, - ], - } -} - -// https://adaptivecards.io/designer - -async function getJSON(query, params) { - const headers = { - "x-api-key": process.env.APP_INSIGHTS_API_KEY, - } - - const queryParams = querystring.stringify(params) - const root = `https://api.applicationinsights.io/v1/apps/${process.env.APP_INSIGHTS_ID}` - const href = `${root}${query}?${queryParams}` - const response = await nodeFetch(href, { headers }) - - if (!response.ok) { - console.error("Error in API call to app insights") - console.error(response) - } - - const json = await response.json() - return json -} - -async function makeQuery(query) { - return getJSON("/query", { query }) -} - -async function getCountForSessions(substr) { - return getCountForQuery(getSessionsAllPrefixed(substr)) -} - -async function getCountForQuery(query) { - const playgroundStats = await makeQuery(query) - // Hah, yep - const result = JSON.parse(playgroundStats.tables[0].rows[0][0])[0] - return result -} - -function getSessionsAllPrefixed(prefix) { - const query = prefix ? `| where name contains "${prefix}"` : "" - return ` - let mainTable = pageViews - | where timestamp > ago(7d) - ${query} - | where true; let resultTable = mainTable; resultTable - | make-series Sessions = dcount(session_Id) default = 0 on timestamp from ago(7d) to now() step iff(true, 7d, 7d) -` -} - -function getUsersAllPrefixed(prefix) { - const query = prefix ? `| where name contains "${prefix}"` : "" - return ` - let mainTable = pageViews - | where timestamp > ago(7d) - ${query} - | where true; let resultTable = mainTable; resultTable - | make-series Sessions = dcount(user_Id) default = 0 on timestamp from ago(7d) to now() step iff(true, 7d, 7d) -` -} - -function getSessionsInList(arr) { - // prettier-ignore - const query = `| where iif('*' in ("${arr.join('", "')}") , 1 == 1, name in ("${arr.join('", "')}"))` - - return ` - let mainTable = pageViews - | where timestamp > ago(7d) - ${query} - | where true; let resultTable = mainTable; resultTable - | make-series Sessions = dcount(session_Id) default = 0 on timestamp from ago(7d) to now() step iff(true, 7d, 7d) -` -} - -async function getDetailsForDownloadIntention() { - const query = `let mainTable = union pageViews, customEvents - | where timestamp > ago(7d) - | where iif('*' in ("Copied npm instructions on Index", "TypeScript: How to set up TypeScript"), 1 == 1, name in ("Copied npm instructions on Index", "TypeScript: How to set up TypeScript")) - | where true; let resultTable = mainTable; resultTable - | make-series Sessions = dcount(session_Id) default = 0 on timestamp from ago(7d) to now() step iff(true, 7d, 7d)` - - const response = await makeQuery(query) - return JSON.parse(response.tables[0].rows[0][0])[0] -} - -function comma(x) { - return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") -} diff --git a/packages/typescriptlang-org/scripts/updateAppInsightsGitHubIssue.js b/packages/typescriptlang-org/scripts/updateAppInsightsGitHubIssue.js deleted file mode 100644 index 4fc684fccc79..000000000000 --- a/packages/typescriptlang-org/scripts/updateAppInsightsGitHubIssue.js +++ /dev/null @@ -1,34 +0,0 @@ -// @ts-check - -// Uses the App Insights API to grab useful analytics - -// See: https://dev.applicationinsights.io/reference/get-events -// https://ms.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/57bfeeed-c34a-4ffd-a06b-ccff27ac91b8/resourceGroups/typescriptlang-org/providers/microsoft.insights/components/TypeScriptLang-Prod-Ai/events -// - -const { - makeMarkdownOfWeeklyAppInsightsInfo, -} = require("./makeMarkdownForAppInsights") -const Octokit = require("@octokit/rest") - -// Get this from OneNote -if (!process.env.GITHUB_TOKEN) - throw new Error("No GitHub Token at process.env.GITHUB_TOKEN") - -const go = async () => { - const octokit = new Octokit({ - auth: process.env.GITHUB_TOKEN, - userAgent: "TS AppInsights Issue Updater", - }) - - const md = await makeMarkdownOfWeeklyAppInsightsInfo() - - await octokit.issues.update({ - owner: "Microsoft", - repo: "TypeScript-Website", - issue_number: 1014, - body: md, - }) -} - -go() diff --git a/packages/typescriptlang-org/src/components/index/AboveTheFold.tsx b/packages/typescriptlang-org/src/components/index/AboveTheFold.tsx index a785a75b13ba..5eda8c3e3c81 100644 --- a/packages/typescriptlang-org/src/components/index/AboveTheFold.tsx +++ b/packages/typescriptlang-org/src/components/index/AboveTheFold.tsx @@ -9,13 +9,6 @@ const Row = (props: { children: any, className?: string }) =>
{props.children}
const Col2 = (props: { children: any }) =>
{props.children}
-const event = (name: string, options?: any) => { - // @ts-ignore - window.appInsights && - // @ts-ignore - window.appInsights.trackEvent({ name }, options) -} - const FluidButton = (props: { href?: string, onClick?: any, title: string, subtitle?: string, icon: JSX.Element, className?: string }) => (
@@ -36,7 +29,6 @@ export const AboveTheFold = () => { const onclick = (e) => { setShowCTALinks(true) e.preventDefault() - event("Home Page CTA Started") return false } @@ -76,7 +68,7 @@ export const AboveTheFold = () => { title={i("index_2_cta_play")} subtitle={i("index_2_cta_play_subtitle")} href="/play" - onClick={() => event("Home Page CTA Exited", { link: "playground" })} + onClick={() => ({ link: "playground" })} icon={ @@ -100,7 +92,7 @@ export const AboveTheFold = () => { title={i("index_2_cta_download")} subtitle={i("index_2_cta_download_subtitle")} href="/download" - onClick={() => event("Home Page CTA Exited", { link: "download" })} + onClick={() => ({ link: "download" })} icon={ diff --git a/packages/typescriptlang-org/src/templates/documentation.tsx b/packages/typescriptlang-org/src/templates/documentation.tsx index 49ff71463fdc..b5feadd3ed44 100644 --- a/packages/typescriptlang-org/src/templates/documentation.tsx +++ b/packages/typescriptlang-org/src/templates/documentation.tsx @@ -18,8 +18,8 @@ import { createIntlLink } from "../components/IntlLink" import { handbookCopy } from "../copy/en/handbook" import { Contributors } from "../components/handbook/Contributors" import { overrideSubNavLinksWithSmoothScroll, updateSidebarOnScroll } from "./scripts/setupSubNavigationSidebar" -import { setupLikeDislikeButtons } from "./scripts/setupLikeDislikeButtons" -import { DislikeUnfilledSVG, LikeUnfilledSVG } from "../components/svgs/documentation" +// import { setupLikeDislikeButtons } from "./scripts/setupLikeDislikeButtons" +// import { DislikeUnfilledSVG, LikeUnfilledSVG } from "../components/svgs/documentation" import { Popup, useQuickInfoPopup } from "../components/Popup" import Helmet from "react-helmet" @@ -69,7 +69,7 @@ const HandbookTemplate: React.FC = (props) => { // Sets current selection updateSidebarOnScroll() - setupLikeDislikeButtons(props.pageContext.slug, i) + // setupLikeDislikeButtons(props.pageContext.slug, i) return () => { @@ -95,13 +95,13 @@ const HandbookTemplate: React.FC = (props) => {
-
+ {/*

Was this page helpful?

-
+
*/}