Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize library #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"devel": true,
"node": true,
"globals": {
"define": true,
"describe": true,
"beforeEach": true,
"afterEach": true,
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Tattletale wraps around the browser’s `console` object, storing your logs in order to send them over XHR for long-term storage and analysis using a service like [Scribe](http://github.com/facebook/scribe).

## Install with npm

```
npm install Tattletale
```

## Usage

```javascript
Expand Down Expand Up @@ -32,3 +38,11 @@ var tattletale = new Tattletale('/log', {
token: window.xsrft
});
```

## Contributors

### Lint, Test, Uglify

```
npm install && npm run build
```
31 changes: 31 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Type definitions for Tattletale.js
// Project: https://github.com/vimeo/tattletale.js
// Definitions by: iconix <https://github.com/iconix>
// Based on: http://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-class-d-ts.html

/*~ Write your module's methods and properties in this class */
declare class __Tattletale {
constructor(url: string, static_request_data?: Object);

someProperty: string[];

log(data: string | number | boolean): void;

empty(): void;

send(callback?: Function): void;
}

/*~ This declaration specifies that the class constructor function
*~ is the exported object from the file
*~
*~ Note that ES6 modules cannot directly export class objects.
*~ This file should be imported using the CommonJS-style:
*~ import x = require('someLibrary');
*~
*~ Refer to the documentation to understand common
*~ workarounds for this limitation of ES6 modules.
*/
declare module 'Tattletale' {
export = __Tattletale;
}
32 changes: 20 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
{
"name": "Tattletale",
"description": "A utility to send console logs over XHR for server-side processing.",
"version": "0.1.0",
"description": "A UMD module for sending console logs over XHR for server-side processing.",
"version": "0.2.0",
"author": "Vimeo, LLC",
"license": "Apache 2.0",
"license": "Apache-2.0",
"main": "tattletale.min.js",
"repository": {
"type": "git",
"url": "[email protected]:vimeo/tattletail.git"
"url": "[email protected]:vimeo/tattletale.js.git"
},
"scripts": {
"build": "grunt"
},
"contributors": [
{
"name": "iconix"
},
{
"name": "Kevin Sweeney"
}
Expand All @@ -19,13 +26,14 @@
"logging"
],
"dependencies": {
"grunt": "~0.4",
"grunt-contrib-jshint": "~0.6",
"grunt-mocha": "~0.3",
"mocha": "~1.10",
"chai": "~1.6",
"sinon": "~1.7",
"sinon-chai": "~2.4",
"grunt-contrib-uglify": "~0.2.2"
"chai": "^3.5.0",
"grunt": "^1.0.1",
"grunt-cli": "^1.2.0",
"grunt-contrib-jshint": "^1.1.0",
"grunt-contrib-uglify": "^2.3.0",
"grunt-mocha": "^1.0.4",
"mocha": "^3.2.0",
"sinon": "^2.1.0",
"sinon-chai": "^2.9.0"
}
}
34 changes: 24 additions & 10 deletions tattletale.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
;(function(window) {
// UMD conversion based on: https://github.com/umdjs/umd/blob/master/templates/returnExports.js

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.Tattletale = factory();
}
}(this, function () {
'use strict';

// Constructor _______________________________________________________________
Expand Down Expand Up @@ -153,16 +168,15 @@
}
};

request.open('POST', self.url, true);
request.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
if (data_to_send) {
request.open('POST', self.url, true);
request.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

request.send(data_to_send);
request.send(data_to_send);
}
}
};

// Exports ___________________________________________________________________

window.Tattletale = Tattletale;

})(window);
return Tattletale;
}));
9 changes: 5 additions & 4 deletions tattletale.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.