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

Add get tags #671

Merged
merged 2 commits into from
Jan 17, 2024
Merged

Add get tags #671

merged 2 commits into from
Jan 17, 2024

Conversation

jinliu9508
Copy link
Contributor

@jinliu9508 jinliu9508 commented Dec 5, 2023

Description

One Line Summary

Add getTags that returns a map of key-value tags

Details

Motivation

Allow user to get access of tags

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
    • If it is hard to explain how any codes changes are related to each other then it most likely needs to be more than one PR
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
    • Simplify with less code, followed by splitting up code into well named functions and variables, followed by adding comments to the code.
  • I have reviewed this PR myself, ensuring it meets each checklist item
    • WIP (Work In Progress) is ok, but explain what is still in progress and what you would like feedback on. Start the PR title with "WIP" to indicate this.

This change is Reviewable

@jinliu9508 jinliu9508 changed the base branch from main to user-model/main December 5, 2023 20:36
Copy link
Contributor

@shepherd-l shepherd-l left a comment

Choose a reason for hiding this comment

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

Will the iOS implementation of getTags be included in this PR?

I forgot to mention but, in the Unity SDK we manage a CHANGELOG. Could you update it with your change?

I recommend manually testing the getTags method on Android and iOS with the example app
You can also add a getTags button to the example app to make testing easier in the future

Nit: could you also update the Migration Guide to include the new method

Reviewable status: 0 of 4 files reviewed, 1 unresolved discussion (waiting on @jinliu9508)


OneSignalExample/Assets/StreamingAssets/SwiftPlugin.framework.meta line 0 at r1 (raw file):
What does deleting this file do?

Copy link
Member

@jkasten2 jkasten2 left a comment

Choose a reason for hiding this comment

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

Let's revert the changes to OneSignalExampleScene.unity in this PR, as it doesn't look related.

OneSignalExample/Assets/OneSignal/CHANGELOG.md Outdated Show resolved Hide resolved
@jinliu9508
Copy link
Contributor Author

Let's revert the changes to OneSignalExampleScene.unity in this PR, as it doesn't look related.

I added a testing button "Get Tags" under the button "Remove Tag" in the example scene so tester can see what getTags() returns. This is a generated file so there are code changes that don't look relevant.

Copy link
Contributor

@shepherd-l shepherd-l left a comment

Choose a reason for hiding this comment

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

Looks good! I have some minor nits
I tested GetTags on an emulated Pixel 4 with Android 12 and physical iPhone 12 with iOS 15.5 and the correct values were returned

Reviewed 3 of 4 files at r1, 4 of 11 files at r3, 4 of 8 files at r4.
Reviewable status: 11 of 18 files reviewed, 7 unresolved discussions (waiting on @jinliu9508, @jkasten2, and @nan-li)


com.onesignal.unity.android/Runtime/AndroidUserManager.cs line 57 at r4 (raw file):

            AndroidJavaObject obj = _user.Call<AndroidJavaObject>("getTags");
            Dictionary<string, string> dictionary = obj.MapToDictionary();
            UnityEngine.Debug.Log(dictionary.Count);

I think you forgot to remove a debug log, could you remove it?
Since the "dictionary" variable is only used for the log, you could also remove it or decide to return it instead


OneSignalExample/Assets/OneSignal/CHANGELOG.md line 19 at r4 (raw file):

## [5.0.5]
### Changed

I think we should also add that we updated the OneSignal Android and iOS SDK to highlight native changes

It should look something like this. You can also see the same comment in the Changelog history


OneSignalExample/Assets/OneSignal/MIGRATION_GUIDE_v3_to_v5.md line 177 at r4 (raw file):

| `void AddSms(string sms)`                             | *Add a new SMS subscription to the current user.*                                                                                                                                                                                        |
| `void RemoveSms(string sms)`                          | *Remove an SMS subscription from the current user.*                                                                                                                                                                                      |
| `Dictionary<string, string> GetTags()`                | *Return a copy of all tags for the current user. Tags are key:value pairs used as building blocks for targeting specific users and/or personalizing messages.*         |

I think we should also highlight that get tags returns the local tags on the user


