Skip to content

Commit 3b9dffd

Browse files
author
Daniel Jih
committed
update documentation
1 parent a6c78a7 commit 3b9dffd

File tree

14 files changed

+4318
-903
lines changed

14 files changed

+4318
-903
lines changed

amplitude.js

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ module.exports = newInstance;
110110
}, {"./amplitude":2}],
111111
2: [function(require, module, exports) {
112112
var AmplitudeClient = require('./amplitude-client');
113-
var constants = require('./constants');
113+
var Constants = require('./constants');
114114
var Identify = require('./identify');
115115
var object = require('object');
116116
var Revenue = require('./revenue');
@@ -120,10 +120,12 @@ var version = require('./version');
120120
var DEFAULT_OPTIONS = require('./options');
121121

122122
/**
123-
* Amplitude SDK API - instance constructor.
123+
* Amplitude SDK API - instance manager.
124124
* @constructor Amplitude
125125
* @public
126126
* @example var amplitude = new Amplitude();
127+
* Function calls directly on amplitude have been deprecated. Please call methods on the default shared instance: amplitude.getInstance() instead.
128+
* See [Readme]{@link https://github.com/amplitude/Amplitude-Javascript#300-update-and-logging-events-to-multiple-amplitude-apps} for more information about this change.
127129
*/
128130
var Amplitude = function Amplitude() {
129131
this.options = object.merge({}, DEFAULT_OPTIONS);
@@ -135,7 +137,7 @@ Amplitude.prototype.Identify = Identify;
135137
Amplitude.prototype.Revenue = Revenue;
136138

137139
Amplitude.prototype.getInstance = function getInstance(instance) {
138-
instance = (utils.isEmptyString(instance) ? constants.DEFAULT_INSTANCE : instance).toLowerCase();
140+
instance = utils.isEmptyString(instance) ? Constants.DEFAULT_INSTANCE : instance.toLowerCase();
139141
var client = this._instances[instance];
140142
if (client === undefined) {
141143
client = new AmplitudeClient(instance);
@@ -298,7 +300,7 @@ Amplitude.prototype.setOptOut = function setOptOut(enable) {
298300
* With a null userId and a completely new deviceId, the current user would appear as a brand new user in dashboard.
299301
* This uses src/uuid.js to regenerate the deviceId.
300302
* @public
301-
* deprecated Please use amplitude.getInstance().regenerateDeviceId();
303+
* @deprecated Please use amplitude.getInstance().regenerateDeviceId();
302304
*/
303305
Amplitude.prototype.regenerateDeviceId = function regenerateDeviceId() {
304306
this.getInstance().regenerateDeviceId();
@@ -495,13 +497,14 @@ var version = require('./version');
495497
var DEFAULT_OPTIONS = require('./options');
496498

497499
/**
498-
* Amplitude SDK API - instance constructor.
499-
* @constructor Amplitude
500+
* AmplitudeClient SDK API - instance constructor.
501+
* The Amplitude class handles creation of client instances, all you need to do is call amplitude.getInstance()
502+
* @constructor AmplitudeClient
500503
* @public
501-
* @example var amplitude = new Amplitude();
504+
* @example var amplitudeClient = new AmplitudeClient();
502505
*/
503506
var AmplitudeClient = function AmplitudeClient(instanceName) {
504-
this._instanceName = (utils.isEmptyString(instanceName) ? Constants.DEFAULT_INSTANCE : instanceName).toLowerCase();
507+
this._instanceName = utils.isEmptyString(instanceName) ? Constants.DEFAULT_INSTANCE : instanceName.toLowerCase();
505508
this._storageSuffix = this._instanceName === Constants.DEFAULT_INSTANCE ? '' : '_' + this._instanceName;
506509
this._unsentEvents = [];
507510
this._unsentIdentifys = [];
@@ -533,7 +536,7 @@ AmplitudeClient.prototype.Revenue = Revenue;
533536
* @param {object} opt_config - (optional) Configuration options.
534537
* See [Readme]{@link https://github.com/amplitude/Amplitude-Javascript#configuration-options} for list of options and default values.
535538
* @param {function} opt_callback - (optional) Provide a callback function to run after initialization is complete.
536-
* @example amplitude.init('API_KEY', 'USER_ID', {includeReferrer: true, includeUtm: true}, function() { alert('init complete'); });
539+
* @example amplitudeClient.init('API_KEY', 'USER_ID', {includeReferrer: true, includeUtm: true}, function() { alert('init complete'); });
537540
*/
538541
AmplitudeClient.prototype.init = function init(apiKey, opt_userId, opt_config, opt_callback) {
539542
if (type(apiKey) !== 'string' || utils.isEmptyString(apiKey)) {
@@ -1005,7 +1008,7 @@ AmplitudeClient.prototype.saveEvents = function saveEvents() {
10051008
* Sets a customer domain for the amplitude cookie. Useful if you want to support cross-subdomain tracking.
10061009
* @public
10071010
* @param {string} domain to set.
1008-
* @example amplitude.setDomain('.amplitude.com');
1011+
* @example amplitudeClient.setDomain('.amplitude.com');
10091012
*/
10101013
AmplitudeClient.prototype.setDomain = function setDomain(domain) {
10111014
if (!utils.validateInput(domain, 'domain', 'string')) {
@@ -1028,7 +1031,7 @@ AmplitudeClient.prototype.setDomain = function setDomain(domain) {
10281031
* Sets an identifier for the current user.
10291032
* @public
10301033
* @param {string} userId - identifier to set. Can be null.
1031-
* @example amplitude.setUserId('joe@gmail.com');
1034+
* @example amplitudeClient.setUserId('joe@gmail.com');
10321035
*/
10331036
AmplitudeClient.prototype.setUserId = function setUserId(userId) {
10341037
try {
@@ -1050,7 +1053,7 @@ AmplitudeClient.prototype.setUserId = function setUserId(userId) {
10501053
* @public
10511054
* @param {string} groupType - the group type (ex: orgId)
10521055
* @param {string|list} groupName - the name of the group (ex: 15), or a list of names of the groups
1053-
* @example amplitude.setGroup('orgId', 15); // this adds the current user to orgId 15.
1056+
* @example amplitudeClient.setGroup('orgId', 15); // this adds the current user to orgId 15.
10541057
*/
10551058
AmplitudeClient.prototype.setGroup = function(groupType, groupName) {
10561059
if (!this._apiKeySet('setGroup()') || !utils.validateInput(groupType, 'groupType', 'string') ||
@@ -1100,7 +1103,7 @@ AmplitudeClient.prototype.regenerateDeviceId = function regenerateDeviceId() {
11001103
* (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.
11011104
* @public
11021105
* @param {string} deviceId - custom deviceId for current user.
1103-
* @example amplitude.setDeviceId('45f0954f-eb79-4463-ac8a-233a6f45a8f0');
1106+
* @example amplitudeClient.setDeviceId('45f0954f-eb79-4463-ac8a-233a6f45a8f0');
11041107
*/
11051108
AmplitudeClient.prototype.setDeviceId = function setDeviceId(deviceId) {
11061109
if (!utils.validateInput(deviceId, 'deviceId', 'string')) {
@@ -1123,7 +1126,7 @@ AmplitudeClient.prototype.setDeviceId = function setDeviceId(deviceId) {
11231126
* @param {object} - object with string keys and values for the user properties to set.
11241127
* @param {boolean} - DEPRECATED opt_replace: in earlier versions of the JS SDK the user properties object was kept in
11251128
* memory and replace = true would replace the object in memory. Now the properties are no longer stored in memory, so replace is deprecated.
1126-
* @example amplitude.setUserProperties({'gender': 'female', 'sign_up_complete': true})
1129+
* @example amplitudeClient.setUserProperties({'gender': 'female', 'sign_up_complete': true})
11271130
*/
11281131
AmplitudeClient.prototype.setUserProperties = function setUserProperties(userProperties) {
11291132
if (!this._apiKeySet('setUserProperties()') || !utils.validateInput(userProperties, 'userProperties', 'object')) {
@@ -1142,7 +1145,7 @@ AmplitudeClient.prototype.setUserProperties = function setUserProperties(userPro
11421145
/**
11431146
* Clear all of the user properties for the current user. Note: clearing user properties is irreversible!
11441147
* @public
1145-
* @example amplitude.clearUserProperties();
1148+
* @example amplitudeClient.clearUserProperties();
11461149
*/
11471150
AmplitudeClient.prototype.clearUserProperties = function clearUserProperties(){
11481151
if (!this._apiKeySet('clearUserProperties()')) {
@@ -1213,7 +1216,7 @@ AmplitudeClient.prototype.identify = function(identify_obj, opt_callback) {
12131216
* Set a versionName for your application.
12141217
* @public
12151218
* @param {string} versionName - The version to set for your application.
1216-
* @example amplitude.setVersionName('1.12.3');
1219+
* @example amplitudeClient.setVersionName('1.12.3');
12171220
*/
12181221
AmplitudeClient.prototype.setVersionName = function setVersionName(versionName) {
12191222
if (!utils.validateInput(versionName, 'versionName', 'string')) {
@@ -1327,7 +1330,7 @@ AmplitudeClient.prototype._limitEventsQueued = function _limitEventsQueued(queue
13271330
* @param {object} eventProperties - (optional) an object with string keys and values for the event properties.
13281331
* @param {Amplitude~eventCallback} opt_callback - (optional) a callback function to run after the event is logged.
13291332
* Note: the server response code and response body from the event upload are passed to the callback function.
1330-
* @example amplitude.logEvent('Clicked Homepage Button', {'finished_flow': false, 'clicks': 15});
1333+
* @example amplitudeClient.logEvent('Clicked Homepage Button', {'finished_flow': false, 'clicks': 15});
13311334
*/
13321335
AmplitudeClient.prototype.logEvent = function logEvent(eventType, eventProperties, opt_callback) {
13331336
if (!this._apiKeySet('logEvent()') || !utils.validateInput(eventType, 'eventType', 'string') ||
@@ -1353,7 +1356,7 @@ AmplitudeClient.prototype.logEvent = function logEvent(eventType, eventPropertie
13531356
* groupName can be a string or an array of strings.
13541357
* @param {Amplitude~eventCallback} opt_callback - (optional) a callback function to run after the event is logged.
13551358
* Note: the server response code and response body from the event upload are passed to the callback function.
1356-
* @example amplitude.logEventWithGroups('Clicked Button', null, {'orgId': 24});
1359+
* @example amplitudeClient.logEventWithGroups('Clicked Button', null, {'orgId': 24});
13571360
*/
13581361
AmplitudeClient.prototype.logEventWithGroups = function(eventType, eventProperties, groups, opt_callback) {
13591362
if (!this._apiKeySet('logEventWithGroup()') ||
@@ -1411,7 +1414,7 @@ AmplitudeClient.prototype.logRevenueV2 = function logRevenueV2(revenue_obj) {
14111414
* @param {number} price - price of revenue event
14121415
* @param {number} quantity - (optional) quantity of products in revenue event. If no quantity specified default to 1.
14131416
* @param {string} product - (optional) product identifier
1414-
* @example amplitude.logRevenue(3.99, 1, 'product_1234');
1417+
* @example amplitudeClient.logRevenue(3.99, 1, 'product_1234');
14151418
*/
14161419
AmplitudeClient.prototype.logRevenue = function logRevenue(price, quantity, product) {
14171420
// Test that the parameters are of the right type.

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.

0 commit comments

Comments
 (0)