From 90ec3193e35288f7c43ab6310539c6ed91dd41a1 Mon Sep 17 00:00:00 2001 From: Kyrylo Shmidt Date: Wed, 6 Mar 2024 11:22:17 +0100 Subject: [PATCH] Add message to open registration dialog in Recent activity panel --- .../RunDigma/runDigmaWithCommandLine.tsx | 1 - .../RecentActivity/RecentActivity.stories.tsx | 10 ++++++++ src/components/RecentActivity/actions.ts | 3 ++- src/components/RecentActivity/index.tsx | 23 +++++++++++++++++-- .../common/RegistrationDialog/index.tsx | 6 +++++ 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/components/Documentation/pages/RunDigma/runDigmaWithCommandLine.tsx b/src/components/Documentation/pages/RunDigma/runDigmaWithCommandLine.tsx index 2820bdb6d..66701c450 100644 --- a/src/components/Documentation/pages/RunDigma/runDigmaWithCommandLine.tsx +++ b/src/components/Documentation/pages/RunDigma/runDigmaWithCommandLine.tsx @@ -113,7 +113,6 @@ export const runDigmaWithCommandLine: PageContent = { curl --create-dirs -O -L --output-dir ./otel https://github.com/digma-ai/otel-java-instrumentation/releases/latest/download/digma-otel-agent-extension.jar export JAVA_TOOL_OPTIONS="-javaagent:/otel/javaagent.jar -Dotel.exporter.otlp.endpoint=http://localhost:5050 -Dotel.javaagent.extensions=/otel/digma-otel-agent-extension.jar -Dotel.metrics.exporter=none -Dotel.logs.exporter=none -Dotel.exporter.otlp.protocol=grpc" - export OTEL_SERVICE_NAME={--ENTER YOUR SERVICE NAME HERE--} export OTEL_RESOURCE_ATTRIBUTES=digma.environment=LOCAL diff --git a/src/components/RecentActivity/RecentActivity.stories.tsx b/src/components/RecentActivity/RecentActivity.stories.tsx index 08d8ff132..5864b156f 100644 --- a/src/components/RecentActivity/RecentActivity.stories.tsx +++ b/src/components/RecentActivity/RecentActivity.stories.tsx @@ -1,6 +1,7 @@ import { Meta, StoryObj } from "@storybook/react"; import { RecentActivity } from "."; import { mockData as liveData } from "./LiveView/mockData"; +import { actions } from "./actions"; import { RecentActivityData } from "./types"; // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction @@ -663,3 +664,12 @@ export const WithNoLiveData: Story = { } } }; + +export const OpenRegistrationDialog: Story = { + play: () => { + window.postMessage({ + type: "digma", + action: actions.OPEN_REGISTRATION_DIALOG + }); + } +}; diff --git a/src/components/RecentActivity/actions.ts b/src/components/RecentActivity/actions.ts index 917e2571c..57125d570 100644 --- a/src/components/RecentActivity/actions.ts +++ b/src/components/RecentActivity/actions.ts @@ -18,5 +18,6 @@ export const actions = addPrefix(ACTION_PREFIX, { APPLY_REMOTE_ENVIRONMENT_SETTINGS: "APPLY_REMOTE_ENVIRONMENT_SETTINGS", SET_REMOTE_ENVIRONMENT_CONNECTION_CHECK_RESULT: "SET_REMOTE_ENVIRONMENT_CONNECTION_CHECK_RESULT", - FINISH_ORG_DIGMA_SETUP: "FINISH_ORG_DIGMA_SETUP" + FINISH_ORG_DIGMA_SETUP: "FINISH_ORG_DIGMA_SETUP", + OPEN_REGISTRATION_DIALOG: "OPEN_REGISTRATION_DIALOG" }); diff --git a/src/components/RecentActivity/index.tsx b/src/components/RecentActivity/index.tsx index 40b18797d..9adbb45a2 100644 --- a/src/components/RecentActivity/index.tsx +++ b/src/components/RecentActivity/index.tsx @@ -141,14 +141,27 @@ export const RecentActivity = (props: RecentActivityProps) => { setLiveData(data as LiveData); }; + const handleOpenRegistrationDialog = () => { + setIsRegistrationPopupVisible(true); + }; + dispatcher.addActionListener(actions.SET_DATA, handleRecentActivityData); dispatcher.addActionListener(actions.SET_LIVE_DATA, handleLiveData); + dispatcher.addActionListener( + actions.OPEN_REGISTRATION_DIALOG, + handleOpenRegistrationDialog + ); return () => { dispatcher.removeActionListener( actions.SET_DATA, handleRecentActivityData ); + dispatcher.removeActionListener(actions.SET_LIVE_DATA, handleLiveData); + dispatcher.removeActionListener( + actions.OPEN_REGISTRATION_DIALOG, + handleOpenRegistrationDialog + ); }; }, []); @@ -339,8 +352,14 @@ export const RecentActivity = (props: RecentActivityProps) => { action: globalActions.REGISTER, payload: { ...formData, - scope: "recent activity add environment", - selectedEnvironmentType: environmentToSetType?.type + ...(environmentToSetType + ? { + scope: "recent activity add environment", + selectedEnvironmentType: environmentToSetType.type + } + : { + scope: "recent activity" + }) } }); diff --git a/src/components/common/RegistrationDialog/index.tsx b/src/components/common/RegistrationDialog/index.tsx index bc862d005..fa2f558d7 100644 --- a/src/components/common/RegistrationDialog/index.tsx +++ b/src/components/common/RegistrationDialog/index.tsx @@ -1,6 +1,7 @@ import { KeyboardEvent, useEffect } from "react"; import { Controller, useForm } from "react-hook-form"; import { isValidEmailFormat } from "../../../utils/isValidEmailFormat"; +import { sendTrackingEvent } from "../../../utils/sendTrackingEvent"; import { NewCircleLoader } from "../NewCircleLoader"; import { EnvelopeIcon } from "../icons/16px/EnvelopeIcon"; import { CrossIcon } from "../icons/CrossIcon"; @@ -51,6 +52,7 @@ export const RegistrationDialog = (props: RegistrationDialogProps) => { }, [setFocus]); const onSubmit = (data: RegistrationFormValues) => { + sendTrackingEvent("registration dialog submit button clicked"); props.onSubmit({ fullName: data.fullName.trim(), email: data.email @@ -58,11 +60,15 @@ export const RegistrationDialog = (props: RegistrationDialogProps) => { }; const handleCloseButtonClick = () => { + sendTrackingEvent("registration dialog close button clicked"); props.onClose(); }; const handleKeyDown = (e: KeyboardEvent) => { if (e.key === "Enter" && isValid) { + sendTrackingEvent( + "registration dialog Enter key pressed and form data is valid" + ); onSubmit(values); } };