Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enhancement: onboard user API for onesignal #3457

Closed
wants to merge 12 commits into from
Prev Previous commit
Next Next commit
fix: lint errors+1
  • Loading branch information
anantjain45823 committed Jun 22, 2024
commit be6265a56a44b59269edc946d281af535bfce83f
6 changes: 3 additions & 3 deletions src/v0/destinations/one_signal/transformV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
response.body.JSON = removeUndefinedAndNullValues(payload);
return response;
}
throw new TransformationError('Payload could not be populated due to wrong input');

Check warning on line 37 in src/v0/destinations/one_signal/transformV2.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/one_signal/transformV2.js#L37

Added line #L37 was not covered by tests
};

/**
Expand All @@ -60,7 +60,7 @@
}
// Following check is to intialise properties object in case we don't get properties object from construct payload
if (!payload.properties) {
payload.properties = {};

Check warning on line 63 in src/v0/destinations/one_signal/transformV2.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/one_signal/transformV2.js#L63

Added line #L63 was not covered by tests
}
payload.subscriptions = getSubscriptions(message, Config);
payload.properties.tags = tags;
Expand Down Expand Up @@ -119,9 +119,9 @@
if (properties && allowedProperties && Array.isArray(allowedProperties)) {
allowedProperties.forEach((item) => {
if (typeof properties[item.propertyName] === 'string') {
const tagName =
event && eventAsTags ? `${event}_${[item.propertyName]}` : item.propertyName;
tags[tagName] = properties[item.propertyName];
const tagName =
event && eventAsTags ? `${event}_${[item.propertyName]}` : item.propertyName;
tags[tagName] = properties[item.propertyName];
}
});
}
Expand All @@ -134,7 +134,7 @@
throw new InstrumentationError('Event type is required');
}
if (!destination.Config.appId) {
throw new ConfigurationError('appId is a required field');

Check warning on line 137 in src/v0/destinations/one_signal/transformV2.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/one_signal/transformV2.js#L137

Added line #L137 was not covered by tests
}
const messageType = message.type.toLowerCase();
let response;
Expand Down
2 changes: 1 addition & 1 deletion src/v0/destinations/one_signal/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
devicePayload.device_type = deviceTypeMapping[message.context?.device?.type?.toLowerCase()];
devicePayload.identifier = message.context?.device?.token
? message.context?.device?.token
: message.context?.device?.id;

Check warning on line 71 in src/v0/destinations/one_signal/utils.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/one_signal/utils.js#L71

Added line #L71 was not covered by tests
}
// Parsing the UA to get the browser info to map the device_type
if (message.channel === 'web' && message.context?.userAgent) {
Expand All @@ -90,17 +90,17 @@
const integrationsObj = getIntegrationsObj(message, 'one_signal');
const devicePayload = {};
if (integrationsObj?.deviceType && integrationsObj?.identifier) {
devicePayload.type = integrationsObj.deviceType;

Check warning on line 93 in src/v0/destinations/one_signal/utils.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/one_signal/utils.js#L93

Added line #L93 was not covered by tests
devicePayload.token = integrationsObj.token || integrationsObj.identifier;
}
// Mapping device type when it is not present in the integrationsObject
if (!devicePayload.type) {
// if channel is mobile, checking for type from `context.device.type`
if (message.channel === 'mobile') {
devicePayload.type = message.context?.device?.type;

Check warning on line 100 in src/v0/destinations/one_signal/utils.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/one_signal/utils.js#L100

Added line #L100 was not covered by tests
devicePayload.token = message.context?.device?.token
? message.context.device.token
: message.context?.device?.id;

Check warning on line 103 in src/v0/destinations/one_signal/utils.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/one_signal/utils.js#L102-L103

Added lines #L102 - L103 were not covered by tests
}
// Parsing the UA to get the browser info to map the device_type
if (message.channel === 'web' && message.context?.userAgent) {
Expand Down Expand Up @@ -136,7 +136,7 @@
count: properties?.quantity,
amount: properties?.amount,
});
return Object.keys(purchaseObject).length > 0 ? [purchaseObject]: [];
return Object.keys(purchaseObject).length > 0 ? [purchaseObject] : [];
};

/**
Expand Down
Loading