Page MenuHomePhabricator

It should be possible to target surveys at users with a specific user agent
Closed, ResolvedPublic3 Estimated Story Points

Description

Chatted to Olga today about targetting KaiOS users and suggesting to them that they try the app.

I suggested that it might be possible to use QuickSurveys to run an external survey where the link is
the app download.

We should first verify that KaiOS can run quicksurveys using https://en.m.wikipedia.beta.wmflabs.org/wiki/Spain?quicksurvey=true

If it does, we could run an external survey where the link is to the KaiOS app download, however we'd need to update QuickSurveys to allow targeting to certain user agents, likely by providing a configurable regular expression.

I think such a feature could have other applications so the feature would be useful beyond this particular use case.

Acceptance criteria

  • The SurveyAudience class will need to be extended to include a user agent field. I suggest this is a regular expression. This will add it to the page, readable by JS.
  • The isInAudience method in ext.quicksurveys.libs/libs.js should check the field and match against user agent.
  • Add a test to tests/qunit/ext.quicksurveys.lib

QA instructions

  • Set up QuickSurveys locally.
  • Because this feature relies on config, add the following (with variations - test with 'Safari', and/or 'Firefox', etc) to local settings:
audience": {
      'userAgent' => [ 'Chrome' ]
}
  • Test seeing/not-seeing surveys in different browsers based on config.

QA Results - Beta (Local)

ACStatusDetails
1T268782#7320604

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

We should first verify that KaiOS can run quicksurveys using https://en.m.wikipedia.beta.wmflabs.org/wiki/Spain?quicksurvey=true

It works on both my Jio2 and Nokia 8110 4G devices.

[...] where the link is to the KaiOS app download

The app is available in the JioStore for the indian market and will be in the KaiStore for the rest of the world in two weeks (fingers crossed) or so. We can link to the app in the KaiStore but not in the JioStore so we may need to be more granular with the UA regexp to target only those devices using the KaiStore.

AMuigai moved this task from Bugs to Watching on the Inuka-Team board.

Note there is a large performance penalty when running a QuickSurvey: T159738
The request here however is pretty straightforward. Having added acceptance criteria.

Would it be possible to run a quick survey in only a specific country or
set of countries?

Estimate it for adding this capability.

@ovasileva @AMuigai If we plan to run the QuickSurvey for longer than several weeks, T159738 should be considered a blocker for running the survey as it would add a performance penalty for all mobile users, not just KaiOS users.

Change 701136 had a related patch set uploaded (by Clare Ming; author: Clare Ming):

[mediawiki/extensions/QuickSurveys@master] Add functionality to target audience with specific user agent

https://gerrit.wikimedia.org/r/701136

cjming assigned this task to phuedx.
cjming added a subscriber: cjming.
cjming assigned this task to phuedx.
cjming assigned this task to phuedx.

hi @phuedx - after the last round of code review, I uncovered a bug with the simple regex which left me wondering if it makes sense to incorporate a proper UA parser library like https://github.com/faisalman/ua-parser-js.

It might be overkill for the current request, but it could help in the future for more granular targeting?

If the regex is a problem, perhaps we should use an enumerated type that maps to regexs. For this particular task we need the ability to target KaiOS so I'd assume to start with good configurations would be firefox, chrome, safari, kaios . This would also put less burden on the person setting up the survey. What do you think?

If the regex is a problem, perhaps we should use an enumerated type that maps to regexs. For this particular task we need the ability to target KaiOS so I'd assume to start with good configurations would be firefox, chrome, safari, kaios . This would also put less burden on the person setting up the survey. What do you think?

thanks @Jdlrobson -- I do have a regex tester function set up for the basics (kaios, chrome, edge, safari, firefox, etc) in the patch which seems to work according to my non-exhaustive testing. I am likely making this more complicated by throwing out the question of using an external library. I think for now, the simple regex map will do the trick. In the future however, if more granular targeting for surveys is desired, we probably should consider using a proper parser lib.

I think for now, the simple regex map will do the trick. In the future however, if more granular targeting for surveys is desired, we probably should consider using a proper parser lib.

Agreed. I recommend creating a task to capture this work so that it can be discussed, prioritised, and worked on whenever it is needed.

Change 701136 merged by jenkins-bot:

[mediawiki/extensions/QuickSurveys@master] Add functionality to target audience with specific user agent

https://gerrit.wikimedia.org/r/701136

Edtadros added a subscriber: Edtadros.

Test Result - Beta

Status: ✅ PASS
Environment: Local
OS: macOS Big Sur
Browser: Chrome
Device: MBP
Emulated Device: NA

Test Artifact(s):

QA Steps

Set up QuickSurveys locally.
Because this feature relies on config, add the following (with variations - test with 'Safari', and/or 'Firefox', etc) to local settings:
audience": {

'userAgent' => [ 'Chrome' ]

}

✅ AC1: Test seeing/not-seeing surveys in different browsers based on config.

Chrome

Screen Shot 2021-08-30 at 6.08.03 PM.png (1×2 px, 1 MB)

Safari
Screen Shot 2021-08-30 at 6.08.46 PM.png (1×2 px, 1 MB)

Firefox
Screen Shot 2021-08-30 at 6.11.31 PM.png (1×2 px, 1 MB)

Created placeholder task for running survey T290090: Run KaiOS quick survey. We can test in production during the survey. Resolving this one. Thanks all!