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

T244548 Set up preview counting for KaiOS app #286

Merged
merged 6 commits into from
Dec 9, 2020

Conversation

hueitan
Copy link
Member

@hueitan hueitan commented Nov 30, 2020

Phabricator Link: https://phabricator.wikimedia.org/T244548

Solution

Similar to useTracking code, reuse the sentEvent util for the data sending

Note

Schema url : https://meta.wikimedia.org/wiki/Schema:VirtualPageView

@hueitan hueitan marked this pull request as ready for review December 1, 2020 10:18
return
}

const logInukaPageView = () => {

Choose a reason for hiding this comment

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

We should probably update the name of this function :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes omg !!! Thanks @neilpquinn

@@ -3,7 +3,14 @@ import { useI18n } from 'hooks'
import { getArticle, getArticleMediaList, getSuggestedArticles } from 'api'
import { canonicalizeTitle } from 'utils'

let currentArticle
Copy link
Collaborator

Choose a reason for hiding this comment

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

Adding global state like that is not great. It took me a while to figure out the whole logic here. It's clever, and it works, but I would like us to explore more conventional (or "boring") options.

One such option is to give ArticlePreview the required info about the source on open

showArticlePreview({ title, lang, dir, <info about the current article> })

Copy link
Member Author

Choose a reason for hiding this comment

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

I start with the conventional options, but then it's really bad =( but anyway, let me try again with it.

Copy link
Member Author

Choose a reason for hiding this comment

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

indeed, yes, useArticleLinksNavigation has galleryItems that also come from the source, we can have everything as the source, so it can pass to showArticlePreview

return
}

if (page === undefined || source === undefined) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

When is this called without page or source?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just in case useArticle() is being called before the useArticle( x, y ), to make sure it returns empty {} instead of error.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this still needed?

@hueitan
Copy link
Member Author

hueitan commented Dec 8, 2020

Ready for review again @stephanebisson

Copy link
Collaborator

@stephanebisson stephanebisson left a comment

Choose a reason for hiding this comment

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

It's annoying to propagate a bunch of article info through many layers but it makes the code very simple and predictable.

Will test tomorrow.

return
}

if (page === undefined || source === undefined) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this still needed?

src/hooks/useArticleLinksNavigation.js Outdated Show resolved Hide resolved
useLayoutEffect(() => {
if (!page) {
return
}
Copy link
Member Author

Choose a reason for hiding this comment

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

so this is still needed here, the summary is a state and start with null until the api request is done

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why useLayoutEffect specifically instead of useEffect?

Layout effect is blocking and should only be used to prevent flickering on visual effects.

@hueitan
Copy link
Member Author

hueitan commented Dec 9, 2020

It's annoying to propagate a bunch of article info through many layers but it makes the code very simple and predictable.

Agree, I see the benefit of this solution now! it's easier to track and predict all the properties.

@stephanebisson stephanebisson merged commit e4aeefb into master Dec 9, 2020
@stephanebisson stephanebisson deleted the T244548-VirtualPageView-Tracking branch December 9, 2020 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants