Skip to content

Latest commit

 

History

History
 
 

ts

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Typewriter in TypeScript

This example repo demonstrates how to setup and use Typewriter in a web TypeScript environment, as a strongly-typed wrapper for analytics-js.

Setup

Install dependencies:

$ yarn

Update the Segment write key in Layout.tsx for the source you want to report analytics to:

analytics.load("<Your source write key>");

Run the development server:

$ yarn run dev
DONE  Compiled successfully in 1409ms                                       18:15:03

> Ready on http://localhost:3000
No type errors found
Version: typescript 3.1.1
Time: 2219ms

Once you run the app, go the debugger to see events coming in!

Typewriter Usage

The generated Typewriter client is available in analytics/generated/index.d.ts.

The JSON schema used to generate this client is available in local-tracking-plans/tracking-plan-slothgram.json.

You can regenerate the Typewriter client with yarn run typewriter.

Instrumentation

See README.md for more information on instrumenting your Typescript app with Typewriter.