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

feat(integrations): feature for server side container url support ga4 #1814

Merged
merged 1 commit into from
Aug 1, 2024
Merged
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
16 changes: 12 additions & 4 deletions packages/analytics-js-integrations/src/integrations/GA4/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
import { Cookie } from '@rudderstack/analytics-js-common/v1.1/utils/storage/cookie';
import Logger from '../../utils/logger';
import { eventsConfig } from './config';
import { constructPayload, flattenJsonPayload, removeTrailingSlashes } from '../../utils/utils';
import {
constructPayload,
flattenJsonPayload,
isDefinedAndNotNull,
removeTrailingSlashes,
} from '../../utils/utils';
import {
shouldSendUserId,
prepareParamsAndEventName,
Expand Down Expand Up @@ -39,6 +44,7 @@
this.overrideClientAndSessionId = config.overrideClientAndSessionId || false;
this.sdkBaseUrl =
removeTrailingSlashes(config.sdkBaseUrl) || 'https://www.googletagmanager.com';
this.serverContainerUrl = config.serverContainerUrl || null;
this.isExtendedGa4_V2 = config.isExtendedGa4_V2 || false;
({
shouldApplyDeviceModeTransformation: this.shouldApplyDeviceModeTransformation,
Expand All @@ -57,6 +63,10 @@
window.gtag('js', new Date());
const gtagParameterObject = {};

if (isDefinedAndNotNull(this.serverContainerUrl)) {
gtagParameterObject.server_container_url = this.serverContainerUrl;

Check warning on line 67 in packages/analytics-js-integrations/src/integrations/GA4/browser.js

View check run for this annotation

Codecov / codecov/patch

packages/analytics-js-integrations/src/integrations/GA4/browser.js#L67

Added line #L67 was not covered by tests
}

if (this.capturePageView === 'rs') {
gtagParameterObject.send_page_view = false;
}
Expand All @@ -71,7 +81,7 @@
gtagParameterObject.cookie_prefix = 'rs';
gtagParameterObject.client_id = this.analytics.getAnonymousId();
gtagParameterObject.session_id = this.analytics.getSessionId();
} else if(!this.isExtendedGa4_V2){
} else if (!this.isExtendedGa4_V2) {
// Cookie migration logic
const clientCookie = this.cookie.get('rs_ga');
const defaultGA4Cookie = this.cookie.get('_ga');
Expand Down Expand Up @@ -271,5 +281,3 @@
};
}
}