From 186feefdb5d08ac64420f93de1bb67bcace0b716 Mon Sep 17 00:00:00 2001 From: Matti Nannt Date: Thu, 22 Feb 2024 19:18:06 +0100 Subject: [PATCH] chore: caching optimisations in sync endpoints (#2111) Co-authored-by: Johannes <72809645+jobenjada@users.noreply.github.com> --- apps/demo/pages/app/index.tsx | 5 +- .../app/docs/api/client/actions/page.mdx | 6 +- apps/web/app/api/cron/report-usage/route.ts | 3 +- apps/web/app/api/cron/weekly_summary/route.ts | 3 +- .../app/api/google-sheet/callback/route.ts | 5 +- .../app/api/internal/csv-conversion/route.ts | 4 +- .../api/internal/excel-conversion/route.ts | 4 +- apps/web/app/api/pipeline/route.ts | 3 +- .../people/[userId]/set-attribute/route.ts | 5 +- .../displays/[displayId]/responded/route.ts | 5 +- .../client/displays/[displayId]/route.ts | 5 +- .../api/v1/(legacy)/client/displays/route.ts | 5 +- .../people/[personId]/set-attribute/route.ts | 5 +- .../client/responses/[responseId]/route.ts | 5 +- .../api/v1/(legacy)/client/responses/route.ts | 5 +- .../app/api/v1/(legacy)/js/actions/route.ts | 5 +- .../people/[personId]/set-attribute/route.ts | 5 +- .../js/people/[personId]/set-user-id/route.ts | 5 +- apps/web/app/api/v1/(legacy)/js/sync/route.ts | 5 +- apps/web/app/api/v1/auth.ts | 3 +- .../client/[environmentId]/actions/route.ts | 5 +- .../displays/[displayId]/route.ts | 5 +- .../client/[environmentId]/displays/route.ts | 5 +- .../in-app/sync/[userId]/route.ts | 24 +- .../[environmentId]/in-app/sync/route.ts | 6 +- .../[environmentId]/people/[userId]/route.ts | 33 +- .../responses/[responseId]/route.ts | 5 +- .../client/[environmentId]/responses/route.ts | 5 +- .../[environmentId]/storage/local/route.ts | 8 +- .../client/[environmentId]/storage/route.ts | 6 +- .../integrations/airtable/callback/route.ts | 4 +- .../v1/integrations/notion/callback/route.ts | 6 +- .../action-classes/[actionClassId]/route.ts | 10 +- .../api/v1/management/action-classes/route.ts | 3 +- .../[attributeClassId]/route.ts | 10 +- .../v1/management/attribute-classes/route.ts | 3 +- apps/web/app/api/v1/management/me/route.ts | 5 +- .../v1/management/people/[personId]/route.ts | 33 +- .../web/app/api/v1/management/people/route.ts | 14 - .../responses/[responseId]/route.ts | 10 +- .../api/v1/management/storage/local/route.ts | 4 +- .../app/api/v1/management/storage/route.ts | 4 +- .../v1/management/surveys/[surveyId]/route.ts | 16 +- .../app/api/v1/management/surveys/route.ts | 3 +- apps/web/app/api/v1/memberships/route.ts | 42 -- .../app/api/v1/users/forgot-password/route.ts | 8 +- apps/web/app/api/v1/users/me/route.ts | 10 +- .../app/api/v1/users/reset-password/route.ts | 8 +- apps/web/app/api/v1/users/route.ts | 14 +- .../api/v1/users/verification-email/route.ts | 10 +- apps/web/app/api/v1/webhooks/route.ts | 3 +- apps/web/app/lib/api/response.ts | 57 +- apps/web/package.json | 26 +- apps/web/vercel.json | 2 +- packages/api/src/api/client/people.ts | 5 +- packages/js/src/lib/actions.ts | 26 +- packages/js/src/lib/config.ts | 2 +- packages/js/src/lib/initialize.ts | 12 +- packages/js/src/lib/person.ts | 23 +- packages/js/src/lib/sync.ts | 34 +- packages/js/src/lib/utils.ts | 1 + packages/js/src/lib/widget.ts | 13 +- packages/lib/action/service.ts | 3 +- packages/types/actions.ts | 1 - packages/types/js.ts | 2 - pnpm-lock.yaml | 499 ++++++++---------- 66 files changed, 494 insertions(+), 625 deletions(-) delete mode 100644 apps/web/app/api/v1/memberships/route.ts create mode 100644 packages/js/src/lib/utils.ts diff --git a/apps/demo/pages/app/index.tsx b/apps/demo/pages/app/index.tsx index 180a742c3d..3abd8a007b 100644 --- a/apps/demo/pages/app/index.tsx +++ b/apps/demo/pages/app/index.tsx @@ -29,7 +29,6 @@ export default function AppPage({}) { environmentId: process.env.NEXT_PUBLIC_FORMBRICKS_ENVIRONMENT_ID, apiHost: process.env.NEXT_PUBLIC_FORMBRICKS_API_HOST, userId, - debug: true, attributes, }); window.formbricks = formbricks; @@ -105,8 +104,8 @@ export default function AppPage({}) { Reset person / pull data from Formbricks app

- On formbricks.reset() a few things happen: New person is created and{" "} - surveys & no-code actions are pulled from Formbricks:. + On formbricks.reset() the local state will be deleted and formbricks gets{" "} + reinitialized.