Skip to content

[WIP] ♻️Moved Analytics Specific AMP URL Variables into Variable Service#19737

Closed
torch2424 wants to merge 16 commits intoampproject:masterfrom
torch2424:19598-move-vars-amp-analytics
Closed

[WIP] ♻️Moved Analytics Specific AMP URL Variables into Variable Service#19737
torch2424 wants to merge 16 commits intoampproject:masterfrom
torch2424:19598-move-vars-amp-analytics

Conversation

@torch2424
Copy link
Copy Markdown
Contributor

closes #19598

This moves variables we have confirmed to not be used outside of <amp-analytics>, into the VariableService of <amp-analytics>. This should reduce the runtime size, by allowing us to remove variables from url-replacement-impl into <amp-analytics>.

NOTE: We are still in the process of removing more variables. But this should allow us to move them a lot easier since all of the "heavy lifting" is already done here 😄

Manual Test / Everything still working

screen shot 2018-12-07 at 6 16 59 pm

@torch2424
Copy link
Copy Markdown
Contributor Author

Did some investigation on why the tests are failing, they seem to all pass on my machine, as long as I keep the window in focus. Will investigate more later, but this should still be good for review 😄

@zhouyx
Copy link
Copy Markdown
Contributor

zhouyx commented Dec 21, 2018

@torch2424 I do remember we agreed to change variable a document level service. But could you remind the reason why we are doing that 😂

And usually I wouldn't mind that much. But the refactoring and change to move variables both sounds risky to me. Could we break this very PR to two please : )Thank you

@torch2424
Copy link
Copy Markdown
Contributor Author

Discussed offline:

We can split this PR into:

  1. Moving the variables:
  2. Moving the variable service onto doc level

Also, as a reminder, we are moving the variable service to doc level for things like stateful variables that will be upcoming in things like amp-next-page (Scroll X, Scroll Y).

@torch2424 torch2424 changed the title ♻️Moved Analytics Specific AMP URL Variables into Variable Service [WIP] ♻️Moved Analytics Specific AMP URL Variables into Variable Service Dec 21, 2018
@torch2424 torch2424 removed the request for review from zhouyx December 21, 2018 19:20
@torch2424
Copy link
Copy Markdown
Contributor Author

Removing @zhouyx as a reviewer. Going to keep this open to use travis to help me debug tests. And then will close this and move into two seperate PRs

@torch2424
Copy link
Copy Markdown
Contributor Author

@zhouyx So I was fixing the tests for this PR, and realized something that I'd like your opinion on.

So in extensions/amp-a4a/0.1/a4a-variable-source.js, we have an allowed list for al of the URL replacements we support in A4A. But we moved some of these into AMP Analytics. Thus, the tests fail when we cannot initialize the variables when creating our A4A variable source.

Thus, in order to keep these variables only in AMP analytics, we must also remove them here. And, If we remove SCROLL_TOP and SCROLL_LEFT from the A4A Variable source, the tests pass:

screen shot 2018-12-26 at 11 19 37 am

I know we decided this would be okay for the AMP use case, but is this also okay for A4A? I'll go ahead and commit this change to the PR, and if the tests no pass, I'll go ahead and split the PR. Thanks! 😄

@zhouyx
Copy link
Copy Markdown
Contributor

zhouyx commented Dec 26, 2018

Great point! According to @jonkeller SCROLL_TOP and SCROLL_LEFT is only used with <amp-analytics> in A4A. So it should be fine to remove them from the A4A list.

I agree we need to be extra careful to not move non-whitelisted variables to the analytics variable list. Could you please add a comment there to the variable list that it will be available to all services who is using amp-analytics including A4A? Thank you!

Another thing that would be helpful is to document what variables are supported in A4A. And if so will the variable resolve to different value when compared to AMP doc. I couldn't find such documentation, if there's one please let me know. Thanks!

@torch2424
Copy link
Copy Markdown
Contributor Author

@zhouyx Awesome! Thanks for the feedback, yeah I can implement all of those changes.

And just as a personal note, The last failing test is the --single-pass --compiled integration test. Appears that it is not doing the replacements for scrollTop in the single pass case. Will be sure to reach out to @erwinmombay after the holidays.

@torch2424
Copy link
Copy Markdown
Contributor Author

If we come back to this, @calebcordry is super rad, and copy pasta's a lot of the code from here to move the service to the doc level in #22137 . Thank you!

This PR just needs to be updated to move the variables around now.

@nainar
Copy link
Copy Markdown
Contributor

nainar commented Jul 20, 2019

Closing this PR as inactive. Please reopen if that isn't the case (preferably as a new PR).

@nainar nainar closed this Jul 20, 2019
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.

Move not globally used variables from source to amp-analytics

4 participants