Skip to content

Commit 356d038

Browse files
committed
update from master, update changelog and readme, update documentation
2 parents c700ea3 + ee57109 commit 356d038

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+19224
-986
lines changed

CHANGELOG.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
## Unreleased
22

3-
* Add support for passing callback function to identify.
4-
* Add support for prepend user property operation.
5-
* Keep sessions and event metadata in sync across multiple windows/tabs.
6-
* Add support for setting groups for users and events.
3+
* Add support for setting groups for users and events. See the [Readme](https://github.com/amplitude/Amplitude-Javascript#setting-groups) for more information.
4+
* Add tracking of each user's initial_utm parameters (which is captured as a set once operation). Utm parameters are now sent only once per user session.
5+
* Add documentation for SDK functions. You can take a look [here](https://rawgit.com/amplitude/Amplitude-Javascript/defensive_cleanup/documentation/Amplitude.html). A link has also been added to the Readme.
6+
7+
### 2.10.0 (March 30, 2016)
8+
9+
* Identify function now accepts a callback function as an argument. The callback will be run after the identify event is sent.
10+
* Add support for `prepend` user property operation. This allows you to insert value(s) at the front of a list. See [Readme](https://github.com/amplitude/Amplitude-Javascript#user-properties-and-user-property-operations) for more details.
11+
* Keep sessions and event metadata in-sync across multiple windows/tabs.
712

813
### 2.9.1 (March 6, 2016)
914

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ TESTS = $(wildcard test/*.js)
44
BINS = node_modules/.bin
55
DUO = $(BINS)/duo
66
MINIFY = $(BINS)/uglifyjs
7+
JSDOC = $(BINS)/jsdoc
78
JSHINT = $(BINS)/jshint
89
BUILD_DIR = build
910
PROJECT = amplitude
@@ -86,6 +87,9 @@ build: $(TESTS) $(OUT) $(SNIPPET_OUT) $(SEGMENT_SNIPPET_OUT) README.md
8687
@$(DUO) --development test/tests.js > build/tests.js
8788
@$(DUO) --development test/snippet-tests.js > build/snippet-tests.js
8889

90+
docs:
91+
@$(JSDOC) -d ./documentation/ src/*.js
92+
8993
#
9094
# Target for release.
9195
#

README.md

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
Amplitude-Javascript
44
====================
55

6+
This Readme will guide you through using Amplitude's Javascript SDK to track users and events. See our [SDK documentation](https://rawgit.com/amplitude/Amplitude-Javascript/master/documentation/Amplitude.html) for a description of all available SDK methods.
7+
68
# Setup #
79
1. If you haven't already, go to http://amplitude.com and register for an account. You will receive an API Key.
810
2. On every page that uses analytics, paste the following Javascript code between the `<head>` and `</head>` tags:
911

1012
```html
1113
<script type="text/javascript">
1214
(function(e,t){var n=e.amplitude||{_q:[]};var r=t.createElement("script");r.type="text/javascript";
13-
r.async=true;r.src="https://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-2.9.1-min.gz.js";
15+
r.async=true;r.src="https://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-2.10.0-min.gz.js";
1416
r.onload=function(){e.amplitude.runQueuedFunctions()};var i=t.getElementsByTagName("script")[0];
1517
i.parentNode.insertBefore(r,i);var s=function(){this._q=[];return this};function o(e){
1618
s.prototype[e]=function(){this._q.push([e].concat(Array.prototype.slice.call(arguments,0)));
@@ -224,18 +226,25 @@ amplitude.init('YOUR_API_KEY_HERE', null, {
224226
});
225227
```
226228

227-
| option | description | default |
229+
| option | type | description | default |
228230
|------------|----------------------------------------------------------------------------------|-----------|
229-
| saveEvents | If `true`, saves events to localStorage and removes them upon successful upload.<br><i>NOTE:</i> Without saving events, events may be lost if the user navigates to another page before events are uploaded. | `true` |
230-
| savedMaxCount | Maximum number of events to save in localStorage. If more events are logged while offline, old events are removed. | 1000 |
231-
| uploadBatchSize | Maximum number of events to send to the server per request. | 100 |
232-
| includeUtm | If `true`, finds utm parameters in the query string or the __utmz cookie, parses, and includes them as user propeties on all events uploaded. | `false` |
233-
| includeReferrer | If `true`, captures the `referrer` and `referring_domain` for each session, as well as the user's `initial_referrer` and `initial_referring_domain` via a set once operation. | `false` |
234-
| batchEvents | If `true`, events are batched together and uploaded only when the number of unsent events is greater than or equal to `eventUploadThreshold` or after `eventUploadPeriodMillis` milliseconds have passed since the first unsent event was logged. | `false` |
235-
| eventUploadThreshold | Minimum number of events to batch together per request if `batchEvents` is `true`. | 30 |
236-
| eventUploadPeriodMillis | Amount of time in milliseconds that the SDK waits before uploading events if `batchEvents` is `true`. | 30\*1000 (30 sec) |
237-
| deviceId | Custom device ID to set | Randomly generated UUID |
238-
| sessionTimeout | Time between logged events before a new session starts in milliseconds | 30\*60\*1000 (30 min) |
231+
| batchEvents | Boolean | If `true`, events are batched together and uploaded only when the number of unsent events is greater than or equal to `eventUploadThreshold` or after `eventUploadPeriodMillis` milliseconds have passed | `false` |
232+
| cookieExpiration | Number | The number of days after which the Amplitude cookie will expire | 365\*10 (10 years) |
233+
| cookieName | String | Custom name for the Amplitude cookie | `'amplitude_id'` |
234+
| deviceId | String | Custom device ID to set. Note this is not recommended unless you really know what you are doing (like if you have your own system for tracking user devices) | Randomly generated UUID |
235+
| domain | String | Custom cookie domain | The top domain of the current page's url |
236+
| eventUploadPeriodMillis | Number | Amount of time in milliseconds that the SDK waits before uploading events if `batchEvents` is `true` | 30\*1000 (30 sec) |
237+
| eventUploadThreshold | Number | Minimum number of events to batch together per request if `batchEvents` is `true` | 30 |
238+
| includeReferrer | Boolean | If `true`, captures the `referrer` and `referring_domain` for each session, as well as the user's `initial_referrer` and `initial_referring_domain` via a set once operation | `false` |
239+
| includeUtm | Boolean | If `true`, finds utm parameters in the query string or the __utmz cookie, parses, and includes them as user propeties on all events uploaded | `false` |
240+
| language | String | Custom language to set | Language determined by browser |
241+
| optOut | Boolean | Whether to opt the current user out of tracking | `false` |
242+
| platform | String | Custom platform to set | `'Web'` |
243+
| savedMaxCount | Number | Maximum number of events to save in localStorage. If more events are logged while offline, old events are removed. | 1000 |
244+
| saveEvents | Boolean | If `true`, saves events to localStorage and removes them upon successful upload.<br><i>NOTE:</i> Without saving events, events may be lost if the user navigates to another page before events are uploaded. | `true` |
245+
| sessionTimeout | Number | Time between logged events before a new session starts in milliseconds | 30\*60\*1000 (30 min) |
246+
| uploadBatchSize | Number | Maximum number of events to send to the server per request. | 100 |
247+
239248

240249
# Advanced #
241250
This SDK automatically grabs useful data about the browser, including browser type and operating system version.
@@ -246,14 +255,14 @@ Amplitude supports assigning users to groups, and performing queries such as cou
246255

247256
In the above example, 'orgId' is a `groupType`, and the value 10 or 15 is the `groupName`. Another example of a `groupType` could a sport that the user participates in, and possible `groupNames` within that type would be tennis, baseball, etc.
248257

249-
You can use `setGroup(groupType, groupName)` to designate which groups a user belongs to. Few things to note: this will also set the `groupType: groupName` as a user property. **This will overwrite any existing groupName value set for that user's groupType, as well as the corresponding user property value.** For example if Joe was in orgId 10, and you call `setGroup('orgId', 20)`, 20 would replace 10. You can also call `setGroup` multiple times with different groupTypes to add a user to different groups. For example Sue is in orgId: 15, and she also plays sport: soccer. Now when querying, you can Count By both orgId and sport. **You are allowed to set up to 5 different groupTypes per user.** Any more than that will be ignored from the query UI, although they will still appear as user properties.
258+
You can use `setGroup(groupType, groupName)` to designate which groups a user belongs to. Few things to note: this will also set the `groupType: groupName` as a user property. **This will overwrite any existing groupName value set for that user's groupType, as well as the corresponding user property value.** For example if Joe was in orgId 10, and you call `setGroup('orgId', 20)`, 20 would replace 10. You can also call `setGroup` multiple times with different groupTypes to add a user to different groups. For example Sue can be in orgId: 15, and she also plays sport: soccer. Now when querying, you can Count By both orgId and sport (although as separate queries). **You are allowed to set up to 5 different groupTypes per user.** Any more than that will be ignored from the Count By Distinct query UI, although they will still appear as user properties for that user.
250259

251260
```javascript
252261
amplitude.setGroup('orgId', 15);
253262
amplitude.setGroup('sport', 'tennis');
254263
```
255264

256-
You can also use `logEventWithGroups` to set event-level groups, meaning the group designation only applies for the specific event being logged and does not persist on the user unless you explicitly set it with `setGroup`.
265+
You can also use `logEventWithGroups` to set event-level groups, meaning the group designation only applies for the specific event being logged and does not persist on the user (unless you explicitly set it with `setGroup`).
257266

258267
```javascript
259268
var eventProperties = {
@@ -335,7 +344,7 @@ If you are using [RequireJS](http://requirejs.org/) to load your Javascript file
335344
```html
336345
<script src='scripts/require.js'></script> <!-- loading RequireJS -->
337346
<script>
338-
require(['https://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-2.9.1-min.gz.js'], function(amplitude) {
347+
require(['https://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-2.10.0-min.gz.js'], function(amplitude) {
339348
amplitude.init('YOUR_API_KEY_HERE'); // replace YOUR_API_KEY_HERE with your Amplitude api key.
340349
window.amplitude = amplitude; // You can bind the amplitude object to window if you want to use it directly.
341350
amplitude.logEvent('Clicked Link A');
@@ -349,7 +358,7 @@ You can also define the path in your RequireJS configuration like so:
349358
<script>
350359
requirejs.config({
351360
paths: {
352-
'amplitude': 'https://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-2.9.1-min.gz'
361+
'amplitude': 'https://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-2.10.0-min.gz'
353362
}
354363
});
355364

amplitude-snippet.min.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(function(e,t){var n=e.amplitude||{_q:[]};var r=t.createElement("script");r.type="text/javascript";
2-
r.async=true;r.src="https://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-2.9.1-min.gz.js";
2+
r.async=true;r.src="https://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-2.10.0-min.gz.js";
33
r.onload=function(){e.amplitude.runQueuedFunctions()};var i=t.getElementsByTagName("script")[0];
44
i.parentNode.insertBefore(r,i);var s=function(){this._q=[];return this};function o(e){
55
s.prototype[e]=function(){this._q.push([e].concat(Array.prototype.slice.call(arguments,0)));

0 commit comments

Comments
 (0)