✨amp-experiment 1.0: Allow an #amp-x_disable_all_experiments_ to disable all experiments#22419
Conversation
Need to test both the disable all works, and the variant gives an object where all values are null
|
@zhouyx This is good to go / ready for review! 😄 |
zhouyx
left a comment
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
question: Can we resolve with Promise.resolve({}) instead. What is the difference between {} and this.getEmptyExperimentToVariant_(config)?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
- 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.
- 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"?
There was a problem hiding this comment.
- 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. 😄
- 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, |
There was a problem hiding this comment.
nit: Do we really need to pass viewer to the function? We could easily get the service from ampdoc.
There was a problem hiding this comment.
So I decided to pass it in, for two reasons:
-
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. -
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 😄
|
@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 "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 |
|
@zhouyx Replied to all comments 😂 Totally open to making changes if you have strong feelings about something, Let me know what you think! |
I agree that's a concern. The only thing I don't like about Actually I was going to ask a different question : ) Wanted to ask what if we have |
|
Sorry, didnt see it just in time but another naming option we can consider is |
I think we should disable all still. Since
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! |
|
Talked to @jeffjose about using the |
|
And not blocking this PR.
Looking at the doc https://github.com/ampproject/amphtml/blob/master/extensions/amp-experiment/amp-experiment.md#style-a-variant, I don't think I still think it makes sense to support some thing like |
🎉 🎉 🎉
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 😄 👍 🎉 |

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 anexperimentToVariantwith null values to ensure the analytics sets the experiment to none.Examples