{"_id":"9466-utm-tracker","_rev":"8-8b8835b77fd0be301d2751a763593da2","name":"9466-utm-tracker","dist-tags":{"latest":"2.0.1"},"versions":{"1.0.0":{"name":"9466-utm-tracker","version":"1.0.0","keywords":["vue","hooks","utm","tracking","analytics"],"author":"","license":"MIT","_id":"9466-utm-tracker@1.0.0","maintainers":[{"name":"kuaner","email":"kuaner@gmail.com"}],"dist":{"shasum":"5226f7b20d9f35acefc00c9efb5789512f3a9166","tarball":"https://registry.npmjs.org/9466-utm-tracker/-/9466-utm-tracker-1.0.0.tgz","fileCount":6,"integrity":"sha512-5hvoU089C17aGGKzBMN7oKKCE0r3KJ6vrp9X+3HalPBxuwbi03+2go7pTqgw2uziWpiYd/nV75HaIy36kZEgFw==","signatures":[{"sig":"MEQCIDGAhQWksKvYuL/779QFz0Qnlu9vH74c0IufDJQhPcXiAiBMka1AaJeN6ekI7pgdJVlxxu9eiQHjkdkmg2RMZYGAsg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5292},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","gitHead":"54324a9e6a0686ee402359283b2d378b18a4b901","scripts":{"build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"kuaner","email":"kuaner@gmail.com"},"_npmVersion":"10.5.2","description":"Vue 3 hooks for handling UTM parameters in URLs and storing them in cookies","directories":{},"_nodeVersion":"20.12.2","dependencies":{"js-cookie":"^3.0.5"},"_hasShrinkwrap":false,"devDependencies":{"vue":"^3.5.13","typescript":"^5.8.2","@types/node":"^22.13.10","@types/js-cookie":"^3.0.6"},"peerDependencies":{"vue":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/9466-utm-tracker_1.0.0_1742365298115_0.9539093796804352","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"9466-utm-tracker","version":"1.1.0","keywords":["vue","hooks","utm","tracking","analytics"],"author":"","license":"MIT","_id":"9466-utm-tracker@1.1.0","maintainers":[{"name":"kuaner","email":"kuaner@gmail.com"}],"dist":{"shasum":"a2fb9ba6c2dbc15b9aec065b6c3bcb713217098d","tarball":"https://registry.npmjs.org/9466-utm-tracker/-/9466-utm-tracker-1.1.0.tgz","fileCount":6,"integrity":"sha512-FT6SDjjnRD4IjdRb3xdvI6PSGdAkQMQmJDgNkhQY/MIpEorjsOLlO0dLr/PwShcBcRIToSP7Jf5m5TpsNOGLnA==","signatures":[{"sig":"MEUCIQCN2zqzfZmKF2+oFHeO4nUrkwDiXt3uVv/6WLFKPk4YBQIgTrzzebRzGdvb5E42Gll9fQpxpHOpPKqwsp2jAtQXFqc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5704},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","gitHead":"54324a9e6a0686ee402359283b2d378b18a4b901","scripts":{"build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"kuaner","email":"kuaner@gmail.com"},"_npmVersion":"10.5.2","description":"Vue 3 hooks for handling UTM parameters in URLs and storing them in cookies","directories":{},"_nodeVersion":"20.12.2","dependencies":{"js-cookie":"^3.0.5"},"_hasShrinkwrap":false,"devDependencies":{"vue":"^3.5.13","jsdom":"^26.0.0","vitest":"^3.0.9","typescript":"^5.8.2","@types/node":"^22.13.10","@vue/test-utils":"^2.4.6","@types/js-cookie":"^3.0.6","@testing-library/vue":"^8.1.0"},"peerDependencies":{"vue":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/9466-utm-tracker_1.1.0_1742366265831_0.5099295430906619","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"9466-utm-tracker","version":"1.1.1","keywords":["vue","hooks","utm","tracking","analytics"],"author":"","license":"MIT","_id":"9466-utm-tracker@1.1.1","maintainers":[{"name":"kuaner","email":"kuaner@gmail.com"}],"dist":{"shasum":"451efa712e0547e0c240df404c07bba04e522c91","tarball":"https://registry.npmjs.org/9466-utm-tracker/-/9466-utm-tracker-1.1.1.tgz","fileCount":6,"integrity":"sha512-nJJOPk8U+swfQaceaSa6WGdBBr7TZOn9gg2/EE69tqgfP2sG3wQahe0k48hXCrkVRgcRRku/bUyRd3xRIomsKQ==","signatures":[{"sig":"MEQCIDF2oc/koQtzL+AehjiZYrgtrBAGBM/Rdw9B7nspl0pxAiB7NVnExolf7MWR1/LZB9bG293npy9oGXGiNAEtgmJpgw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7028},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","gitHead":"54324a9e6a0686ee402359283b2d378b18a4b901","scripts":{"build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"kuaner","email":"kuaner@gmail.com"},"_npmVersion":"10.5.2","description":"Vue 3 hooks for handling UTM parameters in URLs and storing them in cookies","directories":{},"_nodeVersion":"20.12.2","dependencies":{"js-cookie":"^3.0.5"},"_hasShrinkwrap":false,"devDependencies":{"vue":"^3.5.13","jsdom":"^26.0.0","vitest":"^3.0.9","typescript":"^5.8.2","@types/node":"^22.13.10","@vue/test-utils":"^2.4.6","@types/js-cookie":"^3.0.6","@testing-library/vue":"^8.1.0"},"peerDependencies":{"vue":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/9466-utm-tracker_1.1.1_1742366501086_0.2526250565260899","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"9466-utm-tracker","version":"1.2.0","keywords":["vue","hooks","utm","tracking","analytics"],"author":"","license":"MIT","_id":"9466-utm-tracker@1.2.0","maintainers":[{"name":"kuaner","email":"kuaner@gmail.com"}],"dist":{"shasum":"596639885d749e6f2e3913fa81ac2b5bdb3ae898","tarball":"https://registry.npmjs.org/9466-utm-tracker/-/9466-utm-tracker-1.2.0.tgz","fileCount":6,"integrity":"sha512-QAY5mit07k52rj5n2l7HYaXpbGVnorBq3Cf8gnHGy8Kq+UTJ5PRY5ez4obSIPtj6WbLY6TiYZp56ZIZJYed0tg==","signatures":[{"sig":"MEYCIQCJYrjU/ApSog1IVRtClvCIV0Iz0LwswjInW5JVqYcRVQIhAPdu/0DSIgfmJGAHVYIYmkE4vfeWxq6hKkOxw3cE2Nox","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5483},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","gitHead":"54324a9e6a0686ee402359283b2d378b18a4b901","scripts":{"build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"kuaner","email":"kuaner@gmail.com"},"_npmVersion":"10.5.2","description":"Vue 3 hooks for handling UTM parameters in URLs and storing them in cookies","directories":{},"_nodeVersion":"20.12.2","dependencies":{"js-cookie":"^3.0.5"},"_hasShrinkwrap":false,"devDependencies":{"vue":"^3.5.13","jsdom":"^26.0.0","vitest":"^3.0.9","typescript":"^5.8.2","vue-router":"^4.5.0","@types/node":"^22.13.10","@vue/test-utils":"^2.4.6","@types/js-cookie":"^3.0.6","@testing-library/vue":"^8.1.0"},"peerDependencies":{"vue":"^3.0.0","vue-router":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/9466-utm-tracker_1.2.0_1742366889847_0.11942553158023195","host":"s3://npm-registry-packages-npm-production"}},"1.3.0":{"name":"9466-utm-tracker","version":"1.3.0","keywords":["vue","hooks","utm","tracking","analytics"],"author":"","license":"MIT","_id":"9466-utm-tracker@1.3.0","maintainers":[{"name":"kuaner","email":"kuaner@gmail.com"}],"dist":{"shasum":"1ab6c04e1f4ca227864b70d3e628afb890561c1b","tarball":"https://registry.npmjs.org/9466-utm-tracker/-/9466-utm-tracker-1.3.0.tgz","fileCount":6,"integrity":"sha512-lzVNTTI7MpCn9WqxwMveZiJMTRTk84Kvh9KO+vSgqL/u8xPCFGEAxz2EF1VDN5xtNyp/hQqdwt+xhzw6NXgfsg==","signatures":[{"sig":"MEUCIEWGJqMw7bAbCyHX9WCwuHFDihf7fSUFiDHsaYGnCQUuAiEAzMeY4RsNIIcLsFCuwp47pXxrlmzqUyx//FvGQR4O1MY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6389},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","gitHead":"54324a9e6a0686ee402359283b2d378b18a4b901","scripts":{"build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"kuaner","email":"kuaner@gmail.com"},"_npmVersion":"10.5.2","description":"Vue 3 hooks for handling UTM parameters in URLs and storing them in cookies","directories":{},"_nodeVersion":"20.12.2","dependencies":{"js-cookie":"^3.0.5"},"_hasShrinkwrap":false,"devDependencies":{"vue":"^3.5.13","jsdom":"^26.0.0","vitest":"^3.0.9","typescript":"^5.8.2","vue-router":"^4.5.0","@types/node":"^22.13.10","@vue/test-utils":"^2.4.6","@types/js-cookie":"^3.0.6","@testing-library/vue":"^8.1.0"},"peerDependencies":{"vue":"^3.0.0","vue-router":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/9466-utm-tracker_1.3.0_1742367429610_0.9370917193019095","host":"s3://npm-registry-packages-npm-production"}},"1.4.0":{"name":"9466-utm-tracker","version":"1.4.0","keywords":["vue","hooks","utm","tracking","analytics"],"author":"","license":"MIT","_id":"9466-utm-tracker@1.4.0","maintainers":[{"name":"kuaner","email":"kuaner@gmail.com"}],"dist":{"shasum":"9d5bded68cc6310619fe26e9f6455d84caad3a1e","tarball":"https://registry.npmjs.org/9466-utm-tracker/-/9466-utm-tracker-1.4.0.tgz","fileCount":6,"integrity":"sha512-agCwkjQM5UP9VCawO28QtJWpQ82Rt9mYjayi4aXG5AIvmPKmt5UvnYAWxunmBPuzgjeX34j0Ni9pPqoG9S8WDg==","signatures":[{"sig":"MEQCIDnqPpWs/o42CctCZd2dAsKob1Ix/RkDqlG2Qh267m54AiAKD39PdtgASCbtJZUklOLs5Jg84MH4Z18EY+0gzx41ig==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7525},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","gitHead":"54324a9e6a0686ee402359283b2d378b18a4b901","scripts":{"build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"kuaner","email":"kuaner@gmail.com"},"_npmVersion":"10.5.2","description":"Vue 3 hooks for handling UTM parameters in URLs and storing them in cookies","directories":{},"_nodeVersion":"20.12.2","dependencies":{"js-cookie":"^3.0.5"},"_hasShrinkwrap":false,"devDependencies":{"vue":"^3.5.13","jsdom":"^26.0.0","vitest":"^3.0.9","typescript":"^5.8.2","vue-router":"^4.5.0","@types/node":"^22.13.10","@vue/test-utils":"^2.4.6","@types/js-cookie":"^3.0.6","@testing-library/vue":"^8.1.0"},"peerDependencies":{"vue":"^3.0.0","vue-router":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/9466-utm-tracker_1.4.0_1742367851564_0.39571872981972644","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"9466-utm-tracker","version":"2.0.0","keywords":["vue","hooks","utm","tracking","analytics"],"author":"","license":"MIT","_id":"9466-utm-tracker@2.0.0","maintainers":[{"name":"kuaner","email":"kuaner@gmail.com"}],"dist":{"shasum":"426c24c450bc9c46837b79046111422b17c04c75","tarball":"https://registry.npmjs.org/9466-utm-tracker/-/9466-utm-tracker-2.0.0.tgz","fileCount":6,"integrity":"sha512-jmCmzQzYurv9UBDjL4CmKhtobtjSVWVswDGOAkHQa+he5iiztzItC9ch3tf5FuvR52FLSf/LyTBY4TiAwk0tUA==","signatures":[{"sig":"MEQCIHUgmsZqjqdHVat6P2gQPf8asLHKljBHHoHTB7DdsHAoAiBgpRAkbQa8HkGtr2PbK/Yb9yg3zYPkqt5hi2r4UmOlrg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5578},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","gitHead":"54324a9e6a0686ee402359283b2d378b18a4b901","scripts":{"build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"kuaner","email":"kuaner@gmail.com"},"_npmVersion":"10.5.2","description":"Vue 3 hooks for handling UTM parameters in URLs and storing them in cookies","directories":{},"_nodeVersion":"20.12.2","dependencies":{"js-cookie":"^3.0.5"},"_hasShrinkwrap":false,"devDependencies":{"vue":"^3.5.13","jsdom":"^26.0.0","vitest":"^3.0.9","typescript":"^5.8.2","vue-router":"^4.5.0","@types/node":"^22.13.10","@vue/test-utils":"^2.4.6","@types/js-cookie":"^3.0.6","@testing-library/vue":"^8.1.0"},"peerDependencies":{"vue":"^3.0.0","vue-router":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/9466-utm-tracker_2.0.0_1742368516195_0.527488965724842","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"name":"9466-utm-tracker","version":"2.0.1","description":"Vue 3 hooks for handling UTM parameters in URLs and storing them in cookies","type":"module","main":"dist/index.js","module":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","prepare":"npm run build"},"keywords":["vue","hooks","utm","tracking","analytics"],"author":"","license":"MIT","dependencies":{"js-cookie":"^3.0.5"},"devDependencies":{"@testing-library/vue":"^8.1.0","@types/js-cookie":"^3.0.6","@types/node":"^22.13.10","@vue/test-utils":"^2.4.6","jsdom":"^26.0.0","typescript":"^5.8.2","vitest":"^3.0.9","vue":"^3.5.13","vue-router":"^4.5.0"},"peerDependencies":{"vue":"^3.0.0","vue-router":"^4.0.0"},"_id":"9466-utm-tracker@2.0.1","gitHead":"206d1033f4aa500771796b5966f0221cd8752f93","_nodeVersion":"20.12.2","_npmVersion":"10.5.2","dist":{"integrity":"sha512-a28tTErAGfFiWY3VuZUAT4BLwSaXltYBsAhHRhTBac0BsVfx4ux+2EGVRpUK36QjOPwNIw8C6mc3vrwkyOKKmQ==","shasum":"905640221904b6202ab807b192a76ac8f1c47bd2","tarball":"https://registry.npmjs.org/9466-utm-tracker/-/9466-utm-tracker-2.0.1.tgz","fileCount":6,"unpackedSize":5648,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDJ1WIUm2YSI/0I9bkq68Gdy2k6z3uxWbeXkYaq2cfrCAIgbNnyViAF3pum0vFrcVahKBci/pTiQf22fG34UI429UY="}]},"_npmUser":{"name":"kuaner","email":"kuaner@gmail.com"},"directories":{},"maintainers":[{"name":"kuaner","email":"kuaner@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/9466-utm-tracker_2.0.1_1742374286193_0.035475854808595386"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-19T06:21:38.114Z","modified":"2025-03-19T08:51:26.557Z","1.0.0":"2025-03-19T06:21:38.304Z","1.1.0":"2025-03-19T06:37:45.994Z","1.1.1":"2025-03-19T06:41:41.240Z","1.2.0":"2025-03-19T06:48:10.018Z","1.3.0":"2025-03-19T06:57:09.824Z","1.4.0":"2025-03-19T07:04:11.756Z","2.0.0":"2025-03-19T07:15:16.392Z","2.0.1":"2025-03-19T08:51:26.403Z"},"license":"MIT","keywords":["vue","hooks","utm","tracking","analytics"],"description":"Vue 3 hooks for handling UTM parameters in URLs and storing them in cookies","maintainers":[{"name":"kuaner","email":"kuaner@gmail.com"}],"readme":"# 9466-utm-tracker\n\nVue 3 hook，用于处理 URL 中的 utm_source 参数并存储到 cookie 中。\n\n## 安装\n\n```bash\nnpm install 9466-utm-tracker\n```\n\n## 前置要求\n\n- Vue 3\n- Vue Router 4\n\n这个 hook 需要在 Vue Router 环境中使用，因为它依赖于 Vue Router 来获取 URL 参数。\n\n## 使用方法\n\n1. 确保你的应用已经配置了 Vue Router：\n\n```typescript\n// 在你的 router/index.ts 中\nimport { createRouter, createWebHistory } from \"vue-router\";\n\nconst router = createRouter({\n  history: createWebHistory(),\n  routes: [\n    // 你的路由配置\n  ],\n});\n\nexport default router;\n```\n\n2. 在组件中使用 hook：\n\n```typescript\nimport { useUtm } from \"9466-utm-tracker\";\n\nexport default {\n  setup() {\n    const { utmSource } = useUtm({\n      cookieExpireDays: 30, // 可选，默认30天\n      cookieDomain: \".example.com\", // 可选\n      cookiePath: \"/\", // 可选，默认'/'\n    });\n\n    // utmSource 是一个 ref 对象，包含 utm_source 的值\n    console.log(utmSource.value); // 例如: 'google'\n  },\n};\n```\n\nhook 会自动：\n\n1. 在初始化时获取 URL 中的 utm_source 参数\n2. 如果 URL 中有 utm_source 参数，保存到 cookie 中（cookie 名: \\_9466_utm）\n3. 如果 URL 中没有 utm_source 参数，尝试从 cookie 中读取\n4. 当 URL 参数变化时，自动更新并保存新的 utm_source 值\n\n## 支持的 URL 格式\n\n支持以下格式的 URL：\n\n- Hash 模式: `http://example.com/#/path?utm_source=google`\n- History 模式: `http://example.com/path?utm_source=google`\n\n## Cookie 存储\n\nutm_source 参数会直接存储在名为 `_9466_utm` 的 cookie 中，例如：\n\n```\n_9466_utm=google\n```\n\n## 特性\n\n- 🚀 自动从 URL 中获取 utm_source 参数\n- 📦 将 utm_source 保存到 cookie 中\n- 🔄 如果 URL 中没有参数，则从 cookie 中恢复\n- 💪 完整的 TypeScript 支持\n- 🎯 Vue 3 组合式 API\n- 🛣️ 支持 Vue Router 4 的 hash 和 history 模式\n- 🔒 安全的路由参数处理\n\n## API\n\n### useUtm(options?)\n\n主函数，返回一个包含 utm_source 和相关方法的对象。\n\n#### 选项\n\n```typescript\ninterface UseUtmOptions {\n  cookieExpireDays?: number; // cookie 过期天数，默认 30\n  cookieDomain?: string; // cookie 域名\n  cookiePath?: string; // cookie 路径\n}\n```\n\n#### 返回值\n\n```typescript\n{\n  utmSource: Ref<string>; // 响应式的 utm_source 值\n  getUtmFromUrl: () => string; // 从当前 URL 获取 utm_source 的方法\n  getUtmFromCookie: () => string; // 从 cookie 获取 utm_source 的方法\n}\n```\n\n## 许可证\n\nMIT\n","readmeFilename":"README.md"}