Skip to content

Commit

Permalink
chore: update function as per review suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
yashasvibajpai committed Dec 3, 2024
1 parent 70fa123 commit 3eb5c55
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/v1/sources/shopify/webhookTransformations/serverSideUtlis.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,14 @@ const createPropertiesForEcomEventFromWebhook = (message) => {
* @returns {String} anonymousId
*/
const getAnonymousIdFromAttributes = async (event) => {
let anonymousId = null;
if (isDefinedAndNotNull(event) && isDefinedAndNotNull(event.note_attributes)) {
const noteAttributes = event.note_attributes;
const rudderAnonymousIdObject = noteAttributes.find(
(attr) => attr.name === 'rudderAnonymousId',
);
anonymousId = rudderAnonymousIdObject ? rudderAnonymousIdObject.value : null;
if (!isDefinedAndNotNull(event) || !isDefinedAndNotNull(event.note_attributes)) {
return null; // Return early if event or note_attributes is invalid

Check warning on line 49 in src/v1/sources/shopify/webhookTransformations/serverSideUtlis.js

View check run for this annotation

Codecov / codecov/patch

src/v1/sources/shopify/webhookTransformations/serverSideUtlis.js#L49

Added line #L49 was not covered by tests
}
return anonymousId;

const noteAttributes = event.note_attributes;
const rudderAnonymousIdObject = noteAttributes.find((attr) => attr.name === 'rudderAnonymousId');

return rudderAnonymousIdObject ? rudderAnonymousIdObject.value : null;
};

module.exports = {
Expand Down

0 comments on commit 3eb5c55

Please sign in to comment.