Skip to content

Commit a396d6a

Browse files
author
Gabriel Samson
authored
Braze: Revert error catching (#173)
1 parent 5c50bf8 commit a396d6a

File tree

3 files changed

+16
-53
lines changed

3 files changed

+16
-53
lines changed

integrations/appboy/lib/index.js

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -255,25 +255,13 @@ Appboy.prototype.identify = function(identify) {
255255
var phone = identify.phone();
256256
var traits = clone(identify.traits());
257257

258-
if (userId) window.appboy.changeUser(userId);
259-
if (avatar) {
260-
window.appboy.getUser().setAvatarImageUrl(avatar);
261-
}
262-
if (email) {
263-
window.appboy.getUser().setEmail(email);
264-
}
265-
if (firstName) {
266-
window.appboy.getUser().setFirstName(firstName);
267-
}
268-
if (gender) {
269-
window.appboy.getUser().setGender(getGender(gender));
270-
}
271-
if (lastName) {
272-
window.appboy.getUser().setLastName(lastName);
273-
}
274-
if (phone) {
275-
window.appboy.getUser().setPhoneNumber(phone);
276-
}
258+
window.appboy.changeUser(userId);
259+
window.appboy.getUser().setAvatarImageUrl(avatar);
260+
window.appboy.getUser().setEmail(email);
261+
window.appboy.getUser().setFirstName(firstName);
262+
window.appboy.getUser().setGender(getGender(gender));
263+
window.appboy.getUser().setLastName(lastName);
264+
window.appboy.getUser().setPhoneNumber(phone);
277265
if (address) {
278266
window.appboy.getUser().setCountry(address.country);
279267
window.appboy.getUser().setHomeCity(address.city);
@@ -319,17 +307,6 @@ Appboy.prototype.identify = function(identify) {
319307
delete traits[key];
320308
}, reserved);
321309

322-
// Remove nested hash objects as Braze only supports nested array objects in identify calls
323-
// https://segment.com/docs/destinations/braze/#identify
324-
each(function(value, key) {
325-
if (
326-
typeof value === 'object' &&
327-
Array.isArray(value)
328-
) {
329-
delete traits[key];
330-
}
331-
}, traits);
332-
333310
each(function(value, key) {
334311
window.appboy.getUser().setCustomUserAttribute(key, value);
335312
}, traits);
@@ -348,7 +325,7 @@ Appboy.prototype.group = function(group) {
348325
var userId = group.userId();
349326
var groupIdKey = 'ab_segment_group_' + group.groupId();
350327

351-
if (userId) window.appboy.changeUser(userId);
328+
window.appboy.changeUser(userId);
352329
window.appboy.getUser().setCustomUserAttribute(groupIdKey, true);
353330
};
354331

@@ -379,15 +356,7 @@ Appboy.prototype.track = function(track) {
379356
delete properties[key];
380357
}, reserved);
381358

382-
// Remove nested objects as Braze doesn't support nested objects in tracking calls
383-
// https://segment.com/docs/destinations/braze/#track
384-
each(function(value, key) {
385-
if (value != null && typeof value === 'object') {
386-
delete properties[key];
387-
}
388-
}, properties);
389-
390-
if (userId) window.appboy.changeUser(userId);
359+
window.appboy.changeUser(userId);
391360
window.appboy.logCustomEvent(eventName, properties);
392361
};
393362

@@ -410,7 +379,7 @@ Appboy.prototype.page = function(page) {
410379
var eventName = pageEvent.event();
411380
var properties = page.properties();
412381

413-
if (userId) window.appboy.changeUser(userId);
382+
window.appboy.changeUser(userId);
414383
window.appboy.logCustomEvent(eventName, properties);
415384
};
416385

@@ -431,7 +400,7 @@ Appboy.prototype.orderCompleted = function(track) {
431400
var currencyCode = track.currency();
432401
var purchaseProperties = track.properties();
433402

434-
if (userId) window.appboy.changeUser(userId);
403+
window.appboy.changeUser(userId);
435404

436405
// remove reduntant properties
437406
del(purchaseProperties, 'products');

integrations/appboy/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
22
"name": "@segment/analytics.js-integration-appboy",
33
"description": "The Appboy analytics.js integration.",
4-
"version": "1.10.3",
4+
"version": "1.10.0",
55
"keywords": [
66
"analytics.js",
77
"analytics.js-integration",
88
"segment",
9-
"Braze",
109
"Appboy"
1110
],
1211
"main": "lib/index.js",

integrations/appboy/test/index.test.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,10 @@ describe('Appboy', function() {
335335
);
336336
});
337337

338-
it('should handle custom traits of acceptable types and excludes nested hashes', function() {
338+
it('should handle custom traits of all types', function() {
339339
analytics.identify('userId', {
340340
song: "Who's That Chick?",
341341
artists: ['David Guetta', 'Rihanna'],
342-
details: { nested: 'object' },
343342
number: 16,
344343
date: 'Tue Apr 25 2017 14:22:48 GMT-0700 (PDT)'
345344
});
@@ -408,23 +407,19 @@ describe('Appboy', function() {
408407
analytics.called(window.appboy.logCustomEvent, 'event');
409408
});
410409

411-
it('should send all properties except nested arrays and hashes', function() {
410+
it('should send all properties', function() {
412411
analytics.track('event with properties', {
413412
nickname: 'noonz',
414413
spiritAnimal: 'rihanna',
415-
best_friend: 'han',
416-
number_of_friends: 12,
417-
idols: ['beyonce', 'madonna'],
418-
favoriteThings: { whiskers: 'on-kittins' }
414+
best_friend: 'han'
419415
});
420416
analytics.called(
421417
window.appboy.logCustomEvent,
422418
'event with properties',
423419
{
424420
nickname: 'noonz',
425421
spiritAnimal: 'rihanna',
426-
best_friend: 'han',
427-
number_of_friends: 12
422+
best_friend: 'han'
428423
}
429424
);
430425
});

0 commit comments

Comments
 (0)