Skip to content

Commit

Permalink
feat: use uuid instead of fingerprintjs (#20)
Browse files Browse the repository at this point in the history
* feat: use uuid instead of fingerprintjs

* feat: remove fingerprintjs from dependencies

---------

Co-authored-by: punpunkeshin05 <[email protected]>
  • Loading branch information
punchanabu and punchanabu authored Mar 30, 2024
1 parent 9537880 commit aa99712
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 37 deletions.
5 changes: 2 additions & 3 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
"lint": "next lint"
},
"dependencies": {
"@fingerprintjs/fingerprintjs": "^4.2.2",
"axios": "^1.6.8",
"js-cookie": "^3.0.5",
"next": "14.1.4",
"react": "^18",
"react-dom": "^18",
"socket.io-client": "^4.7.5",
"uuid": "^9.0.1",
"universal-cookie": "^7.1.0"
"universal-cookie": "^7.1.0",
"uuid": "^9.0.1"
},
"devDependencies": {
"@types/js-cookie": "^3.0.6",
Expand Down
22 changes: 7 additions & 15 deletions apps/web/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 11 additions & 13 deletions apps/web/src/app/(screen)/screen/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { useEffect, useState } from "react";
import OverLay from "./components/Overlay";
import Display from "./components/Display";
import Cookies from "universal-cookie";
import FingerprintJS from "@fingerprintjs/fingerprintjs";
import { Socket, io } from "socket.io-client";
import { v4 as uuidv4 } from 'uuid';

const Screen = () => {
let fid: string | null = null;
const [showedPage, setShowPage] = useState<"overlay" | "display">("overlay");
const [ data, setData ] = useState({
status: "waiting",
Expand Down Expand Up @@ -61,20 +62,17 @@ const Screen = () => {
};

(async () => {
const savedCid = cookies.get('cid');

if(!cookies.get('fid')){
const fp = await FingerprintJS.load();
const result = await fp.get();
const fid = result.visitorId;
cookies.set('fid', fid)
fid = cookies.get('fid');
if (!fid) {
fid = uuidv4();
cookies.set('fid', fid);
}

const fid = cookies.get('fid')
const savedCid = cookies.get('cid');

const extraHeaders: { [key: string]: string } = {
fid: fid,
name: 'pun1'
fid: fid || '',
name: 'john'
};

if (savedCid) {
Expand Down
9 changes: 3 additions & 6 deletions apps/web/src/app/(user)/shake/[university]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import ShakeComponent from '../../../../components/Shake';
import { useParams, useSearchParams } from "next/navigation";
import { Suspense } from 'react';
import { io, Socket } from "socket.io-client";
import FingerprintJS from '@fingerprintjs/fingerprintjs';
import Cookies from 'universal-cookie';

import { v4 as uuidv4 } from 'uuid';
let shaking: { x: number; y: number; z: number } | undefined;

function normalize(x: number, y: number, z: number) {
Expand Down Expand Up @@ -55,17 +54,15 @@ export default function Shake() {
(async () => {
fid = cookies.get('fid');
if (!fid) {
const fp = await FingerprintJS.load();
const result = await fp.get();
fid = result.visitorId;
fid = uuidv4();
cookies.set('fid', fid);
}


const savedCid = cookies.get('cid');

const extraHeaders: { [key: string]: string } = {
fid: fid,
fid: fid || '',
name: 'john'
};

Expand Down

0 comments on commit aa99712

Please sign in to comment.