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

[browserstack-service] Add Funnel Data instrumentation [v8] #12392

Merged
merged 24 commits into from
Mar 6, 2024

Conversation

sriteja777
Copy link
Contributor

@sriteja777 sriteja777 commented Mar 1, 2024

Proposed changes

  • Send instrumentation details at start and end of build
  • Refactor code to use a single listener for all frameworks test details reporting.

Types of changes

  • Polish (an improvement for an existing feature)
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (improvements to the project's docs)
  • Specification changes (updates to WebDriver command specifications)
  • Internal updates (everything related to internal scripts, governance documentation and CI files)

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Backport Request

//: # (The current main branch is the development branch for WebdriverIO v9. If your change should be released to the current major version of WebdriverIO (v8), please raise another PR with the same changes against the v8 branch.)

  • This change is solely for v9 and doesn't need to be back-ported
  • Back-ported PR at #XXXXX

Further comments

Reviewers: @webdriverio/project-committers

Copy link
Member

@christian-bromann christian-bromann 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 the PR. I would generally advise not to wrap everything within a try/catch.

packages/wdio-browserstack-service/src/data-store.ts Outdated Show resolved Hide resolved
packages/wdio-browserstack-service/src/exitHandler.ts Outdated Show resolved Hide resolved
Comment on lines +63 to +65
try {
this.hookStartedStats.triggered()
this.sendBatchEvents(this.getEventForHook('HookRunStarted', hookData))
Copy link
Member

Choose a reason for hiding this comment

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

Why is this wrapped in a try/catch block?

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 sendBatchEvents method calls add method of RequestQueueHandler which can throw exception

  • currently when build start not yet completed.

This try catch is added to mainly get the proper instrumentation on how many events, we were able to send properly and how many failed. That's why this try catch is needed to catch the instrumentation properly, we are re-throwing the exception from here after catching.

Comment on lines +73 to +75
try {
this.hookFinishedStats.triggered(hookData.result)
this.sendBatchEvents(this.getEventForHook('HookRunFinished', hookData))
Copy link
Member

Choose a reason for hiding this comment

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

same

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 sendBatchEvents method calls add method of RequestQueueHandler which can throw exception

  • currently when build start not yet completed.

This try catch is added to mainly get the proper instrumentation on how many events, we were able to send properly and how many failed. That's why this try catch is needed to catch the instrumentation properly, we are re-throwing the exception from here after catching.

}).json()
BStackLogger.debug(`[${logTag}] Success response: ${JSON.stringify(data)}`)
} catch (error) {
BStackLogger.debug(`[${logTag}] Failed. Error: ${error}`)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we return an error object here too similar to line 23?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually this method should throw error for any reason it is not able to make the request, forgot to update it before. Have updated it now to throw errors

@sriteja777
Copy link
Contributor Author

Hey @christian-bromann, thanks for the quick review of the PR and sorry for my delay in responding. Have replied to all comments and made changes wherever necessary. Please re-review the PR

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

Two last comments. Can we raise a similar PR to main and optionally v7 if you like to backport this.

packages/wdio-browserstack-service/src/config.ts Outdated Show resolved Hide resolved
packages/wdio-browserstack-service/src/request-handler.ts Outdated Show resolved Hide resolved
@sriteja777
Copy link
Contributor Author

sriteja777 commented Mar 5, 2024

Hey @christian-bromann, have resolved the comments. Also the failing tests doesn't seem related to the changes.

  • For v7, I am creating the PR will share for review in some while.
  • For v9, my current local setup is breaking with v9. Need to check more on it. It may take some time to create a v9 PR for this.

@christian-bromann
Copy link
Member

christian-bromann commented Mar 5, 2024

  • For v9, my cuurent local setup is breaking with v9.

Let me know if I can help to resolve the issue. I recommend checking out v9 in a separate directory since we switched to pnpm which resolves dependencies very differently.

That said, I wanted to make sure that we have all 3 PRs ready to go before merging.

@sriteja777
Copy link
Contributor Author

v9 is working for me locally now. I was trying out v9 branch day before yesterday, but faced some typescript errors when ran the setup. Not sure what merged in main now, but with latest pull, currently it is working for me 🎉 . Will try to create the v9 PR for this.

@christian-bromann It might take some time for me (possibly tomorrow) to create a v9 PR as I need to port the changes and test them. Possible for merging this PR for now? Will share the v7 and v9 PRs as soon as they are ready.

@christian-bromann
Copy link
Member

I am happy to merge once we have the PR for main branch to ensure we don't diverge between both future supported versions.

@sriteja777
Copy link
Contributor Author

sriteja777 commented Mar 5, 2024

Sure @christian-bromann, I will try to create rest of the PRs asap. Thanks!

@christian-bromann christian-bromann added the PR: New Feature 🚀 PRs that contain new features label Mar 5, 2024
@sriteja777 sriteja777 changed the title [browserstack-service] Add Funnel Data instrumentation [browserstack-service] Add Funnel Data instrumentation [v8] Mar 6, 2024
@sriteja777
Copy link
Contributor Author

Hey @christian-bromann, have created PRs for main and v7. Please have a look

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: New Feature 🚀 PRs that contain new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants