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

Sync proto with g3 to include url_from_markup AnalyticsContext field #3571

Merged
merged 9 commits into from
Sep 20, 2024
Prev Previous commit
Next Next commit
Update analytics-service to include urlFromMarkup
in tests to fix e2e testing error.
  • Loading branch information
caroljli committed Sep 20, 2024
commit 12318b4c111ac22bcc30f492b702dd69ae99307c
1 change: 1 addition & 0 deletions src/runtime/analytics-service-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ describes.realWin('AnalyticsService', (env) => {
expect(context.getReferringOrigin()).to.equal(
'https://scenic-2017.appspot.com'
);
expect(context.getUrlFromMarkup()).to.equal(URL);
expect(analyticsService.getSku()).to.equal('basic');
const labels = context.getLabelList();
expect(labels.length).to.equal(1);
Expand Down
31 changes: 16 additions & 15 deletions src/runtime/analytics-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import {ActivityIframePort, ActivityPorts} from '../components/activities';
import { ActivityIframePort, ActivityPorts } from '../components/activities';
import {
AnalyticsContext,
AnalyticsEvent,
Expand All @@ -25,20 +25,20 @@ import {
FinishedLoggingResponse,
Timestamp,
} from '../proto/api_messages';
import {ClientEvent} from '../api/client-event-manager-api';
import {ClientEventManager} from './client-event-manager';
import {Deps} from './deps';
import {Doc} from '../model/doc';
import {INTERNAL_RUNTIME_VERSION} from '../constants';
import {createElement} from '../utils/dom';
import {feUrl} from './services';
import {getCanonicalUrl} from '../utils/url';
import {getOnExperiments} from './experiments';
import {getSwgTransactionId} from '../utils/string';
import {log} from '../utils/log';
import {parseQueryString, parseUrl} from '../utils/url';
import {setImportantStyles} from '../utils/style';
import {toDuration, toTimestamp} from '../utils/date-utils';
import { ClientEvent } from '../api/client-event-manager-api';
import { ClientEventManager } from './client-event-manager';
import { Deps } from './deps';
import { Doc } from '../model/doc';
import { INTERNAL_RUNTIME_VERSION } from '../constants';
import { createElement } from '../utils/dom';
import { feUrl } from './services';
import { getCanonicalUrl } from '../utils/url';
import { getOnExperiments } from './experiments';
import { getSwgTransactionId } from '../utils/string';
import { log } from '../utils/log';
import { parseQueryString, parseUrl } from '../utils/url';
import { setImportantStyles } from '../utils/style';
import { toDuration, toTimestamp } from '../utils/date-utils';

const iframeStyles = {
opacity: '0',
Expand Down Expand Up @@ -209,6 +209,7 @@ export class AnalyticsService {
context.setClientVersion(`SwG ${INTERNAL_RUNTIME_VERSION}`);
context.setUrl(getCanonicalUrl(this.doc_));
context.setIsLockedContent(this.deps_.pageConfig().isLocked());
context.setUrlFromMarkup(getCanonicalUrl(this.doc_));

const utmParams = parseQueryString(this.getQueryString_());
const campaign = utmParams['utm_campaign'];
Expand Down
2 changes: 1 addition & 1 deletion src/utils/url-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ describe('serializeProtoMessageForUrl', () => {
['Timestamp', 22222, 0],
['Duration', 100, 0],
false,
null,
'baseUrl',
];
const analyticsEventMetaArray = ['AnalyticsEventMeta', 1, true, null];
const eventParamsArray = [
Expand Down
Loading