{"id":18376753,"url":"https://github.com/hcodes/lyam","last_synced_at":"2025-05-08T21:02:50.432Z","repository":{"id":35150905,"uuid":"205783382","full_name":"hcodes/lyam","owner":"hcodes","description":"Лёгкая Я.Метрика","archived":false,"fork":false,"pushed_at":"2025-04-24T20:42:09.000Z","size":674,"stargazers_count":30,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-24T21:42:09.392Z","etag":null,"topics":["lightweight","metrika","typescript","yandex","yandex-metrika"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/lyam","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hcodes.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2019-09-02T05:32:57.000Z","updated_at":"2025-04-24T20:42:13.000Z","dependencies_parsed_at":"2024-06-21T19:18:52.338Z","dependency_job_id":"c6c20394-b541-42fe-b6c3-f60fe92d666c","html_url":"https://github.com/hcodes/lyam","commit_stats":{"total_commits":108,"total_committers":3,"mean_commits":36.0,"dds":0.09259259259259256,"last_synced_commit":"4ec98a2a63e2e12ca45cb8017b3edb7c55fd5c94"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcodes%2Flyam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcodes%2Flyam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcodes%2Flyam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcodes%2Flyam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hcodes","download_url":"https://codeload.github.com/hcodes/lyam/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253149575,"owners_count":21861734,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["lightweight","metrika","typescript","yandex","yandex-metrika"],"created_at":"2024-11-06T00:24:38.589Z","updated_at":"2025-05-08T21:02:50.410Z","avatar_url":"https://github.com/hcodes.png","language":"TypeScript","readme":"# Лёгкая Я.Метрика\n\n[![NPM version](https://img.shields.io/npm/v/lyam.svg)](https://www.npmjs.com/package/lyam)\n[![NPM Downloads](https://img.shields.io/npm/dm/lyam.svg?style=flat)](https://www.npmjs.org/package/lyam)\n[![install size](https://packagephobia.com/badge?p=lyam)](https://packagephobia.com/result?p=lyam)\n\n## Мотивация\n[Скрипт Метрики](https://mc.yandex.ru/metrika/tag.js) занимает более 350 КБ (90 КБ в GZIP), для лёгких страниц и небольших пакетов он громоздкий.\n\n\u003cimg width=\"350\" src=\"https://raw.githubusercontent.com/hcodes/lyam/refs/heads/master/images/feather.jpg\" /\u003e\n\n## Преимущества\n- [Сверхмалый размер кода](https://bundlephobia.com/result?p=lyam).\n- Код подключается в основной бандл проекта, нет дополнительного запроса на загрузку скрипта и парсинга кода Метрики.\n- Использование в serviceWorker’е, электрон-приложениях и т.д.\n\n## Использование\n\n```js\nimport { hit } from 'lyam';\n\nconst counterId = '12345';\n\n// Если не указаны параметры, то адрес страницы берётся из location.href,\n// заголовок страницы из document.title и\n// реферер из document.referrer.\nhit(counterId);\n```\n\nСо всеми параметрами:\n```js\nimport { hit } from 'lyam';\n\nconst counterId = '12345';\nconst userVars = { myParam: 123 };\n\nhit(counterId, {\n  referrer: 'https://anothersite.ru',\n  title: 'My document title',\n  url: 'https://mysite.ru'\n}, userVars);\n```\n\n### Отправка цели\n\n```js\nimport { hit, reachGoal } from 'lyam';\n\nconst counterId = '12345';\nhit(counterId);\n\n// ...\n\nreachGoal(counterId, 'MY_GOAL_NAME');\n\n```\n\n### Отправка цели с параметрами визита\n\n```js\nimport { hit, reachGoal } from 'lyam';\n\nconst counterId = '12345';\nhit(counterId);\n\n// ...\n\nconst userVars = { myParam: 123 };\nreachGoal(counterId, 'MY_GOAL_NAME', userVars);\n\n```\n\n### Внешняя ссылка\n```js\nimport { hit, extLink } from 'lyam';\n\nconst counterId = '12345';\nhit(counterId);\n\n// ...\n\nextLink(counterId, 'https://externalsite.ru');\n```\n\n### Загрузка файла\n```js\nimport { hit, file } from 'lyam';\n\nconst counterId = '12345';\nhit(counterId);\n\n// ...\n\nfile(counterId, 'https://mysite.ru/file.zip');\n```\n\n### Не отказ\n```js\nimport { hit, notBounce } from 'lyam';\n\nconst counterId = '12345';\nhit(counterId);\n\n// ...\n\nsetTimeout(() =\u003e {\n    notBounce(counterId);\n}, 15000); // 15 сек.\n```\n\n### Параметры визита\n```js\nimport { hit, params } from 'lyam';\n\nconst counterId = '12345';\nhit(counterId);\n\n// ...\n\nparams(counterId, { myParam: 123 });\n```\n\n### Пользовательские параметры\n```js\nimport { hit, userParams } from 'lyam';\n\nconst counterId = '12345';\nhit(counterId);\n\n// ...\n\nuserParams(counterId, { myParam: 1, UserID: 12345 });\n```\n\n## CSP\n```\nContent-Security-Policy:\n  ...\n  img-src https://mc.yandex.ru;\n  connect-src https://mc.yandex.ru;\n  ...\n```\n\n## [Лицензия](./LICENSE)\nMIT\n\n## Ссылки\n- [React/Preact-компонент для Яндекс Метрики](https://github.com/hcodes/react-metrika)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhcodes%2Flyam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhcodes%2Flyam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhcodes%2Flyam/lists"}