Skip to content

Conversation

@STalukder20
Copy link
Contributor

@STalukder20 STalukder20 commented Nov 10, 2024

WHY

Resolves #14492

  • Added a new action for Spotify to get currently playing track for user.

Summary by CodeRabbit

  • New Features
    • Introduced a new action to retrieve the currently playing track on Spotify, enhancing user experience by providing real-time playback information.
  • Bug Fixes
    • Implemented error handling for API calls to ensure users receive clear feedback in case of issues.
  • Chores
    • Updated the version of the Spotify component and its dependencies to improve performance and compatibility.

@vercel
Copy link

vercel bot commented Nov 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Nov 11, 2024 4:30pm

@vercel
Copy link

vercel bot commented Nov 10, 2024

@STalukder20 is attempting to deploy a commit to the Pipedreamers Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 10, 2024

Walkthrough

A new module has been introduced to retrieve the currently playing track on a user's Spotify account. This module, named "Get currently playing track," includes essential properties such as description, key, version, and type. It utilizes Axios to make a request to the Spotify API, specifically targeting the endpoint for currently playing tracks. The implementation includes error handling and returns detailed information about the track, including its type, name, and playback status.

Changes

File Path Change Summary
components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs Introduced a new action to retrieve the currently playing track from Spotify, including its properties and error handling.
components/spotify/package.json Updated version from 0.7.0 to 0.7.1 and upgraded dependency on @pipedream/platform from ^1.4.0 to ^3.0.3. Added new dependency on lodash.

Assessment against linked issues

