Skip to content

Commit e125160

Browse files
committed
refactor utm and referrer logic
1 parent 83d43df commit e125160

File tree

10 files changed

+280
-204
lines changed

10 files changed

+280
-204
lines changed

amplitude.js

Lines changed: 69 additions & 51 deletions
Large diffs are not rendered by default.

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: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ <h4 class="name" id="clearUserProperties"><span class="type-signature"></span>cl
196196

197197
<dt class="tag-source">Source:</dt>
198198
<dd class="tag-source"><ul class="dummy"><li>
199-
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line620">line 620</a>
199+
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line622">line 622</a>
200200
</li></ul></dd>
201201

202202

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

284284
<dt class="tag-source">Source:</dt>
285285
<dd class="tag-source"><ul class="dummy"><li>
286-
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line207">line 207</a>
286+
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line208">line 208</a>
287287
</li></ul></dd>
288288

289289

@@ -344,7 +344,8 @@ <h4 class="name" id="identify"><span class="type-signature"></span>identify<span
344344

345345
<div class="description">
346346
Send an identify call containing user property operations to Amplitude servers.
347-
See <a href="https://github.com/amplitude/Amplitude-Javascript#user-properties-and-user-property-operations">Readme</a> for more information on the Identify API and user property operations.
347+
See <a href="https://github.com/amplitude/Amplitude-Javascript#user-properties-and-user-property-operations">Readme</a>
348+
for more information on the Identify API and user property operations.
348349
</div>
349350

350351

@@ -419,7 +420,8 @@ <h5>Parameters:</h5>
419420

420421

421422

422-
<td class="description last">(optional) callback function to run when the identify event has been sent. Note: the server response code and response body from the identify event upload are passed to the callback function.</td>
423+
<td class="description last">(optional) callback function to run when the identify event has been sent.
424+
Note: the server response code and response body from the identify event upload are passed to the callback function.</td>
423425
</tr>
424426

425427

@@ -460,7 +462,7 @@ <h5>Parameters:</h5>
460462

461463
<dt class="tag-source">Source:</dt>
462464
<dd class="tag-source"><ul class="dummy"><li>
463-
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line638">line 638</a>
465+
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line642">line 642</a>
464466
</li></ul></dd>
465467

466468

@@ -603,7 +605,8 @@ <h5>Parameters:</h5>
603605

604606

605607

606-
<td class="description last">(optional) Configuration options. See <a href="https://github.com/amplitude/Amplitude-Javascript#configuration-options">Readme</a> for list of options and default values.</td>
608+
<td class="description last">(optional) Configuration options.
609+
See <a href="https://github.com/amplitude/Amplitude-Javascript#configuration-options">Readme</a> for list of options and default values.</td>
607610
</tr>
608611

609612

@@ -667,7 +670,7 @@ <h5>Parameters:</h5>
667670

668671
<dt class="tag-source">Source:</dt>
669672
<dd class="tag-source"><ul class="dummy"><li>
670-
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line68">line 68</a>
673+
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line69">line 69</a>
671674
</li></ul></dd>
672675

673676

@@ -754,7 +757,7 @@ <h4 class="name" id="isNewSession"><span class="type-signature"></span>isNewSess
754757

755758
<dt class="tag-source">Source:</dt>
756759
<dd class="tag-source"><ul class="dummy"><li>
757-
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line198">line 198</a>
760+
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line199">line 199</a>
758761
</li></ul></dd>
759762

760763

@@ -912,7 +915,8 @@ <h5>Parameters:</h5>
912915

913916

914917

915-
<td class="description last">(optional) a callback function to run after the event is logged. Note: the server response code and response body from the identify event upload are passed to the callback function.</td>
918+
<td class="description last">(optional) a callback function to run after the event is logged.
919+
Note: the server response code and response body from the identify event upload are passed to the callback function.</td>
916920
</tr>
917921

918922

@@ -953,7 +957,7 @@ <h5>Parameters:</h5>
953957

954958
<dt class="tag-source">Source:</dt>
955959
<dd class="tag-source"><ul class="dummy"><li>
956-
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line785">line 785</a>
960+
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line790">line 790</a>
957961
</li></ul></dd>
958962

959963

@@ -1135,7 +1139,7 @@ <h5>Parameters:</h5>
11351139

11361140
<dt class="tag-source">Source:</dt>
11371141
<dd class="tag-source"><ul class="dummy"><li>
1138-
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line812">line 812</a>
1142+
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line817">line 817</a>
11391143
</li></ul></dd>
11401144

11411145

@@ -1223,7 +1227,7 @@ <h4 class="name" id="saveEvents"><span class="type-signature"></span>saveEvents<
12231227

12241228
<dt class="tag-source">Source:</dt>
12251229
<dd class="tag-source"><ul class="dummy"><li>
1226-
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line497">line 497</a>
1230+
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line496">line 496</a>
12271231
</li></ul></dd>
12281232

12291233

@@ -1261,7 +1265,8 @@ <h4 class="name" id="sendEvents"><span class="type-signature"></span>sendEvents<
12611265

12621266

12631267
<div class="description">
1264-
Send unsent events. Note: this is called automatically after events are logged if option batchEvents is false. If batchEvents is true, then events are only sent when batch criterias are met.
1268+
Send unsent events. Note: this is called automatically after events are logged if option batchEvents is false.
1269+
If batchEvents is true, then events are only sent when batch criterias are met.
12651270
</div>
12661271

12671272

@@ -1313,7 +1318,8 @@ <h5>Parameters:</h5>
13131318

13141319

13151320

1316-
<td class="description last">(optional) callback to run after events are sent. Note the server response code and response body are passed to the callback as input arguments.</td>
1321+
<td class="description last">(optional) callback to run after events are sent.
1322+
Note the server response code and response body are passed to the callback as input arguments.</td>
13171323
</tr>
13181324

13191325

@@ -1354,7 +1360,7 @@ <h5>Parameters:</h5>
13541360

13551361
<dt class="tag-source">Source:</dt>
13561362
<dd class="tag-source"><ul class="dummy"><li>
1357-
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line860">line 860</a>
1363+
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line867">line 867</a>
13581364
</li></ul></dd>
13591365

13601366

@@ -1392,7 +1398,9 @@ <h4 class="name" id="setDeviceId"><span class="type-signature"></span>setDeviceI
13921398

13931399

13941400
<div class="description">
1395-
Sets a custom deviceId for current user. Note: this is not recommended unless you know what you are doing (like if you have your own system for managing deviceIds). Make sure the deviceId you set is sufficiently unique (we recommend something like a UUID - see src/uuid.js for an example of how to generate) to prevent conflicts with other devices in our system.
1401+
Sets a custom deviceId for current user. Note: this is not recommended unless you know what you are doing
1402+
(like if you have your own system for managing deviceIds). Make sure the deviceId you set is sufficiently unique
1403+
(we recommend something like a UUID - see src/uuid.js for an example of how to generate) to prevent conflicts with other devices in our system.
13961404
</div>
13971405

13981406

@@ -1485,7 +1493,7 @@ <h5>Parameters:</h5>
14851493

14861494
<dt class="tag-source">Source:</dt>
14871495
<dd class="tag-source"><ul class="dummy"><li>
1488-
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line578">line 578</a>
1496+
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line579">line 579</a>
14891497
</li></ul></dd>
14901498

14911499

@@ -1621,7 +1629,7 @@ <h5>Parameters:</h5>
16211629

16221630
<dt class="tag-source">Source:</dt>
16231631
<dd class="tag-source"><ul class="dummy"><li>
1624-
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line517">line 517</a>
1632+
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line516">line 516</a>
16251633
</li></ul></dd>
16261634

16271635

@@ -1710,7 +1718,7 @@ <h4 class="name" id="setGlobalUserProperties"><span class="type-signature"></spa
17101718

17111719
<dt class="tag-source">Source:</dt>
17121720
<dd class="tag-source"><ul class="dummy"><li>
1713-
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line993">line 993</a>
1721+
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line1000">line 1000</a>
17141722
</li></ul></dd>
17151723

17161724

@@ -1841,7 +1849,7 @@ <h5>Parameters:</h5>
18411849

18421850
<dt class="tag-source">Source:</dt>
18431851
<dd class="tag-source"><ul class="dummy"><li>
1844-
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line559">line 559</a>
1852+
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line558">line 558</a>
18451853
</li></ul></dd>
18461854

18471855

@@ -1972,7 +1980,7 @@ <h5>Parameters:</h5>
19721980

19731981
<dt class="tag-source">Source:</dt>
19741982
<dd class="tag-source"><ul class="dummy"><li>
1975-
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line540">line 540</a>
1983+
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line539">line 539</a>
19761984
</li></ul></dd>
19771985

19781986

@@ -2090,7 +2098,8 @@ <h5>Parameters:</h5>
20902098

