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

✨ Start logging AMP URL on SwG Pages #26480

Merged
merged 3 commits into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export class GoogleSubscriptionsPlatform {
isFromUserAction: false,
additionalParameters: null,
});
this.runtime_.analytics().setUrl(ampdoc.getUrl());
resolver();

this.runtime_.setOnLoginRequest(request => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {SubscriptionsScoreFactor} from '../../../amp-subscriptions/0.1/score-fac
import {toggleExperiment} from '../../../../src/experiments';

const PLATFORM_ID = 'subscribe.google.com';
const AMP_URL = 'myAMPurl.amp';

describes.realWin('amp-subscriptions-google', {amp: true}, env => {
let ampdoc;
Expand All @@ -61,6 +62,7 @@ describes.realWin('amp-subscriptions-google', {amp: true}, env => {
element = env.win.document.createElement('script');
element.id = 'amp-subscriptions';
env.win.document.head.appendChild(element);
env.sandbox.stub(ampdoc, 'getUrl').callsFake(() => AMP_URL);
pageConfig = new PageConfig('example.org:basic', true);
xhr = Services.xhrFor(env.win);
viewer = Services.viewerForDoc(ampdoc);
Expand Down Expand Up @@ -138,6 +140,11 @@ describes.realWin('amp-subscriptions-google', {amp: true}, env => {
return stub.args[0][0];
}

it('should set the current URL in analytics', () => {
const swgAnalytics = platform.runtime_.analytics();
expect(swgAnalytics.getContext().getUrl()).to.equal(AMP_URL);
});

it('should reset runtime on platform reset', () => {
expect(methods.reset).to.not.be.called;
platform.reset();
Expand Down