@testrelic/playwright-analytics 2.3.18 → 2.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testrelic/playwright-analytics",
3
- "version": "2.3.18",
3
+ "version": "2.4.1",
4
4
  "description": "Playwright test analytics reporter with E2E navigation tracking, API call capture, network stats, failure diagnostics, and interactive HTML reports",
5
5
  "keywords": [
6
6
  "playwright",
@@ -74,6 +74,7 @@
74
74
  },
75
75
  "files": [
76
76
  "dist",
77
+ "scripts",
77
78
  "timeline-schema.json",
78
79
  "README.md"
79
80
  ],
@@ -81,7 +82,7 @@
81
82
  "@playwright/test": ">=1.35.0"
82
83
  },
83
84
  "dependencies": {
84
- "@testrelic/core": "2.3.18"
85
+ "@testrelic/core": "2.4.1"
85
86
  },
86
87
  "devDependencies": {
87
88
  "@playwright/test": "^1.35.0",
@@ -106,6 +107,7 @@
106
107
  },
107
108
  "scripts": {
108
109
  "build": "tsup",
110
+ "postinstall": "node scripts/postinstall.cjs",
109
111
  "test": "vitest run --exclude '**/e2e/**'",
110
112
  "test:watch": "vitest",
111
113
  "test:integration": "vitest run --config vitest.integration.config.ts",
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Postinstall script: scaffolds `.testrelic/testrelic-config.json` in the user's
3
+ * project root when `@testrelic/playwright-analytics` is installed as a dependency.
4
+ *
5
+ * Skips silently when:
6
+ * - Running inside a CI environment (CI=true)
7
+ * - INIT_CWD is not set (e.g. direct development install of the package itself)
8
+ * - The config file already exists (idempotent)
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ const { existsSync, mkdirSync, writeFileSync } = require('fs');
14
+ const { join } = require('path');
15
+
16
+ // npm sets INIT_CWD to the directory where `npm install` was run (the user's project root).
17
+ const projectRoot = process.env.INIT_CWD;
18
+
19
+ // Skip if not running as a dependency install (e.g. during the package's own development)
20
+ if (!projectRoot) process.exit(0);
21
+
22
+ // Skip in CI environments to avoid creating files unexpectedly in pipelines
23
+ if (process.env.CI === 'true' || process.env.CI === '1') process.exit(0);
24
+
25
+ // Skip if the install is happening inside node_modules itself (nested install scenario)
26
+ if (projectRoot.includes('node_modules')) process.exit(0);
27
+
28
+ const configDir = join(projectRoot, '.testrelic');
29
+ const configFile = join(configDir, 'testrelic-config.json');
30
+
31
+ // Idempotent: skip if config already exists
32
+ if (existsSync(configFile)) process.exit(0);
33
+
34
+ const template = {
35
+ cloud: {
36
+ apiKey: '$TESTRELIC_API_KEY',
37
+ endpoint: 'https://platform.testrelic.ai/api/v1',
38
+ upload: 'both',
39
+ },
40
+ 'testrelic-repo': {
41
+ name: 'my-project',
42
+ },
43
+ };
44
+
45
+ try {
46
+ mkdirSync(configDir, { recursive: true });
47
+ writeFileSync(configFile, JSON.stringify(template, null, 2) + '\n', 'utf-8');
48
+ process.stdout.write(
49
+ '[testrelic] Created .testrelic/testrelic-config.json — update "testrelic-repo.name" and set TESTRELIC_API_KEY.\n',
50
+ );
51
+ } catch (err) {
52
+ // Non-fatal: log but do not fail the install
53
+ process.stderr.write('[testrelic] Could not create .testrelic/testrelic-config.json: ' + err.message + '\n');
54
+ }