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

bug 1567320: add support for funnel_experiment and funnel_variation a… #95

Merged
merged 11 commits into from Jan 10, 2020

Conversation

oremj
Copy link
Contributor

@oremj oremj commented Jul 19, 2019

…ttribution keys

Copy link
Contributor

@hoosteeno hoosteeno left a comment

Choose a reason for hiding this comment

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

r+wc

if len(unEscapedCode) > 200 {
logEntry.WithField("code_len", len(code)).Error("code longer than 200 characters")
return "", errors.New("code longer than 200 characters")
if len(unEscapedCode) > 400 {
Copy link
Contributor

Choose a reason for hiding this comment

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

We've talked about increasing this to e.g. 600 or 800 to make sure we can accommodate a long UA string if needed.

Copy link

Choose a reason for hiding this comment

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

Making a length increase should be fine long term as long as we keep in mind there are existing Firefox releases that reject attribution over 200 characters: https://hg.mozilla.org/releases/mozilla-release/file/2c8be14a89c92e56dbfc10ad32284e628a517a93/browser/components/attribution/AttributionCode.jsm#l24

Choose a reason for hiding this comment

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

I thought the size limitation had something to do with the stub installer.

Copy link

Choose a reason for hiding this comment

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

I have a patch that increases the length firefox accepts: https://phabricator.services.mozilla.com/D57906

Comment on lines 20 to 21
"funnel_experiment": true,
"funnel_variation": true,
Copy link

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.

We should aim for consistency here. funnel_ is not adding anything to these parameters. If Firefox expects experiment and variation, then we should plan on those being sent all the way from the start. Bedrock work hasn't begun, so we can get this in.

Choose a reason for hiding this comment

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

IIRC funnel_ was requested. On windows portions are stripped somewhere along the way to reduce data size I think, but they are not for osx (which doesn't work anyway, I noticed Mardak comment on some bug about using the quarantine data, that's what we tried).

Copy link

@Mardak Mardak Dec 17, 2019

Choose a reason for hiding this comment

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

Looks like this was the last comment in the firefox bug re: prefix or not:
https://bugzilla.mozilla.org/show_bug.cgi?id=1515172#c37

This seems to say the url may contain "utm_" and "funnel_" that then end up getting stripped before stored as attribution.

Looking at the AttributionCode.jsm logic, it does seem to support "utm_" and "funnel_" and no-prefix for url-based attribution for mac while on windows, it only wants the stripped versions, e.g., "source" "medium" as before and the new "experiment"

Choose a reason for hiding this comment

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

prefixed is supported of osx. non-prefixed is for windows. The stub installer is limited to 200 characters.

mozilla/bedrock#7474 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

prefixed is supported of osx. non-prefixed is for windows. The stub installer is limited to 200 characters.

Let's walk backwards:

  • does telemetry require any particular param format?
  • does the stub binary require any particular param format?
  • can we simplify to avoid different behavior per platform?

Since we're working on the stubattribution service here, presumably we can plan to support those requirements.

And since we're working on Bedrock in mozilla/bedrock#7474, we can plan to support them there, too.

mozilla/bedrock#7474 (comment)

Where, specifically, is the constraint? In https://bugzilla.mozilla.org/show_bug.cgi?id=1406005#c49, mhowell says the stub binary is limited to 1010. In this PR, we can see that it was limited to 200, and is now set to 400, and I'm requesting 600-800. Are there any other hard constraints to be aware of?

Choose a reason for hiding this comment

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

I've no opinions here, just attempting to relay what I can remember (hopefully relatively accurate) from when I looked at this last...

I didn't run into anything with specific limits/formats in the telemetry data.

To my knowledge the windows stub binary wouldn't require any specific format. The download service that builds the stub might, and IIRC that is a) where the prefix is stripped, b) has a hard coded list of what keys are allowed into the stub.

I'd verify in current code what the current limit is. Seems like 1000 as mentioned should be enough.

osx attributions (if a workaround is ever figured out) happen via the quarantine database, so the param keys are unchanged from whatever the referrer url was. That is why the service tries to support both with/without prefix.

Copy link

Choose a reason for hiding this comment

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

It looks like the time this logic here (stubattribution validator.go) is used, there's a combined attribution_code that is parsed and handles keys like "source" and pretty sure there's no knowledge of "utm" anywhere in this repository.

From my searching around, stripping of "utm_" happens on bedrock backend as part of the hmac signature generation process which currently accepts {utm_source, utm_medium, …} json and returns {attribution_code, attribution_sig} json where the "attribution_code" has the concatenated prefix-stripped keys.

https://github.com/mozilla/bedrock/blob/67a2debdfcbd4a72cc3b5b0998a136aea7964704/bedrock/firefox/views.py#L95-L96

So yes it looks like validator.go should use "experiment" and "variation" without "funnel_" just like it doesn't currently expect "utm_*". And these prefix-less attribution will work with existing windows firefox 71.

(And attribution doesn't work quite right on osx anyway, and doesn't get called from bedrock anyway, so we don't really need to worry about compatibility yet. https://bugzilla.mozilla.org/show_bug.cgi?id=1525076 )

Copy link
Contributor

@hoosteeno hoosteeno left a comment

Choose a reason for hiding this comment

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

I can't review for code quality but the implementation changes in the most recent 2 commits look good to me. r+

@@ -148,6 +148,8 @@ func pingdomHandler(w http.ResponseWriter, req *http.Request) {
attrQuery.Set("medium", "pingdom")
attrQuery.Set("campaign", "pingdom")
attrQuery.Set("content", "pingdom")
attrQuery.Set("funnel_experiment", "pingdom")
attrQuery.Set("funnel_variation", "pingdom")
Copy link

Choose a reason for hiding this comment

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

I'm not sure how this pingdom stuff works (or if it's used?), but I would guess the query params should be the funnel_-less versions.

"campaign": true,
"content": true,
"experiment": true,
"variation": true,
Copy link

Choose a reason for hiding this comment

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

Just noting, and we probably don't need to change anything here -- this allows experiment or variation to be set without the other, which could totally be valid, e.g., some experiment with no variation compared against a baseline no-experiment.

Choose a reason for hiding this comment

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

Oh, does this need "ua"? https://searchfox.org/mozilla-central/rev/a92ed79b0bc746159fc31af1586adbfa9e45e264/browser/components/attribution/AttributionCode.jsm#35

Probably could use a comment in the code for validAttributionKeys that it should match what is in firefox also.

"net/url"
"time"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

const maxUnescapedCodeLen = 600
Copy link

Choose a reason for hiding this comment

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

Also just noting and probably don't need to change anything here either -- Firefox does a length check against the escaped code length while the check here is against the unescaped length.

Choose a reason for hiding this comment

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

Copy link

@Mardak Mardak left a comment

Choose a reason for hiding this comment

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

Main potential concern is the pingdom using funnel_ prefix and rest should be fine.

Copy link

@mixedpuppy mixedpuppy left a comment

Choose a reason for hiding this comment

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

This all looks ok functionally, just my question about the set of required attributes should be answered prior to landing.

"net/url"
"time"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

const maxUnescapedCodeLen = 600

Choose a reason for hiding this comment

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

"variation": true,
}

var requiredAttributionKeys = []string{

Choose a reason for hiding this comment

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

I'm not familiar with the code here, so just going on what I see here, name indicates to me that all these must be present.

Do we really require all these to be present? At this point I don't remember what AMO passes in (or if that functionality still exists on AMO, or if this change would affect that). Perhaps @jvillalobos can answer the AMO part.

Copy link

Choose a reason for hiding this comment

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

For links going to AMO we require source and medium and, depending on the case, campaign or content.

Choose a reason for hiding this comment

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

Ok, if we do not always include campaign or content, then we probably shouldn't have a set of required attributes here.

Copy link
Contributor

@hoosteeno hoosteeno Jan 7, 2020

Choose a reason for hiding this comment

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

I don't have all the details about the decision to make attributes required, but I do suspect it relates in part to concerns about passing web history into client telemetry (which is a data classification concern). That is primarily an issue with the "source" param, hinted at in an origin bug for this feature. Since we only allow attribution for a subset of possible sources, we have to require source.

It's also true that without a source and some other value, attribution isn't particularly useful. Source is required; medium and campaign are very valuable; content is not always helpful, and often omitted.

On www, we fill up some empty params with default values to ensure they can pass this validation, which does not provide any information value over simply making them optional.

Choose a reason for hiding this comment

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

On www, we fill up some empty params with default values to ensure they can pass this validation, which does not provide any information value over simply making them optional.

Ahh, that might be reasonable then, but a code comment here explaining that would be helpful.

Copy link

@Mardak Mardak left a comment

Choose a reason for hiding this comment

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

Sorry for the late change, with Firefox 73 supporting ua going to release in about a month, we would like to get that change in to stubattribution sooner than later. https://hg.mozilla.org/mozilla-central/rev/325f8606c0c1

Hopefully this should be relatively straightforward with the existing refactoring done in this PR.

@oremj
Copy link
Contributor Author

oremj commented Jan 9, 2020

@Mardak I think I've addressed all your concerts, will you please you re-review?


if code == "" {
logEntry.Error("code is empty")
return "", errors.New("code is empty")
Copy link

Choose a reason for hiding this comment

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

When does this trigger? Or is the validCodes test with "" wrong? Should empty code result in the 3 "not set" and "other" source?

Copy link

Choose a reason for hiding this comment

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

Oh I see fixed in 5cfc62f

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This only triggers if attributioncode="" or no attribution code parameter is in the query string. In that case, it just redirects to a standard non-attributed installer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've also updated the tests.

@oremj oremj merged commit 2c30f89 into master Jan 10, 2020
@oremj oremj deleted the bug-1567320-additional-parameters branch January 10, 2020 23:02
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.

None yet

5 participants