Skip to content

Commit 340e9cf

Browse files
committed
make track_charge a NOOP
1 parent 7d9d3a5 commit 340e9cf

File tree

2 files changed

+1
-71
lines changed

2 files changed

+1
-71
lines changed

src/mixpanel-people.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -263,17 +263,7 @@ MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name
263263
* @deprecated
264264
*/
265265
MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function(amount, properties, callback) {
266-
if (!_.isNumber(amount)) {
267-
amount = parseFloat(amount);
268-
if (isNaN(amount)) {
269-
console.error('Invalid value passed to mixpanel.people.track_charge - must be a number');
270-
return;
271-
}
272-
}
273-
274-
return this.append('$transactions', _.extend({
275-
'$amount': amount
276-
}, properties), callback);
266+
console.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
277267
});
278268

279269
/*

tests/test.js

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2838,65 +2838,6 @@
28382838

28392839
});
28402840

2841-
mpmodule("mixpanel.people.track_charge");
2842-
2843-
test("track_charge (basic functionality)", 2, function() {
2844-
var amt = 50,
2845-
amt_2 = 20,
2846-
charge = {
2847-
'$amount': amt
2848-
}
2849-
charge_2 = {
2850-
'$amount': amt_2
2851-
}
2852-
2853-
var i = mixpanel.people.track_charge(amt);
2854-
ok(contains_obj(i['$append']['$transactions'], charge), '.track_charge() correctly appends to the $transactions object');
2855-
2856-
mixpanel.test.identify(this.id);
2857-
i = mixpanel.test.people.track_charge(amt_2);
2858-
ok(contains_obj(i['$append']['$transactions'], charge_2), '.track_charge() works for additional libs');
2859-
});
2860-
2861-
test("track_charge accepts properties", 1, function() {
2862-
var amt = 50,
2863-
time = new Date('feb 1 2012'),
2864-
charge = {
2865-
'$amount': amt,
2866-
'$time': date_to_ISO(time)
2867-
};
2868-
2869-
var i = mixpanel.people.track_charge(amt, {
2870-
'$time': time
2871-
});
2872-
ok(contains_obj(i['$append']['$transactions'], charge), '.track_charge() correctly appends to the $transactions object');
2873-
});
2874-
2875-
test("track_charge handles numeric strings", 1, function() {
2876-
var amt = " 40.56 ",
2877-
charge = {
2878-
'$amount': 40.56
2879-
}
2880-
var i = mixpanel.people.track_charge(amt);
2881-
2882-
ok(contains_obj(i['$append']['$transactions'], charge), '.track_charge() correctly converts numeric strings');
2883-
});
2884-
2885-
// callsError may fail if there is no console, so we can't expect 2 tests
2886-
test("track_charge handles invalid values", function() {
2887-
if (window.console) {
2888-
callsError(function(restore_console) {
2889-
mixpanel.people.track_charge();
2890-
restore_console();
2891-
}, ".track_charge() should call an error if called with no arguments");
2892-
2893-
callsError(function(restore_console) {
2894-
mixpanel.people.track_charge("asdf");
2895-
restore_console();
2896-
}, ".track_charge() should call an error if called with a non-numeric string argument");
2897-
}
2898-
});
2899-
29002841
mpmodule("mixpanel.people.clear_charges");
29012842

29022843
test("clear_charges", 1, function() {
@@ -5569,7 +5510,6 @@
55695510
gdprTestMethod('increment' , ['prop_name' , 1 ]);
55705511
gdprTestMethod('append' , ['prop_name' , 'prop_value' ]);
55715512
gdprTestMethod('union' , ['prop_name' , 'prop_value' ]);
5572-
gdprTestMethod('track_charge', [1 , {prop: 'value'}]);
55735513

55745514
test('opt out of cookies', 42, function() {
55755515
var name;

0 commit comments

Comments
 (0)