-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - streamlabs #15557
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
New Components - streamlabs #15557
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
WalkthroughThis pull request introduces new modules for Streamlabs integration. The changes add actions for creating donations, sending alerts, and sending test alerts. Additionally, a common module for supported currencies and a dedicated package descriptor have been added. The primary Streamlabs app component has been refactored to include new helper methods (_baseUrl, _accessToken, _makeRequest) along with public methods for the new actions, while removing the obsolete authKeys method. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant CD as CreateDonation Module
participant App as Streamlabs App
participant API as Streamlabs API
U->>CD: Initiate donation action
CD->>App: Call createDonation(opts)
App->>App: Process donation data (parse amount, timestamp)
App->>API: _makeRequest('/donation', data)
API-->>App: Response (donation_id)
App-->>CD: Return donation summary
CD-->>U: Output confirmation message
sequenceDiagram
participant U as User
participant A as Alert Module
participant TA as TestAlert Module
participant App as Streamlabs App
participant API as Streamlabs API
U->>A: Trigger send alert action
A->>App: Call sendAlert(opts)
App->>API: _makeRequest('/alert', opts)
API-->>App: Alert response
App-->>A: Return alert summary
A-->>U: Output confirmation message
U->>TA: Trigger send test alert action
TA->>App: Call sendTestAlert(opts)
App->>API: _makeRequest('/test-alert', opts)
API-->>App: Test alert response
App-->>TA: Return test alert summary
TA-->>U: Output confirmation message
Assessment against linked issues
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🧹 Nitpick comments (2)
components/streamlabs/actions/send-test-alert/send-test-alert.mjs (1)
53-63: Enhance response handling and add type validationThe run method should validate that the alert type is appropriate for the selected platform and provide more detailed success messages.
async run({ $ }) { + const validTypes = this.platform === "twitch" + ? ["follow", "subscription", "donation", "host", "bits", "raid"] + : ["subscription", "sponsor", "superchat", "donation"]; + + if (!validTypes.includes(this.type)) { + throw new Error(`Invalid alert type "${this.type}" for platform "${this.platform}"`); + } + const response = await this.streamlabs.sendTestAlert({ $, data: { platform: this.platform, type: this.type, }, }); - $.export("$summary", "Successfully sent test alert"); + $.export("$summary", `Successfully sent ${this.type} test alert on ${this.platform}`); return response; }components/streamlabs/actions/create-donation/create-donation.mjs (1)
45-54: Convert skipAlert to boolean typeThe skipAlert parameter should be a boolean type instead of a string with yes/no options.
skipAlert: { - type: "string", + type: "boolean", label: "Skip Alert", description: "Set to `yes` if you need to skip the alert. Default is `no`", - options: [ - "yes", - "no", - ], optional: true, + default: false, },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (6)
components/streamlabs/actions/create-donation/create-donation.mjs(1 hunks)components/streamlabs/actions/send-alert/send-alert.mjs(1 hunks)components/streamlabs/actions/send-test-alert/send-test-alert.mjs(1 hunks)components/streamlabs/common/currencies.mjs(1 hunks)components/streamlabs/package.json(1 hunks)components/streamlabs/streamlabs.app.mjs(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- components/streamlabs/package.json
- components/streamlabs/common/currencies.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Publish TypeScript components
- GitHub Check: pnpm publish
- GitHub Check: Verify TypeScript components
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
components/streamlabs/streamlabs.app.mjs (3)
8-13: Add error handling for OAuth token access.The
_accessTokenmethod should validate the token's presence to provide a better error message._accessToken() { + if (!this.$auth.oauth_access_token) { + throw new Error('OAuth access token not found. Please check your authentication configuration.'); + } return this.$auth.oauth_access_token; }
14-28: Add request validation and error handling.The
_makeRequestmethod should validate inputs and include error handling._makeRequest({ $ = this, path, data, ...otherOpts }) { + if (!path) { + throw new Error('Path parameter is required'); + } + try { return axios($, { ...otherOpts, url: `${this._baseUrl()}${path}`, data: { access_token: this._accessToken(), ...data, }, }); + } catch (error) { + throw new Error(`Request failed: ${error.message}`); + } }
43-49: Add error handling and request validation.The
sendTestAlertmethod should validate inputs and include error handling.async sendTestAlert(opts = {}) { + if (!opts.type) { + throw new Error('Alert type is required'); + } + try { return this._makeRequest({ method: "POST", path: "/alerts/send_test_alert", ...opts, }); + } catch (err) { + throw new Error(`Failed to send test alert: ${err.message}`); + } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
components/streamlabs/streamlabs.app.mjs(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Verify TypeScript components
- GitHub Check: pnpm publish
- GitHub Check: Publish TypeScript components
🔇 Additional comments (2)
components/streamlabs/streamlabs.app.mjs (2)
1-7: LGTM!The import and module structure follows Pipedream's standard component pattern.
29-42: Add error handling to API methods.The public methods should include error handling to provide meaningful error messages.
async sendAlert(opts = {}) { + try { return this._makeRequest({ method: "POST", path: "/alerts", ...opts, }); + } catch (err) { + throw new Error(`Failed to send alert: ${err.message}`); + } } async createDonation(opts = {}) { + try { return this._makeRequest({ method: "POST", path: "/donations", ...opts, }); + } catch (err) { + throw new Error(`Failed to create donation: ${err.message}`); + } }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @michelle0927, LGTM! Ready for QA!
Resolves #15136.
Summary by CodeRabbit