Objective Addressed Explanation
Get currently playing track functionality (#14492)

Suggested labels

action

Suggested reviewers

  • jcortes

🐰 In the land of Spotify, tracks play with glee,
A new action's here, come dance with me!
With Axios in hand, we fetch with delight,
Currently playing, oh what a sight!
So hop along now, let music unfold,
In the rhythm of code, new stories are told! 🎶


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fc2aee9 and 12a5a04.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • components/spotify/package.json (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/spotify/package.json

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dylburger dylburger added the User submitted Submitted by a user label Nov 10, 2024
@pipedream-component-development
Copy link
Collaborator

Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified.

@pipedream-component-development
Copy link
Collaborator

Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (3)
components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs (2)

5-10: Enhance the action description

While the description is clear, it could be more detailed to help users understand the action better. Consider adding information about:

  • The types of items that can be returned (tracks/episodes)
  • What happens when nothing is playing
  • The optional market parameter's purpose
-  description: "Get the object currently being played on the user's Spotify account.",
+  description: "Get the object (track or episode) currently being played on the user's Spotify account. Returns null if nothing is playing. Optionally specify a market to apply track relinking.",

1-39: Fix code formatting issues

The code has several formatting inconsistencies:

  • Inconsistent indentation
  • Mixed string quotes
  • Missing semicolon and final newline

Consider using a formatter like Prettier to automatically fix these issues.

🧰 Tools
🪛 eslint

[error] 12-12: Expected indentation of 4 spaces but found 6.

(indent)


[error] 13-13: Expected indentation of 4 spaces but found 6.

(indent)


[error] 14-14: Expected indentation of 6 spaces but found 8.

(indent)


[error] 15-15: Expected indentation of 8 spaces but found 10.

(indent)


[error] 16-16: Expected indentation of 8 spaces but found 10.

(indent)


[error] 17-17: Expected indentation of 6 spaces but found 8.

(indent)


[error] 18-18: Expected indentation of 6 spaces but found 8.

(indent)


[error] 19-19: Expected indentation of 4 spaces but found 6.

(indent)


[error] 22-22: Unexpected line break after this opening brace.

(object-curly-newline)


[error] 24-24: Unexpected line break before this closing brace.

(object-curly-newline)


[error] 26-26: Expected indentation of 4 spaces but found 6.

(indent)


[error] 28-28: Strings must use doublequote.

(quotes)


[error] 39-39: Newline required at end of file but not found.

(eol-last)


[error] 39-39: Missing semicolon.

(semi)

docs-v2/pages/components/index.mdx (1)

Line range hint 1-98: Consider adding Spotify-specific examples.

Since this PR introduces a new Spotify action, consider enhancing the documentation with Spotify-specific examples in the "Actions" section, similar to how Google Sheets is used as an example.

Example addition for the Actions section:

 **Example**
 
 The Add Single Row action for Google Sheets is a prebuilt component in Pipedream's registry that can be added to a workflow and configured in seconds. Users can configure it in seconds and send workflow data to Google Sheets without having to learn the Google Sheets API.
+
+Another example is the Get Currently Playing Track action for Spotify, which allows users to retrieve information about the track currently playing on their Spotify account. This action can be easily configured in a workflow to access real-time playback data without directly interacting with the Spotify API.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8c7e032 and 55b4435.

📒 Files selected for processing (2)
  • components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs (1 hunks)
  • docs-v2/pages/components/index.mdx (1 hunks)
🧰 Additional context used
🪛 eslint
components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs

[error] 12-12: Expected indentation of 4 spaces but found 6.

(indent)


[error] 13-13: Expected indentation of 4 spaces but found 6.

(indent)


[error] 14-14: Expected indentation of 6 spaces but found 8.

(indent)


[error] 15-15: Expected indentation of 8 spaces but found 10.

(indent)


[error] 16-16: Expected indentation of 8 spaces but found 10.

(indent)


[error] 17-17: Expected indentation of 6 spaces but found 8.

(indent)


[error] 18-18: Expected indentation of 6 spaces but found 8.

(indent)


[error] 19-19: Expected indentation of 4 spaces but found 6.

(indent)


[error] 22-22: Unexpected line break after this opening brace.

(object-curly-newline)


[error] 24-24: Unexpected line break before this closing brace.

(object-curly-newline)


[error] 26-26: Expected indentation of 4 spaces but found 6.

(indent)


[error] 28-28: Strings must use doublequote.

(quotes)


[error] 39-39: Newline required at end of file but not found.

(eol-last)


[error] 39-39: Missing semicolon.

(semi)

🔇 Additional comments (4)
components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs (2)

1-3: LGTM! Imports are well-organized

The necessary dependencies are properly imported using named imports, and constants are appropriately separated into a constants file.


26-33: Verify API implementation against Spotify documentation

The implementation needs verification against the Spotify Get Currently Playing Track API:

  1. Confirm the endpoint path is correct
  2. Verify all available query parameters are considered
  3. Check response structure matches API documentation
✅ Verification successful

The previous search might have failed due to specific path format. Let's try broader patterns to understand the Spotify API implementation context and verify the endpoint usage.


Let's examine the actual implementation files to verify the API endpoint usage and configuration.


We need to verify the ITEM_TYPES constants and any test files to fully validate the implementation against Spotify's API documentation.


Implementation matches Spotify API specifications

The implementation correctly follows the Spotify Get Currently Playing Track API specifications:

  1. The endpoint path /me/player/currently-playing is correct
  2. The implementation properly handles the optional market parameter
  3. The additional_types parameter correctly includes both "track" and "episode" types as per the API spec
  4. The constants are properly defined and used for type specifications
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other Spotify API endpoint implementations for consistency
rg -l "player/currently-playing" --type js

Length of output: 42


Script:

#!/bin/bash
# Search for Spotify API endpoint implementations with broader pattern and context
rg -A 5 "spotify.*player" --type js

# Look for any Spotify API related constants or configurations
rg -A 3 "SPOTIFY.*API|API.*SPOTIFY" --type js

# Search for files that might contain Spotify API related code
fd -e js -e mjs spotify

Length of output: 146


Script:

#!/bin/bash
# Let's examine the Spotify app file for API configurations and endpoints
cat components/spotify/spotify.app.mjs

# Also check the specific action file
cat components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs

Length of output: 14269


Script:

#!/bin/bash
# Let's check the constants file for ITEM_TYPES definition
cat components/spotify/consts.mjs

# Also search for any test files that might validate this endpoint
fd -e test.js -e test.mjs spotify

Length of output: 466

🧰 Tools
🪛 eslint

[error] 26-26: Expected indentation of 4 spaces but found 6.

(indent)


[error] 28-28: Strings must use doublequote.

(quotes)

docs-v2/pages/components/index.mdx (2)

97-98: LGTM! Path references are now more explicit.

The change from relative to absolute paths for quickstart guides improves clarity and maintainability.


Line range hint 1-98: Documentation structure aligns well with the new Spotify action.

The documentation provides comprehensive coverage of component types, development, and usage, which will help users understand how to work with the new Spotify "Get currently playing track" action. The sections on:

  • Component types (Sources vs Actions)
  • Using components
  • Managing privately published components
  • Sharing components

All provide relevant context for users implementing the new Spotify integration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (3)
components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs (3)

5-18: Consider updating the version number for initial release.

The configuration looks good, but since this is a new action ready for production, consider starting with version "1.0.0" instead of "0.0.1".

-  version: "0.0.1",
+  version: "1.0.0",
🧰 Tools
🪛 eslint

[error] 15-15: A linebreak is required after '['.

(array-bracket-newline)


[error] 15-15: There should be a linebreak after this element.

(array-element-newline)


[error] 15-15: A linebreak is required before ']'.

(array-bracket-newline)


35-37: Consider handling empty response more gracefully.

The current implementation uses fallback values for empty responses, but we should consider adding more context for better user experience.

-      const itemType = res?.currently_playing_type || 'track';
-      const itemName = res?.item?.name || 'Nothing';
-      $.export("$summary", `Currently playing ${itemType}: ${itemName}`);
+      if (!res) {
+        $.export("$summary", "No track currently playing");
+      } else {
+        const itemType = res.currently_playing_type || "track";
+        const itemName = res.item?.name || "Unknown";
+        $.export("$summary", `Currently playing ${itemType}: ${itemName}`);
+      }
🧰 Tools
🪛 eslint

[error] 35-35: Strings must use doublequote.

(quotes)


[error] 36-36: Strings must use doublequote.

(quotes)


39-45: Consider adding timestamp to the response.

The response structure is good, but adding a timestamp could be valuable for tracking when the track information was retrieved.

       return {
         playing: !!res,
         type: res?.currently_playing_type,
         item: res?.item,
         progress_ms: res?.progress_ms,
         is_playing: res?.is_playing,
+        timestamp: new Date().toISOString(),
       };
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 55b4435 and 7061384.

📒 Files selected for processing (1)
  • components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs (1 hunks)
🧰 Additional context used
🪛 eslint
components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs

[error] 15-15: A linebreak is required after '['.

(array-bracket-newline)


[error] 15-15: There should be a linebreak after this element.

(array-element-newline)


[error] 15-15: A linebreak is required before ']'.

(array-bracket-newline)


[error] 27-27: Strings must use doublequote.

(quotes)


[error] 30-30: A linebreak is required after '['.

(array-bracket-newline)


[error] 30-30: There should be a linebreak after this element.

(array-element-newline)


[error] 30-30: A linebreak is required before ']'.

(array-bracket-newline)


[error] 30-30: Strings must use doublequote.

(quotes)


[error] 32-33: Missing trailing comma.

(comma-dangle)


[error] 35-35: Strings must use doublequote.

(quotes)


[error] 36-36: Strings must use doublequote.

(quotes)


[error] 47-47: 'err' is not defined.

(no-undef)

🔇 Additional comments (2)
components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs (2)

1-3: LGTM! Imports are properly structured.

The imports follow best practices by using ES module syntax and importing specific dependencies from both the Pipedream platform and local modules.


28-31: Verify API endpoint parameters.

Let's verify that the endpoint parameters match the Spotify API documentation.

🧰 Tools
🪛 eslint

[error] 30-30: A linebreak is required after '['.

(array-bracket-newline)


[error] 30-30: There should be a linebreak after this element.

(array-element-newline)


[error] 30-30: A linebreak is required before ']'.

(array-bracket-newline)


[error] 30-30: Strings must use doublequote.

(quotes)

Copy link
Collaborator

@michelle0927 michelle0927 left a comment

Choose a reason for hiding this comment

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

Thanks so much for your contribution! Ready for QA!

@vunguyenhung
Copy link
Collaborator

Hi everyone, all test cases are passed! Ready for release!

Test report
https://vunguyenhung.notion.site/Action-Spotify-Get-currently-playing-track-13bbf548bb5e81399455edfacc3c30b8

@michelle0927 michelle0927 merged commit ebe92f3 into PipedreamHQ:master Nov 12, 2024
10 of 11 checks passed
lcaresia pushed a commit that referenced this pull request Dec 3, 2024
* Fix two broken links in docs

* Spotify action component to retrieve currently playing track for user.

* Set action version to 0.0.1

* Added support for action to retrive currently playing podcast episodes.

* Undo unrelated change.

* Added error handling, response is now structured, and formatting fixes.

* Set action version to 0.0.1

* Fixed typo

* package version, doc link, formatting

* pnpm-lock.yaml

* lodash dependency

* pnpm-lock.yaml

---------

Co-authored-by: michelle0927 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

User submitted Submitted by a user

Projects

Development

Successfully merging this pull request may close these issues.

[Spotify] Get currently playing track

5 participants