-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pierre-Alexandre St-Jean
committed
Apr 26, 2016
1 parent
5d570a6
commit 6f7f356
Showing
19 changed files
with
156 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.DS_STORE | ||
|
||
dist/* | ||
dist_test/* | ||
node_modules/* | ||
typings/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
"scripts": { | ||
"build:webpack": "webpack", | ||
"build:tsc": "tsc", | ||
"test": "tsc -p test && ava", | ||
"test": "tsc -p tsconfig.test.json && ava \"**/*test.js\"", | ||
"clean": "rm -rf dist/*" | ||
}, | ||
"author": "Pierre-Alexandre St-Jean <[email protected]>", | ||
|
@@ -20,7 +20,10 @@ | |
"ava": "^0.14.0", | ||
"es6-promise": "3.1.2", | ||
"exports-loader": "0.6.3", | ||
"express": "^4.13.4", | ||
"isomorphic-fetch": "2.2.1", | ||
"jsdom": "^8.4.0", | ||
"sinon": "^1.17.3", | ||
"ts-loader": "0.8.2", | ||
"tslint": "3.8.0", | ||
"tslint-loader": "2.1.3", | ||
|
@@ -35,5 +38,11 @@ | |
"dist/**/*.js.map", | ||
"src/**/*.ts", | ||
"LICENSE" | ||
] | ||
], | ||
"ava": { | ||
"require": [ | ||
"babel-register", | ||
"./test/helpers/setup-browser-env.js" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import test from 'ava'; | ||
import * as analytics from '../src/analytics'; | ||
|
||
import * as express from 'express'; | ||
import * as http from 'http'; | ||
|
||
var app:express.Application = express(); | ||
const server: http.Server = (<any>http).createServer(app).listen() | ||
app.set('port', server.address().port); | ||
|
||
test('Analytics: can post a view event', t => { | ||
|
||
const response : analytics.ViewEventResponse = { | ||
raw:undefined, | ||
visitId : '123', | ||
visitorId: '213' | ||
} | ||
|
||
app.post('/analytics/view',(req,res) => { | ||
res.status(200).send(JSON.stringify(response)); | ||
}); | ||
|
||
const client = new analytics.Client({ | ||
token: 'token', | ||
endpoint:`http://localhost:${server.address().port}` | ||
}); | ||
|
||
return client.sendViewEvent({location:'here'}).then((res: analytics.ViewEventResponse)=> { | ||
t.not(res.raw,undefined); | ||
t.is(res.visitId,response.visitId); | ||
t.is(res.visitorId,response.visitorId); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
global.document = require('jsdom').jsdom('<body></body>'); | ||
global.window = document.defaultView; | ||
global.navigator = window.navigator; | ||
global.fetch = require('isomorphic-fetch'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
interface IteratorResult<T> { | ||
done: boolean; | ||
value?: T; | ||
} | ||
|
||
interface Iterator<T> { | ||
next(value?: any): IteratorResult<T>; | ||
return?(value?: any): IteratorResult<T>; | ||
throw?(e?: any): IteratorResult<T>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import test from 'ava'; | ||
import simpleanalytics from '../src/simpleanalytics'; | ||
|
||
import * as express from 'express'; | ||
import * as http from 'http'; | ||
|
||
var app:express.Application = express(); | ||
const responder = (req: express.Request,res: express.Response) => { | ||
res.status(200).send("{}") | ||
} | ||
app.post('/analytics/view',responder); | ||
const server: http.Server = (<any>http).createServer(app).listen() | ||
app.set('port', server.address().port); | ||
|
||
|
||
test('SimpleAnalytics: can\'t call without initiating', t => { | ||
t.throws(()=>{ simpleanalytics('send') }, /init/) | ||
}); | ||
test('SimpleAnalytics: can\'t init without token', t => { | ||
t.throws(()=>{ simpleanalytics('init') }, /token/); | ||
}); | ||
|
||
test('SimpleAnalytics: can send pageview', t => { | ||
simpleanalytics('init','MYTOKEN', `http://localhost:${server.address().port}`) | ||
simpleanalytics('send','pageview') | ||
}); | ||
|
||
|
||
test('SimpleAnalytics: can send pageview with customdata', t => { | ||
simpleanalytics('init','MYTOKEN', `http://localhost:${server.address().port}`) | ||
simpleanalytics('send','pageview', {somedata:'asd'}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"outDir": "dist", | ||
"module": "commonjs", | ||
"declaration": true, | ||
"noImplicitAny": true, | ||
"removeComments": true, | ||
"sourceMap": true | ||
}, | ||
"files": [ | ||
"src/browser.ts", | ||
"src/analytics.ts", | ||
"src/index.ts", | ||
"src/objectAssign.ts", | ||
"src/donottrack.ts", | ||
"src/history.ts", | ||
"src/detector.ts", | ||
"typings/main.d.ts" | ||
] | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es5", | ||
"outDir": "dist", | ||
"declaration": true, | ||
"noImplicitAny": true, | ||
"removeComments": true, | ||
"sourceMap": true | ||
}, | ||
"files": [ | ||
"src/analytics.ts", | ||
"src/browser.ts", | ||
"src/detector.ts", | ||
"src/donottrack.ts", | ||
"src/history.ts", | ||
"src/index.ts", | ||
"src/objectassign.ts", | ||
"src/simpleanalytics.ts", | ||
"typings/main.d.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es5", | ||
"outDir": "dist_test", | ||
"declaration": false, | ||
"noImplicitAny": true, | ||
"removeComments": true, | ||
"sourceMap": true | ||
}, | ||
"files": [ | ||
"test/lib.d.ts", | ||
"test/simpleanalytics_test.ts", | ||
"test/analytics_test.ts", | ||
"typings/main.d.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
{ | ||
"ambientDependencies": { | ||
"es6-promise": "github:DefinitelyTyped/DefinitelyTyped/es6-promise/es6-promise.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd", | ||
"isomorphic-fetch": "github:DefinitelyTyped/DefinitelyTyped/isomorphic-fetch/isomorphic-fetch.d.ts#56295f5058cac7ae458540423c50ac2dcf9fc711" | ||
"es6-promise": "registry:dt/es6-promise#0.0.0+20160423074304", | ||
"express": "registry:dt/express#4.0.0+20160317120654", | ||
"express-serve-static-core": "registry:dt/express-serve-static-core#0.0.0+20160322035842", | ||
"isomorphic-fetch": "github:DefinitelyTyped/DefinitelyTyped/isomorphic-fetch/isomorphic-fetch.d.ts#56295f5058cac7ae458540423c50ac2dcf9fc711", | ||
"serve-static": "registry:dt/serve-static#0.0.0+20160317120654", | ||
"sinon": "registry:dt/sinon#1.16.0+20160317120654" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters