Skip to content

Commit 4ba7721

Browse files
authored
Merge pull request #2569 from surishubham/testmuCom
cookie, amplitude cross domain tracking - IN-11826
2 parents 6e87606 + d9f69fe commit 4ba7721

File tree

98 files changed

+453
-109
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+453
-109
lines changed

custom.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,75 @@
120120
})
121121
}
122122

123+
const getLoginUrlWithCookies = (baseUrl) => {
124+
const currentHost = window.location.hostname;
125+
const allowedDomains = ['testmuai.com', 'testmuaiinternal.com', 'testmuinternal.ai'];
126+
const isAllowedDomain = allowedDomains.some(domain =>
127+
currentHost === domain || currentHost.endsWith('.' + domain)
128+
);
129+
if (!isAllowedDomain) return baseUrl;
130+
131+
const allowedCookies = ['utm', 'utm_base', 'lt_gclid', 'gclid', 'initial_referrer', 'exit_popup_dismissed', 'google_button_clicked'];
132+
const cookies = document.cookie;
133+
if (!cookies || cookies.trim() === '') return baseUrl;
134+
135+
try {
136+
const cookieArray = cookies.split(';').map(c => c.trim()).filter(Boolean).map(c => {
137+
const [name, ...valueParts] = c.split('=');
138+
return { key: name.trim(), value: valueParts.join('=') };
139+
}).filter(c => allowedCookies.includes(c.key));
140+
141+
if (cookieArray.length === 0) return baseUrl;
142+
143+
const encodedCookies = btoa(JSON.stringify(cookieArray));
144+
try {
145+
const urlObj = new URL(baseUrl.startsWith('http') ? baseUrl : baseUrl, window.location.origin);
146+
try {
147+
const amplitudeInstance = window.amplitude?.getInstance?.() || window.amplitude;
148+
let deviceId = amplitudeInstance?.options?.deviceId || amplitudeInstance?.getDeviceId?.();
149+
if (!deviceId) { amplitudeInstance?.regenerateDeviceId?.(); deviceId = amplitudeInstance?.options?.deviceId; }
150+
if (deviceId) urlObj.searchParams.set('deviceId', deviceId);
151+
} catch (e) { /* ignore */ }
152+
urlObj.searchParams.set('cookies', encodedCookies);
153+
return baseUrl.startsWith('http') ? urlObj.toString() : urlObj.pathname + urlObj.search;
154+
} catch (error) {
155+
const urlWithoutCookies = baseUrl.replace(/[&?]cookies=[^&]*/g, '');
156+
const separator = urlWithoutCookies.includes('?') ? '&' : '?';
157+
return urlWithoutCookies + separator + 'cookies=' + encodedCookies;
158+
}
159+
} catch (error) {
160+
return baseUrl;
161+
}
162+
};
163+
123164
window.addEventListener('DOMContentLoaded', (event) => {
124165
getUsernameToken('dom');
166+
167+
// Attach CookieTrackingSignup handler to the navbar "Get Started" button
168+
const signBtn = document.getElementById('signbtn');
169+
if (signBtn) {
170+
signBtn.addEventListener('click', function (e) {
171+
if (typeof window.sendAnalytics === 'function') {
172+
window.sendAnalytics('signup_button_clicked', {
173+
'event': 'signup_button_clicked',
174+
'eventCategory': 'Click',
175+
'eventAction': 'header',
176+
'eventLabel': window.location.href,
177+
});
178+
}
179+
if (typeof window.logAmplitude === 'function') {
180+
window.logAmplitude("click CTA - web pages", { "cta_text": "Get Started Free", "cta_type": "page header", "page_category": "Website header" });
181+
}
182+
183+
// Append cookies to the URL before navigation
184+
const anchorElement = e.currentTarget;
185+
const currentHref = anchorElement?.href || 'https://stage-accounts.lambdatestinternal.com/register';
186+
const urlWithCookies = getLoginUrlWithCookies(currentHref);
187+
if (anchorElement) {
188+
anchorElement.href = urlWithCookies;
189+
}
190+
});
191+
}
125192
});
126193

