Skip to content

Conversation

@Dhruwang
Copy link
Member

What does this PR do?

Fixes FOR-1445

  • Created a new service function getActionsByPersonId
  • Added pagination to activity timeline
  • Now we display only actions in activity timeline
  • Deleted Activity service
Screen-Recording-2023-10-26-at-10.19.52.PM.mp4

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change adds a new database migration
  • This change requires a documentation update

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read How we Code at Formbricks
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand bits
  • Ran pnpm build
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues
  • First PR at Formbricks? Please sign the CLA! Without it we wont be able to merge it 🙏

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Formbricks Docs if changes were necessary

@vercel
Copy link

vercel bot commented Oct 26, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
formbricks-cloud ⬜️ Ignored (Inspect) Visit Preview Oct 30, 2023 0:09am
formbricks-com ⬜️ Ignored (Inspect) Visit Preview Oct 30, 2023 0:09am

@github-actions
Copy link
Contributor

github-actions bot commented Oct 26, 2023

Thank you for following the naming conventions for pull request titles! 🙏

@review-agent-prime
Copy link
Contributor

The changes in this PR are generally well done. However, there are a few areas that could be improved:

  1. In ActivityFeed.tsx, the ITEMS_PER_PAGE constant is defined inside the ActivityFeed function. This constant could be moved outside of the function to avoid redefining it on every render.
const ITEMS_PER_PAGE = 5;

export default function ActivityFeed({ actions, sortByDate, environment }: ActivityFeedProps) {
  // ...
}
  1. In ActivityItemComponents.tsx, the ActivityItemIcon and ActivityItemContent components are not handling the case when actionItem.actionClass is undefined. This could potentially lead to a runtime error. You should add a check for this case.
export const ActivityItemIcon = ({ actionItem }: { actionItem: TAction }) => (
  <div className="h-12 w-12 rounded-full bg-white p-3 text-slate-500  duration-100 ease-in-out group-hover:scale-110 group-hover:text-slate-600">
    {actionItem.actionClass && (
      <div>
        {actionItem.actionClass.type === "code" && <CodeBracketIcon />}
        {actionItem.actionClass.type === "noCode" && <CursorArrowRaysIcon />}
        {actionItem.actionClass.type === "automatic" && <SparklesIcon />}
      </div>
    )}
  </div>
);
  1. In ActivityItemPopover component, you are assuming that actionItem.actionClass is not undefined. This could potentially lead to a runtime error. You should add a check for this case.
export const ActivityItemPopover = ({
  actionItem,
  children,
}: {
  actionItem: TAction;
  children: React.ReactNode;
}) => {
  return (
    <Popover>
      <PopoverTrigger className="group">{children}</PopoverTrigger>
      <PopoverContent className="bg-white">
        <div>
          {actionItem.actionClass && (
            <div>
              <Label className="font-normal text-slate-400">Action Label</Label>
              <p className=" mb-2 text-sm font-medium text-slate-900">{actionItem.actionClass.name}</p>
              <Label className="font-normal text-slate-400">Action Description</Label>
              <p className="text-sm font-medium text-slate-900">{actionItem.actionClass.description}</p>
              <Label className="font-normal text-slate-400">Action Type</Label>
              <p className="text-sm font-medium text-slate-900">{actionItem.actionClass.type}</p>
            </div>
          )}
        </div>
      </PopoverContent>
    </Popover>
  );
};
  1. In service.ts, the getActionsByPersonId function is not handling the case when action.eventClass is undefined. This could potentially lead to a runtime error. You should add a check for this case.
actionsPrisma.forEach((action) => {
  actions.push({
    id: action.id,
    createdAt: action.createdAt,
    sessionId: action.sessionId,
    properties: action.properties,
    actionClass: action.eventClass || null,
  });
});
  1. In loading.tsx, the actionItemList array contains two items with the same id value. This could potentially lead to issues with React's key prop in lists. You should ensure that all items in a list have unique id values.
const actionItemList: TAction[] = [
  {
    id: "demoId1",
    // ...
  },
  {
    id: "demoId2",
    // ...
  },
];

Copy link
Member

@mattinannt mattinannt left a comment

Choose a reason for hiding this comment

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

🙏👍
I changed the behaviour a bit since a problem came up where users might have thousands of actions inside their account. To solve this I'm now getting the first page from the backend and to make displays even easier, I only show the last 10 actions here and fade them out.

@mattinannt mattinannt enabled auto-merge October 30, 2023 12:09
@mattinannt mattinannt added this pull request to the merge queue Oct 30, 2023
Merged via the queue into main with commit 2e2c22a Oct 30, 2023
@mattinannt mattinannt deleted the migrate-activity-service branch October 30, 2023 12:24
kevinkong91 added a commit to kevinkong91/formbricks that referenced this pull request Oct 30, 2023
* main: (28 commits)
  chore: Add Table of Contents to README (formbricks#1427)
  fix: account deletion failing issue (formbricks#1509)
  fix: remove welcome card from email preview (formbricks#1495)
  fix(bug): default role implemented (formbricks#1524)
  fix: changing description of Code Action (formbricks#1522)
  refactor: Migrate activity service (formbricks#1471)
  fix: Error in Docs navigation formbricks#1518 (formbricks#1521)
  feat: dynamic title and description (formbricks#1459)
  fix: Spelling Errors (formbricks#1517)
  fix: added scrollbar whenever overflowed in the settings/profile page (formbricks#1498)
  fix: long url not getting reset after closing modal (formbricks#1502)
  fix: Unexpected Behavior when Toggling Italics in Text Editor and improve clarity of formatting status (formbricks#1506)
  fix: zod pin validation failing (formbricks#1507)
  fix: Error message on Login not shown  (formbricks#1508)
  fix: downgrade nextjs to fix error with react email (formbricks#1516)
  chore: downgrade next version in formbricks-com (formbricks#1513)
  feat: picture selection question (formbricks#1388)
  feat: formtribe leaderboard update as per today (formbricks#1505)
  fix: Added if statement for preventing use of reserved word in question ID (formbricks#1435)
  fix: Disabling Welcome Card leads buggy preview (formbricks#1320)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants