Skip to content

Conversation

@zzz0108
Copy link
Contributor

@zzz0108 zzz0108 commented Oct 13, 2022

Details

This fixes the crash when we enable

ONYX_METRICS=true
CAPTURE_METRICS=true

Please refer to this accepted proposal for more details

Related Issues

Expensify/App#10622

Automated Tests

This is a bug fix, no new behavior is introduced so I didn't add tests.

Linked PRs

Will update when a new Onyx version with this change is released, I assume there'll be another PR to bump the Onyx version in https://github.com/Expensify/App

Screenshots

Screenshots showing no crash happens in any platform after the fix

Web

Screen Shot 2022-10-13 at 17 57 55

Mobile Web

Screen Shot 2022-10-13 at 17 58 45

Desktop

Screen Shot 2022-10-13 at 17 28 09

iOS

Simulator Screen Shot - iPhone 13 - 2022-10-13 at 17 21 27

Android

processed

@zzz0108 zzz0108 requested a review from a team as a code owner October 13, 2022 09:37
@github-actions
Copy link
Contributor

github-actions bot commented Oct 13, 2022

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@melvin-bot melvin-bot bot requested review from aldo-expensify and removed request for a team October 13, 2022 09:37
@zzz0108
Copy link
Contributor Author

zzz0108 commented Oct 13, 2022

I have read the CLA Document and I hereby sign the CLA

@zzz0108
Copy link
Contributor Author

zzz0108 commented Oct 13, 2022

recheck

@puneetlath
Copy link
Contributor

@Santhosh-Sellavel and I should review this.

@puneetlath puneetlath self-requested a review October 13, 2022 19:51
@Santhosh-Sellavel
Copy link

Santhosh-Sellavel commented Oct 13, 2022

@christianwen

Seems this test is relevant to this issue, wondering should this test had to be failed earlier.

it('Should decorate exposed methods', () => {
// Given Onyx is initialized with `captureMetrics: true`
Onyx.init({
keys: ONYX_KEYS,
registerStorageEventListener: jest.fn(),
captureMetrics: true,
});
// When calling decorated methods through Onyx[methodName]
const methods = ['set', 'multiSet', 'clear', 'merge', 'mergeCollection'];
methods.forEach(name => Onyx[name]('mockKey', {mockKey: {mockValue: 'mockValue'}}));
return waitForPromisesToResolve()
.then(() => {
// Then metrics should have captured data for each method
const summaries = Onyx.getMetrics().summaries;
methods.forEach((name) => {
expect(summaries[`Onyx:${name}`].total).toBeGreaterThan(0);
});
});
});
});

Any thoughts?

cc: @puneetlath

@zzz0108
Copy link
Contributor Author

zzz0108 commented Oct 17, 2022

@Santhosh-Sellavel that test doesn't fail because it's using the react-native implementation in lib/metrics/index.native.js, it's not using the noop in lib/metrics/index.web.js

@Santhosh-Sellavel
Copy link

Santhosh-Sellavel commented Oct 17, 2022

So are we missing unit tests for the web?

@Santhosh-Sellavel
Copy link

@puneetlath Any thoughts on this #198 (comment)

@puneetlath
Copy link
Contributor

Agreed - can we add a test for the web scenario?

@Santhosh-Sellavel
Copy link

@christianwen any update?

@zzz0108
Copy link
Contributor Author

zzz0108 commented Oct 27, 2022

@Santhosh-Sellavel sorry I'll add the tests today, been a bit occupied this week

@zzz0108
Copy link
Contributor Author

zzz0108 commented Oct 27, 2022

@Santhosh-Sellavel unit test added, thanks

Copy link

@Santhosh-Sellavel Santhosh-Sellavel 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! Will test on PR against E/App.
All you @puneetlath @aldo-expensify

@puneetlath
Copy link
Contributor

@christianwen can you please merge main.

@zzz0108
Copy link
Contributor Author

zzz0108 commented Oct 31, 2022

@puneetlath done, @Santhosh-Sellavel can give the review again. Please note there's the other merged PR #206 that has one of the change in this PR (the Onyx.update change), so I've removed that redundant change in this PR as part of the conflict resolution

@puneetlath puneetlath merged commit cc6a29f into Expensify:main Oct 31, 2022
@tgolen tgolen mentioned this pull request Nov 16, 2022
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