Skip to content
This repository has been archived by the owner on Dec 12, 2018. It is now read-only.

Yt twitch integration fixes #64

Merged
merged 3 commits into from
Sep 1, 2018
Merged

Yt twitch integration fixes #64

merged 3 commits into from
Sep 1, 2018

Conversation

SergeyZhukovsky
Copy link
Contributor

No description provided.

// }
// }
// }
void getTwitchParts(const std::string& query, std::vector<std::map<std::string, std::string>>& parts) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I added params into OnXHRLoad so we could parse the query string using the chromium libs. Can we use that here? Seems safer to use the chromium parsing and decode

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

or add it to OnPostData if we're parsing from there?

Copy link
Contributor Author

@SergeyZhukovsky SergeyZhukovsky Aug 31, 2018

Choose a reason for hiding this comment

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

the post data is based64 value and it's not really a query, it's a json object like that [{"event":"experiment_branch","properties":{"platform":"mobile_web","language":"en-us","gitHash":"964ae46c471c406f935380d04b8d8013904d88de","location":"channel","time":1535684252.833,"experiment_id":"aa19fae8-0e00-4922-8f1f-6699cc654671","experiment_name":"mobile_web_singapore_first_byte","experiment_group":"control","app_version":"964ae46c471c406f935380d04b8d8013904d88de","browser":"Mozilla/5.0 (Linux; Android) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.91 Mobile Safari/537.36 Brave","device_id":"ZTjPk6OrfHoCSCzSOcJ5hWwZgwExewqn","domain":"m.twitch.tv","host":"https://m.twitch.tv","app_session_id":"sUlnF57mQVSgT7z2Ewid1tlnAkX8I9d5","url":"https://m.twitch.tv/sypherpk","viewport_height":604,"viewport_width":412,"device_orientation":"portrait"}}] and there are can be several events in one upload data

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, so you're splitting out the JSON chunks and then parsing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's just a one big chunk that's actually an array of objects, in most cases there is just one element in that array.

const uint64_t& current_time) = 0;
const std::string& first_party_url,
const std::string& referrer,
const VisitData& visit_data) = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

what goes in this VisitData that is different from the OnLoad call?

Copy link
Contributor

Choose a reason for hiding this comment

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

or is this because we're considering this an independent visit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep we consider it as independent visit

media_publisher_info->twitchEventInfo_.status_ = getTwitchStatus(oldInfo, twitchEventInfo);

ledger_->SetMediaPublisherInfo(realDuration, std::move(media_publisher_info), updated_visit_data,
std::bind(&onVisitSavedDummy, _1, _2));
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want to get notified if this doesn't save successfully?

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe a TODO for some error handling?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

probably it's just has to be removed, I'm going to remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

better to keep it probably as it goes the same way right now as other publishers, the same function call

ledger::Result result,
std::unique_ptr<ledger::MediaPublisherInfo> info) {
SaveMediaVisit(visit_data, duration);
callback(result, std::move(info));
Copy link
Contributor

Choose a reason for hiding this comment

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

SaveMediaVisit is async so shouldn't this run when it actually completes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the callback is a callback above that we want to remove onVisitSavedDummy

Copy link
Contributor

Choose a reason for hiding this comment

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

right, but either way don't we want to wait until SaveMediaVisit actually completes to run the callback? SaveMediaVisit might fail and even if it succeeds, it hasn't succeeded yet

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it's a general problem with saveVisit because it doesn't currently have any way to report success/failure so probably a separate issue we should file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't need to wait any result at all as we don't need to do anything there, we can just remove that callback call

Copy link
Contributor

Choose a reason for hiding this comment

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

can you put a TODO here and I'll create an issue to report success/failure from saveVisit?

Copy link
Contributor

Choose a reason for hiding this comment

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

#65

Copy link
Contributor

Choose a reason for hiding this comment

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

I strongly disagree about not having a callback at all. We need callbacks for async operations to report success/failure. We can't go back to the kind of code we had in browser-laptop that ignored errors

Copy link
Contributor

Choose a reason for hiding this comment

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

we don't need to fix the callback issue in this PR, but we should fix it

Copy link
Contributor

Choose a reason for hiding this comment

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

I captured in the ticket above

@@ -61,6 +64,10 @@ class LEDGER_EXPORT LedgerClient {
PublisherInfoCallback callback) = 0;
virtual void LoadPublisherInfo(PublisherInfoFilter filter,
PublisherInfoCallback callback) = 0;
virtual void LoadMediaPublisherInfo(const std::string& publisher_id,
Copy link
Contributor

@bridiver bridiver Aug 31, 2018

Choose a reason for hiding this comment

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

I thought we wanted to go the other direction we these and tell the client what to save? This seems to do the opposite of the changes we want to make for PublisherInfo. Shouldn't we just pass the serialized json here for load and save?

Copy link
Contributor

Choose a reason for hiding this comment

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

just like we do with state and previously did with publisher info before converting to sqlite

@SergeyZhukovsky SergeyZhukovsky merged commit cb51a35 into master Sep 1, 2018
@NejcZdovc NejcZdovc deleted the yt_twitch branch September 3, 2018 04:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants