Skip to content

Commit 22eb040

Browse files
committed
update documentation
1 parent de9acd0 commit 22eb040

File tree

9 files changed

+86
-55
lines changed

9 files changed

+86
-55
lines changed

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#line840">line 840</a>
3094+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line871">line 871</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 Sep 14 2016 13:32:02 GMT-0700 (PDT)
3140+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Oct 19 2016 00:42:27 GMT-0700 (PDT)
31413141
</footer>
31423142

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

documentation/AmplitudeClient.html

Lines changed: 19 additions & 19 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#line1130">line 1130</a>
188+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line1161">line 1161</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#line671">line 671</a>
271+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line702">line 702</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#line233">line 233</a>
358+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line250">line 250</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#line707">line 707</a>
537+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line738">line 738</a>
538538
</li></ul></dd>
539539

540540

@@ -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#line224">line 224</a>
832+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line241">line 241</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#line857">line 857</a>
1032+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line888">line 888</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#line883">line 883</a>
1243+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line914">line 914</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#line941">line 941</a>
1427+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line972">line 972</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#line912">line 912</a>
1566+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line943">line 943</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#line617">line 617</a>
1657+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line642">line 642</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#line629">line 629</a>
1790+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line654">line 654</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#line534">line 534</a>
1926+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line559">line 559</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#line1120">line 1120</a>
2015+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line1151">line 1151</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#line579">line 579</a>
2178+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line604">line 604</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#line597">line 597</a>
2314+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line622">line 622</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#line557">line 557</a>
2445+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line582">line 582</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#line652">line 652</a>
2605+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line677">line 677</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#line742">line 742</a>
2741+
<a href="amplitude-client.js.html">amplitude-client.js</a>, <a href="amplitude-client.js.html#line773">line 773</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 Sep 14 2016 13:32:02 GMT-0700 (PDT)
2794+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Oct 19 2016 00:42:27 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 Sep 14 2016 13:32:02 GMT-0700 (PDT)
1298+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Oct 19 2016 00:42:27 GMT-0700 (PDT)
12991299
</footer>
13001300

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

documentation/Revenue.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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 Sep 14 2016 13:32:02 GMT-0700 (PDT)
968+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Oct 19 2016 00:42:27 GMT-0700 (PDT)
969969
</footer>
970970

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

documentation/amplitude-client.js.html

Lines changed: 59 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,15 @@ <h1 class="page-title">Source: amplitude-client.js</h1>
119119
this._sessionId = now;
120120

121121
// only capture UTM params and referrer if new session
122-
if (this.options.includeUtm) {
123-
this._initUtmData();
124-
}
125-
if (this.options.includeReferrer) {
126-
this._saveReferrer(this._getReferrer());
122+
if (this.options.saveParamsReferrerOncePerSession) {
123+
this._trackParamsAndReferrer();
127124
}
128125
}
126+
127+
if (!this.options.saveParamsReferrerOncePerSession) {
128+
this._trackParamsAndReferrer();
129+
}
130+
129131
this._lastEventTime = now;
130132
_saveCookieData(this);
131133

@@ -160,6 +162,21 @@ <h1 class="page-title">Source: amplitude-client.js</h1>
160162
}
161163
};
162164

165+
/**
166+
* @private
167+
*/
168+
AmplitudeClient.prototype._trackParamsAndReferrer = function _trackParamsAndReferrer() {
169+
if (this.options.includeUtm) {
170+
this._initUtmData();
171+
}
172+
if (this.options.includeReferrer) {
173+
this._saveReferrer(this._getReferrer());
174+
}
175+
if (this.options.includeGclid) {
176+
this._saveGclid(this._getUrlParams());
177+
}
178+
};
179+
163180
/**
164181
* Parse and validate user specified config values and overwrite existing option value
165182
* DEFAULT_OPTIONS provides list of all config keys that are modifiable, as well as expected types for values
@@ -460,17 +477,18 @@ <h1 class="page-title">Source: amplitude-client.js</h1>
460477
* @private
461478
*/
462479
AmplitudeClient.prototype._initUtmData = function _initUtmData(queryParams, cookieParams) {
463-
queryParams = queryParams || location.search;
480+
queryParams = queryParams || this._getUrlParams();
464481
cookieParams = cookieParams || this.cookieStorage.get('__utmz');
465482
var utmProperties = getUtmData(cookieParams, queryParams);
466-
_sendUserPropertiesOncePerSession(this, Constants.UTM_PROPERTIES, utmProperties);
483+
_sendParamsReferrerUserProperties(this, utmProperties);
467484
};
468485

