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 Oct 30, 2023
1 parent 222ab8d commit cb9dcb8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 38 deletions.
36 changes: 0 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions www/netlify/functions/trackCLICommands.js
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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 cb9dcb8

Please sign in to comment.