Skip to content

✨amp-experiment 1.0: Allow an #amp-x_disable_all_experiments_ to disable all experiments#22419

Merged
torch2424 merged 9 commits intoampproject:masterfrom
torch2424:disable-all-experiments
Jun 4, 2019
Merged

✨amp-experiment 1.0: Allow an #amp-x_disable_all_experiments_ to disable all experiments#22419
torch2424 merged 9 commits intoampproject:masterfrom
torch2424:disable-all-experiments

Conversation

@torch2424
Copy link
Copy Markdown
Contributor

@torch2424 torch2424 commented May 21, 2019

relates to #20225
relates to #21705

This allows adding a #amp-x_disable_all_experiments_ to disable all of the experiments that would be run normally by amp-experiment. Part of this, is ensuring the variants service returns an experimentToVariant with null values to ensure the analytics sets the experiment to none.

Examples

Screen Shot 2019-05-20 at 6 16 15 PM

Screen Shot 2019-05-20 at 6 16 01 PM

Screen Shot 2019-05-20 at 6 16 52 PM

@torch2424 torch2424 requested a review from zhouyx May 21, 2019 21:54
@torch2424
Copy link
Copy Markdown
Contributor Author

@zhouyx This is good to go / ready for review! 😄

Copy link
Copy Markdown
Contributor

@zhouyx zhouyx left a comment

Choose a reason for hiding this comment

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

The change looks good. Two question, 1. Should the #amp-x_disable_all_experiments_ works along with amp-x-experiment=name?
2. would #amp-x-disable-all-experiments be a better name than #amp-x_disable_al_experiments_?
Thanks


