Skip to content

Commit 4674ac5

Browse files
committed
Merge pull request #64 from amplitude/defensive_cleanup
Defensive cleanup
2 parents b79a5a5 + 938952f commit 4674ac5

Some content is hidden

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

46 files changed

+18666
-952
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+
* 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.
4+
* 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.
5+
36
### 2.10.0 (March 30, 2016)
47

58
* Identify function now accepts a callback function as an argument. The callback will be run after the identify event is sent.

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: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
Amplitude-Javascript
44
====================
55

6+
This Readme will guide you through using Amplitude's Javascript SDK to track users and events. You can also take a look at the [SDK documentation](https://rawgit.com/amplitude/Amplitude-Javascript/defensive_cleanup/documentation/Amplitude.html).
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:
@@ -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.

0 commit comments

Comments
 (0)