@mintlify/common
Version:
Commonly shared code within Mintlify
125 lines (124 loc) • 4.46 kB
JavaScript
export const PAGE_VIEW_EVENT = 'docs.content.view';
/**
* Analytics event names following a standardized naming convention.
*
* @description All event names follow the format: `platform.noun.action`
* - **platform**: The platform where the event occurs (e.g., 'docs')
* - **noun**: The component or feature being interacted with (e.g., 'expandable', 'search')
* - **action**: The specific action taken (e.g., 'open', 'click', 'copy')
*/
export const ANALYTICS_EVENTS = [
PAGE_VIEW_EVENT,
'docs.expandable.open',
'docs.expandable.close',
'docs.accordion.open',
'docs.accordion.close',
'docs.navitem.click',
'docs.navitem.cta_click',
'docs.search.query',
'docs.search.close',
'docs.api_playground.request',
'docs.search.result_click',
'docs.code_block.copy',
'docs.code_block.ask_ai',
'docs.feedback.thumbs_up',
'docs.feedback.thumbs_down',
'docs.feedback.detailed_submitted',
'docs.footer.powered_by_mintlify_click',
'docs.assistant.enter',
'docs.assistant.completed',
'docs.assistant.shared',
'docs.assistant.source_click',
'docs.assistant.web_search_click',
'docs.assistant.thumbs_up',
'docs.assistant.thumbs_down',
'docs.assistant.suggestion_click',
'docs.assistant.question_option_click',
'docs.assistant.starter_question_clicked',
'docs.assistant.maximize_click',
'docs.assistant.minimize_click',
'docs.assistant.copy_response',
'docs.assistant.ask_ai_on_text_selection',
'docs.assistant.spam_detected',
'docs.assistant.attachment_upload',
'docs.assistant.attachment_rejected',
'docs.assistant.attachment_limit_exceeded',
'docs.context_menu.copy_page',
'docs.context_menu.copy_mcp_link',
'docs.context_menu.ai_provider_click',
'docs.context_menu.install_mcp_server',
'docs.context_menu.copy_add_mcp_command',
'docs.context_menu.download_api_spec',
'docs.autopilot.suggestion.created',
'docs.autopilot.suggestion.no_suggestion',
'mcp.tool_call.search',
'docs.content.md.view',
'docs.banner.atlas_signup_click',
'docs.banner.atlas_claim_click',
'docs.banner.atlas_share_click',
'docs.atlas_content.view',
'docs.search.comparison',
'preview_widget.file_list.viewed',
'preview_widget.file.opened',
'preview_widget.file.editor_opened',
];
export function isAnalyticsEvent(value) {
return ANALYTICS_EVENTS.includes(value);
}
/**
* @deprecated Use the new format instead
* @Date 2025-06-16 (remove this in two months)
*/
export const DEPRECATED_ANALYTICS_EVENTS = [
'expandable_open',
'expandable_close',
'accordion_open',
'accordion_close',
'header_nav_item_click',
'cta_click',
'scroll_to_bottom',
'search_close',
'api_playground_call',
'search_result_click',
'chat_enter',
'chat_followup',
'chat_completed',
'code_block_copy',
'chat_shared',
'thumb_vote',
'powered_by_mintlify_click',
'ai_chat_citation_click',
'ai_chat_feedback_positive_click',
'ai_chat_feedback_negative_click',
'ask_ai_code_block',
'assistant.spam_detected',
];
/** @deprecated Use isAnalyticsEvent instead */
export function isDeprecatedAnalyticsEvent(value) {
return DEPRECATED_ANALYTICS_EVENTS.includes(value);
}
/**
* Mapping from new analytics events to their deprecated equivalents
* to maintain backward compatibility
*/
export const analyticsEventMapping = {
'docs.expandable.open': 'expandable_open',
'docs.expandable.close': 'expandable_close',
'docs.accordion.open': 'accordion_open',
'docs.accordion.close': 'accordion_close',
'docs.navitem.click': 'header_nav_item_click',
'docs.navitem.cta_click': 'cta_click',
'docs.search.close': 'search_close',
'docs.api_playground.request': 'api_playground_call',
'docs.search.result_click': 'search_result_click',
'docs.code_block.copy': 'code_block_copy',
'docs.code_block.ask_ai': 'ask_ai_code_block',
'docs.footer.powered_by_mintlify_click': 'powered_by_mintlify_click',
'docs.assistant.enter': 'chat_enter',
'docs.assistant.completed': 'chat_completed',
'docs.assistant.shared': 'chat_shared',
'docs.assistant.source_click': 'ai_chat_citation_click',
'docs.assistant.thumbs_up': 'ai_chat_feedback_positive_click',
'docs.assistant.thumbs_down': 'ai_chat_feedback_negative_click',
'docs.assistant.spam_detected': 'assistant.spam_detected',
};