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

Moving more code into shared #571

Merged
merged 10 commits into from
Jun 28, 2024
Merged

Moving more code into shared #571

merged 10 commits into from
Jun 28, 2024

Conversation

bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Jun 27, 2024

Continuation of PRO-720; follows up to #562

Moving much of the replayio utility-type code into the new shared package so that we can use those Node APIs for querying the list of recording and uploading or deleting them.

Most of this was rote but I did make a couple of changes worth calling out explicitly:

  • I changed the value returned by fetchAuthIdsFromGraphQL from { userId: string | null; workspaceId: string | null } to { id: string; type: "user" | "workspace" } and updated the callers; this was easier to work with (from a types perspective)
    • Grafana still gets userId or workspaceId though, just not both
  • Logger is now eagerly instantiated; the initialize() method will accept a name and version and pass them along to the Grafana instance. Logging before initialization (or in Jest tests) will be local-only.
    • Note that a version parameter is also supported now (so we can associate Grafana logs with specific releases)
    • Both name and version should probably be imported and passed directly from package.json (which is what I am currently doing for Puppeteer and replayio)
    • Note that I've replaced the previous "replayio" name prefix with whatever the passed package name is
  • Lots of debug(...args) logging has been changed to logger.debug("...", {...args})
  • I've moved mixpanel and launch-darkly code over to shared too, even though (for now) replayio is the only thing using this stuff
  • I also tidied up the getRecordings method to not create so many throw-away arrays; (I didn't just do this for performance, but TypeScript was complaining about the return array containing recordings and undefined with the previous code structure)

Next steps

  • Remove the test-utils dependency on @replayio/replay (and delete @replayio/replay)
  • Update test-utils to be a peer dependency so that it will get inlined as well (to resolve ambiguous logger ownership)
  • Audit logger.debug entries and decide which ones should be info, log, or even error
  • Address any added TODO [PRO-720] comments

Copy link

changeset-bot bot commented Jun 27, 2024

⚠️ No Changeset found

Latest commit: 483206c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@bvaughn
Copy link
Contributor Author

bvaughn commented Jun 27, 2024

What is going on with CI:

 trackEvent › authenticated › should track pending promises until resolved or rejected

               +test |     TypeError: Cannot read properties of undefined (reading 'debug')

               +test |       15 |     eventName = `replayio.${eventName}`;
               +test |       16 |   }
               +test |     > 17 |   logger.logger.debug(`trackEvent: "${eventName}"`, { properties });
               +test |          |                 ^
               +test |       18 |   trackEventImplementation(mixpanelAPI, eventName, properties);
               +test |       19 | }
               +test |       20 | async function trackEventImplementation(mixpanelAPI, eventName, properties) {

This error would make sense if the code had logger.logger.debug but it does not:

logger.debug(`trackEvent: "${eventName}"`, { properties });

Is this some Jest module mocking gone wrong or what?

@@ -3,7 +3,6 @@
"version": "0.0.0",
"private": true,
"exports": {
"./logger": "./dist/logger/index.js",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooof I didn't know about (or forgot about) this one

Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking, anything to do here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was intentional. It fixed the weird logger.logger.debug change. My comment was to Mateusz; I just meant that I'd forgot it existed so I didn't think to try deleting it.

@bvaughn bvaughn requested review from Andarist, callingmedic911 and miriambudayr and removed request for Andarist and callingmedic911 June 27, 2024 21:33
Copy link
Contributor

@callingmedic911 callingmedic911 left a comment

Choose a reason for hiding this comment

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

lgtm
image

Copy link

replay-io bot commented Jun 27, 2024

Status Complete ↗︎
Commit 0023fa7
Results
2 Failed
  • clicks a disappearing button
  • should fail on this test
  • 42 Passed
  • adds items
  • adds new items using a custom command
  • adds todos following the fixture
  • adds todos following the fixture
  • adds todos following the fixture
  • adds todos following the fixture
  • calls inform
  • complete all checkbox should update state when items are completed / cleared
  • gets a number
  • only gets a number
  • only gets a number
  • should allow me to add todo items
  • should allow me to clear the complete state of all items
  • should allow me to display active items
  • should allow me to display all items
  • should allow me to display completed items
  • should allow me to edit an item
  • should allow me to mark all items as completed
  • should allow me to mark items as complete
  • should allow me to un-mark items as complete
  • should append new items to the bottom of the list
  • should be hidden when there are no items that are completed
  • should cancel edits on escape
  • should clear text input field when an item is added
  • should display the correct text
  • should display the current number of todo items
  • should focus on the todo input field
  • should hide #main and #footer
  • should hide other controls when editing
  • should highlight the currently applied filter
  • should intercept postman
  • should invoke some commands that have exceptional option handling
  • should log
  • should persist its data
  • should remove completed items when clicked
  • should remove the item if an empty text string was entered
  • should respect the back button
  • should save edits on blur
  • should show #main and #footer when items added
  • should trim entered text
  • should trim text input
  • yields a number
  • @bvaughn bvaughn marked this pull request as ready for review June 28, 2024 02:45
    @bvaughn bvaughn merged commit 33656ea into main Jun 28, 2024
    7 checks passed
    @bvaughn bvaughn deleted the PRO-720-part-2 branch June 28, 2024 02:46
    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