20912099

20922100

2093-
<td class="description last">DEPRECATED opt_replace: in earlier versions of the JS SDK the user properties object was kept in memory and replace = true would replace the object in memory. Now the properties are no longer stored in memory, so replace is deprecated.</td>
2101+
<td class="description last">DEPRECATED opt_replace: in earlier versions of the JS SDK the user properties object was kept in
2102+
memory and replace = true would replace the object in memory. Now the properties are no longer stored in memory, so replace is deprecated.</td>
20942103
</tr>
20952104

20962105

@@ -2131,7 +2140,7 @@ <h5>Parameters:</h5>
21312140

21322141
<dt class="tag-source">Source:</dt>
21332142
<dd class="tag-source"><ul class="dummy"><li>
2134-
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line600">line 600</a>
2143+
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line602">line 602</a>
21352144
</li></ul></dd>
21362145

21372146

@@ -2267,7 +2276,7 @@ <h5>Parameters:</h5>
22672276

22682277
<dt class="tag-source">Source:</dt>
22692278
<dd class="tag-source"><ul class="dummy"><li>
2270-
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line678">line 678</a>
2279+
<a href="amplitude.js.html">amplitude.js</a>, <a href="amplitude.js.html#line682">line 682</a>
22712280
</li></ul></dd>
22722281

22732282

@@ -2320,7 +2329,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
23202329
<br class="clear">
23212330

23222331
<footer>
2323-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Fri Apr 01 2016 16:45:14 GMT-0700 (PDT)
2332+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Fri Apr 01 2016 17:34:16 GMT-0700 (PDT)
23242333
</footer>
23252334

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

documentation/Identify.html

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ <h4 class="name" id="add"><span class="type-signature"></span>add<span class="si
158158

159159

160160
<div class="description">
161-
Increment a user property by a given value (can also be negative to decrement). If the user property does not have a value set yet, it will be initialized to 0 before being incremented.
161+
Increment a user property by a given value (can also be negative to decrement).
162+
If the user property does not have a value set yet, it will be initialized to 0 before being incremented.
162163
</div>
163164

164165

@@ -277,7 +278,7 @@ <h5>Parameters:</h5>
277278

278279
<dt class="tag-source">Source:</dt>
279280
<dd class="tag-source"><ul class="dummy"><li>
280-
<a href="identify.js.html">identify.js</a>, <a href="identify.js.html#line44">line 44</a>
281+
<a href="identify.js.html">identify.js</a>, <a href="identify.js.html#line45">line 45</a>
281282
</li></ul></dd>
282283

283284

@@ -344,8 +345,10 @@ <h4 class="name" id="append"><span class="type-signature"></span>append<span cla
344345

345346
<div class="description">
346347
Append a value or values to a user property.
347-
If the user property does not have a value set yet, it will be initialized to an empty list before the new values are appended.
348-
If the user property has an existing value and it is not a list, the existing value will be converted into a list with the new values appended.
348+
If the user property does not have a value set yet,
349+
it will be initialized to an empty list before the new values are appended.
350+
If the user property has an existing value and it is not a list,
351+
the existing value will be converted into a list with the new values appended.
349352
</div>
350353

351354

@@ -429,7 +432,8 @@ <h5>Parameters:</h5>
429432

430433

431434

432-
<td class="description last">A value or values to append. Values can be numbers, strings, lists, or object (key:value dict will be flattened).</td>
435+
<td class="description last">A value or values to append.
436+
Values can be numbers, strings, lists, or object (key:value dict will be flattened).</td>
433437
</tr>
434438

435439

@@ -470,7 +474,7 @@ <h5>Parameters:</h5>
470474

471475
<dt class="tag-source">Source:</dt>
472476
<dd class="tag-source"><ul class="dummy"><li>
473-
<a href="identify.js.html">identify.js</a>, <a href="identify.js.html#line65">line 65</a>
477+
<a href="identify.js.html">identify.js</a>, <a href="identify.js.html#line69">line 69</a>
474478
</li></ul></dd>
475479

476480

@@ -537,9 +541,12 @@ <h4 class="name" id="prepend"><span class="type-signature"></span>prepend<span c
537541

538542