127194
function selectText(htmlelement) {

docs/accelq-integration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ slug: accelq-integration/
1414
canonical: https://www.testmuai.com/support/docs/accelq-integration/
1515
---
1616
import BrandName, { BRAND_URL } from '@site/src/component/BrandName';
17+
import { CookieTrackingSignup } from '@site/src/component/CookieTracking';
1718

1819

1920
<script type="application/ld+json"
@@ -50,7 +51,7 @@ By integrating <BrandName /> with ACCELQ, you can perform web and mobile app aut
5051
## Prerequisites
5152
---
5253

53-
1. Make sure you have a <BrandName /> account. If you don't have an account yet, [sign up for free](https://accounts.lambdatest.com/register).
54+
1. Make sure you have a <BrandName /> account. If you don't have an account yet, <a href="https://accounts.lambdatest.com/register" onClick={CookieTrackingSignup}>sign up for free</a>.
5455

5556
2. To integrate <BrandName /> with ACCELQ, you will need a <BrandName /> username and access key.
5657

docs/airbrake-integration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ slug: airbrake-integration/
2323
canonical: https://www.testmuai.com/support/docs/airbrake-integration/
2424
---
2525
import BrandName, { BRAND_URL } from '@site/src/component/BrandName';
26+
import { CookieTrackingSignup } from '@site/src/component/CookieTracking';
2627

2728

2829
<script type="application/ld+json"
@@ -72,7 +73,7 @@ Airbrake is a software tool and service designed to assist developers in trackin
7273
## Integrating Airbrake With <BrandName />
7374
***
7475

75-
**Step 1:** Sign in to your <BrandName /> account. Don't have an account, [register for free](https://accounts.lambdatest.com/register).
76+
**Step 1:** Sign in to your <BrandName /> account. Don't have an account, <a href="https://accounts.lambdatest.com/register" onClick={CookieTrackingSignup}>register for free</a>.
7677

7778
**Step 2:** Select **Integrations** from the left sidebar and head to **Airbrake**.
7879

docs/algoshack-integration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ slug: algoqa-integration/
1414
canonical: https://www.testmuai.com/support/docs/algoqa-integration/
1515
---
1616
import BrandName, { BRAND_URL } from '@site/src/component/BrandName';
17+
import { CookieTrackingSignup } from '@site/src/component/CookieTracking';
1718

1819

1920
<script type="application/ld+json"
@@ -50,7 +51,7 @@ By integrating <BrandName /> with algoQA, you can perform automated browser test
5051
## Prerequisites
5152
---
5253

53-
1. Make sure you have a <BrandName /> account. If you don't have an account yet, [sign up for free](https://accounts.lambdatest.com/register).
54+
1. Make sure you have a <BrandName /> account. If you don't have an account yet, <a href="https://accounts.lambdatest.com/register" onClick={CookieTrackingSignup}>sign up for free</a>.
5455

5556
2. To run automated tests, you will need <BrandName /> Username and Access Key. You can get them from the <BrandName /> Automation Dashboard under **Access Key**.
5657

docs/analytics-create-dashboard.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ canonical: https://www.testmuai.com/support/docs/analytics-create-dashboard/
1313

1414

1515
import BrandName, { BRAND_URL } from '@site/src/component/BrandName';
16+
import CookieTrackingLogin, { CookieTrackingSignup } from '@site/src/component/CookieTracking'
1617

1718
<script type="application/ld+json"
1819
dangerouslySetInnerHTML={{ __html: JSON.stringify({
@@ -48,7 +49,7 @@ Add widgets of multiple products and various insights to your dashboard. You can
4849

4950
The following are requirements:
5051

51-
- Should be logged in to the [TestMu AI application](https://accounts.lambdatest.com/login) using your credentials. If account is not created, please create an new account [here](https://accounts.lambdatest.com/register).
52+
- Should be logged in to the <a href="https://accounts.lambdatest.com/login" onClick={CookieTrackingLogin}>TestMu AI application</a> using your credentials. If account is not created, please create an new account <a href="https://accounts.lambdatest.com/register" onClick={CookieTrackingSignup}>here</a>.
5253
- Have executed any tests on the TestMu AI Cloud Platform. _(Optional)_
5354

5455
### Step 1: Navigate to TestMu AI Insights

docs/analytics-dashboards-custom-widgets.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ canonical: https://www.testmuai.com/support/docs/dashboards-custom-widgets/
1919

2020
import NewTag from '../src/component/newTag';
2121
import BrandName, { BRAND_URL } from '@site/src/component/BrandName';
22+
import CookieTrackingLogin from '@site/src/component/CookieTracking';
2223

2324

2425
<script type="application/ld+json"
@@ -62,7 +63,7 @@ The following steps are common to all custom widget types. After completing thes
6263

6364
### Step 1: Navigate to Insights
6465

65-
1. Log in to your [LambdaTest account](https://accounts.lambdatest.com/login).
66+
1. Log in to your <a href="https://accounts.lambdatest.com/login" onClick={CookieTrackingLogin}>LambdaTest account</a>.
6667
2. Navigate to the **Insights** section from the left sidebar or visit [https://analytics.lambdatest.com/](https://analytics.lambdatest.com/).
6768
3. Click on the **Dashboards** tab.
6869

docs/analytics-modules-command-logs.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ canonical: https://www.testmuai.com/support/docs/analytics-modules-test-intellig
1313

1414
import NewTag from '../src/component/newTag';
1515
import BrandName, { BRAND_URL } from '@site/src/component/BrandName';
16+
import { CookieTrackingSignup } from '@site/src/component/CookieTracking';
1617

1718

1819

@@ -48,7 +49,7 @@ TestMu AI Analytics help you intelligently analyze your test execution steps on
4849

4950
### Prerequisites for using Command Logs Analytics
5051
The following are the steps to use Command Logs Analytics:
51-
1. You should have a <BrandName /> account. If you don't have one, you can sign up [here](https://accounts.lambdatest.com/register).
52+
1. You should have a <BrandName /> account. If you don't have one, you can sign up <a href="https://accounts.lambdatest.com/register" onClick={CookieTrackingSignup}>here</a>.
5253
2. You should have access to the `Test Intelligence` subscription plan. You can join the waitlist [here](https://www.lambdatest.com/test-intelligence).
5354
3. Go to `Analytics` from the left navigation menu and create a new Dashboard by clicking on the `Create New Dashboard` button.
5455
4. Select the `Create Custom Dashboard` option from the `Create New Dashboard` dropdown.

docs/analytics-modules-resource-utilization.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ slug: analytics-modules-resource-utilization/
1616
canonical: https://www.testmuai.com/support/docs/analytics-modules-resource-utilization/
1717
---
1818
import BrandName, { BRAND_URL } from '@site/src/component/BrandName';
19+
import CookieTrackingLogin from '@site/src/component/CookieTracking';
1920

2021

2122
<script type="application/ld+json"
@@ -124,7 +125,7 @@ Unlike the standard Concurrency Trends widgets, Custom Concurrency Trends allows
124125

125126
### How to Create a Dashboard with Custom Concurrency Trends
126127

127-
**Step 1:** Log in to your [LambdaTest account](https://accounts.lambdatest.com/login) and navigate to **Insights** from the left sidebar.
128+
**Step 1:** Log in to your <a href="https://accounts.lambdatest.com/login" onClick={CookieTrackingLogin}>LambdaTest account</a> and navigate to **Insights** from the left sidebar.
128129

129130
**Step 2:** Click on the **+ Create New** button and select **Pre-built Widgets**.
130131

docs/app-automation-on-emulators-simulators.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ canonical: https://www.testmuai.com/support/docs/app-automation-on-emulators-sim
1616
import CodeBlock from '@theme/CodeBlock';
1717
import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/component/keys";
1818
import BrandName, { BRAND_URL } from '@site/src/component/BrandName';
19+
import { CookieTrackingSignup } from '@site/src/component/CookieTracking';
1920

2021

2122
<script type="application/ld+json"
@@ -64,7 +65,7 @@ Currently, App Automation is available for Emulators and Simulators in the Beta
6465

6566
Bеforе you gеt startеd with App Automation on LambdaTеst, makе surе you havе thе following prеrеquisitеs in placе:
6667

67-
1. [Sign up for a LambdaTеst account](https://accounts.lambdatest.com/register) if you havеn't alrеady.
68+
1. <a href="https://accounts.lambdatest.com/register" onClick={CookieTrackingSignup}>Sign up for a LambdaTеst account</a> if you havеn't alrеady.
6869

6970
2. Install [Appium Java Client](https://github.com/appium/java-client).
7071

docs/appium-androidtv.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Tabs from '@theme/Tabs';
2424
import TabItem from '@theme/TabItem';
2525
import RealDeviceTag from '../src/component/realDevice';
2626
import BrandName, { BRAND_URL } from '@site/src/component/BrandName';
27+
import { CookieTrackingSignup } from '@site/src/component/CookieTracking';
2728

2829

2930
<script type="application/ld+json"
@@ -72,7 +73,7 @@ By the end of this topic, you will be able to:
7273

7374
Before you can start performing App automation testing with Appium, you would need to follow these steps:
7475

75-
- You have access to <BrandName /> username and accessKey. If you have not registered yet, you can do the same by visiting our [website](https://accounts.lambdatest.com/register). You will be able to access the credentials in the [<BrandName /> Profile](https://accounts.lambdatest.com/detail/profile)
76+
- You have access to <BrandName /> username and accessKey. If you have not registered yet, you can do the same by visiting our <a href="https://accounts.lambdatest.com/register" onClick={CookieTrackingSignup}>website</a>. You will be able to access the credentials in the [<BrandName /> Profile](https://accounts.lambdatest.com/detail/profile)
7677
- Install the latest Python build from the [official website](https://www.python.org/downloads/). We recommend using the latest version.
7778
- Make sure **pip** is installed in your system. You can install **pip** from [pip documentation](https://pip.pypa.io/en/stable/installation/).
7879

0 commit comments

Comments
 (0)