Skip to content

Commit

Permalink
Update examples to use up-to-date Typewriter (#23)
Browse files Browse the repository at this point in the history
While on a call with Seth, we realized that the examples used a heavily outdated version of Typewriter. This PR goes through and updates the JS examples to use a linked version of Typewriter, so that it is always up-to-date.
  • Loading branch information
colinking committed Oct 29, 2018
1 parent dd1ddba commit 4af1311
Show file tree
Hide file tree
Showing 22 changed files with 2,631 additions and 2,981 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -70,3 +70,6 @@ dist
.rpt2_cache

.DS_Store

# We use yarn.lock
package-lock.json
2,529 changes: 2,529 additions & 0 deletions examples/js/generated/index.js

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions examples/js/package.json
Expand Up @@ -3,8 +3,9 @@
"version": "1.0.0",
"description": "Example app showcasing Typewriter in Javascript",
"scripts": {
"build": "npm run typewriter-local && next build",
"dev": "npm run typewriter-local && next",
"build": "yarn run typewriter-local && next build",
"preinstall": "cd ../.. && yarn link",
"dev": "yarn run typewriter-local && next",
"typewriter-remote": "typewriter gen-js --trackingPlanId {YOUR_TRACKING_PLAN_ID} --workspaceSlug {YOUR_WORKSPACE_SLUG} --token {YOUR_API_TOKEN} --outputPath ./pages/generated",
"typewriter-local": "typewriter gen-js --inputPath ../local-tracking-plans/tracking-plan-web.json --outputPath ./pages/generated",
"generate": "yarn run typewriter-local"
Expand All @@ -17,9 +18,6 @@
"react": "^16.2.0",
"react-dom": "^16.2.0"
},
"devDependencies": {
"typewriter": "1.0.0"
},
"main": "index.js",
"private": false
}
8 changes: 4 additions & 4 deletions examples/js/pages/generated/index.js
Expand Up @@ -5,7 +5,7 @@ const genOptions = (context = { library: {} }) => ({
...context.library,
typewriter: {
name: "gen-js",
version: "3.2.0"
version: "3.2.1"
}
}
}
Expand Down Expand Up @@ -110,7 +110,7 @@ export default class Analytics {
throw new Error(JSON.stringify(validate.errors, null, 2));
}
}
this.analytics.track("Feed Viewed", props, genOptions(ctx));
this.analytics.track("Feed Viewed", props, genOptions(context));
}
photoViewed(props, context) {
if (this.propertyValidation) {
Expand Down Expand Up @@ -196,7 +196,7 @@ export default class Analytics {
throw new Error(JSON.stringify(validate.errors, null, 2));
}
}
this.analytics.track("Photo Viewed", props, genOptions(ctx));
this.analytics.track("Photo Viewed", props, genOptions(context));
}
profileViewed(props, context) {
if (this.propertyValidation) {
Expand Down Expand Up @@ -282,6 +282,6 @@ export default class Analytics {
throw new Error(JSON.stringify(validate.errors, null, 2));
}
}
this.analytics.track("Profile Viewed", props, genOptions(ctx));
this.analytics.track("Profile Viewed", props, genOptions(context));
}
}
7 changes: 4 additions & 3 deletions examples/js/pages/index.js
Expand Up @@ -3,7 +3,7 @@ import Router from 'next/router'
import Modal from '../components/Modal'
import Layout from '../components/Layout'

import * as analytics from './generated'
import Analytics from './generated'

export default class extends React.Component {
static getInitialProps () {
Expand All @@ -13,7 +13,8 @@ export default class extends React.Component {
}

componentDidMount () {
analytics.feedViewed({ profileId: '3' })
const appAnalytics = new Analytics(window.analytics)
appAnalytics.feedViewed({ profileId: '3' })
}

dismissModal () {
Expand Down Expand Up @@ -79,4 +80,4 @@ export default class extends React.Component {
</Layout>
)
}
}
}
7 changes: 4 additions & 3 deletions examples/js/pages/photo.js
@@ -1,11 +1,12 @@
import React from 'react'
import Frame from '../components/Frame'
import Layout from '../components/Layout'
import * as analytics from './generated'
import Analytics from './generated'

export default class Photo extends React.Component {
componentDidMount() {
analytics.photoViewed({ photoID: '3' })
const appAnalytics = new Analytics(window.analytics)
appAnalytics.photoViewed({ photoID: '3' })
}
render() {
return (
Expand All @@ -29,4 +30,4 @@ export default class Photo extends React.Component {
</Layout>
)
}
}
}
5 changes: 3 additions & 2 deletions examples/js/pages/profile.js
@@ -1,10 +1,11 @@
import React from 'react'
import Layout from '../components/Layout'
import * as analytics from './generated'
import Analytics from './generated'

export default class Profile extends React.Component {
componentDidMount() {
analytics.profileViewed({ profileId: '3' })
const appAnalytics = new Analytics(window.analytics)
appAnalytics.profileViewed({ profileId: '3' })
}
render() {
return (
Expand Down

0 comments on commit 4af1311

Please sign in to comment.