Skip to content

Commit 5be4bdc

Browse files
committed
WIP - need to test filter user attributes and see if it is keyed by name or number
1 parent 34bee4e commit 5be4bdc

2 files changed

Lines changed: 6 additions & 39 deletions

File tree

src/Rokt-Kit.js

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -116,38 +116,6 @@ var constructor = function () {
116116
}
117117
}
118118

119-
/**
120-
* Gets the string representation of an identity type
121-
* @param {number} identityType - The identity type number
122-
* @returns {string} The human readable string for the identity type
123-
*/
124-
function getIdentityName(identityType) {
125-
var identityTypes = {
126-
0: 'other',
127-
1: 'customerid',
128-
2: 'facebook',
129-
3: 'twitter',
130-
4: 'google',
131-
5: 'microsoft',
132-
6: 'yahoo',
133-
7: 'email',
134-
9: 'facebookcustomaudienceid',
135-
10: 'other2',
136-
11: 'other3',
137-
12: 'other4',
138-
13: 'other5',
139-
14: 'other6',
140-
15: 'other7',
141-
16: 'other8',
142-
17: 'other9',
143-
18: 'other10',
144-
19: 'mobile_number',
145-
20: 'phone_number_2',
146-
21: 'phone_number_3',
147-
};
148-
return identityTypes[identityType] || 'unknown';
149-
}
150-
151119
/**
152120
* Adds user identities to the attributes object
153121
* @param {Object} attributes - The attributes object to add identities to
@@ -159,15 +127,14 @@ var constructor = function () {
159127
return attributes;
160128
}
161129

162-
var userIdentities = filteredUser.getUserIdentities();
130+
var userIdentities = filteredUser.getUserIdentities().userIdentities;
163131
if (!userIdentities) {
164132
return attributes;
165133
}
166134

167-
for (var identityType in userIdentities) {
168-
if (userIdentities.hasOwnProperty(identityType)) {
169-
var identityValue = userIdentities[identityType];
170-
var identityKey = getIdentityName(parseInt(identityType));
135+
for (var identityKey in userIdentities) {
136+
if (userIdentities.hasOwnProperty(identityKey)) {
137+
var identityValue = userIdentities[identityKey];
171138
attributes[identityKey] = identityValue;
172139
}
173140
}

test/src/tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ describe('Rokt Forwarder', () => {
654654
return 'abc';
655655
},
656656
getUserIdentities: function () {
657-
return null;
657+
return { userIdentities: {} };
658658
},
659659
},
660660
};
@@ -699,7 +699,7 @@ describe('Rokt Forwarder', () => {
699699
);
700700
});
701701

702-
it('should handle case when userAttributes is null but userIdentities exist', async () => {
702+
it.only('should handle case when userAttributes is null but userIdentities exist', async () => {
703703
window.mParticle.Rokt.filters = {
704704
userAttributeFilters: [],
705705
filterUserAttributes: function () {

0 commit comments

Comments
 (0)