Skip to content
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Unreleased

* `productId` is no longer a required field for `Revenue` logged via `logRevenueV2`.
* Track raw user agent string for backend filtering.

### 3.0.1 (June 22, 2016)

* Update README with link to our [Google Tag Manager integration demo app](https://github.com/amplitude/GTM-Web-Demo).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ var revenue = new amplitude.Revenue().setProductId('com.company.productId').setP
amplitude.getInstance().logRevenueV2(revenue);
```

`productId` and `price` are required fields. `quantity` defaults to 1 if not specified. Each field has a corresponding `set` method (for example `setProductId`, `setQuantity`, etc). This table describes the different fields available:
`price` is a required field. `quantity` defaults to 1 if not specified. Each field has a corresponding `set` method (for example `setProductId`, `setQuantity`, etc). This table describes the different fields available:

| Name | Type | Description | default |
|--------------------|------------|----------------------------------------------------------------------------------------------------------|---------|
Expand Down
19 changes: 9 additions & 10 deletions amplitude.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,8 @@ var AmplitudeClient = function AmplitudeClient(instanceName) {
this._newSession = false;
this._sequenceNumber = 0;
this._sessionId = null;

this._userAgent = (navigator && navigator.userAgent) || null;
};

AmplitudeClient.prototype.Identify = Identify;
Expand Down Expand Up @@ -1279,7 +1281,8 @@ AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventPropert
version: version
},
sequence_number: sequenceNumber, // for ordering events and identifys
groups: utils.truncate(utils.validateGroups(groups))
groups: utils.truncate(utils.validateGroups(groups)),
user_agent: this._userAgent
// country: null
};

Expand Down Expand Up @@ -3813,14 +3816,14 @@ var utils = require('./utils');

/*
* Wrapper for logging Revenue data. Revenue objects get passed to amplitude.logRevenueV2 to send to Amplitude servers.
* Note: productId and price are required fields. If quantity is not specified, then defaults to 1.
* Note: price is the only required field. If quantity is not specified, then defaults to 1.
*/

/**
* Revenue API - instance constructor. Revenue objects are a wrapper for revenue data.
* Each method updates a revenue property in the Revenue object, and returns the same Revenue object,
* allowing you to chain multiple method calls together.
* Note: productId and price are required fields to log revenue events.
* Note: price is a required field to log revenue events.
* If quantity is not specified then defaults to 1.
* See [Readme]{@link https://github.com/amplitude/Amplitude-Javascript#tracking-revenue} for more information
* about logging Revenue.
Expand All @@ -3830,17 +3833,17 @@ var utils = require('./utils');
*/
var Revenue = function Revenue() {
// required fields
this._productId = null;
this._quantity = 1;
this._price = null;

// optional fields
this._productId = null;
this._quantity = 1;
this._revenueType = null;
this._properties = null;
};

/**
* Set a value for the product identifer. This field is required for all revenue being logged.
* Set a value for the product identifer.
* @public
* @param {string} productId - The value for the product identifier. Empty and invalid strings are ignored.
* @return {Revenue} Returns the same Revenue object, allowing you to chain multiple method calls together.
Expand Down Expand Up @@ -3932,10 +3935,6 @@ Revenue.prototype.setEventProperties = function setEventProperties(eventProperti
* @private
*/
Revenue.prototype._isValidRevenue = function _isValidRevenue() {
if (type(this._productId) !== 'string' || utils.isEmptyString(this._productId)) {
utils.log('Invalid revenue, need to set productId field');
return false;
}
if (type(this._price) !== 'number') {
utils.log('Invalid revenue, need to set price field');
return false;
Expand Down
4 changes: 2 additions & 2 deletions amplitude.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions documentation/Amplitude.html
Original file line number Diff line number Diff line change
Expand Up @@ -3091,7 +3091,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line837">line 837</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line840">line 840</a>
</li></ul></dd>


Expand Down Expand Up @@ -3137,7 +3137,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jun 22 2016 14:19:08 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jul 06 2016 13:45:46 GMT-0700 (PDT)
</footer>

<script> prettyPrint(); </script>
Expand Down
40 changes: 20 additions & 20 deletions documentation/AmplitudeClient.html
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ <h4 class="name" id="__VERSION__"><span class="type-signature"></span>__VERSION_

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line1126">line 1126</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line1129">line 1129</a>
</li></ul></dd>


Expand Down Expand Up @@ -268,7 +268,7 @@ <h4 class="name" id="clearUserProperties"><span class="type-signature"></span>cl

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line669">line 669</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line671">line 671</a>
</li></ul></dd>


Expand Down Expand Up @@ -355,7 +355,7 @@ <h4 class="name" id="getSessionId"><span class="type-signature"></span>getSessio

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line231">line 231</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line233">line 233</a>
</li></ul></dd>


Expand Down Expand Up @@ -534,7 +534,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line705">line 705</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line707">line 707</a>
</li></ul></dd>


Expand Down Expand Up @@ -742,7 +742,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line60">line 60</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line62">line 62</a>
</li></ul></dd>


Expand Down Expand Up @@ -829,7 +829,7 @@ <h4 class="name" id="isNewSession"><span class="type-signature"></span>isNewSess

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line222">line 222</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line224">line 224</a>
</li></ul></dd>


Expand Down Expand Up @@ -1029,7 +1029,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line854">line 854</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line857">line 857</a>
</li></ul></dd>


Expand Down Expand Up @@ -1240,7 +1240,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line880">line 880</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line883">line 883</a>
</li></ul></dd>


Expand Down Expand Up @@ -1424,7 +1424,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line938">line 938</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line941">line 941</a>
</li></ul></dd>


Expand Down Expand Up @@ -1563,7 +1563,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line909">line 909</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line912">line 912</a>
</li></ul></dd>


Expand Down Expand Up @@ -1654,7 +1654,7 @@ <h4 class="name" id="regenerateDeviceId"><span class="type-signature"></span>reg

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line615">line 615</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line617">line 617</a>
</li></ul></dd>


Expand Down Expand Up @@ -1787,7 +1787,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line627">line 627</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line629">line 629</a>
</li></ul></dd>


Expand Down Expand Up @@ -1923,7 +1923,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line532">line 532</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line534">line 534</a>
</li></ul></dd>


Expand Down Expand Up @@ -2012,7 +2012,7 @@ <h4 class="name" id="setGlobalUserProperties"><span class="type-signature"></spa

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line1116">line 1116</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line1119">line 1119</a>
</li></ul></dd>


Expand Down Expand Up @@ -2175,7 +2175,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line577">line 577</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line579">line 579</a>
</li></ul></dd>


Expand Down Expand Up @@ -2311,7 +2311,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line595">line 595</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line597">line 597</a>
</li></ul></dd>


Expand Down Expand Up @@ -2442,7 +2442,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line555">line 555</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line557">line 557</a>
</li></ul></dd>


Expand Down Expand Up @@ -2602,7 +2602,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line650">line 650</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line652">line 652</a>
</li></ul></dd>


Expand Down Expand Up @@ -2738,7 +2738,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line740">line 740</a>
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line742">line 742</a>
</li></ul></dd>


Expand Down Expand Up @@ -2791,7 +2791,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jun 22 2016 14:19:08 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jul 06 2016 13:45:46 GMT-0700 (PDT)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion documentation/Identify.html
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jun 22 2016 14:19:08 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jul 06 2016 13:45:46 GMT-0700 (PDT)
</footer>

<script> prettyPrint(); </script>
Expand Down
6 changes: 3 additions & 3 deletions documentation/Revenue.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h4 class="name" id="Revenue"><span class="type-signature"></span>new Revenue<sp
Revenue API - instance constructor. Revenue objects are a wrapper for revenue data.
Each method updates a revenue property in the Revenue object, and returns the same Revenue object,
allowing you to chain multiple method calls together.
Note: productId and price are required fields to log revenue events.
Note: price is a required field to log revenue events.
If quantity is not specified then defaults to 1.
See <a href="https://github.com/amplitude/Amplitude-Javascript#tracking-revenue">Readme</a> for more information
about logging Revenue.
Expand Down Expand Up @@ -478,7 +478,7 @@ <h4 class="name" id="setProductId"><span class="type-signature"></span>setProduc


<div class="description">
Set a value for the product identifer. This field is required for all revenue being logged.
Set a value for the product identifer.
</div>


Expand Down Expand Up @@ -965,7 +965,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jun 22 2016 14:19:08 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jul 06 2016 13:45:46 GMT-0700 (PDT)
</footer>

<script> prettyPrint(); </script>
Expand Down
7 changes: 5 additions & 2 deletions documentation/amplitude-client.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ <h1 class="page-title">Source: amplitude-client.js</h1>
this._newSession = false;
this._sequenceNumber = 0;
this._sessionId = null;

this._userAgent = (navigator &amp;&amp; navigator.userAgent) || null;
};

AmplitudeClient.prototype.Identify = Identify;
Expand Down Expand Up @@ -826,7 +828,8 @@ <h1 class="page-title">Source: amplitude-client.js</h1>
version: version
},
sequence_number: sequenceNumber, // for ordering events and identifys
groups: utils.truncate(utils.validateGroups(groups))
groups: utils.truncate(utils.validateGroups(groups)),
user_agent: this._userAgent
// country: null
};

Expand Down Expand Up @@ -1170,7 +1173,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jun 22 2016 14:19:08 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jul 06 2016 13:45:46 GMT-0700 (PDT)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion documentation/amplitude.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jun 22 2016 14:19:08 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jul 06 2016 13:45:46 GMT-0700 (PDT)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion documentation/identify.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jun 22 2016 14:19:08 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jul 06 2016 13:45:46 GMT-0700 (PDT)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion documentation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jun 22 2016 14:19:08 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jul 06 2016 13:45:46 GMT-0700 (PDT)
</footer>

<script> prettyPrint(); </script>
Expand Down
Loading