-
Notifications
You must be signed in to change notification settings - Fork 434
[feature] Add user onboarding #2986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ashrafchowdury
wants to merge
58
commits into
release/v0.69.3
Choose a base branch
from
feature/user-onbroading-to-app
base: release/v0.69.3
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,834
−440
Draft
Changes from all commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
722b808
implemented onboarding feature on the app
ashrafchowdury d8c851e
fixed codeql issue
ashrafchowdury dac403b
fixed trace drawer issue
ashrafchowdury abde757
fixed modal target issues
ashrafchowdury c779453
implemented steps for online eval creation
ashrafchowdury 72613b1
fix playground step
ashrafchowdury 82cacf5
fixed viewport issue
ashrafchowdury 91ffc44
cleandup evaluation tours
ashrafchowdury ceb8d8d
fix the failure issue
ashrafchowdury 5b445dd
added steps for online eval detail page
ashrafchowdury 8805bc3
added sme journey
ashrafchowdury db1508a
fixed issue
ashrafchowdury a7af7e1
show onboarding for specific pages
ashrafchowdury 2b6a0ce
fixed bugs
ashrafchowdury c4dbc5e
implemented posthog on onboarding
ashrafchowdury 92d9ef4
fix pnpm file
ashrafchowdury 716953f
fixed constant opening issue
ashrafchowdury 1fbf3e4
fixed issues
ashrafchowdury 11aac7b
Merge branch 'release/v0.62.6' of https://github.com/Agenta-AI/agenta…
ashrafchowdury c1aec44
fix code
ashrafchowdury 754eb3d
format code
ashrafchowdury 0444cc4
Merge branch 'main' of https://github.com/Agenta-AI/agenta into featu…
ashrafchowdury 9d6bcb9
cleanup
ashrafchowdury 5b9c76c
removed redundend playground steps
ashrafchowdury b3767e8
fixed issue for finish actions
ashrafchowdury 202c2f0
cleaned up breadcrumb
ashrafchowdury 34114e0
cleaned up old code
ashrafchowdury 2bf80b4
added auto advance step feature
ashrafchowdury 431218b
added widget
ashrafchowdury b8f4ad7
added extra utils on the onboarding step
ashrafchowdury d291bbb
refactored code
ashrafchowdury ae18f0f
triggering steps based on given tour id
ashrafchowdury ebfdc5d
created online evaluation in one click
ashrafchowdury b7fac29
made the tracker consistent
ashrafchowdury 0e8fdb3
improved card ui
ashrafchowdury 86c7db3
reverted post-signup changes
ashrafchowdury 075eee3
Merge branch 'main' of https://github.com/Agenta-AI/agenta into featu…
ashrafchowdury 3c0d9c5
added posthog tracker
ashrafchowdury 9088e9e
improved widget reposition
ashrafchowdury b621e3b
added steps for prompt-management
ashrafchowdury 45d11fc
fixed the arrow
ashrafchowdury 51e9f11
fix bug
ashrafchowdury 96da033
removed floating button
ashrafchowdury 1529dbf
improved card ui
ashrafchowdury f041074
added a default "LLM-as-a-judge" evaluator on BE
ashrafchowdury d8e2d84
remove file
ashrafchowdury 9ca0372
removed old auto eval steps code
ashrafchowdury 4b2aef0
cleandup and reverted code changes
ashrafchowdury 3de2014
fix
ashrafchowdury 2d909b1
removed unused steps
ashrafchowdury 43a9410
improved ui
ashrafchowdury fe8ccc2
added general guild open step
ashrafchowdury 2bf7e3d
Merge branch 'main' of https://github.com/Agenta-AI/agenta into featu…
ashrafchowdury 3a69f70
Merge branch 'release/v0.69.3' into feature/user-onbroading-to-app
mmabrouk 13609c1
Refactor onboarding state management to utilize activePreviewRunIdAto…
mmabrouk 8154da7
Refactor onboarding components to improve code organization and consi…
mmabrouk e298b60
revert changes to backend
mmabrouk aa829a4
chore(web): replace nextstepjs patch with @agentaai/nextstepjs package
mmabrouk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
web/oss/src/components/Onboarding/components/CustomNextStepProvider/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| import {useEffect, useRef} from "react" | ||
|
|
||
| import {useAtomValue, useSetAtom} from "jotai" | ||
| import {NextStep, useNextStep} from "@agentaai/nextstepjs" | ||
|
|
||
| import { | ||
| isNewUserAtom, | ||
| onboardingStepsAtom, | ||
| triggerOnboardingAtom, | ||
| userOnboardingStatusAtom, | ||
| } from "@/oss/state/onboarding" | ||
| import {urlLocationAtom} from "@/oss/state/url" | ||
|
|
||
| import OnboardingCard from "../../index" | ||
| import OnboardingAutoAdvance from "../OnboardingAutoAdvance" | ||
|
|
||
| const CustomNextStepProvider = ({children}: {children: React.ReactNode}) => { | ||
| const onboardingSteps = useAtomValue(onboardingStepsAtom) | ||
| const isNewUser = useAtomValue(isNewUserAtom) | ||
| const userLocation = useAtomValue(urlLocationAtom) | ||
| const userOnboardingJourneyStatus = useAtomValue(userOnboardingStatusAtom) | ||
| const manualTrigger = useAtomValue(triggerOnboardingAtom) | ||
| const setTriggerOnboarding = useSetAtom(triggerOnboardingAtom) | ||
| const {startNextStep} = useNextStep() | ||
| const autoStartSignatureRef = useRef<string | null>(null) | ||
|
|
||
| const previousSectionRef = useRef(userLocation.resolvedSection ?? userLocation.section) | ||
| useEffect(() => { | ||
| const resolvedSection = userLocation.resolvedSection ?? userLocation.section | ||
| if (previousSectionRef.current !== resolvedSection) { | ||
| previousSectionRef.current = resolvedSection | ||
| if (!manualTrigger) { | ||
| setTriggerOnboarding(null) | ||
| } | ||
| } | ||
| }, [userLocation.resolvedSection, userLocation.section, manualTrigger, setTriggerOnboarding]) | ||
|
|
||
| useEffect(() => { | ||
| if (!isNewUser) { | ||
| autoStartSignatureRef.current = null | ||
| return | ||
| } | ||
|
|
||
| const normalizedSection = userLocation.resolvedSection | ||
| if (!normalizedSection) { | ||
| autoStartSignatureRef.current = null | ||
| return | ||
| } | ||
|
|
||
| if (!onboardingSteps?.length) { | ||
| autoStartSignatureRef.current = null | ||
| return | ||
| } | ||
|
|
||
| const currentTour = onboardingSteps[0] | ||
| if (!currentTour?.tour) return | ||
|
|
||
| const tourSection = | ||
| (currentTour.steps?.find((step) => step?.onboardingSection) | ||
| ?.onboardingSection as keyof typeof userOnboardingJourneyStatus) ?? | ||
| normalizedSection | ||
|
|
||
| const signature = `${tourSection}:${currentTour.tour}:${currentTour.steps?.length ?? 0}` | ||
| if (autoStartSignatureRef.current === signature) return | ||
|
|
||
| autoStartSignatureRef.current = signature | ||
|
|
||
| startNextStep(currentTour.tour) | ||
| }, [ | ||
| isNewUser, | ||
| userLocation.resolvedSection, | ||
| userOnboardingJourneyStatus, | ||
| onboardingSteps, | ||
| startNextStep, | ||
| ]) | ||
|
|
||
| const lastManualTriggerRef = useRef<typeof manualTrigger>(null) | ||
| useEffect(() => { | ||
| if (!manualTrigger) { | ||
| lastManualTriggerRef.current = null | ||
| return | ||
| } | ||
| if (!onboardingSteps?.length) return | ||
| if (lastManualTriggerRef.current === manualTrigger) return | ||
|
|
||
| lastManualTriggerRef.current = manualTrigger | ||
| const targetTour = | ||
| manualTrigger.tourId !== undefined | ||
| ? (onboardingSteps.find((tour) => tour.tour === manualTrigger.tourId) ?? | ||
| onboardingSteps[0]) | ||
| : onboardingSteps[0] | ||
| const tourId = targetTour?.tour | ||
| if (!tourId) return | ||
|
|
||
| startNextStep(tourId) | ||
| }, [manualTrigger, onboardingSteps, startNextStep]) | ||
|
|
||
| const handleComplete = () => { | ||
| setTriggerOnboarding(null) | ||
| } | ||
|
|
||
| return ( | ||
| <NextStep | ||
| steps={onboardingSteps} | ||
| cardComponent={OnboardingCard} | ||
| showNextStep={true} | ||
| onComplete={handleComplete} | ||
| > | ||
| <OnboardingAutoAdvance /> | ||
| {children} | ||
| </NextStep> | ||
| ) | ||
| } | ||
|
|
||
| export default CustomNextStepProvider |
67 changes: 67 additions & 0 deletions
67
web/oss/src/components/Onboarding/components/NextViewport/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import {forwardRef, useEffect, useRef, type MutableRefObject, type ReactNode} from "react" | ||
|
|
||
| import clsx from "clsx" | ||
|
|
||
| interface NextViewportProps { | ||
| id: string | ||
| className?: string | ||
| children: ReactNode | ||
| } | ||
|
|
||
| const NextViewport = forwardRef<HTMLDivElement, NextViewportProps>( | ||
| ({id, className, children}, forwardedRef) => { | ||
| const containerRef = useRef<HTMLDivElement | null>(null) | ||
|
|
||
| useEffect(() => { | ||
| const node = containerRef.current | ||
| if (typeof window === "undefined" || !node) return | ||
|
|
||
| let animationFrame: number | null = null | ||
| const notifyViewportChange = () => { | ||
| window.dispatchEvent(new CustomEvent("nextstep:viewport-scroll", {detail: {id}})) | ||
| window.dispatchEvent(new Event("resize")) | ||
| } | ||
|
|
||
| const scheduleNotification = () => { | ||
| if (animationFrame) cancelAnimationFrame(animationFrame) | ||
| animationFrame = window.requestAnimationFrame(() => { | ||
| notifyViewportChange() | ||
| }) | ||
| } | ||
|
|
||
| const resizeObserver = | ||
| typeof ResizeObserver !== "undefined" | ||
| ? new ResizeObserver(() => scheduleNotification()) | ||
| : null | ||
|
|
||
| resizeObserver?.observe(node) | ||
| node.addEventListener("scroll", scheduleNotification, {passive: true}) | ||
| scheduleNotification() | ||
|
|
||
| return () => { | ||
| node.removeEventListener("scroll", scheduleNotification) | ||
| resizeObserver?.disconnect() | ||
| if (animationFrame) cancelAnimationFrame(animationFrame) | ||
| } | ||
| }, [id]) | ||
|
|
||
| const setRef = (node: HTMLDivElement | null) => { | ||
| containerRef.current = node | ||
| if (typeof forwardedRef === "function") { | ||
| forwardedRef(node) | ||
| } else if (forwardedRef) { | ||
| ;(forwardedRef as MutableRefObject<HTMLDivElement | null>).current = node | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <div id={id} ref={setRef} className={clsx("relative h-full w-full", className)}> | ||
| {children} | ||
| </div> | ||
| ) | ||
| }, | ||
| ) | ||
|
|
||
| NextViewport.displayName = "NextViewport" | ||
|
|
||
| export default NextViewport |
97 changes: 97 additions & 0 deletions
97
web/oss/src/components/Onboarding/components/OnboardingAutoAdvance/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import {useEffect, useMemo} from "react" | ||
|
|
||
| import {useAtomValue, useSetAtom} from "jotai" | ||
| import {useNextStep} from "@agentaai/nextstepjs" | ||
|
|
||
| import { | ||
| onboardingStepsAtom, | ||
| triggerOnboardingAtom, | ||
| updateUserOnboardingStatusAtom, | ||
| } from "@/oss/state/onboarding" | ||
| import type {OnboardingStep, UserOnboardingStatus} from "@/oss/state/onboarding/types" | ||
| import {urlLocationAtom} from "@/oss/state/url" | ||
|
|
||
| const OnboardingAutoAdvance = () => { | ||
| const onboardingTours = useAtomValue(onboardingStepsAtom) | ||
| const updateUserOnboardingStatus = useSetAtom(updateUserOnboardingStatusAtom) | ||
| const setTriggerOnboarding = useSetAtom(triggerOnboardingAtom) | ||
| const userLocation = useAtomValue(urlLocationAtom) | ||
| const {currentTour, currentStep, isNextStepVisible, setCurrentStep, closeNextStep} = | ||
| useNextStep() | ||
|
|
||
| const {activeStep, totalSteps} = useMemo(() => { | ||
| if (!currentTour) { | ||
| return {activeStep: null, totalSteps: 0} | ||
| } | ||
|
|
||
| const matchingTour = onboardingTours.find((tour) => tour.tour === currentTour) | ||
| if (!matchingTour) { | ||
| return {activeStep: null, totalSteps: 0} | ||
| } | ||
|
|
||
| const step = matchingTour.steps[currentStep] as OnboardingStep | undefined | ||
| return {activeStep: step ?? null, totalSteps: matchingTour.steps.length} | ||
| }, [currentTour, currentStep, onboardingTours]) | ||
|
|
||
| const resolvedSectionFromLocation = useMemo( | ||
| () => userLocation.resolvedSection ?? userLocation.section, | ||
| [userLocation.resolvedSection, userLocation.section], | ||
| ) | ||
|
|
||
| useEffect(() => { | ||
| if (!activeStep?.advanceOnClick || !activeStep.selector || !isNextStepVisible) { | ||
| return | ||
| } | ||
|
|
||
| const handleClick = async (event: MouseEvent) => { | ||
| if (!activeStep.selector) return | ||
|
|
||
| const target = event.target | ||
| if (!(target instanceof Element)) return | ||
|
|
||
| const matchedTarget = target.closest(activeStep.selector) | ||
| if (!matchedTarget) { | ||
| return | ||
| } | ||
|
|
||
| try { | ||
| await activeStep.onNext?.() | ||
| } catch (error) { | ||
| console.error("Failed to run onboarding advance handler", error) | ||
| } | ||
|
|
||
| if (currentStep >= totalSteps - 1) { | ||
| const resolvedSection = | ||
| (activeStep?.onboardingSection as keyof UserOnboardingStatus | undefined) ?? | ||
| resolvedSectionFromLocation | ||
| if (resolvedSection) { | ||
| updateUserOnboardingStatus({section: resolvedSection, status: "done"}) | ||
| } | ||
| setTriggerOnboarding(null) | ||
| closeNextStep() | ||
| return | ||
| } | ||
|
|
||
| setCurrentStep(currentStep + 1) | ||
| } | ||
|
|
||
| document.addEventListener("click", handleClick, true) | ||
| return () => { | ||
| document.removeEventListener("click", handleClick, true) | ||
| } | ||
| }, [ | ||
| activeStep, | ||
| currentStep, | ||
| totalSteps, | ||
| isNextStepVisible, | ||
| closeNextStep, | ||
| setCurrentStep, | ||
| resolvedSectionFromLocation, | ||
| setTriggerOnboarding, | ||
| updateUserOnboardingStatus, | ||
| ]) | ||
|
|
||
| return null | ||
| } | ||
|
|
||
| export default OnboardingAutoAdvance |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First check the below asnwer for better context. Since we have added a patch directory, we need to add that on dockerfile as well