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

[WIP] Twitter : adding ads_stream #21

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

[WIP] Twitter : adding ads_stream #21

wants to merge 2 commits into from

Conversation

c200bzh
Copy link

@c200bzh c200bzh commented Jan 27, 2025

Adding billing endpoint from x ads api that will get us the amount we spend on each promoted tweet
For now nothing is changed with the auth system.

@c200bzh c200bzh added the enhancement New feature or request label Jan 27, 2025
@c200bzh c200bzh requested a review from a team January 27, 2025 08:19
tweet = slice.get("parent", {})
yield {
"promoted_tweet_id": tweet.get("id"),
# "created_at": tweet.get("created_at")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is it commented out ?

"id": stream_slice.get("promoted_tweet_id"),
# "created_at": stream_slice.get("created_at"),
# "stats_date": record.get("date"),
"billed_engagements": record.get("billed_engagements", []),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I dont see any billed_engagments for the endpoint.
https://developer.x.com/en/docs/x-ads-api/analytics/api-reference/synchronous

Copy link
Author

Choose a reason for hiding this comment

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

The metrics from the BILLING endpoint are described here : https://docs.x.com/x-ads-api/analytics#available-metrics-by-metrics-group

Comment on lines 68 to 69
# "created_at": stream_slice.get("created_at"),
# "stats_date": record.get("date"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why commented out ?

# "created_at": stream_slice.get("created_at"),
# "stats_date": record.get("date"),
"billed_engagements": record.get("billed_engagements", []),
"billed_charge_local_micro": record.get("billed_charge_local_micro", []),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same

@@ -0,0 +1,25 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't the schema contains all those fields ? :

          "segment": null,
          "metrics": {
            "impressions": [
              1233
            ],
            "tweets_send": null,
            "qualified_impressions": null,
            "follows": null,
            "app_clicks": null,
            "retweets": null,
            "likes": [
              1
            ],
            "engagements": [
              58
            ],
            "clicks": [
              58
            ],
            "card_engagements": null,
            "poll_card_vote": null,
            "replies": null,
            "carousel_swipes": null
          }
    ```

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

also the date could be usefull

stream_state: Mapping[str, Any] = None,
**kwargs
) -> Iterable[Optional[Mapping[str, Any]]]:
# Reuse TweetPromoted's stream_slices to get promoted tweets
Copy link
Collaborator

Choose a reason for hiding this comment

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

If i remember correctly doing a substream of a substream didn't worked for me.
Also if we can get the list of promoted tweet through an endpoint that could be cleaner that the lets try all tweet of the last month and see if we get any result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants