typewriter icon indicating copy to clipboard operation
typewriter copied to clipboard

Supporting other segment methods

Open defjosiah opened this issue 6 years ago • 3 comments

feature proposal ✍️

Please detail the following items when filing a feature request:

Wanted to request that the generated Analytics object would include typed methods for more than just the "track" event.

Ideally, we'd be able to use this as a typesafe wrapper around the whole segment api.

For instance, an example usage from our codebase (simplified):

   // track is an initialized generated analytics client
    window.analytics.identify({
      'ab-test-variation': Cookies.get('ab-test-variation') || 'no-cookie',
    });
    track.variationViewed({
      'ab-test-variation': Cookies.get('ab-test-variation'),
    });

Ideally instead of "window.analytics" we could always just use a generated client with typesafe args.

In the ideal case, it would probably include a schema for the (in this instance) identify call. But even a loose typescript type like {[key: string]: any} would be nice.

Also, thanks for this library! It's fantastic, it's not that often that there is an immediate "I wish this existed", "oh my gosh it does" event.

defjosiah avatar May 18 '19 03:05 defjosiah

Thanks for raising this issue, @defjosiah!

Just added identify and group to the v7.x roadmap: https://github.com/segmentio/typewriter/pull/59 We'll probably add these as a typed .identify() and .group() call.

We'll add page and screen call support at some point in the future, it's just lower priority for us right now, since we don't yet support named page calls in the Segment Tracking Plan editor.

colinking avatar May 19 '19 14:05 colinking

Awesome! Thank you, that'll be great.

defjosiah avatar May 19 '19 22:05 defjosiah

Heads up that we just shipped v7 (you can try it out with npx typewriter init), but we cut identify/group support from scope for that release. It's still on our roadmap for a v7.x release, though.

Will leave this issue up until it's live.

colinking avatar Oct 21 '19 20:10 colinking