You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: amplitude.js
+90-9Lines changed: 90 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -2289,17 +2289,16 @@ module.exports = {
2289
2289
2290
2290
},{"./constants":3,"./type":12}],
2291
2291
12: [function(require,module,exports){
2292
-
/* Taken from: https://github.com/component/type */
2293
-
2294
2292
/**
2295
2293
* toString ref.
2294
+
* @private
2296
2295
*/
2297
2296
2298
2297
vartoString=Object.prototype.toString;
2299
2298
2300
2299
/**
2301
2300
* Return the type of `val`.
2302
-
*
2301
+
*@private
2303
2302
* @param {Mixed} val
2304
2303
* @return {String}
2305
2304
* @api public
@@ -2487,11 +2486,32 @@ var AMP_OP_SET = '$set';
2487
2486
varAMP_OP_SET_ONCE='$setOnce';
2488
2487
varAMP_OP_UNSET='$unset';
2489
2488
2489
+
/**
2490
+
* Identify API - instance constructor. Identify objects are a wrapper for user property operations.
2491
+
* Each method adds a user property operation to the Identify object, and returns the same Identify object,
2492
+
* allowing you to chain multiple method calls together.
2493
+
* Note: if the same user property is used in multiple operations on a single Identify object,
2494
+
* only the first operation on that property will be saved, and the rest will be ignored.
2495
+
* See [Readme]{@link https://github.com/amplitude/Amplitude-Javascript#user-properties-and-user-property-operations}
2496
+
* for more information on the Identify API and user property operations.
2497
+
* @constructor Identify
2498
+
* @public
2499
+
* @example var identify = new amplitude.Identify();
2500
+
*/
2490
2501
varIdentify=function(){
2491
2502
this.userPropertiesOperations={};
2492
2503
this.properties=[];// keep track of keys that have been added
2493
2504
};
2494
2505
2506
+
/**
2507
+
* 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.
2508
+
* @public
2509
+
* @param {string} property - The user property key.
2510
+
* @param {number/string} value - The amount by which to increment the user property. Allows numbers as strings (ex: '123').
2511
+
* @return {Identify_object} Returns the same Identify object, allowing you to chain multiple method calls together.
2512
+
* @example var identify = new amplitude.Identify().add('karma', 1).add('friends', 1);
2513
+
* amplitude.identify(identify); // send the Identify call
* 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.
2527
+
* 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.
2528
+
* @public
2529
+
* @param {string} property - The user property key.
2530
+
* @param {number/string/list/object} value - A value or values to append. Values can be numbers, strings, lists, or object (key:value dict will be flattened).
2531
+
* @return {Identify_object} Returns the same Identify object, allowing you to chain multiple method calls together.
2532
+
* @example var identify = new amplitude.Identify().append('ab-tests', 'new-user-tests');
* Prepend a value or values to a user property. Prepend means inserting the value or values at the front of a list.
2561
+
* 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.
2562
+
* 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.
2563
+
* @public
2564
+
* @param {string} property - The user property key.
2565
+
* @param {number/string/list/object} value - A value or values to prepend. Values can be numbers, strings, lists, or object (key:value dict will be flattened).
2566
+
* @return {Identify_object} Returns the same Identify object, allowing you to chain multiple method calls together.
2567
+
* @example var identify = new amplitude.Identify().prepend('ab-tests', 'new-user-tests');
* Sets the value of a given user property. If a value already exists, it will be overwriten with the new value.
2578
+
* @public
2579
+
* @param {string} property - The user property key.
2580
+
* @param {number/string/list/object} value - A value or values to set. Values can be numbers, strings, lists, or object (key:value dict will be flattened).
2581
+
* @return {Identify_object} Returns the same Identify object, allowing you to chain multiple method calls together.
2582
+
* @example var identify = new amplitude.Identify().set('user_type', 'beta');
2583
+
* identify.set('name', {'first': 'John', 'last': 'Doe'}); // dict is flattened and becomes name.first: John, name.last: Doe
2584
+
* amplitude.identify(identify); // send the Identify call
2585
+
*/
2528
2586
Identify.prototype.set=function(property,value){
2529
2587
this._addOperation(AMP_OP_SET,property,value);
2530
2588
returnthis;
2531
2589
};
2532
2590
2591
+
/**
2592
+
* 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.
2593
+
* Useful for capturing properties such as 'initial_signup_date', 'initial_referrer', etc.
2594
+
* @public
2595
+
* @param {string} property - The user property key.
2596
+
* @param {number/string/list/object} value - A value or values to set once. Values can be numbers, strings, lists, or object (key:value dict will be flattened).
2597
+
* @return {Identify_object} Returns the same Identify object, allowing you to chain multiple method calls together.
2598
+
* @example var identify = new amplitude.Identify().setOnce('sign_up_date', '2016-04-01');
2599
+
* amplitude.identify(identify); // send the Identify call
0 commit comments