Skip to content

Commit 7fcf451

Browse files
authored
Merge pull request #86 from amplitude/3.0.2-candidate
3.0.2 candidate
2 parents ed405af + 347017c commit 7fcf451

17 files changed

+80
-65
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## Unreleased
22

3+
* `productId` is no longer a required field for `Revenue` logged via `logRevenueV2`.
4+
* Track raw user agent string for backend filtering.
5+
36
### 3.0.1 (June 22, 2016)
47

58
* Update README with link to our [Google Tag Manager integration demo app](https://github.com/amplitude/GTM-Web-Demo).

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ var revenue = new amplitude.Revenue().setProductId('com.company.productId').setP
270270
amplitude.getInstance().logRevenueV2(revenue);
271271
```
272272
273-
`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:
273+
`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:
274274
275275
| Name | Type | Description | default |
276276
|--------------------|------------|----------------------------------------------------------------------------------------------------------|---------|

amplitude.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,8 @@ var AmplitudeClient = function AmplitudeClient(instanceName) {
522522
this._newSession = false;
523523
this._sequenceNumber = 0;
524524
this._sessionId = null;
525+
526+
this._userAgent = (navigator && navigator.userAgent) || null;
525527
};
526528

527529
AmplitudeClient.prototype.Identify = Identify;
@@ -1279,7 +1281,8 @@ AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventPropert
12791281
version: version
12801282
},
12811283
sequence_number: sequenceNumber, // for ordering events and identifys
1282-
groups: utils.truncate(utils.validateGroups(groups))
1284+
groups: utils.truncate(utils.validateGroups(groups)),
1285+
user_agent: this._userAgent
12831286
// country: null
12841287
};
12851288

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

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

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

38373838
// optional fields
3839+
this._productId = null;
3840+
this._quantity = 1;
38383841
this._revenueType = null;
38393842
this._properties = null;
38403843
};
38413844

38423845
/**
3843-
* Set a value for the product identifer. This field is required for all revenue being logged.
3846+
* Set a value for the product identifer.
38443847
* @public
38453848
* @param {string} productId - The value for the product identifier. Empty and invalid strings are ignored.
38463849
* @return {Revenue} Returns the same Revenue object, allowing you to chain multiple method calls together.
@@ -3932,10 +3935,6 @@ Revenue.prototype.setEventProperties = function setEventProperties(eventProperti
39323935
* @private
39333936
*/
39343937
Revenue.prototype._isValidRevenue = function _isValidRevenue() {
3935-
if (type(this._productId) !== 'string' || utils.isEmptyString(this._productId)) {
3936-
utils.log('Invalid revenue, need to set productId field');
3937-
return false;
3938-
}
39393938
if (type(this._price) !== 'number') {
39403939
utils.log('Invalid revenue, need to set price field');
39413940
return false;

amplitude.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

documentation/Amplitude.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3091,7 +3091,7 @@ <h5>Parameters:</h5>
30913091

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

30973097

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

31393139
<footer>
3140-
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)
3140+
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)
31413141
</footer>
31423142

31433143
<script> prettyPrint(); </script>

documentation/AmplitudeClient.html

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ <h4 class="name" id="__VERSION__"><span class="type-signature"></span>__VERSION_
185185

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

191191

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

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

274274

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

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

361361

@@ -534,7 +534,7 @@ <h5>Parameters:</h5>
534534

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

540540

@@ -742,7 +742,7 @@ <h5>Parameters:</h5>
742742

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

748748

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

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

835835

@@ -1029,7 +1029,7 @@ <h5>Parameters:</h5>
10291029

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

10351035

@@ -1240,7 +1240,7 @@ <h5>Parameters:</h5>
12401240

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

12461246

@@ -1424,7 +1424,7 @@ <h5>Parameters:</h5>
14241424

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

14301430

@@ -1563,7 +1563,7 @@ <h5>Parameters:</h5>
15631563

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

15691569

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

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

16601660

@@ -1787,7 +1787,7 @@ <h5>Parameters:</h5>
17871787

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

17931793

@@ -1923,7 +1923,7 @@ <h5>Parameters:</h5>
19231923

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

19291929

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

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

20182018

@@ -2175,7 +2175,7 @@ <h5>Parameters:</h5>
21752175

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

21812181

@@ -2311,7 +2311,7 @@ <h5>Parameters:</h5>
23112311

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

23172317

@@ -2442,7 +2442,7 @@ <h5>Parameters:</h5>
24422442

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

24482448

@@ -2602,7 +2602,7 @@ <h5>Parameters:</h5>
26022602

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

26082608

@@ -2738,7 +2738,7 @@ <h5>Parameters:</h5>
27382738

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

27442744

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

27932793
<footer>
2794-
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)
2794+
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)
27952795
</footer>
27962796

27972797
<script> prettyPrint(); </script>

documentation/Identify.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
12951295
<br class="clear">
12961296

12971297
<footer>
1298-
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)
1298+
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)
12991299
</footer>
13001300

13011301
<script> prettyPrint(); </script>

documentation/Revenue.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ <h4 class="name" id="Revenue"><span class="type-signature"></span>new Revenue<sp
5050
Revenue API - instance constructor. Revenue objects are a wrapper for revenue data.
5151
Each method updates a revenue property in the Revenue object, and returns the same Revenue object,
5252
allowing you to chain multiple method calls together.
53-
Note: productId and price are required fields to log revenue events.
53+
Note: price is a required field to log revenue events.
5454
If quantity is not specified then defaults to 1.
5555
See <a href="https://github.com/amplitude/Amplitude-Javascript#tracking-revenue">Readme</a> for more information
5656
about logging Revenue.
@@ -478,7 +478,7 @@ <h4 class="name" id="setProductId"><span class="type-signature"></span>setProduc
478478

479479

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

484484

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

967967
<footer>
968-
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)
968+
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)
969969
</footer>
970970

971971
<script> prettyPrint(); </script>

documentation/amplitude-client.js.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ <h1 class="page-title">Source: amplitude-client.js</h1>
6969
this._newSession = false;
7070
this._sequenceNumber = 0;
7171
this._sessionId = null;
72+
73+
this._userAgent = (navigator &amp;&amp; navigator.userAgent) || null;
7274
};
7375

7476
AmplitudeClient.prototype.Identify = Identify;
@@ -826,7 +828,8 @@ <h1 class="page-title">Source: amplitude-client.js</h1>
826828
version: version
827829
},
828830
sequence_number: sequenceNumber, // for ordering events and identifys
829-
groups: utils.truncate(utils.validateGroups(groups))
831+
groups: utils.truncate(utils.validateGroups(groups)),
832+
user_agent: this._userAgent
830833
// country: null
831834
};
832835

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

11721175
<footer>
1173-
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)
1176+
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)
11741177
</footer>
11751178

11761179
<script> prettyPrint(); </script>

documentation/amplitude.js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
409409
<br class="clear">
410410

411411
<footer>
412-
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)
412+
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)
413413
</footer>
414414

415415
<script> prettyPrint(); </script>

0 commit comments

Comments
 (0)