Skip to content

fix(dashboard): Improve ux for jit variables #8259

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

Merged
merged 1 commit into from
May 14, 2025
Merged

Conversation

SokratisVidros
Copy link
Contributor

This change affects every step but Email for now A PR for email will follow.

Introduce the concept of JIT variables that are added to JIT namespaces as you type.

When the user types foo, we don't suggest anything. Users can pick a payload from the dropdown, but then they need to click on the payload pill and edit the variable name, which is bad UX.

This PR improves the DX by suggesting the following as the user types foo.

  • "payload.foo"
  • "subscriber.data.foo"

Try it in the preview deployment.

@SokratisVidros SokratisVidros self-assigned this May 7, 2025
Copy link

netlify bot commented May 7, 2025

Deploy Preview for dashboard-v2-novu-staging ready!

Name Link
🔨 Latest commit 01796c0
🔍 Latest deploy log https://app.netlify.com/sites/dashboard-v2-novu-staging/deploys/68246b74786a900008195417
😎 Deploy Preview https://deploy-preview-8259.dashboard-v2.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

// Novu JIT namespaces
const PAYLOAD_NAMESPACE = 'payload';
const SUBSCRIBER_DATA_NAMESPACE = 'subscriber.data';
const STEP_PAYLOAD_REGEX = /^steps\.[^.]+\.events\[\d+\]\.payload/;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the email step, we will also have current; but when iterating over the events we should probably also do current.payload

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct, but this code is not used in the email. We have a different way to calculate them. It will be in a follow up PR.

} else if (!searchText.startsWith(namespace)) {
// For all other values, suggest payload.whatever, subscriber.data.whatever
acc.push({
name: `${namespace}.${searchLower.trim()}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't use searchLower as in the result it will suggest me wrong variable name; for example I have variable in my payload firstName, so I typed {{firstName}}, but in the dropdown it suggests payload.firstname

Screenshot 2025-05-08 at 10 05 16

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the attention to detail. Good catch.

acc.push({
name: `${namespace}.${searchLower.trim()}`,
type: 'variable',
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these doesn't seem to be correct suggestions:

here second variable, and last two
Screenshot 2025-05-08 at 10 09 31

and in this one all them:
Screenshot 2025-05-08 at 10 08 03

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue with the payload.steps and subscriber.data.steps is technically correct, as we can have a payload with a nested steps value. But from the user's perspective, it isn't very clear. So I added a specific rule to exclude them if the term starts with steps.

The sentenceSummary is shown and is boosted as it is defined as steps.digest-event.events. So there is a match.

One way to resolve this is for the special variables to be shown in a separate section in the dropdown. Any other ideas?

Introduce the concept of JIT variables that are added to JIT namespaces as you type.

When the user types foo, we don't suggest anything. Users can pick a payload from the dropdown, but then they need to click on the payload pill, and edit the variable name, which is bad UX.

This PR improves the DX by suggesting the following as the user types foo.

- "payload.foo"
- "subscriber.data.foo"
@SokratisVidros SokratisVidros merged commit 52073bb into next May 14, 2025
26 of 27 checks passed
@SokratisVidros SokratisVidros deleted the payload_ux branch May 14, 2025 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants