npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@segment/prism

v0.1.9

Published

A templating engine for generating strongly typed analytics clients across languages using the schema defined by a Tracking Plan ## Install

Downloads

210

Maintainers

harksinghharksinghfhalim-segmentfhalim-segmentcfreecfreeldelossantosldelossantoshjoonpmhjoonpmceline-segmentceline-segmentpmcanseco-segmentpmcanseco-segmentmasiramasiraamillet89amillet89cholt002cholt002av-segmentav-segmentaghotikaraghotikarvikrant-segmentvikrant-segmentlarryatsegmentlarryatsegmentscruwys1scruwys1kyliepedersenkyliepedersenjinaparkjinaparkcdignam-segmentcdignam-segmentsegmentiosegmentiojrupasinghejrupasinghelateefatlateefatyash-twilioyash-twiliosowjanyasegmentsowjanyasegmentebru.odokebru.odokryanligonryanligonlpediredlalpediredlabrookstaylorjrbrookstaylorjrnithan-twilionithan-twiliodean-huynhdean-huynhwdbettswdbettsn2parkon2parkojayakrishnannairjayakrishnannairrhall-twiliorhall-twiliokarimkeshwanikarimkeshwanityson_segmenttyson_segmentjgabe13jgabe13bgamwellbgamwellpoojasegmentpoojasegmentmaryam.sharifmaryam.sharifwally.tgwally.tgsalolivaressalolivareserikdwerikdwchenxiangzhangchenxiangzhangjusteenjusteenmericssonmericssonprayansh-segmenttprayansh-segmenttjeremylarkinjeremylarkinbsneedbsneeddanieljackinsdanieljackinssegment-sethsegment-sethsayan-das-insayan-das-injames9446james9446priscilla.giattipriscilla.giattinlsunnlsundrew-thompsondrew-thompsonsegment-jsinghsegment-jsinghmcoulibalimcoulibaliandrius-segmentandrius-segmentvalerieernstvalerieernstnithin-bennynithin-bennyainatancincoainatancincoskondamuriskondamuriclintz.segclintz.segreplateroreplateroslenin-twilioslenin-twiliocsayusocsayusoseanhan-segmentseanhan-segmentnevermore2022nevermore2022ama0223ama0223gilomergilomerandrew.hoyleandrew.hoylemarcelopvmarcelopveric.rognereric.rognerkdharaiyakdharaiyajon.anderson-at-segment.comjon.anderson-at-segment.comstacy.songstacy.songrexatsegmentrexatsegmentnickaguilarnickaguilarbradenbeckerbradenbeckerreneewangreneewangdan.laskydan.laskysam.tapiasam.tapialnambalnambavikramkumar19vikramkumar19mpriyad25mpriyad25jeremy.parkerjeremy.parkersmidgessmidgesnageshgolemnageshgolemsudojatinsudojatinpmaidpmaidsethsegmentsethsegmentjair.avilesjair.avilesmanali-bhosalemanali-bhosaleelmoselyeeelmoselyeechtoombschtoombspeterdemartinipeterdemartinivincen7tranvincen7transujin0sujin0lfdelossantoslfdelossantosemmy.byrneemmy.byrnefelttripfelttripsa-jsootersa-jsooterlluque-twiliolluque-twiliokevinburkesegmentkevinburkesegmentafsha-nazim-segafsha-nazim-segsong4yousong4youdavid.anusontarangkul.segmentdavid.anusontarangkul.segmentjyim008jyim008michaelghsegmichaelghsegaishikawakiaishikawakitwjosiahtwjosiahtanya.gupta.segmenttanya.gupta.segmentsindhusegmentsindhusegmentprabhnoor1997prabhnoor1997chihchun-twiliochihchun-twiliopmiller-twiliopmiller-twiliovbatanovvbatanovsimpixelatedsimpixelatedmcullenmeyermcullenmeyerneeharikakondipatineeharikakondipatiarunlalam-segmentarunlalam-segmentmschaszbergermschaszbergershuvrajit9904shuvrajit9904abhinavsurekaabhinavsurekavaradarajan-twvaradarajan-twimmanojimmanojblangtwilioblangtwiliojsh-wujsh-wusethnutetwiliosethnutetwiliorrivera-segmentrrivera-segmentsegment-adminsegment-adminbgillanbgillantcgilberttcgilbertmckern_segmentmckern_segmentmaneesh.dharma29maneesh.dharma29joetessyjoetessydominicbarnesdominicbarnesmugelstadmugelstadjalexy12jalexy12pmuninpmuninwhaider_twiliowhaider_twilioariel.silvestriariel.silvestrishraddha-twilioshraddha-twiliomichelrmichelrbrandon.scott-segmentbrandon.scott-segmentjfehrman.segmentjfehrman.segmentprayansh-twilioprayansh-twiliodangmai-segmentdangmai-segmentaaronklishaaronklishbrianhumphreystwiliobrianhumphreystwiliormukundanrmukundanashwitha.bgashwitha.bgryanrouleau-segmentryanrouleau-segmentfunlufunlutdibaccotdibaccofauzy.yyfauzy.yynlubchenconlubchencoarubiochavezarubiochavezphillip.thomasphillip.thomasjkusa_segmentjkusa_segmentrollcoderollcodemeg1000meg1000nainy.agrawalnainy.agrawalseg-rustybaileyseg-rustybaileyjbandi-twiliojbandi-twiliosaisagarkappaganthulasaisagarkappaganthulaforgetfulfellowforgetfulfellowpooja.patilpooja.patiljoe.ayoub.segmentjoe.ayoub.segmenthmohanram_seghmohanram_segbrian.aguirrebrian.aguirreenyi.asonyeenyi.asonyefarhan0581farhan0581tbrennanjtbrennanjparag.pandaparag.pandaharsh.vardhanharsh.vardhansshaikh_segmentsshaikh_segmentxinghao.huangxinghao.huangshupadhyayshupadhyayjohn.lee1100john.lee1100kx-segmentkx-segmentsegment_fansegment_fandazu70dazu70sai-patanjalisai-patanjaliemilyjiaemilyjiay.yuy.yuea_segmentea_segmentyli119yli119pooyajpooyajbharath.boregowdabharath.boregowdaigracheva-twilioigracheva-twiliobenattwiliobenattwiliomarinheromarinherodobrin.ganevdobrin.ganevalfrimpongalfrimpongdharpateldharpatelalecjacobs-segmentalecjacobs-segmentcjo2cjo2yashnit-segmentyashnit-segmentdltnbrks-segmentdltnbrks-segmentachandrashekaranachandrashekaranhimanshuphhimanshuphpraguptapraguptatw-dgarciatw-dgarciaalayvoraalayvoraaparna.singhalaparna.singhalynguyenynguyentimmyzsearcytimmyzsearcylweimersegmentlweimersegmentanton-vylushchakanton-vylushchakazhaotwilioazhaotwiliorokatyalrokatyalkjoerreskjoerresmsarafmsarafvikakumarvikakumaraditi.raveeshaditi.raveeshchenchensegmentcomchenchensegmentcomsanket.mishrasanket.mishraodoren_segmentodoren_segmentjxin_twiliojxin_twiliorcheedhallarcheedhallajbasiglio-segmentjbasiglio-segmentviveksainaneesegmentviveksainaneesegmentpriyanshispriyanshisabhinav.mehtaabhinav.mehtapreetyppreetypakash.gautam07akash.gautam07nanotimmnanotimmyshkpryshkprsrivig21srivig21ssunejassunejabala.singareddybala.singareddymoyara2moyara2arjunbhandagearjunbhandageakodankiryakodankiryrodhilton_twiliorodhilton_twiliocdelaomartinezcdelaomartinezgbatragbatraspencerattickspenceratticksegmentseansegmentseansundareswar.jayakumarsundareswar.jayakumarhrishi-segmenthrishi-segmentkalyannistalakalyannistalavaibhavnandavaibhavnandabannapplebannapplesrishti-nemasrishti-nemagsolis_segmentgsolis_segmentitsarijitrayitsarijitraynirai-6nirai-6bhavanki-segmentbhavanki-segmenthhwsegmenthhwsegmentandrew.hallandrew.hallkspachinokspachinojcohentwilio2jcohentwilio2dsolowdsolownanette.ranesnanette.ranesamigandhiamigandhiguthriesegmentguthriesegmentmiguelpdiaz8miguelpdiaz8mansarimansarikathlynnkathlynnchris.chanchris.chanmhodarkar-segmentmhodarkar-segmentsandhya16sandhya16hema-bahirwani-segmenthema-bahirwani-segmentbnakkinabnakkinapraveenugiripraveenugiriighorelaighorelanemery-segmentnemery-segmentwlumsegmentwlumsegmentnat-gridnat-gridneedcaffeineneedcaffeinekbhargavaram-sgkbhargavaram-sgirfan.ali.segmentirfan.ali.segmented-twilion-npmed-twilion-npmaubreysineaubreysinesethgrid_segmentsethgrid_segmentjibrangjibrangseg-leonelsanchesseg-leonelsanchessmccoy-twiliosmccoy-twiliodevthaledevthaleandwivediandwivediaditya_segmentaditya_segmentpoojapatilsegpoojapatilseggaprabhugaprabhumonusegmentmonusegmentjkilpatrick-segmentjkilpatrick-segmentdasanchezdasancheznsolanki-starnsolanki-staratitshah.segatitshah.segwongwilliamwongwilliamankit.gupta.unthinkableankit.gupta.unthinkableshazan77shazan77darcimmdarcimmjesswatsonjesswatsonafgan-segmentafgan-segmenttwiliochiragtwiliochiragfarbod_segmentfarbod_segmentgrsmithgrsmithharsh-joshi99harsh-joshi99anvesh_reddy_1311anvesh_reddy_1311aleman842aleman842abueide-segmentabueide-segmentcaseyk09caseyk09ankigupta92ankigupta92psandquistpsandquistjagsinghjagsinghdcp-twiliodcp-twilioagerbas-segmentagerbas-segmentamitsinglaatsegamitsinglaatsegjoy-twiliojoy-twilioamanda.maamanda.majinesh-twiliojinesh-twilioardev_npmardev_npmnikumar-segment-newnikumar-segment-newsarthak-twiliosarthak-twilionupur-twilionupur-twiliovkundnanivkundnaniprathoresegmentprathoresegmentmmilhansegmmilhansegshubhkrishnashubhkrishnakvivekabhiramkvivekabhiramajsinghsegajsinghsegkkolhe-twiliokkolhe-twilioprassinghprassinghseg-ajasinghseg-ajasinghmdkhan-twmdkhan-twmahitmahitmfkimbellmfkimbelll0adedl0adedjay-savlajay-savlalaksh25laksh25sbommarito-segmentsbommarito-segmentcsmonlaicsmonlaibha_segmentbha_segmentayagrawal7ayagrawal7mayguptamaygupta

Keywords

Readme

prism

A templating engine for generating strongly typed analytics clients across languages using the schema defined by a Tracking Plan

Install

Yarn

yarn global add @segment/prism

npm

npm install @segment/prism -g

Run

The following will generate a client api based on the Tracking Plan with id rs_15cyAM8Ce7hudhJ2dH50xIkywoe at the the path defined by outputPath

prism gen-js \ 
  --id rs_15cyAM8Ce7hudhJ2dH50xIkywoe \
  --token [your_token] \
  --outputPath .

An API token can be obtained by navigating to the API Keys page for a workspace containing the Tracking Plan you intend to generate a client for:

https://app.segment.com/{your_workspace_name}/settings/api-keys

API Keys

To run this tool against a local Tracking Plan file, run the following command (see the file referenced by the --inputPath switch as an example of the format that's expected):

prism gen-ts \
  --inputPath src/lib/__tests__/trackingPlanFixture.json \
  --outputPath .

To get a description of each of the provided arguments for this command, run prism gen-ts --help

Options:
  --help        Show help                                              [boolean]
  --version     Show version number                                    [boolean]
  --id          The resource id for a Tracking Plan                     [string]
  --token       The auth token for a user                               [string]
  --outputPath  The output path for the files                           [string]
  --inputPath   The path to a local tracking plan file                  [string]

To get a list of available language targets, run prism --help

Commands:
  gen-android  Generate a strongly typed Android client from a Tracking Plan
  gen-js       Generate an analytics.js wrapper from a Tracking Plan
  gen-ts       Generate a typescript type definitions from a Tracking Plan

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]

Build and run locally [WIP]

From within this project directory:

npm install
npm run build

# The build library is now available in ./dist 

node ./dist/index.js gen-js \ 
  --id rs_15cyAM8Ce7hudhJ2dH50xIkywoe \
  --token [your_token] \
  --outputPath .

Add New Language Targets

(TODO - extend this section)

  1. Create a gen-{your-lang-here}.ts file in src/commands (see existing commands for examples to work from)

  2. Export the variables command (the name of the command), desc (its description), builder (an object that captures the parameters your command takes -- in the majority of cases you can just re-export builder in src/lib/index.ts) and handler -- covered below

  3. The handler export is the function that accepts an array of Tracking Plan events and a reference to an api instance -- (note the handler must be wrapped by the getTypeTrackHandler() function) here you can extract type information and other metadata from the events and use it to format a data payload that can be provided to the api instance's render() method

/*
 * gen-go.ts
 */

export const handler = getTypedTrackHandler((events, api) => {
  
  const structs = transformEventsIntoGoStructs(events)
  
  return api.render('analytics', 'go', {
    structs
  })
}, command)

The first argument of render specifies the name of a template file (in the case of this hypothetical go client generator, this would be a reference to a handlebars template file at src/resources/go/analytics.hbs) -- this works similar in spirit to an express view engine. The name of the language in gen-{language} will correspond to the resource path where templates are found

The second argument to render specifies the generated file's extension (analytics.go)

A single promise must be returned from a handler -- in order to render multiple files, use a Promise.all() to concurrently render them to disk:

/*
 * gen-node.ts
 */

export const handler = getTypedTrackHandler((events, api) => {
  // ...

  return Promise.all([
    api.render('package', 'json', {
      versionInfo,
      otherData
    }),
    api.render('Readme', 'md', {
      models,
      someOtherStuff
    }),
    api.render('index', 'js', {
      models
    })
  ])
}, command)
  1. To give an idea of what a generator produces, include the ouput of your command in samples/{language} (TODO: standarize a source input to use for generating samples when the --file option lands for specifying a local json file)