469486
/**
470-
* Since user properties are propagated on server, only send once per session, don't need to send with every event
487+
* The calling function should determine when it is appropriate to send these user properties. This function
488+
* will no longer contain any session storage checking logic.
471489
* @private
472490
*/
473-
var _sendUserPropertiesOncePerSession = function _sendUserPropertiesOncePerSession(scope, storageKey, userProperties) {
491+
var _sendParamsReferrerUserProperties = function _sendParamsReferrerUserProperties(scope, userProperties) {
474492
if (type(userProperties) !== 'object' || Object.keys(userProperties).length === 0) {
475493
return;
476494
}
@@ -480,20 +498,7 @@ <h1 class="page-title">Source: amplitude-client.js</h1>
480498
for (var key in userProperties) {
481499
if (userProperties.hasOwnProperty(key)) {
482500
identify.setOnce('initial_' + key, userProperties[key]);
483-
}
484-
}
485-
486-
// only save userProperties if not already in sessionStorage under key or if storage disabled
487-
var hasSessionStorage = utils.sessionStorageEnabled();
488-
if ((hasSessionStorage &amp;&amp; !(scope._getFromStorage(sessionStorage, storageKey))) || !hasSessionStorage) {
489-
for (var property in userProperties) {
490-
if (userProperties.hasOwnProperty(property)) {
491-
identify.set(property, userProperties[property]);
492-
}
493-
}
494-
495-
if (hasSessionStorage) {
496-
scope._setInStorage(sessionStorage, storageKey, JSON.stringify(userProperties));
501+
identify.set(key, userProperties[key]);
497502
}
498503
}
499504

@@ -507,6 +512,26 @@ <h1 class="page-title">Source: amplitude-client.js</h1>
507512
return document.referrer;
508513
};
509514

515+
/**
516+
* @private
517+
*/
518+
AmplitudeClient.prototype._getUrlParams = function _getUrlParams() {
519+
return location.search;
520+
};
521+
522+
/**
523+
* Try to fetch Google Gclid from url params.
524+
* @private
525+
*/
526+
AmplitudeClient.prototype._saveGclid = function _saveGclid(urlParams) {
527+
var gclid = utils.getQueryParam('gclid', urlParams);
528+
if (utils.isEmptyString(gclid)) {
529+
return;
530+
}
531+
var gclidProperties = {'gclid': gclid};
532+
_sendParamsReferrerUserProperties(this, gclidProperties);
533+
};
534+
510535
/**
511536
* Parse the domain from referrer info
512537
* @private
@@ -535,7 +560,7 @@ <h1 class="page-title">Source: amplitude-client.js</h1>
535560
'referrer': referrer,
536561
'referring_domain': this._getReferringDomain(referrer)
537562
};
538-
_sendUserPropertiesOncePerSession(this, Constants.REFERRER, referrerInfo);
563+
_sendParamsReferrerUserProperties(this, referrerInfo);
539564
};
540565

541566
/**
@@ -681,11 +706,17 @@ <h1 class="page-title">Source: amplitude-client.js</h1>
681706
if (!this._apiKeySet('setUserProperties()') || !utils.validateInput(userProperties, 'userProperties', 'object')) {
682707
return;
683708
}
709+
// sanitize the userProperties dict before converting into identify
710+
var sanitized = utils.truncate(utils.validateProperties(userProperties));
711+
if (Object.keys(sanitized).length === 0) {
712+
return;
713+
}
714+
684715
// convert userProperties into an identify call
685716
var identify = new Identify();
686-
for (var property in userProperties) {
687-
if (userProperties.hasOwnProperty(property)) {
688-
identify.set(property, userProperties[property]);
717+
for (var property in sanitized) {
718+
if (sanitized.hasOwnProperty(property)) {
719+
identify.set(property, sanitized[property]);
689720
}
690721
}
691722
this.identify(identify);
@@ -1174,7 +1205,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
11741205
<br class="clear">
11751206

11761207
<footer>
1177-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Sep 14 2016 13:32:02 GMT-0700 (PDT)
1208+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Oct 19 2016 00:42:27 GMT-0700 (PDT)
11781209
</footer>
11791210

11801211
<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 Sep 14 2016 13:32:02 GMT-0700 (PDT)
412+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Oct 19 2016 00:42:27 GMT-0700 (PDT)
413413
</footer>
414414

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

documentation/identify.js.html

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

228228
<footer>
229-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Sep 14 2016 13:32:02 GMT-0700 (PDT)
229+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Oct 19 2016 00:42:27 GMT-0700 (PDT)
230230
</footer>
231231

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

documentation/index.html

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

5858
<footer>
59-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Sep 14 2016 13:32:02 GMT-0700 (PDT)
59+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Oct 19 2016 00:42:27 GMT-0700 (PDT)
6060
</footer>
6161

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

documentation/revenue.js.html

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

198198
<footer>
199-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Sep 14 2016 13:32:02 GMT-0700 (PDT)
199+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Oct 19 2016 00:42:27 GMT-0700 (PDT)
200200
</footer>
201201

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

0 commit comments

Comments
 (0)