539543
<div class="description">
540-
Prepend a value or values to a user property. Prepend means inserting the value or values at the front of a list.
541-
If the user property does not have a value set yet, it will be initialized to an empty list before the new values are prepended.
542-
If the user property has an existing value and it is not a list, the existing value will be converted into a list with the new values prepended.
544+
Prepend a value or values to a user property.
545+
Prepend means inserting the value or values at the front of a list.
546+
If the user property does not have a value set yet,
547+
it will be initialized to an empty list before the new values are prepended.
548+
If the user property has an existing value and it is not a list,
549+
the existing value will be converted into a list with the new values prepended.
543550
</div>
544551

545552

@@ -623,7 +630,8 @@ <h5>Parameters:</h5>
623630

624631

625632

626-
<td class="description last">A value or values to prepend. Values can be numbers, strings, lists, or object (key:value dict will be flattened).</td>
633+
<td class="description last">A value or values to prepend.
634+
Values can be numbers, strings, lists, or object (key:value dict will be flattened).</td>
627635
</tr>
628636

629637

@@ -664,7 +672,7 @@ <h5>Parameters:</h5>
664672

665673
<dt class="tag-source">Source:</dt>
666674
<dd class="tag-source"><ul class="dummy"><li>
667-
<a href="identify.js.html">identify.js</a>, <a href="identify.js.html#line100">line 100</a>
675+
<a href="identify.js.html">identify.js</a>, <a href="identify.js.html#line108">line 108</a>
668676
</li></ul></dd>
669677

670678

@@ -815,7 +823,8 @@ <h5>Parameters:</h5>
815823

816824

817825

818-
<td class="description last">A value or values to set. Values can be numbers, strings, lists, or object (key:value dict will be flattened).</td>
826+
<td class="description last">A value or values to set.
827+
Values can be numbers, strings, lists, or object (key:value dict will be flattened).</td>
819828
</tr>
820829

821830

@@ -856,7 +865,7 @@ <h5>Parameters:</h5>
856865

857866
<dt class="tag-source">Source:</dt>
858867
<dd class="tag-source"><ul class="dummy"><li>
859-
<a href="identify.js.html">identify.js</a>, <a href="identify.js.html#line115">line 115</a>
868+
<a href="identify.js.html">identify.js</a>, <a href="identify.js.html#line124">line 124</a>
860869
</li></ul></dd>
861870

862871

@@ -923,7 +932,8 @@ <h4 class="name" id="setOnce"><span class="type-signature"></span>setOnce<span c
923932

924933

925934
<div class="description">
926-
Sets the value of a given user property only once. Subsequent setOnce operations on that user property will be ignored; however, that user property can still be modified through any of the other operations.
935+
Sets the value of a given user property only once. Subsequent setOnce operations on that user property will be ignored;
936+
however, that user property can still be modified through any of the other operations.
927937
Useful for capturing properties such as 'initial_signup_date', 'initial_referrer', etc.
928938
</div>
929939

@@ -1008,7 +1018,8 @@ <h5>Parameters:</h5>
10081018

10091019

10101020

1011-
<td class="description last">A value or values to set once. Values can be numbers, strings, lists, or object (key:value dict will be flattened).</td>
1021+
<td class="description last">A value or values to set once.
1022+
Values can be numbers, strings, lists, or object (key:value dict will be flattened).</td>
10121023
</tr>
10131024

10141025

@@ -1049,7 +1060,7 @@ <h5>Parameters:</h5>
10491060

10501061
<dt class="tag-source">Source:</dt>
10511062
<dd class="tag-source"><ul class="dummy"><li>
1052-
<a href="identify.js.html">identify.js</a>, <a href="identify.js.html#line130">line 130</a>
1063+
<a href="identify.js.html">identify.js</a>, <a href="identify.js.html#line141">line 141</a>
10531064
</li></ul></dd>
10541065

10551066

@@ -1208,7 +1219,7 @@ <h5>Parameters:</h5>
12081219

12091220
<dt class="tag-source">Source:</dt>
12101221
<dd class="tag-source"><ul class="dummy"><li>
1211-
<a href="identify.js.html">identify.js</a>, <a href="identify.js.html#line143">line 143</a>
1222+
<a href="identify.js.html">identify.js</a>, <a href="identify.js.html#line154">line 154</a>
12121223
</li></ul></dd>
12131224

12141225

@@ -1284,7 +1295,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
12841295
<br class="clear">
12851296

12861297
<footer>
1287-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Fri Apr 01 2016 16:45:14 GMT-0700 (PDT)
1298+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Fri Apr 01 2016 17:34:16 GMT-0700 (PDT)
12881299
</footer>
12891300

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

0 commit comments

Comments
 (0)