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

[Telemetry API] Prevent Subscriptions with different options from overwriting each other #7930

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

jvigliotta
Copy link
Contributor

@jvigliotta jvigliotta commented Nov 14, 2024

Closes #7933

Describe your changes:

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Is this a notable change that will require a special callout in the release notes? For example, will this break compatibility with existing APIs or projects that consume these plugins?

Author Checklist

  • Changes address original issue?
  • Tests included and/or updated with changes?
  • Has this been smoke tested?
  • Have you associated this PR with a type: label? Note: this is not necessarily the same as the original issue.
  • Have you associated a milestone with this PR? Note: leave blank if unsure.
  • Testing instructions included in associated issue OR is this a dependency/testcase change?

Reviewer Checklist

  • Changes appear to address issue?
  • Reviewer has tested changes by following the provided instructions?
  • Changes appear not to be breaking changes?
  • Appropriate automated tests included?
  • Code style and in-line documentation are appropriate?

Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 57.24%. Comparing base (ea9947c) to head (6569c75).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7930      +/-   ##
==========================================
- Coverage   57.66%   57.24%   -0.42%     
==========================================
  Files         677      677              
  Lines       27373    27404      +31     
  Branches     2689     2689              
==========================================
- Hits        15784    15688      -96     
- Misses      11250    11375     +125     
- Partials      339      341       +2     
Flag Coverage Δ
e2e-ci 62.63% <100.00%> (+0.15%) ⬆️
e2e-full 23.59% <5.26%> (-34.55%) ⬇️
unit 49.34% <65.78%> (-0.02%) ⬇️
Files with missing lines Coverage Δ
example/generator/GeneratorMetadataProvider.js 100.00% <ø> (ø)
example/generator/StateGeneratorProvider.js 100.00% <100.00%> (ø)
src/api/telemetry/TelemetryAPI.js 90.11% <100.00%> (+0.90%) ⬆️

... and 19 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ea9947c...6569c75. Read the comment docs.

@jvigliotta jvigliotta marked this pull request as ready for review November 20, 2024 20:03
Copy link
Contributor

@akhenry akhenry left a comment

Choose a reason for hiding this comment

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

I think the hash code is the right approach here, thanks. I think we can simplify the code a little with a few tweaks,

src/api/telemetry/TelemetryAPI.js Outdated Show resolved Hide resolved
src/api/telemetry/TelemetryAPI.js Outdated Show resolved Hide resolved
src/api/telemetry/TelemetryAPI.js Fixed Show resolved Hide resolved

for (const key of Object.keys(value)) {
const sanitizedValue = this.#sanitizeForSerialization(value[key]);
// Replace functions and non-plain objects with their key names
Copy link
Contributor

Choose a reason for hiding this comment

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

if (Array.isArray(value)) {
return value.map((item) => this.#sanitizeForSerialization(item));
return value.map((item, index) => this.sanitizeForSerialization(String(index), item));
Copy link
Contributor

Choose a reason for hiding this comment

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

Just return the array itself, the replacer function (sanitizeForSerialization) will automatically be called for each member. see docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#the_replacer_parameter

// Wait for some data to populate
// eslint-disable-next-line playwright/no-wait-for-timeout
await page.waitForTimeout(2000); // Wait for a few state changes

Copy link
Contributor

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TelemetryAPI] Subscriptions need to be unique based on request options
2 participants