Skip to content
Closed
Show file tree
Hide file tree
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
35 changes: 35 additions & 0 deletions test-server/npm/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/amplitude.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>NPM Analytics Browser Test</title>
</head>
<body>
<div id="app">
<h1>NPM Analytics Browser Test</h1>
<p>This page tests importing @amplitude/analytics-browser from npm.</p>
<button id="trackEvent">Track Test Event</button>
<div id="status" style="margin-top: 10px;"></div>
</div>
<script type="module">
import * as amplitude from './node_modules/@amplitude/analytics-browser/lib/esm/index.js';

window.amplitude = amplitude;

const status = document.getElementById('status');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Button has no click handler and status variable unused

The button with id trackEvent labeled "Track Test Event" has no click event listener attached, so clicking it won't explicitly track an event. Additionally, the status variable on line 21 is declared via document.getElementById('status') but never used in the script. Other similar test files like reset-test.html properly wire up click handlers and use status elements for feedback. This appears to be incomplete implementation that was committed.

Fix in Cursor Fix in Web


amplitude.init(
import.meta.env.VITE_AMPLITUDE_API_KEY,
import.meta.env.VITE_AMPLITUDE_USER_ID || 'npm-test-user',
{
autocapture: true,
}
);

amplitude.track('Testing Event');
</script>
</body>
</html>

143 changes: 143 additions & 0 deletions test-server/npm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions test-server/npm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "npm",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"@amplitude/analytics-browser": "^2.33.2-pnpm-migration.0"
}
}
2 changes: 1 addition & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function fileListingPlugin() {
const files = await glob('**/*.html', {
cwd: testServerDir,
absolute: false,
ignore: ['**/dist/**']
ignore: ['**/dist/**', '**/node_modules/**']
});

const fileList = files.map(file => ({
Expand Down
Loading