// Ensure downstream consumers don't wait for the promise forever.
variantsService.init(
Promise.resolve(this.getEmptyExperimentToVariant_(config))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

question: Can we resolve with Promise.resolve({}) instead. What is the difference between {} and this.getEmptyExperimentToVariant_(config)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So the reason why I changed this to this.getEmptyExperimentToVariant_(config), is because doing Promise.resolve({}) ends up throwing an error when trying to send out analytics ping.

Thus, I figured people would want to test that the ping is being sent out even when experiments are disabled. And since they are being disabled with this.getEmptyExperimentToVariant_(config), it sets the param to equal none. Meaning the experiment was not applied 😄

Let me know if this makes sense. I personally think that getting a ping that essentially says "all experiments are not being applied" is better than just throwing an error from the analytics side of things.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let me know if this makes sense. I personally think that getting a ping that essentially says "all experiments are not being applied" is better than just throwing an error from the analytics side of things.

Oh definitely! A few thoughts:

  1. Do you think it's worth it to cache the emptyExperimentToVariant object so that we don't need to create it every time? Really depends on how many times do you expect the function to be called.
  2. In the case where 'amp-experiment-1.0' is not enabled. Do we expect that as user error? If so on the analytics side should we throw error or still send ping says "all experiments are not being applied"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@zhouyx

  1. Do you think it's worth it to cache the emptyExperimentToVariant object so that we don't need to create it every time? Really depends on how many times do you expect the function to be called.

Nope, because it is and always should only be called once. 😄

  1. In the case where 'amp-experiment-1.0' is not enabled. Do we expect that as user error? If so on the analytics side should we throw error or still send ping says "all experiments are not being applied"?

Ummmm I think we should still only throw an error on the experiment side. As this is an amp-experiment error, and not an amp-analytics error. And a ping saying all experiments are not being applied is not wrong. 😄

return allocateVariant(
this.getAmpDoc(),
ampdoc,
viewer,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Do we really need to pass viewer to the function? We could easily get the service from ampdoc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So I decided to pass it in, for two reasons:

  1. We need access to viewer anyways now to check for _disable_all_experiments_ on the URL. And I thought it would be better practice to pass it in to remove dependencies from our help 'variants.ts' file.

  2. We want to be sensitive about performance. Trying to re-grab the viewer every single time would be slower than just passing it in.

Totally open to doing it inside of allocateVariant though. It is up to you 😄 But personally, I think this is the way to go for now unless you have strong feelings about it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't have a strong feeling about this. So feel free to merge.
But I'd be curious to know the performance difference between passing the viewer versus getting the viewer from ampdoc.
Personally I imagine Services.viewerForDoc(ampdoc) is very cheap as it's only reading some stored value from doc.

@choumx Could you shed us some light on the performance difference between the two. 1. passing as an argument, 2. retrieving using ampdoc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@zhouyx

Asked @kristoferbaxter on this since they are also with me in Berlin 😄

But they stated performance wise the change would be negligible, but mentioned they would personally hoist it out of the loop haha 😂

I think we all don't have strong feelings on this, so, I'll go ahead and merge, and we can resolve if needed back in California 😄

<script async custom-element="amp-user-notification" src="https://cdn.ampproject.org/v0/amp-user-notification-0.1.js"></script>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<style amp-custom>
amp-user-notification {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the change for?

Copy link
Copy Markdown
Contributor Author

@torch2424 torch2424 May 31, 2019

Choose a reason for hiding this comment

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

This is for the manual testing example, to add a background to the "allow background color" setting for the experiment. It was just hard to see without any styling so I added that 😄

@torch2424
Copy link
Copy Markdown
Contributor Author

@zhouyx To reply to your last two questions:

"1. Should the #amp-x_disable_all_experiments_ works along with amp-x-experiment=name?"

So this is something @jeffjose and I discussed. This will conflict with any experiment named _disable_all_experiments_. Which is why we surrounded it with _ and made it very verbose. After seeing the code in how hash params are ahndled, we can totally change this to something like: amp-experiment-disable-all-experiments=true, which won't have any conflicts. But I think it may make more sense to retain the amp-x- prefix as it stays consistent. Open to either one 😄

"2. would #amp-x-disable-all-experiments be a better name than #amp-x-disable_al_experiments?"

As stated above, using underscores to make it less likely to conflict 😄 If we decided to keep the amp-x- prefeix, I'd vote for keeping underscores unless you have strong feelings about this.

@torch2424
Copy link
Copy Markdown
Contributor Author

@zhouyx Replied to all comments 😂 Totally open to making changes if you have strong feelings about something, Let me know what you think!

@zhouyx
Copy link
Copy Markdown
Contributor

zhouyx commented Jun 1, 2019

"1. Should the #amp-x_disable_all_experiments_ works along with amp-x-experiment=name?"
So this is something @jeffjose and I discussed. This will conflict with any experiment named disable_all_experiments. Which is why we surrounded it with _ and made it very verbose. After seeing the code in how hash params are ahndled, we can totally change this to something like: amp-experiment-disable-all-experiments=true, which won't have any conflicts. But I think it may make more sense to retain the amp-x- prefix as it stays consistent. Open to either one 😄

I agree that's a concern. The only thing I don't like about #amp-x_disable_all_experiments_ is that it combines hyphen and underscore and I assume it's very easy to type it wrong 😢 . But I agree it makes more sense to retain the amp-x- prefix. I don't have a strong opinion on the naming : ) I'll let you decide.

Actually I was going to ask a different question : ) Wanted to ask what if we have #amp-x_disable_all_experiments&amp-x-experiment=name, should we respect both? Or amp-x_disable_all_experiment_ can override the other value.

@jeffjose
Copy link
Copy Markdown
Contributor

jeffjose commented Jun 1, 2019

Sorry, didnt see it just in time but another naming option we can consider is i-amp-experiment-disable. We already use i-amphtml-* in CSS classes, and i- is meant to be internal.

@torch2424
Copy link
Copy Markdown
Contributor Author

@zhouyx

Wanted to ask what if we have #amp-x_disable_all_experiments&amp-x-experiment=name, should we respect both? Or amp-x_disable_all_experiment_ can override the other value.

I think we should disable all still. Since amp-x-experiment= means, hey, "disable all experiments except this one". And "amp-x_disable_all_experiments" means disable all the experiments. I think logically it would make more sense to respect the "more powerful param" for a lack of better words 😂

I agree that's a concern. The only thing I don't like about #amp-x_disable_all_experiments_ is that it combines hyphen and underscore and I assume it's very easy to type it wrong 😢 . But I agree it makes more sense to retain the amp-x- prefix. I don't have a strong opinion on the naming : ) I'll let you decide.

Yeah I agree with that 🤔 I'll go with @jeffjose solution as it avoid conflicts, and honestly should probably only be used by vendors. We can always change this before going to PROD with docs, since it would be a one line change.

On that note, will make these changes, and merge 😄 Thank you everyone!

@torch2424
Copy link
Copy Markdown
Contributor Author

@jeffjose @zhouyx

One last note, couldn't rename to i-:

Screen Shot 2019-06-03 at 6 09 11 PM

And so I just renamed to amp-x-disable-all-experiments. And like I said above, we can bikeshed the name later once I get back to California 😄

@zhouyx
Copy link
Copy Markdown
Contributor

zhouyx commented Jun 3, 2019

Talked to @jeffjose about using the i-amphtml-*. i-* is supposed for internal use only, we need to avoid using that prefix as a user opt-in flag. amp-x-disable-all-experiments sounds good.

@zhouyx
Copy link
Copy Markdown
Contributor

zhouyx commented Jun 3, 2019

And not blocking this PR.

I think we should disable all still. Since amp-x-experiment= means, hey, "disable all experiments except this one". And "amp-x_disable_all_experiments" means disable all the experiments. I think logically it would make more sense to respect the "more powerful param" for a lack of better words 😂

Looking at the doc https://github.com/ampproject/amphtml/blob/master/extensions/amp-experiment/amp-experiment.md#style-a-variant, I don't think amp-x- is used to disable other experiments, but to specify variant. Please correct me if that's not the case.

I still think it makes sense to support some thing like #amp-x-disable-all&amp-x-Aexperiment='treatment1' in the future. So one could disable all experiment except experimentA. What do you think?

@torch2424
Copy link
Copy Markdown
Contributor Author

@zhouyx

Talked to @jeffjose about using the i-amphtml-. i- is supposed for internal use only, we need to avoid using that prefix as a user opt-in flag. amp-x-disable-all-experiments sounds good.

🎉 🎉 🎉

I still think it makes sense to support some thing like #amp-x-disable-all&amp-x-Aexperiment='treatment1' in the future. So one could disable all experiment except experimentA. What do you think?

Ah, well you make a good point. Especially with the docs. I don't mind implementing this in the future 😄

I went ahead and added this to the tracking issue: #21705

Going to merge this PR! Thanks for looking into this 😄 👍 🎉

@torch2424 torch2424 merged commit c23c179 into ampproject:master Jun 4, 2019
@torch2424 torch2424 deleted the disable-all-experiments branch June 4, 2019 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants