|
10 | 10 | as.onload = function() {window.amplitude.runQueuedFunctions();}; |
11 | 11 | var s = document.getElementsByTagName('script')[0]; |
12 | 12 | s.parentNode.insertBefore(as, s); |
13 | | - var Identify = function() {this._q = []; return this;}; |
14 | | - function proxyIdentify(fn) { |
15 | | - Identify.prototype[fn] = function() { |
| 13 | + function proxy(obj, fn) { |
| 14 | + obj.prototype[fn] = function() { |
16 | 15 | this._q.push([fn].concat(Array.prototype.slice.call(arguments, 0))); return this; |
17 | 16 | }; |
18 | 17 | } |
19 | | - var identifyFuncs = ['add', 'append', 'clearAll', 'set', 'setOnce', 'unset']; |
20 | | - for (var i = 0; i < identifyFuncs.length; i++) {proxyIdentify(identifyFuncs[i]);} |
| 18 | + var Identify = function() {this._q = []; return this;}; |
| 19 | + var identifyFuncs = ['add', 'append', 'clearAll', 'prepend', 'set', 'setOnce', 'unset']; |
| 20 | + for (var i = 0; i < identifyFuncs.length; i++) {proxy(Identify,identifyFuncs[i]);} |
21 | 21 | amplitude.Identify = Identify; |
| 22 | + var Revenue = function() {this._q = []; return this;}; |
| 23 | + var revenueFuncs = ['setProductId', 'setQuantity', 'setPrice', 'setRevenueType', 'setEventProperties']; |
| 24 | + for (var j = 0; j < revenueFuncs.length; j++) {proxy(Revenue, revenueFuncs[j]);} |
| 25 | + amplitude.Revenue = Revenue; |
22 | 26 | var funcs = ['init', 'logEvent', 'logRevenue', 'setUserId', 'setUserProperties', |
23 | 27 | 'setOptOut', 'setVersionName', 'setDomain', 'setDeviceId', |
24 | | - 'setGlobalUserProperties', 'identify', 'clearUserProperties']; |
| 28 | + 'setGlobalUserProperties', 'identify', 'clearUserProperties', |
| 29 | + 'logRevenueV2']; |
25 | 30 | function setUpProxy(instance) { |
26 | | - function proxy(fn) { |
| 31 | + function proxyMain(fn) { |
27 | 32 | instance[fn] = function() { |
28 | 33 | instance._q.push([fn].concat(Array.prototype.slice.call(arguments, 0))); |
29 | 34 | }; |
30 | 35 | } |
31 | | - for (var j = 0; j < funcs.length; j++) {proxy(funcs[j]);} |
| 36 | + for (var k = 0; k < funcs.length; k++) {proxyMain(funcs[k]);} |
32 | 37 | } |
33 | 38 | setUpProxy(amplitude); |
34 | 39 | window.amplitude = amplitude; |
|
0 commit comments