Skip to content

Conversation

@ssilare-adobe
Copy link
Contributor

SITES-36715

Add CPC Calculation Utility

Summary

Adds a new utility function to calculate Cost Per Click (CPC) values from Ahrefs organic traffic data stored in S3.

Changes

  • Added calculateCPCValue function in metrics-store.js

    • Fetches organic traffic data from S3 for a given site
    • Calculates CPC value based on cost and traffic metrics
    • Returns default value (1.5) when data is unavailable or invalid
    • Full error handling and validation
  • Added getObjectFromKey helper in s3.js

    • Generic utility to retrieve and parse objects from S3
    • Handles JSON parsing with fallback to raw content
    • Graceful error handling for missing objects
  • Added DEFAULT_CPC_VALUE constant (1.5)

  • Updated exports in index.js and index.d.ts

Please ensure your pull request adheres to the following guidelines:

  • make sure to link the related issues in this description
  • when merging / squashing, make sure the fixed issue references are visible in the commits, for easy compilation of release notes

Related Issues

Thanks for contributing!

@ssilare-adobe ssilare-adobe requested a review from a team October 28, 2025 04:17
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.

2 participants