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

call private ios pages API #69

Merged
merged 14 commits into from
Sep 6, 2023

Conversation

RyanCommits
Copy link
Contributor

@RyanCommits RyanCommits commented Jul 25, 2023

With the following JS code:

const startRecording = () => {
    let page;
    page = new FullStory.FSPage('Home', { tired: 'man', obj: { hmm: 'hmm' }, aaa: { hmm: 'hmm' } });
    page.start({ pageName: 'erp', Homes: 'erp', woman: 'wo', obj: 3, aaa: { pop: 'op' } });
    page.update({ updates: 'updates' });
    page.end();
  };

  const stopRecording = () => {
    let page;
    page = new FullStory.FSPage('Test');
    page.start();
    page.update({ updates: 'updates' });
    page.end();
  };

Old RN Architecture:
https://app.staging.fullstory.com/ui/KWH/session/4688480919289856:4741929862889472

New RN Architecture:
https://app.staging.fullstory.com/ui/KWH/session/4688480919289856:6558104800395264

* Fix TS types
* Fix immutable object merge issue (Old Architecture)
* Fix Java method declaration on Old Architecture

Copy link
Contributor

@jwise jwise left a comment

Choose a reason for hiding this comment

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

Hmm, Reece made a good point about compatibility with different versions. Some comments inline.

ios/FullStory.mm Outdated
dispatch_async(dispatch_get_main_queue(), ^{
self->_page = [FS pageWithName:pageName properties:pageProperties];
[FS pageViewWithNonce:uuid name:pageName properties:pageProperties];
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment in the related Android PR reminded me that this could be a problem if paired with a plugin that does not have pageViewWithNonce. We presumably either need to check the plugin version -- or we need to check this with something like:

Suggested change
[FS pageViewWithNonce:uuid name:pageName properties:pageProperties];
if (![FS respondsToSelector:@selector(pageViewWithNonce:name:properties:)]) {
...react native logging mechanism to complain...
} else {
[FS pageViewWithNonce:uuid name:pageName properties:pageProperties];
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a check

@RyanCommits RyanCommits force-pushed the ryanwang/android-pages-api branch 2 times, most recently from 5526414 to bcc384c Compare August 25, 2023 19:17
@RyanCommits RyanCommits force-pushed the ryanwang/ios-pages-api branch from d5a88de to bd11bf6 Compare August 26, 2023 02:28
@@ -35,7 +35,7 @@ public class FullStoryModuleImpl {
updatePageProperties = null;
endPage = null;
Log.println(Log.ERROR, NAME, "Unable to access native FullStory pages API. Pages API will not function correctly. " +
"Make sure that your plugin is at least version 1.38; if the issue persists, please contact FullStory Support.");
"Make sure that your plugin is at least version 1.41; if the issue persists, please contact FullStory Support.");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bumped this Android message to 1.41 since we edited the iOS private API's made available in 1.41. We want the recommended version for Pages API to be consistent.

Copy link
Contributor

Choose a reason for hiding this comment

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

This check and informative log message is Android-specific. We should have a similar check and log message for iOS.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The error message PagesAPIError in ios/FullStory.mm serves this purpose. Not sure if you missed it or if you mean something else?

@RyanCommits RyanCommits requested a review from jwise August 26, 2023 02:34
Base automatically changed from ryanwang/android-pages-api to ryanwang/add-pages-api August 31, 2023 18:13
@RyanCommits RyanCommits force-pushed the ryanwang/ios-pages-api branch from 807b50d to 984484e Compare August 31, 2023 18:21
@RyanCommits RyanCommits force-pushed the ryanwang/ios-pages-api branch from a430578 to 4c41df2 Compare August 31, 2023 18:38
Copy link

@ReeceLaF ReeceLaF left a comment

Choose a reason for hiding this comment

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

LGTM, but I'll let @jwise approve as its iOS.

Copy link
Contributor

@martin-fs martin-fs left a comment

Choose a reason for hiding this comment

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

Thanks for pointing out that iOS log message - I think it's because I was skimming for an "Unable to access pages" type of message and didn't see it. So, consider a couple of small string changes, but otherwise looks good!

ios/FullStory.mm Outdated
});
}
if (![FS respondsToSelector:@selector(_updatePageWithNonce:properties:)]) {
RCTLogError(PagesAPIError, @"endPage");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think "endPage" should be "updatePage" here.

ios/FullStory.mm Outdated
}

NSString *const PagesAPIError = @"Unable to call %@. Make sure that your plugin is at least version 1.41; if the issue persists, please contact FullStory Support.";
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add some verbiage similar to the Android log, like "Unable to access native FullStory pages API. Pages API will not function correctly. ". This will help the clarity of the log message and the consistency between platforms.

@RyanCommits RyanCommits merged commit c6ff20e into ryanwang/add-pages-api Sep 6, 2023
@RyanCommits RyanCommits deleted the ryanwang/ios-pages-api branch September 6, 2023 18:26
RyanCommits added a commit that referenced this pull request Sep 13, 2023
* add pages API to JS spec

* add pages API to iOS

* add Android pages API

* Add Android pages implementation (#68)

* Add Android pages implementation

* updates on feedback
- update legacy RN native module method declarations
- replace System.out with android.util.Log
- initialize reflected methods once
- getUUID is async
- fix page properties merge
- add TS FSPage types

* cleanup and fix turbomodule

* remove private functions from export

* remove page methods from types

* add error message

* generate UUID with Math.random()

* remove async method

* update method type to synchronous

* update android log

---------

Co-authored-by: Ryan Wang <[email protected]>

* call private ios pages API (#69)

* Add Android pages implementation

* updates on feedback
- update legacy RN native module method declarations
- replace System.out with android.util.Log
- initialize reflected methods once
- getUUID is async
- fix page properties merge
- add TS FSPage types

* cleanup and fix turbomodule

* remove private functions from export

* remove page methods from types

* add error message

* generate UUID with Math.random()

* remove async method

* update method type to synchronous

* implement ios pages API

* formatting

* formatting

* Fix rebase regression

* Edit error message

---------

Co-authored-by: Ryan Wang <[email protected]>

* Improve Pages types and add testing (#76)

Co-authored-by: Ryan Wang <[email protected]>

* use uppercase UUIDs, exclude lib/ from jest

* implement new uuid generator, update tests

---------

Co-authored-by: Ryan Wang <[email protected]>
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.

5 participants