Skip to content

Commit 5c50bf8

Browse files
NikoRobertsGabriel Samson
authored andcommitted
Checking userId is present before any changeUser (#170)
1 parent 59aa25f commit 5c50bf8

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

integrations/appboy/lib/index.js

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

258-
if (userId) {
259-
window.appboy.changeUser(userId);
260-
}
258+
if (userId) window.appboy.changeUser(userId);
261259
if (avatar) {
262260
window.appboy.getUser().setAvatarImageUrl(avatar);
263261
}
@@ -350,7 +348,7 @@ Appboy.prototype.group = function(group) {
350348
var userId = group.userId();
351349
var groupIdKey = 'ab_segment_group_' + group.groupId();
352350

353-
window.appboy.changeUser(userId);
351+
if (userId) window.appboy.changeUser(userId);
354352
window.appboy.getUser().setCustomUserAttribute(groupIdKey, true);
355353
};
356354

@@ -389,7 +387,7 @@ Appboy.prototype.track = function(track) {
389387
}
390388
}, properties);
391389

392-
window.appboy.changeUser(userId);
390+
if (userId) window.appboy.changeUser(userId);
393391
window.appboy.logCustomEvent(eventName, properties);
394392
};
395393

@@ -412,7 +410,7 @@ Appboy.prototype.page = function(page) {
412410
var eventName = pageEvent.event();
413411
var properties = page.properties();
414412

415-
window.appboy.changeUser(userId);
413+
if (userId) window.appboy.changeUser(userId);
416414
window.appboy.logCustomEvent(eventName, properties);
417415
};
418416

@@ -433,7 +431,7 @@ Appboy.prototype.orderCompleted = function(track) {
433431
var currencyCode = track.currency();
434432
var purchaseProperties = track.properties();
435433

436-
window.appboy.changeUser(userId);
434+
if (userId) window.appboy.changeUser(userId);
437435

438436
// remove reduntant properties
439437
del(purchaseProperties, 'products');

integrations/appboy/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@segment/analytics.js-integration-appboy",
33
"description": "The Appboy analytics.js integration.",
4-
"version": "1.10.2",
4+
"version": "1.10.3",
55
"keywords": [
66
"analytics.js",
77
"analytics.js-integration",

0 commit comments

Comments
 (0)