{"id":21702736,"url":"https://github.com/christyharagan/segment-tsd-generator","last_synced_at":"2025-07-08T21:33:45.958Z","repository":{"id":41785740,"uuid":"237414429","full_name":"christyharagan/segment-tsd-generator","owner":"christyharagan","description":"Generate .d.ts files from Segment Protocol Tracking Plans","archived":false,"fork":false,"pushed_at":"2023-05-07T21:49:59.000Z","size":42,"stargazers_count":3,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-16T08:15:56.108Z","etag":null,"topics":["segment","segmentio","tracking-plan","typescript-definitions"],"latest_commit_sha":null,"homepage":"","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/christyharagan.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2020-01-31T11:13:10.000Z","updated_at":"2023-05-29T04:24:54.000Z","dependencies_parsed_at":"2024-06-21T20:17:51.592Z","dependency_job_id":"674c46fc-b202-4e5e-9151-b8bbb2363eef","html_url":"https://github.com/christyharagan/segment-tsd-generator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/christyharagan/segment-tsd-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christyharagan%2Fsegment-tsd-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christyharagan%2Fsegment-tsd-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christyharagan%2Fsegment-tsd-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christyharagan%2Fsegment-tsd-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/christyharagan","download_url":"https://codeload.github.com/christyharagan/segment-tsd-generator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christyharagan%2Fsegment-tsd-generator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264353092,"owners_count":23595031,"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":["segment","segmentio","tracking-plan","typescript-definitions"],"created_at":"2024-11-25T21:18:46.029Z","updated_at":"2025-07-08T21:33:45.940Z","avatar_url":"https://github.com/christyharagan.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Segment TSD Generator\n===\n\nOverview\n---\n\n[Segment](https://segment.com)'s [Protocols](https://segment.com/product/protocols) enable users to creating [tracking plans](https://segment.com/academy/collecting-data/how-to-create-a-tracking-plan/) and then govern all events that are sent to Segment to ensure they conform to this tracking plan. This project creates TypeScript definition files from these to give developers strongly typed access to Segment's various JavaScript/TypeScript APIs and SDKs.\n\nComparison to TypeWriter\n---\n\nSegment already has an open-source library called [TypeWriter](https://github.com/segmentio/typewriter) that does something similar (although it also supports the [iOS](https://segment.com/docs/connections/sources/catalog/libraries/mobile/ios/) and [Android](https://segment.com/docs/connections/sources/catalog/libraries/mobile/android/) SDKs; however on the JavaScript/TypeScript front, it is specifically used for Analytics JS). TypeWriter takes a different approach to this project. TypeWriter creates helper functions, where-as this project merely creates TypeScript definitions that fit over the \"vanilla\" calls of e.g. the [Analytics JS](https://github.com/segmentio/analytics.js/) SDK.\n\nReasons to use TypeWriter\n\n * You want typing definitions for the iOS and Android SDKS\n * You want to use convenience methods for Analytics JS rather than make calls against the raw API\n\nReasons to use Segment TSD Generator\n\n * You have already used the raw Analytics JS methods and want to retrofit Types over the top of your existing code\n * You want to use the typings for Node JS calling against the [HTTP Tracking API](https://segment.com/docs/connections/sources/catalog/libraries/server/http-api/), or in [Custom Sources](https://segment.com/docs/connections/sources/custom-sources/) or [Custom Destinations](https://segment.com/docs/connections/destinations/custom-destinations/). For this use-case, you may also consider using [Segment TypeScript Definitions](https://github.com/christyharagan/segment-typescript-definitions), which provide TypeScript definition files for these APIs/environments.\n\nInstall\n---\n\n Install via NPM:\n\n```\nnpm i --save segment-tsd-generator\n```\n\nor Yarn:\n\n```\nyarn install segment-tsd-generator\n```\n\nExample Usage\n---\n\n```ts\nimport {getTrackingPlan} from 'segment-typescript-api/cjs/config-api'\nimport generator from 'segment-tsd-generator'\nimport * as fs from 'fs'\n\nlet WORKSPACE_TOKEN = '123'\nlet WORKSPACE_SLUG = 'my-workspace'\n\ngetTrackingPlan(WORKSPACE_TOKEN, WORKSPACE_SLUG, 'My Tracking Plan').then(generator).then(tsd=\u003e{\n  fs.writeFile('my_tracking_plan.d.ts', tsd, 'utf8', (err) =\u003e {\n    if (err) {\n      console.err(err)\n    } else {\n      // Do awesome stuff with you definition file\n    }\n  })\n})\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristyharagan%2Fsegment-tsd-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristyharagan%2Fsegment-tsd-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristyharagan%2Fsegment-tsd-generator/lists"}