{"_id":"@altcha/tracker","_rev":"2-0de620e78bc246ea47686c2bcb5f990c","name":"@altcha/tracker","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@altcha/tracker","version":"0.1.0","keywords":["altcha","analytics","statistics","tracker","svelte"],"author":{"url":"https://altcha.org","name":"Daniel Regeci"},"license":"MIT","_id":"@altcha/tracker@0.1.0","maintainers":[{"name":"ovx","email":"getc88@gmail.com"}],"homepage":"https://altcha.org","bugs":{"url":"https://github.com/altcha-org/tracker/issues"},"dist":{"shasum":"70657621f9d71753f16a938773acaa65d16a846e","tarball":"https://registry.npmjs.org/@altcha/tracker/-/tracker-0.1.0.tgz","fileCount":6,"integrity":"sha512-ZA2NYHT29Y5nPNcD4krpd/sM9ogT1eWbPfLwaq+Ex31fiSBNJnes8Nn0M/WaWVoV0n5r0q9OEcb+gb2patjLFA==","signatures":[{"sig":"MEYCIQDGckT8AlFXktzyUVklgW90C0TtfZX0K+g1/mBW9wHozAIhANkJnO6dmwsIuf8VJMAU6RtZwUmgO7axQnMeMGfdjDdv","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@altcha%2ftracker@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":44846},"main":"./dist/tracker.umd.cjs","type":"module","module":"./dist/tracker.js","exports":{".":{"import":"./dist/tracker.js","require":"./dist/tracker.umd.cjs"}},"gitHead":"0a6a6698643cb9224be2fb463c30068784445f60","scripts":{"dev":"vite","test":"vitest run","build":"npm run build:module && npm run build:bundle","format":"prettier --write ./src/**/*","prepare":"husky","preview":"vite preview","build:bundle":"rimraf dist_bundle && tsc && vite build -c vite.bundle.config.js","build:module":"rimraf dist && tsc && vite build -c vite.config.js"},"_npmUser":{"name":"ovx","email":"getc88@gmail.com"},"repository":{"url":"git+https://github.com/altcha-org/tracker.git","type":"git"},"_npmVersion":"10.8.2","description":"JavaScript client for ALTCHA Analytics.","directories":{},"_nodeVersion":"20.17.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^5.4.1","husky":"^9.1.6","jsdom":"^25.0.1","rimraf":"^6.0.1","vitest":"^2.1.1","prettier":"^3.3.3","typescript":"^5.5.3"},"optionalDependencies":{"@rollup/rollup-linux-x64-gnu":"4.18.0"},"_npmOperationalInternal":{"tmp":"tmp/tracker_0.1.0_1728648232304_0.5431149537894755","host":"s3://npm-registry-packages"}},"0.1.1":{"name":"@altcha/tracker","version":"0.1.1","keywords":["altcha","analytics","statistics","tracker","svelte"],"author":{"url":"https://altcha.org","name":"Daniel Regeci"},"license":"MIT","_id":"@altcha/tracker@0.1.1","maintainers":[{"name":"ovx","email":"getc88@gmail.com"}],"homepage":"https://altcha.org","bugs":{"url":"https://github.com/altcha-org/tracker/issues"},"dist":{"shasum":"13edff53fc9de028fcb71aae2632b26de151160b","tarball":"https://registry.npmjs.org/@altcha/tracker/-/tracker-0.1.1.tgz","fileCount":6,"integrity":"sha512-IuQP3WO6UWG7d/yWuDIJQN+ftzLiIgIxUH4jd4hztxEFXCvhrSrQTBspQG0xznQc/P8S5xnn03InPpNKsDvA4Q==","signatures":[{"sig":"MEUCIQDHrz6u0W1hMr8x9vZxAwOIkYfHlILkNuvp8YLg1YkJiwIgdi3R0v/1wqibREjfAgXBQBTFdS9WNOgwn/VOdnEq/IY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@altcha%2ftracker@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":44847},"main":"./dist/tracker.umd.cjs","type":"module","module":"./dist/tracker.js","exports":{".":{"import":"./dist/tracker.js","require":"./dist/tracker.umd.cjs"}},"gitHead":"1ce8ed008f127eea2d0d67b6331daeda09a242d9","scripts":{"dev":"vite","test":"vitest run","build":"npm run build:module && npm run build:bundle","format":"prettier --write ./src/**/*","prepare":"husky","preview":"vite preview","build:bundle":"rimraf dist_bundle && tsc && vite build -c vite.bundle.config.js","build:module":"rimraf dist && tsc && vite build -c vite.config.js"},"_npmUser":{"name":"ovx","email":"getc88@gmail.com"},"repository":{"url":"git+https://github.com/altcha-org/tracker.git","type":"git"},"_npmVersion":"10.8.2","description":"JavaScript client for ALTCHA Analytics.","directories":{},"_nodeVersion":"20.17.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^5.4.1","husky":"^9.1.6","jsdom":"^25.0.1","rimraf":"^6.0.1","vitest":"^2.1.1","prettier":"^3.3.3","typescript":"^5.5.3"},"optionalDependencies":{"@rollup/rollup-linux-x64-gnu":"4.18.0"},"_npmOperationalInternal":{"tmp":"tmp/tracker_0.1.1_1728718265809_0.6069885074169072","host":"s3://npm-registry-packages"}},"0.2.0":{"name":"@altcha/tracker","description":"JavaScript client for ALTCHA Analytics.","version":"0.2.0","license":"MIT","author":{"name":"Daniel Regeci","url":"https://altcha.org"},"homepage":"https://altcha.org","repository":{"type":"git","url":"git+https://github.com/altcha-org/tracker.git"},"type":"module","keywords":["altcha","analytics","statistics","tracker","svelte"],"main":"./dist/tracker.umd.cjs","module":"./dist/tracker.js","exports":{".":{"import":"./dist/tracker.js","require":"./dist/tracker.umd.cjs"}},"scripts":{"dev":"vite","build":"npm run build:module && npm run build:bundle","build:module":"rimraf dist && tsc && vite build -c vite.config.js","build:bundle":"rimraf dist_bundle && tsc && vite build -c vite.bundle.config.js","format":"prettier --write ./src/**/*","preview":"vite preview","test":"vitest run","prepare":"husky"},"devDependencies":{"husky":"^9.1.6","jsdom":"^25.0.1","prettier":"^3.3.3","rimraf":"^6.0.1","typescript":"^5.5.3","vite":"^5.4.1","vitest":"^2.1.1"},"optionalDependencies":{"@rollup/rollup-linux-x64-gnu":"4.18.0"},"_id":"@altcha/tracker@0.2.0","gitHead":"534460fe9bdca06ffd30f625f3f68a919847d650","bugs":{"url":"https://github.com/altcha-org/tracker/issues"},"_nodeVersion":"20.17.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-AHwRiiRAi0P4+SBmMGmrXy5qdhpiQTVsptf1sDxv6vlLhaXoQ2XBL9VV0pqrkY/wid1tDbPmxcpvjy4XXJdNkA==","shasum":"b27a63286b5be8af58b2c029dae2954d97067583","tarball":"https://registry.npmjs.org/@altcha/tracker/-/tracker-0.2.0.tgz","fileCount":6,"unpackedSize":51442,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@altcha%2ftracker@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQClrJhfD36O1zQYMEcv4YxruysQl9Ata6pdWrBgm9WA9AIhAPaT+sOlM/WFx59WwY6You4gtfVe2+ZhMz4NLfwkRihn"}]},"_npmUser":{"name":"ovx","email":"getc88@gmail.com"},"directories":{},"maintainers":[{"name":"ovx","email":"getc88@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tracker_0.2.0_1728872416811_0.7292661509355574"},"_hasShrinkwrap":false}},"time":{"created":"2024-10-11T12:03:52.128Z","modified":"2024-10-14T02:20:17.470Z","0.1.0":"2024-10-11T12:03:52.542Z","0.1.1":"2024-10-12T07:31:05.971Z","0.2.0":"2024-10-14T02:20:17.024Z"},"bugs":{"url":"https://github.com/altcha-org/tracker/issues"},"author":{"name":"Daniel Regeci","url":"https://altcha.org"},"license":"MIT","homepage":"https://altcha.org","keywords":["altcha","analytics","statistics","tracker","svelte"],"repository":{"type":"git","url":"git+https://github.com/altcha-org/tracker.git"},"description":"JavaScript client for ALTCHA Analytics.","maintainers":[{"name":"ovx","email":"getc88@gmail.com"}],"readme":"# ALTCHA Analytics Tracker\n\nThis repository contains the front-end library for collecting analytics data with ALTCHA Analytics.\n\n## Why ALTCHA Analytics?\n\nALTCHA Analytics provides a privacy-first, GDPR-compliant alternative to traditional analytics platforms like Google Analytics. Unlike most other services, it operates without cookies or fingerprinting, ensuring that all data is anonymized by default.\n\n**Key Features**:\n- Compliant with GDPR, CCPA, and PECR regulations\n- No cookies or fingerprinting required\n- Flexible: Use for web, app, or API analytics\n- Customizable event tracking and properties\n- Lightweight (~4kB gzipped)\n\n## Installation & Usage\n\nYou can integrate ALTCHA Analytics in two ways:\n\n1. **Module** (Recommended for modern frameworks such as React, Vue, Angular)\n2. **Script Tag** (Simple HTML inclusion)\n\n### 1. Module Installation (Preferred for Frameworks)\n\nInstall via npm:\n\n```bash\nnpm install @altcha/tracker\n```\n\nInitialize the tracker in your app:\n\n```javascript\nimport { Tracker } from '@altcha/tracker';\n\nconst tracker = new Tracker({\n  projectId: 'pro_...',\n});\n```\n\n### 2. Script Tag Integration\n\nSimply add the following snippet to your HTML:\n\n```html\n<script\n  defer\n  data-project-id=\"pro_...\"\n  src=\"https://eu.altcha.org/js/script.js\"\n></script>\n```\n\nMake sure to replace `\"pro_...\"` with your unique `projectId`.\n\n## Configuration\n\nThe `Tracker` class constructor accepts the following configuration options:\n\n- **`allowSearchParams?: string[]`** – By default, the script removes all query parameters (those after `?` in the URL). Use this option to whitelist specific parameters that should be tracked.\n- **`apiUrl?: string`** – Override the default API URL for reporting events.\n- **`appVersion?: string`** – Track the version of your application (max 12 characters).\n- **`click?: IBaseExtensionOptions | boolean`** – Disable or configure the `click` extension (see below for details).\n- **`cookie?: ICookieExtensionOptions | boolean`** – Disable or configure the `cookie` extension.\n- **`debug?: boolean`** – Enable debug mode for logging.\n- **`globalName?: string | null | false`** – Override the default global variable name for the Tracker instance. Set to `null` to skip global registration.\n- **`hash?: IBaseExtensionOptions | boolean`** – Disable or configure the `hash` extension.\n- **`keyboard?: IBaseExtensionOptions | boolean`** – Disable or configure the `keyboard` extension.\n- **`mouse?: IBaseExtensionOptions | boolean`** – Disable or configure the `mouse` extension.\n- **`projectId: string`** – Required ALTCHA project ID (format: `pro_{unique_id}`).\n- **`pushstate?: IBaseExtensionOptions | boolean`** – Disable or configure the `pushstate` extension.\n- **`respectDnt?: boolean`** – When `true`, the tracker will not report any events if the user's browser is configured with `Do Not Track` or `globalPrivacyControl`.\n- **`uniqueId?: string`** – Provide the user's unique ID, if applicable, to track returning visitors.\n- **`visibility?: IVisibilityExtensionOptions | boolean`** – Disable or configure the `visibility` extension.\n\nThese options can also be provided as attributes in the `<script>` tag, for example: `data-project-id=\"pro_...\"`.\n\n### Example Configuration:\n\n```javascript\nnew Tracker({\n  projectId: 'pro_...',\n  appVersion: 'v1.0.1',\n  debug: true,\n  respectDnt: true,\n  allowSearchParams: ['page_id'],\n});\n```\n\n### HTML Example Configuration:\n\n```html\n<script\n  defer\n  data-project-id=\"pro_...\"\n  data-app-version=\"v1.0.1\"\n  data-debug=\"true\"\n  data-respect-dnt=\"true\"\n  src=\"https://eu.altcha.org/js/script.js\"\n></script>\n```\n\n## Extensions\n\nTracking features are provided through \"extensions,\" which can be individually enabled or disabled depending on your needs and privacy concerns.\n\n### Click\n\nEnabled by default.  \n\nTracks user mouse/pointer interactions, detecting exit events and outbound links.\n\n### Cookie\n\nDisabled by default.  \n\nThe `cookie` extension tracks returning visitors by setting a small cookie (`_altcha_visited=1`) that expires in 30 days.\n\nYou can configure this extension with the following options:\n\n```js\nnew Tracker({\n  projectId: '...',\n  cookie: {\n    // Cookie expiration in days\n    cookieExpireDays: 30,\n    // Cookie name\n    cookieName: '_altcha_visited',\n    // Cookie path (defaults to '/')\n    cookiePath: '/',\n  }\n})\n```\n\nNote: Enabling this extension may require user consent under GDPR.\n\n### Filter\n\nEnabled by default.\n\nEvent filtering allows you to exclude events based on the user-agent, hostname, or a custom filter function. This helps you ensure only relevant events are tracked.\n\nBy default, the filtering extension ignores:\n\n- Bots and crawlers.\n- Private hostnames such as `localhost`, `127.0.0.1`, and `*.local`.\n\nYou can also manually prevent your own events from being tracked by setting `localStorage.altcha_ignore=true` in the browser.\n\n```js\nnew Tracker({\n  projectId: '...',\n  filter: {\n    // Set to true to allow reporting of events made by bots and crawlers (default: false).\n    allowBots: true,\n    \n    // A custom function for additional event filtering. \n    // Return `false` to ignore the event, or `undefined` to continue with the built-in checks.\n    checkFn: (event) => {\n      return false;  // Example: Ignore all events.\n    },\n    \n    // An array of hostnames to ignore from tracking.\n    // Override the default list of private hostnames.\n    hostnames: ['localhost'],\n  }\n});\n```\n\n### Hash\n\nDisabled by default.  \n\nTracks the `#hash` part of the URL when using hash-based routing in your application.\n\n### Keyboard\n\nEnabled by default.  \n\nDetects exit events triggered by keyboard shortcuts (e.g., closing the tab).\n\n### Mouse\n\nEnabled by default.  \n\nDetects exit events triggered by pointer (e.g., closing the tab using the mouse).\n\n### PushState\n\nEnabled by default.  \n\nAutomatically detects pageviews when `history.pushState()` is called. If disabled, use `.trackPageview()` or `.trackEvent()` to manually report events.\n\n### Visibility\n\nEnabled by default.  \n\nTracks exit events when the tab/window is hidden during page unload.\n\n## Implementation Details\n\nThis script reports collected events in bulk when the page unloads, using the [`sendBeacon()`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon) function. You can configure the API endpoint via the `apiUrl` option.\n\n### Exit Events\n\nExit events are reported when the user leaves the website (e.g., by closing the tab or navigating elsewhere).  \nTo track these events accurately, ensure the following extensions are enabled: `click`, `keyboard`, `mouse`, `visibility`. Disabling these will reduce the accuracy of visit duration data.\n\n### Respect for Privacy (Do Not Track)\n\nIf you respect users' privacy preferences and want to disable tracking when `Do Not Track` is enabled in the browser, you can set the `respectDnt` option to `true`.\n\n```javascript\nnew Tracker({\n  projectId: '...',\n  respectDnt: true, // disable tracking for users with Do Not Track enabled\n});\n```\n\n### Debug Mode\n\nEnabling `debug` mode logs additional information to the browser console, which is helpful for development purposes.\n\n```javascript\nnew Tracker({\n  projectId: '...',\n  debug: true, // enable debug logging\n});\n```\n\n## API Reference\n\nThe following is a quick overview of the main methods available in the ALTCHA Analytics tracker:\n\n- `trackPageview(event: IEvent, unload: boolean = false)`: Track page views.\n- `trackEvent(event: IEvent, unload: boolean = false)`: Track custom events.\n- `destroy()`: Destroys the tracker instance.\n\n### Types\n\nFor TypeScript types and interfaces, see [/src/types.ts](/src/types.ts).\n\n\n## License\n\nALTCHA Analytics is licensed under the MIT License. See the `LICENSE` file for more details.\n","readmeFilename":"README.md"}