diff --git a/package-lock.json b/package-lock.json index 10835df16a..11ae322957 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12761,42 +12761,6 @@ "node": "*" } }, - "node_modules/cheerio": { - "version": "1.0.0-rc.12", - "dev": true, - "license": "MIT", - "dependencies": { - "cheerio-select": "^2.1.0", - "dom-serializer": "^2.0.0", - "domhandler": "^5.0.3", - "domutils": "^3.0.1", - "htmlparser2": "^8.0.1", - "parse5": "^7.0.0", - "parse5-htmlparser2-tree-adapter": "^7.0.0" - }, - "engines": { - "node": ">= 6" - }, - "funding": { - "url": "https://github.com/cheeriojs/cheerio?sponsor=1" - } - }, - "node_modules/cheerio-select": { - "version": "2.1.0", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "boolbase": "^1.0.0", - "css-select": "^5.1.0", - "css-what": "^6.1.0", - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3", - "domutils": "^3.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, "node_modules/child_process": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/child_process/-/child_process-1.0.2.tgz", diff --git a/www/netlify/functions/trackCLICommands.js b/www/netlify/functions/trackCLICommands.js new file mode 100644 index 0000000000..be1f9265a0 --- /dev/null +++ b/www/netlify/functions/trackCLICommands.js @@ -0,0 +1,23 @@ +const { v4: uuidv4 } = require('uuid'); +const Analytics = require('analytics-node'); + +const analytics = new Analytics(process.env.SEGMENT_KEY); + +exports.handler = async function eventHandler(event) { + // Only allow POST + if (event.httpMethod !== 'POST') { + return { statusCode: 405, body: 'Method Not Allowed' }; + } + const { eventName } = JSON.parse(event.body); + // dispatch event to Segment + analytics.track({ + anonymousId: uuidv4(), + event: 'openedx.paragon.functions.track-cli-commands.run', + properties: { eventName }, + }); + + return { + statusCode: 200, + body: JSON.stringify({ success: true }), + }; +}; diff --git a/www/netlify/functions/trackGenerateComponent.js b/www/netlify/functions/trackGenerateComponent.js index b0b29ed3b3..30d149d22f 100644 --- a/www/netlify/functions/trackGenerateComponent.js +++ b/www/netlify/functions/trackGenerateComponent.js @@ -8,12 +8,12 @@ exports.handler = async function eventHandler(event) { if (event.httpMethod !== 'POST') { return { statusCode: 405, body: 'Method Not Allowed' }; } - const { componentName } = JSON.parse(event.body); + const { eventName } = JSON.parse(event.body); // dispatch event to Segment analytics.track({ anonymousId: uuidv4(), event: 'openedx.paragon.functions.track-generate-component.created', - properties: { componentName }, + properties: { eventName }, }); return {