OneSignalExample/Assets/OneSignal/Example/OneSignalExampleBehaviour.cs line 380 at r4 (raw file):

        Dictionary<string, string> dict = OneSignal.User.GetTags();
        string dictionaryString = "{";
        foreach(KeyValuePair < string, string > keyValues in dict) {  

Nit: could you remove the extra spaces next to the "<" and ">" to look like <string, string>


OneSignalExample/Assets/OneSignal/Example/OneSignalExampleScene.unity line 11343 at r4 (raw file):

    m_VerticalOverflow: 0
    m_LineSpacing: 1
  m_Text: Get Tag

Nit but could you change the button to say "Get Tags" to match the GetTags method name


OneSignalExample/Assets/StreamingAssets/SwiftPlugin.framework.meta line at r1 (raw file):

Previously, shepherd-l (Shepherd) wrote…

What does deleting this file do?

Why was this file deleted? I don't think we need to delete this file

Copy link
Contributor Author

@jinliu9508 jinliu9508 left a comment

Choose a reason for hiding this comment

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

I have committed a change addressing all of the concerns, please take a look again!

Reviewed 3 of 4 files at r1, 7 of 11 files at r3, 8 of 8 files at r4.
Reviewable status: 11 of 18 files reviewed, 7 unresolved discussions (waiting on @jkasten2, @nan-li, and @shepherd-l)

Copy link
Contributor Author

@jinliu9508 jinliu9508 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 11 of 18 files reviewed, 5 unresolved discussions (waiting on @jkasten2, @nan-li, and @shepherd-l)


com.onesignal.unity.android/Runtime/AndroidUserManager.cs line 57 at r4 (raw file):

Previously, shepherd-l (Shepherd) wrote…

I think you forgot to remove a debug log, could you remove it?
Since the "dictionary" variable is only used for the log, you could also remove it or decide to return it instead

Done.


OneSignalExample/Assets/OneSignal/CHANGELOG.md line 22 at r3 (raw file):

Previously, jkasten2 (Josh Kasten) wrote…

This should be under the "Changed" section instead of "Fixed".

Done.


OneSignalExample/Assets/OneSignal/CHANGELOG.md line 19 at r4 (raw file):

Previously, shepherd-l (Shepherd) wrote…

I think we should also add that we updated the OneSignal Android and iOS SDK to highlight native changes

It should look something like this. You can also see the same comment in the Changelog history

Done.


OneSignalExample/Assets/OneSignal/MIGRATION_GUIDE_v3_to_v5.md line 177 at r4 (raw file):

Previously, shepherd-l (Shepherd) wrote…

I think we should also highlight that get tags returns the local tags on the user

Done.


OneSignalExample/Assets/StreamingAssets/SwiftPlugin.framework.meta line at r1 (raw file):

Previously, shepherd-l (Shepherd) wrote…

Why was this file deleted? I don't think we need to delete this file

Done.

@jinliu9508 jinliu9508 requested a review from shepherd-l January 11, 2024 22:49
Copy link
Contributor

@shepherd-l shepherd-l left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 11 of 18 files reviewed, 1 unresolved discussion (waiting on @jinliu9508, @jkasten2, and @nan-li)

@jinliu9508 jinliu9508 merged commit a5b4f7e into user-model/main Jan 17, 2024
1 of 2 checks passed
@jinliu9508 jinliu9508 deleted the add-getTags branch January 17, 2024 17:35
jinliu9508 added a commit that referenced this pull request Feb 23, 2024
Add public getTags() method that returns tags from the local user
jinliu9508 added a commit that referenced this pull request Feb 27, 2024
Add public getTags() method that returns tags from the local user
jinliu9508 added a commit that referenced this pull request Feb 27, 2024
Add public getTags() method that returns tags from the local user
jinliu9508 added a commit that referenced this pull request Feb 27, 2024
Add public getTags() method that returns tags from the local user
jinliu9508 added a commit that referenced this pull request Feb 27, 2024
Add public getTags() method that returns tags from the local user
jinliu9508 added a commit that referenced this pull request Mar 1, 2024
Add public getTags() method that returns tags from the local user
jinliu9508 added a commit that referenced this pull request Mar 4, 2024
Add public getTags() method that returns tags from the local user
jinliu9508 added a commit that referenced this pull request Mar 4, 2024
Add public getTags() method that returns tags from the local user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants