From db01eafb245464533df0a5bda6fc57b92e26fa20 Mon Sep 17 00:00:00 2001 From: Matthias Nannt Date: Fri, 2 Sep 2022 16:18:26 +0200 Subject: [PATCH] remove user fingerprinting --- components/results/ResultsInsights.tsx | 17 ++++++----------- components/results/ResultsSummary.tsx | 11 +++-------- lib/submissionSessions.ts | 7 +------ package.json | 2 +- .../api/forms/[id]/submissionSessions/index.ts | 13 +++++-------- pages/forms/[id]/results/insights.tsx | 2 +- .../migration.sql | 8 ++++++++ prisma/schema.prisma | 1 - yarn.lock | 18 +++++------------- 9 files changed, 30 insertions(+), 49 deletions(-) create mode 100644 prisma/migrations/20220902135652_remove_session_fingerprint/migration.sql diff --git a/components/results/ResultsInsights.tsx b/components/results/ResultsInsights.tsx index 19ba1040da..603824d16d 100644 --- a/components/results/ResultsInsights.tsx +++ b/components/results/ResultsInsights.tsx @@ -21,18 +21,12 @@ export default function ResultsAnalytics({ formId }) { const stats = useMemo(() => { if (analytics) { return [ - { - id: "uniqueUsers", - name: "Unique Users", - stat: analytics.uniqueUsers || "--", - toolTipText: "Tracked without cookies using fingerprinting technique", - trend: undefined, - }, { id: "totalSubmissions", name: "Total Submissions", stat: analytics.totalSubmissions || "--", trend: undefined, + toolTipText: undefined, }, { id: "lastSubmission", @@ -41,6 +35,7 @@ export default function ResultsAnalytics({ formId }) { ? timeSince(analytics.lastSubmissionAt) : "--", smallerText: true, + toolTipText: undefined, }, ]; } @@ -51,10 +46,10 @@ export default function ResultsAnalytics({ formId }) { } return ( - <> -

Analytics

+
+

Analytics

-
+
{stats.map((item) => (
- + ); } diff --git a/components/results/ResultsSummary.tsx b/components/results/ResultsSummary.tsx index dfc10956b7..78ed2146a9 100644 --- a/components/results/ResultsSummary.tsx +++ b/components/results/ResultsSummary.tsx @@ -33,18 +33,12 @@ export default function ResultsSummary({ formId }) { const stats = useMemo(() => { if (insights) { return [ - { - id: "uniqueUsers", - name: "Unique Users", - stat: insights.uniqueUsers || "--", - toolTipText: "Tracked without cookies using fingerprinting technique", - trend: undefined, - }, { id: "totalSubmissions", name: "Total Submissions", stat: insights.totalSubmissions || "--", trend: undefined, + toolTipText: undefined, }, { id: "lastSubmission", @@ -53,6 +47,7 @@ export default function ResultsSummary({ formId }) { ? timeSince(insights.lastSubmissionAt) : "--", smallerText: true, + toolTipText: undefined, }, ]; } @@ -67,7 +62,7 @@ export default function ResultsSummary({ formId }) {

Responses Overview

-
+
{stats.map((item) => ( { export const getSubmissionAnalytics = ( submissionSessions: SubmissionSession[] ) => { - const uniqueUsers = []; let totalSubmissions = 0; let lastSubmissionAt = null; for (const submissionSession of submissionSessions) { // collect unique users - if (!uniqueUsers.includes(submissionSession.userFingerprint)) { - uniqueUsers.push(submissionSession.userFingerprint); - } if (submissionSession.events.length > 0) { totalSubmissions += 1; const lastSubmission = @@ -84,7 +80,6 @@ export const getSubmissionAnalytics = ( } return { lastSubmissionAt, - uniqueUsers: uniqueUsers.length, totalSubmissions: totalSubmissions, }; }; @@ -155,4 +150,4 @@ export const getSubmissionSummary = ( } } return summary; -}; \ No newline at end of file +}; diff --git a/package.json b/package.json index 5ca53713f0..7fd1a7fde5 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@headlessui/react": "^1.6.1", "@heroicons/react": "^2.0.8", "@prisma/client": "^4.2.1", - "@snoopforms/react": "^0.2.2", + "@snoopforms/react": "^0.3.0", "bcryptjs": "^2.4.3", "chart.js": "^3.8.2", "crypto": "^1.0.1", diff --git a/pages/api/forms/[id]/submissionSessions/index.ts b/pages/api/forms/[id]/submissionSessions/index.ts index 6bd44ed20e..418eeda92c 100644 --- a/pages/api/forms/[id]/submissionSessions/index.ts +++ b/pages/api/forms/[id]/submissionSessions/index.ts @@ -27,12 +27,10 @@ export default async function handle( // check if user is form owner const ownership = await formHasOwnership(session, formId); if (!ownership) { - return res - .status(401) - .json({ - message: - "You are not authorized to access this form and their submissions", - }); + return res.status(401).json({ + message: + "You are not authorized to access this form and their submissions", + }); } const submissionSessionsData = await prisma.submissionSession.findMany({ @@ -57,9 +55,8 @@ export default async function handle( // Required fields in body: - // Optional fields in body: - if (req.method === "POST") { - const { userFingerprint } = req.body; const prismaRes = await prisma.submissionSession.create({ - data: { userFingerprint, form: { connect: { id: formId } } }, + data: { form: { connect: { id: formId } } }, }); return res.json(prismaRes); } diff --git a/pages/forms/[id]/results/insights.tsx b/pages/forms/[id]/results/insights.tsx index 4ca97ebdc7..db24d4cd9f 100644 --- a/pages/forms/[id]/results/insights.tsx +++ b/pages/forms/[id]/results/insights.tsx @@ -33,7 +33,7 @@ function ResultsInsightsPage() { breadcrumbs={[{ name: form?.name, href: "#", current: true }]} steps={formMenuSteps} currentStep="results" - limitHeightScreen={true} + limitHeightScreen={false} >