Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions integrations/appboy/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,17 @@ Appboy.prototype.identify = function(identify) {
delete traits[key];
}, reserved);

// Remove nested hash objects as Braze only supports nested array objects in identify calls
// https://segment.com/docs/destinations/braze/#identify
each(function(value, key) {
if (
typeof value === 'object' &&
Array.isArray(value)
) {
delete traits[key];
}
}, traits);

each(function(value, key) {
window.appboy.getUser().setCustomUserAttribute(key, value);
}, traits);
Expand Down Expand Up @@ -356,6 +367,14 @@ Appboy.prototype.track = function(track) {
delete properties[key];
}, reserved);

// Remove nested objects as Braze doesn't support nested objects in tracking calls
// https://segment.com/docs/destinations/braze/#track
each(function(value, key) {
if (value != null && typeof value === 'object') {
delete properties[key];
}
}, properties);

window.appboy.changeUser(userId);
window.appboy.logCustomEvent(eventName, properties);
};
Expand Down
3 changes: 2 additions & 1 deletion integrations/appboy/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "@segment/analytics.js-integration-appboy",
"description": "The Appboy analytics.js integration.",
"version": "1.10.0",
"version": "1.10.1",
"keywords": [
"analytics.js",
"analytics.js-integration",
"segment",
"Braze",
"Appboy"
],
"main": "lib/index.js",
Expand Down
13 changes: 9 additions & 4 deletions integrations/appboy/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,11 @@ describe('Appboy', function() {
);
});

it('should handle custom traits of all types', function() {
it('should handle custom traits of acceptable types and excludes nested hashes', function() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('should handle custom traits of acceptable types and excludes nested hashes', function() {
it('should handle custom traits of acceptable types and excludes nested objects', function() {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arrays are not objects?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typeof([])
"object"

analytics.identify('userId', {
song: "Who's That Chick?",
artists: ['David Guetta', 'Rihanna'],
details: { nested: 'object' },
number: 16,
date: 'Tue Apr 25 2017 14:22:48 GMT-0700 (PDT)'
});
Expand Down Expand Up @@ -407,19 +408,23 @@ describe('Appboy', function() {
analytics.called(window.appboy.logCustomEvent, 'event');
});

it('should send all properties', function() {
it('should send all properties except nested arrays and hashes', function() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('should send all properties except nested arrays and hashes', function() {
it('should send all properties except nested arrays and objects', function() {

analytics.track('event with properties', {
nickname: 'noonz',
spiritAnimal: 'rihanna',
best_friend: 'han'
best_friend: 'han',
number_of_friends: 12,
idols: ['beyonce', 'madonna'],
favoriteThings: { whiskers: 'on-kittins' }
});
analytics.called(
window.appboy.logCustomEvent,
'event with properties',
{
nickname: 'noonz',
spiritAnimal: 'rihanna',
best_friend: 'han'
best_friend: 'han',
number_of_friends: 12
}
);
});
Expand Down