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

feat(providers): improve expo response management and multi device token #4508

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

p-fernandez
Copy link
Contributor

What change does this PR introduce?

Improves the response management of the Expo Provider and finally handles error cases.
In SendMessagePush we improve the information provided for the responses showing the device token that has failed or succeeded for situations of subscribers with multiple device tokens in the channel integration.

Why was this change needed?

This work is part of the bug discovered by @jainpawan21. Execution Details wasn't showing clearly that some device tokens were failing when using multiple active providers and using multiple device tokens for the same subscriber.
Also the Expo provider implementation had a lot of room to improve and was part to blame of the situation we were having.

Other information (Screenshots)

Expo provider will still miss multi token management (inherited tech debt).

Screenshots:
Screenshot 2023-10-12 at 16 59 21
Screenshot 2023-10-12 at 16 59 28

@p-fernandez p-fernandez self-assigned this Oct 12, 2023
@linear
Copy link

linear bot commented Oct 12, 2023


if (!result) {
integrationsWithErrors++;
const target = (overrides as { deviceTokens?: string[] }).deviceTokens || deviceTokens;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracting the deviceTokens out of this.sendMessage allowed us to easily loop them reusing the new flow implemented in #4495.

Comment on lines -158 to -159
command,
command.payload,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also taking advantage of cleaning the function arguments.

subscriber: IPushOptions['subscriber'],
integration: IntegrationEntity,
target: string[],
deviceToken: string,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now we will miss the functionalities of sending multiple tokens at the same time in exchange of better execution details without doing breaking changes in the providers.
We need to implement auxiliary methods in the providers to handle the multiple token and to handle properly their responses.

@@ -340,7 +315,7 @@ export class SendMessagePush extends SendMessageBase {
status: ExecutionDetailsStatusEnum.SUCCESS,
isTest: false,
isRetry: false,
raw: JSON.stringify(result),
raw: JSON.stringify({ result, deviceToken }),
Copy link
Contributor Author

@p-fernandez p-fernandez Oct 12, 2023

Choose a reason for hiding this comment

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

We add the device token in the execution detail raw information to help users to identify which ones succeeded or failed, though it can be arguable if we shouldn't as identifies the device of a user. We need to be careful with them.

Some providers treat the device token as not PII, like for example OneSignal:
https://documentation.onesignal.com/docs/handling-personal-data#push-tokens, but we should analyse our own risks.
CC: @scopsy @Cliftonz @djabarovgeorge @jainpawan21

Copy link
Member

@jainpawan21 jainpawan21 Oct 13, 2023

Choose a reason for hiding this comment

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

@scopsy is it good to proceed?

@@ -17,7 +17,7 @@ export class PushFactory implements IPushFactory {
new PushWebhookHandler(),
];

getHandler(integration: IntegrationEntity) {
getHandler(integration: IntegrationEntity): IPushHandler {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Type wasn't being infered by TypeScript. +1 for team explicit here.

@@ -43,6 +44,8 @@ const LOG_CONTEXT = 'SendMessagePush';
export class SendMessagePush extends SendMessageBase {
channelType = ChannelTypeEnum.PUSH;

private pushFactory;
Copy link
Contributor

Choose a reason for hiding this comment

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

@p-fernandez due to how nestjs works, we cannot have this one here as a private method, as nestjs @Injectable classes are singletons, and this will be reused across multiple executions. Which we don't want We need here to not store it as a method but rather pass it.

@p-fernandez p-fernandez force-pushed the nv-3023-handle-multiple-device-tokens-in-expo branch from 612e10d to e36dee3 Compare October 12, 2023 17:03
@p-fernandez p-fernandez requested a review from scopsy October 12, 2023 17:04
Base automatically changed from nv-3021-handle-push-empty-device-tokens to v0.20.x October 13, 2023 08:02
@p-fernandez p-fernandez merged commit 00e72bf into v0.20.x Oct 13, 2023
24 of 25 checks passed
@p-fernandez p-fernandez deleted the nv-3023-handle-multiple-device-tokens-in-expo branch October 13, 2023 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants