Skip to content

Commit

Permalink
refactor: refactoring after review
Browse files Browse the repository at this point in the history
  • Loading branch information
PKulkoRaccoonGang committed Sep 12, 2023
1 parent c35e0c5 commit 584a448
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
23 changes: 23 additions & 0 deletions 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 }),
};
};
4 changes: 2 additions & 2 deletions www/netlify/functions/trackGenerateComponent.js
Expand Up @@ -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 {
Expand Down

0 comments on commit 584a448

Please sign in to comment.