{"id":30048295,"url":"https://github.com/segmentio/snippet","last_synced_at":"2025-08-07T10:09:01.114Z","repository":{"id":10606870,"uuid":"12823768","full_name":"segmentio/snippet","owner":"segmentio","description":"Render the analytics.js snippet.","archived":false,"fork":false,"pushed_at":"2024-02-22T19:01:43.000Z","size":2128,"stargazers_count":51,"open_issues_count":42,"forks_count":18,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-07-30T19:22:26.562Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/segmentio.png","metadata":{"files":{"readme":"README.md","changelog":"History.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}},"created_at":"2013-09-14T03:22:32.000Z","updated_at":"2025-07-08T20:38:57.000Z","dependencies_parsed_at":"2024-02-22T20:26:08.193Z","dependency_job_id":"6f345af7-f282-4d34-84e8-ec8b9799d1bd","html_url":"https://github.com/segmentio/snippet","commit_stats":{"total_commits":123,"total_committers":26,"mean_commits":4.730769230769231,"dds":0.8617886178861789,"last_synced_commit":"e78d454030861b2e13c2601a55daa55415e06e24"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"purl":"pkg:github/segmentio/snippet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/segmentio%2Fsnippet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/segmentio%2Fsnippet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/segmentio%2Fsnippet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/segmentio%2Fsnippet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/segmentio","download_url":"https://codeload.github.com/segmentio/snippet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/segmentio%2Fsnippet/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269238051,"owners_count":24383466,"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","status":"online","status_checked_at":"2025-08-07T02:00:09.698Z","response_time":73,"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":"2025-08-07T10:08:55.570Z","updated_at":"2025-08-07T10:09:01.107Z","avatar_url":"https://github.com/segmentio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @segment/snippet\n\nRender the analytics.js snippet.\n\nThe recommended way to use analytics.js is to follow the [analytics.js quickstart guide](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/quickstart/). If you absolutely need to generate a snippet dynamically, this is an alternate solution. Note that when using this in-browser, the global `analytics` object will not be defined until the snippet is rendered and executed.\n\nFor information on browser support, see: https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/supported-browsers/\n\n## Installation\n```sh\n# npm\nnpm install @segment/snippet\n\n# yarn\nyarn add @segment/snippet\n\n# pnpm\npnpm add @segment/snippet\n```\n## Example\n\n```js\nconst snippet = require('@segment/snippet');\n\nconst contents = snippet.max({\n  host: 'cdn.segment.com',\n  apiKey: '03fwkuu3',\n  page: {\n    category: 'Docs',\n    name: 'Integrations',\n    properties: {\n      foo: 'bar'\n    }\n  }\n});\n```\n\n## API\n\n### snippet.max(options)\n\nReturns the maxified version of the analytics.js snippet given a set of `options`:\n\n* `host`: the domain name where the analytics.js script is hosted.\n* `useHostForBundles`: If set to `true`, the snippet will include the `_cdn` property to tell analytics.js where to fetch bundles from.\n* `apiKey`: the `apiKey` to load in the snippet.\n* `page`: the options to pass to `analytics.page`. if `page` is `false`, then the `page()` call will be omitted.\n* `load`: If object, these are the settings passed as the second argument to analytics.load. This can be useful if you want to override Segment.io integration behavior, or if you want dynamically control which integraions load on the client-side for things like GDPR. If set to `false` the `load()` call will be omitted.\n* `ajsPath`: override the default analytics.min.js location\n\n\n### snippet.min(options)\n\nReturns the minified version of the snippet.\n\n\n## Development\n\n### Installation + QA\n```\nnvm use\nyarn install\nmake lint\nmake test\n```\n\n### Running tests in Saucelabs\n```\nSAUCE=true make test\n```\n\n## Releasing\n1. Publish to `npm`\n```sh\ngit checkout master \u0026\u0026 git pull --ff-only\nnpm version \u003cpatch|minor|major\u003e\ngit push --follow-tags\nmake build\nnpm publish\n```\n2. Create a [new github release](https://github.com/segmentio/snippet/releases).\n\n3. Bump package version on [segmentio/app](https://github.com/segmentio/app/blob/main/packages/app/package.json).\n\n4. Update _all_ example snippets on [public docs repo](https://github.com/segmentio/segment-docs) via search + replace \n- Get example snippet by runnings `yarn fixture` and observing generated `tmp.fixture.*.js` files. \n- Tip: double-check that the fixture's `SNIPPET_VERSION` refers to the new npm version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsegmentio%2Fsnippet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsegmentio%2Fsnippet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsegmentio%2Fsnippet/lists"}