From b1fa37496f7f8062578f79489a774939e64658bd Mon Sep 17 00:00:00 2001 From: PKulkoRaccoonGang Date: Sun, 17 Dec 2023 19:05:31 +0200 Subject: [PATCH] refactor: added segment constant for component generator --- www/netlify/functions/trackGenerateComponent.js | 3 ++- www/segment-events/constants.js | 1 + www/src/components/Menu.tsx | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/www/netlify/functions/trackGenerateComponent.js b/www/netlify/functions/trackGenerateComponent.js index b0b29ed3b3..5f44db94a7 100644 --- a/www/netlify/functions/trackGenerateComponent.js +++ b/www/netlify/functions/trackGenerateComponent.js @@ -1,5 +1,6 @@ const { v4: uuidv4 } = require('uuid'); const Analytics = require('analytics-node'); +const { COMPONENT_GENERATED_EVENT } = require('../../segment-events'); const analytics = new Analytics(process.env.SEGMENT_KEY); @@ -12,7 +13,7 @@ exports.handler = async function eventHandler(event) { // dispatch event to Segment analytics.track({ anonymousId: uuidv4(), - event: 'openedx.paragon.functions.track-generate-component.created', + event: COMPONENT_GENERATED_EVENT, properties: { componentName }, }); diff --git a/www/segment-events/constants.js b/www/segment-events/constants.js index f9b935ab26..728aa08ef0 100644 --- a/www/segment-events/constants.js +++ b/www/segment-events/constants.js @@ -7,6 +7,7 @@ export const ICON_COPIED_EVENT = 'openedx.paragon.docs.icons-table.selected-icon export const LEAVE_FEEDBACK_CLICKED_EVENT = 'openedx.paragon.docs.leave-feedback.clicked'; export const CONTRAST_CHECKER_CLICKED_EVENT = 'openedx.paragon.docs.menu.tools.visit-contrast-checker.clicked'; export const PAGE_EDIT_BTN_CLICKED_EVENT = 'openedx.paragon.docs.page-edit.clicked'; +export const COMPONENT_GENERATED_EVENT = 'openedx.paragon.functions.track-generate-component.created'; export const PLAYGROUND_EVENTS = { LINK_CLICKED: 'openedx.paragon.docs.menu.playground.visit-playground.clicked', diff --git a/www/src/components/Menu.tsx b/www/src/components/Menu.tsx index c6338e713b..e80eade226 100644 --- a/www/src/components/Menu.tsx +++ b/www/src/components/Menu.tsx @@ -16,7 +16,11 @@ import classNames from 'classnames'; import Search from './Search'; import { SettingsContext } from '../context/SettingsContext'; import { THEMES } from '../../theme-config'; -import { PLAYGROUND_EVENTS, sendUserAnalyticsEvent, CONTRAST_CHECKER_CLICKED_EVENT } from '../../segment-events'; +import { + PLAYGROUND_EVENTS, + sendUserAnalyticsEvent, + CONTRAST_CHECKER_CLICKED_EVENT, +} from '../../segment-events'; import { FOUNDATION_PAGES } from '../config'; // MDX transforms markdown generated by gatsby-transformer-react-docgen