Skip to content

Commit

Permalink
✨ Start logging AMP URL on SwG Pages (#26480)
Browse files Browse the repository at this point in the history
* simplify

* add test

* improve test
  • Loading branch information
mborof authored and Dima Voytenko committed Jan 24, 2020
1 parent 666ed40 commit 0432d1d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
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
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

0 comments on commit 0432d1d

Please sign in to comment.