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): Add possibility to Onesignal choose version api #6976

Open
wants to merge 6 commits into
base: next
Choose a base branch
from

Conversation

suplere
Copy link

@suplere suplere commented Nov 12, 2024

What changed? Why was the change needed?

This PR add possibility to Onesignal provider choose between:
a) player model
b) user model

User model documentation

Expand for optional sections

Special notes for your reviewer

Copy link

netlify bot commented Nov 12, 2024

Deploy Preview for novu-stg-vite-dashboard-poc ready!

Name Link
🔨 Latest commit 9743b4c
🔍 Latest deploy log https://app.netlify.com/sites/novu-stg-vite-dashboard-poc/deploys/6735e73cd7d3b70008fa8080
😎 Deploy Preview https://deploy-preview-6976--novu-stg-vite-dashboard-poc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@L-U-C-K-Y
Copy link
Contributor

@suplere nice, you created a new one, I actually also just did, what do you think about my MR?
I like that you use the new API, I just changed the key with an override, a bit simpler: #6979

@L-U-C-K-Y
Copy link
Contributor

L-U-C-K-Y commented Nov 13, 2024

@suplere I would vote for your version! I'll close mine after this is merged.
Thank you so much

@scopsy sorry for tagging you again, but is the better MR, would highly appreciate if we could get it merged to unblock our users

Copy link

@Michael-JobDone Michael-JobDone left a comment

Choose a reason for hiding this comment

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

👍

@suplere
Copy link
Author

suplere commented Nov 13, 2024

This solution use new API. This allows you to use the new and recommended Onesignal API. The old API (with player model) may be marked as obsolete or unsupported over time.

@L-U-C-K-Y
Copy link
Contributor

This solution use new API. This allows you to use the new and recommended Onesignal API. The old API (with player model) may be marked as obsolete or unsupported over time.

Absolutely, I closed mine

@@ -606,6 +606,18 @@ export const oneSignalConfig: IConfigCredentials[] = [
type: 'text',
required: true,
},
{
key: CredentialsKeyEnum.Region,
Copy link
Contributor

Choose a reason for hiding this comment

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

@suplere do we need to use CredentialsKeyEnum.Domain here as we use this.apiVersion = config.domain; in the provider?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I have updated this to be apiVersion and passed the proper info from the handler

},
}
: { include_player_ids: options.target };

const notification = this.transform(bridgeProviderData, {
Copy link
Contributor

Choose a reason for hiding this comment

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

@L-U-C-K-Y, do you know by chance if the API body signature is similar to both modes and API endpoints?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm just wondering if we even need to change the BASE URL at all

Copy link
Contributor

@L-U-C-K-Y L-U-C-K-Y Nov 14, 2024

Choose a reason for hiding this comment

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

@scopsy yes that would still be required if we want to keep "include_player_ids" in the older model.
Your change looks all good for me 😄

v9
See here the API Documentation for v9 (old):
https://documentation.onesignal.com/v9.0/reference/create-notification

image

V9 does not have the key include_aliases (was named: include_external_user_ids and still had the concept of player ids and therefore had include_player_ids.

v11.6
And here 11.6 (new):
https://documentation.onesignal.com/reference/push-notification

image

V11.6 has include_aliases where we can send the external ids, but no include_player_ids.
In the new versions, player ids are not used anymore and the recommended way is the external id:

https://documentation.onesignal.com/docs/users

It is always recommended to use the External ID to identify users because this is the only way to track a user across all their subscriptions.

Copy link
Author

@suplere suplere left a comment

Choose a reason for hiding this comment

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

Hello, it is looks better than my version.

Comment on lines +51 to +55
? {
include_aliases: {
external_id: options.target,
},
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
? {
include_aliases: {
external_id: options.target,
},
}
? {
include_aliases: {
external_id: options.target,
},
target_channel: 'push',
}

I just noticed in the docs that we would need to include the target_channel for the new API endpoint:

image

Comment on lines +56 to +58
include_aliases: {
external_id: ['userId'],
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
include_aliases: {
external_id: ['userId'],
},
include_aliases: {
external_id: ['userId'],
},
target_channel: 'push',

I just noticed in the docs that we would need to include the target_channel for the new API endpoint:

image

@suplere
Copy link
Author

suplere commented Nov 21, 2024

Is there some problem ?

@scopsy
Copy link
Contributor

scopsy commented Nov 21, 2024

@suplere could you take a look on @L-U-C-K-Y suggestions?

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.

4 participants