{"id":22957366,"url":"https://github.com/biohacker0/detection-tracking-hooks","last_synced_at":"2026-07-11T02:31:27.597Z","repository":{"id":224946193,"uuid":"764663102","full_name":"biohacker0/Detection-Tracking-Hooks","owner":"biohacker0","description":"A library of hooks to know what thing someone copied, how much time they spent on a page, track their session data, detect print requests on pages, page view counts etc","archived":false,"fork":false,"pushed_at":"2024-02-28T14:04:48.000Z","size":333,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-24T12:40:53.468Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/biohacker0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-02-28T13:44:57.000Z","updated_at":"2024-02-28T13:46:01.000Z","dependencies_parsed_at":"2024-02-28T15:05:57.233Z","dependency_job_id":null,"html_url":"https://github.com/biohacker0/Detection-Tracking-Hooks","commit_stats":null,"previous_names":["biohacker0/detection-tracking-hooks"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/biohacker0/Detection-Tracking-Hooks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biohacker0%2FDetection-Tracking-Hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biohacker0%2FDetection-Tracking-Hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biohacker0%2FDetection-Tracking-Hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biohacker0%2FDetection-Tracking-Hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/biohacker0","download_url":"https://codeload.github.com/biohacker0/Detection-Tracking-Hooks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biohacker0%2FDetection-Tracking-Hooks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35349259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-11T02:00:05.354Z","response_time":104,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-14T17:16:20.437Z","updated_at":"2026-07-11T02:31:27.580Z","avatar_url":"https://github.com/biohacker0.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"This repository contains custom React hooks designed to enhance your application's functionality in various aspects including copy detection, error tracking, print detection, page view tracking, and measuring time spent on a page.\n\n## Table of Contents\n\n1. [Introduction](#introduction)\n2. [Installation](#installation)\n3. [Usage](#usage)\n    - [useCopyDetection](#usecopydetection)\n    - [useErrorTracking](#useerrortracking)\n    - [usePrintDetection](#useprintdetection)\n    - [usePageViewTracking](#usepageviewtracking)\n    - [useTimeSpentOnPage](#usetimespentonpage)\n\n## Introduction\n\nThis collection of custom hooks provides convenient solutions to common problems faced in web development when working with React applications. Each hook serves a specific purpose and can be easily integrated into your project to enhance user experience and developer productivity.\n\n## Installation\n\nTo use these custom hooks in your React project, you can simply copy the hook files (`useCopyDetection.js`, `useErrorTracking.js`, `usePrintDetection.js`, `usePageViewTracking.js`, `useTimeSpentOnPage.js`) into your project's directory. Make sure to adjust the import paths according to your project structure.\n\n## Usage\n\n### useCopyDetection\n\nThis hook detects when text is copied on the webpage and invokes a callback function with the copied text as a parameter.\n\n```javascript\nimport { useState } from 'react';\nimport useCopyDetection from './useCopyDetection';\n\nconst App = () =\u003e {\n  const handleCopy = (copiedText) =\u003e {\n    console.log(\"Copied text:\", copiedText);\n    // Perform actions with the copied text\n  };\n  useCopyDetection(handleCopy);\n\n  return (\n    // Your JSX components\n  );\n};\n\n```\n\n### useErrorTracking\n\nThis hook tracks errors that occur within your application and sends them to a designated error tracking service.\n\n```javascript\nimport useErrorTracking from './useErrorTracking';\n\nconst App = () =\u003e {\n   useErrorTracking();\n  // Simulate an error\n  const throwError = () =\u003e {\n    throw new Error(\"This is a test error\");\n  };\n\n  return (\n         \u003cdiv\u003e\n        \u003ch1\u003eError Tracking Test\u003c/h1\u003e\n        \u003cbutton onClick={throwError}\u003eThrow Error\u003c/button\u003e\n      \u003c/div\u003e\n  );\n};\n\n```\n\n### usePrintDetection\n\nThis hook detects when the user initiates a print action on the webpage.\n\n```javascript\nimport { useState } from 'react';\nimport usePrintDetection from './usePrintDetection';\n\nconst App = () =\u003e {\n  const [isPrinting, setIsPrinting] = useState(false);\n  usePrintDetection(setIsPrinting);\n\n  return (\n        \u003cdiv\u003e\n        \u003ch1\u003ePrint Detection Test\u003c/h1\u003e\n        \u003cp\u003eIs Printing: {isPrinting ? \"Yes\" : \"No\"}\u003c/p\u003e\n      \u003c/div\u003e\n  );\n}\n\n```\n\n### usePageViewTracking\n\nThis hook tracks the number of page views using session storage.\n\n```javascript\nimport { useEffect, useState } from 'react';\nimport usePageViewTracking from './usePageViewTracking';\n\nconst App = () =\u003e {\n  const [pageViews, setPageViews] = useState(0);\n\n  useEffect(() =\u003e {\n    const pageViews = parseInt(sessionStorage.getItem(\"page_view_tracker_page_views\"), 10) || 0;\n    setPageViews(pageViews);\n    console.log(\"Page Views:\", pageViews);\n  }, []);\n\n  usePageViewTracking(); // Make sure to call usePageViewTracking after initializing the state\n\n  return (\n    // Your JSX components\n  );\n};\n\n```\n\n### useTimeSpentOnPage\n\nThis hook measures the time spent by the user on the current page.\n\n```javascript\nimport useTimeSpentOnPage from './useTimeSpentOnPage';\n\nconst App = () =\u003e {\n  const timeSpent = useTimeSpentOnPage();\n\n  return (\n        \u003cdiv\u003e\n        \u003ch1\u003eTime Spent On Page Test\u003c/h1\u003e\n        \u003cp\u003eTime Spent On Page: {timeSpent} seconds\u003c/p\u003e\n      \u003c/div\u003e\n  );\n};\n\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiohacker0%2Fdetection-tracking-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbiohacker0%2Fdetection-tracking-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiohacker0%2Fdetection-tracking-hooks/lists"}