Skip to content

Conversation

iamdharmesh
Copy link
Collaborator

@iamdharmesh iamdharmesh commented Oct 9, 2025

PR adds REST endpoint for the create ad campaign.

Closes https://linear.app/a8c/issue/REDTWOO-70/implement-the-budget-form-rest-controller

Note

@iamdharmesh iamdharmesh self-assigned this Oct 10, 2025
@iamdharmesh iamdharmesh changed the title [WIP] REDTWOO-70: Implement Create Campaign REST Controller REDTWOO-70: Implement Create Campaign REST Controller Oct 13, 2025
@iamdharmesh iamdharmesh requested a review from joemcgill October 13, 2025 10:25
@iamdharmesh iamdharmesh marked this pull request as ready for review October 13, 2025 11:40
Copy link
Collaborator

@joemcgill joemcgill left a comment

Choose a reason for hiding this comment

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

Thanks @iamdharmesh, left a few questions and suggestions. Can you review?

*/
private function create_product_set() {
// Get the product set ID from the transients.
$product_set_id = Transients::get( TransientDefaults::PRODUCT_SET_ID );
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure Transients are the best storage for this data as transients can by definition get dropped from the system depending on how cache is set up on a store.

Is the intention to ensure that if a product set has already been created that we don't create a new one? If so, saving to an option might be a better choice. Hard to say without knowing more context.

This probably applies to the above method as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure Transients are the best storage for this data as transients can by definition get dropped from the system depending on how cache is set up on a store.

Agree on this. In happy path scenario this storage won't be used. This will be only used in case create Ad Group or Create Ad fails and user retry the create campaign again. So, the intention here to reuse the initially created product set ID incase the create Ad Group or Create Ad fails and merchant retry to create it in certain time frame.

Initially, I thought to go with options but it comes with headache to discard it and there is no harm in create one more product set in case transient get cleared before it get used. So, I went with transient here. However, I’m open to discussing or switching to options if you think it’s a more suitable storage method.

Copy link
Collaborator

Choose a reason for hiding this comment

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

As long as you've thought through this limitation and think that transients are the right storage mechanism, I think that's ok. One thing to think about is how this REST API endpoint might get used apart from the initial use case of setting up an account for the first time.

For example, what happens when someone starts onboarding and then decides to disconnect and start over with a different account? At minimum, these transients should likely be keyed to an ads account ID or similar and make sure that they get cleared whenever the account is disconnected to avoid edge case errors.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For example, what happens when someone starts onboarding and then decides to disconnect and start over with a different account? At minimum, these transients should likely be keyed to an ads account ID or similar and make sure that they get cleared whenever the account is disconnected to avoid edge case errors.

We are already clearing it when user disconnect or in case of successful campaign creation. But definitely agree on using ad account ID in key on top of that would be far better. Will update it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated in fd23b7d

@iamdharmesh iamdharmesh requested a review from joemcgill October 13, 2025 18:01
@Sidsector9
Copy link
Collaborator

@joemcgill @iamdharmesh don't merge this yet. I've gotten some more details and will add those changes here.

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