@amplitude/gtm-snippet 2.26.2 → 2.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/e2e/gtm-snippet.spec.ts +62 -0
- package/lib/amplitude-wrapper.js +2 -2
- package/lib/scripts/analytics-browser-gtm-wrapper.min.js +1 -1
- package/lib/scripts/analytics-browser-gtm-wrapper.min.js.gz +0 -0
- package/lib/scripts/analytics-browser-gtm-wrapper.min.js.map +1 -1
- package/package.json +4 -4
- package/playwright.config.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.27.1](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/gtm-snippet@2.26.3...@amplitude/gtm-snippet@2.27.1) (2025-10-21)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @amplitude/gtm-snippet
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [2.27.0](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/gtm-snippet@2.26.2...@amplitude/gtm-snippet@2.27.0) (2025-10-17)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @amplitude/gtm-snippet
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [2.26.2](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/gtm-snippet@2.26.1...@amplitude/gtm-snippet@2.26.2) (2025-10-15)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @amplitude/gtm-snippet
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { test, expect, Page } from '@playwright/test';
|
|
2
|
+
|
|
3
|
+
test.describe('GTM Snippet Page', () => {
|
|
4
|
+
let requests: any[] = [];
|
|
5
|
+
|
|
6
|
+
test.beforeEach(async ({ page }) => {
|
|
7
|
+
requests = [];
|
|
8
|
+
// Intercept Amplitude API calls
|
|
9
|
+
await page.route('https://api2.amplitude.com/2/httpapi', async (route) => {
|
|
10
|
+
const request = route.request();
|
|
11
|
+
const postData = request.postData();
|
|
12
|
+
if (postData) {
|
|
13
|
+
const data = JSON.parse(postData);
|
|
14
|
+
requests.push(data);
|
|
15
|
+
}
|
|
16
|
+
await route.continue();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('should load GTM snippet page and track event', async ({ page }) => {
|
|
21
|
+
// Navigate to the GTM snippet page
|
|
22
|
+
const response = await page.goto('/gtm-snippet/gtm-snippet.html', {
|
|
23
|
+
waitUntil: 'networkidle',
|
|
24
|
+
timeout: 30000,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Check if the response was successful
|
|
28
|
+
expect(response?.status()).toBe(200);
|
|
29
|
+
|
|
30
|
+
// Wait for the Amplitude SDK to be available
|
|
31
|
+
await page.waitForFunction(() => {
|
|
32
|
+
return typeof (window as any).amplitude !== 'undefined';
|
|
33
|
+
}, { timeout: 10000 });
|
|
34
|
+
|
|
35
|
+
// Verify amplitude is defined
|
|
36
|
+
const amplitudeDefined = await page.evaluate(() => {
|
|
37
|
+
return typeof (window as any).amplitude !== 'undefined';
|
|
38
|
+
});
|
|
39
|
+
expect(amplitudeDefined).toBe(true);
|
|
40
|
+
|
|
41
|
+
// track an event
|
|
42
|
+
await page.evaluate(() => {
|
|
43
|
+
(window as any).amplitude.track('GTM Snippet Test');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Wait for network requests to complete
|
|
47
|
+
await page.waitForLoadState('networkidle');
|
|
48
|
+
await page.waitForTimeout(1000);
|
|
49
|
+
|
|
50
|
+
// Verify that at least one request was made
|
|
51
|
+
expect(requests.length).toBeGreaterThan(0);
|
|
52
|
+
|
|
53
|
+
// Verify the GTM Snippet Test event was tracked
|
|
54
|
+
const events = requests[0].events;
|
|
55
|
+
expect(events).toBeDefined();
|
|
56
|
+
expect(events.length).toBeGreaterThan(0);
|
|
57
|
+
const gtmSnippetEvent = events.find((event: any) => event.event_type === 'GTM Snippet Test');
|
|
58
|
+
expect(gtmSnippetEvent).toBeDefined();
|
|
59
|
+
expect(gtmSnippetEvent.event_type).toBe('GTM Snippet Test');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|