@lokalise/playwright-reporters 1.9.0 → 1.9.2

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.
@@ -10,8 +10,12 @@ export interface CIContext {
10
10
  commitSha?: string;
11
11
  /** Pull request number */
12
12
  prNumber?: string;
13
- /** CI job identifier */
13
+ /** CI job identifier (numeric ID) */
14
14
  ciJobId?: string;
15
+ /** CI job name (e.g., 'lokalise-main/PR-123') */
16
+ jobName?: string;
17
+ /** CI build number */
18
+ buildNumber?: string;
15
19
  /** What triggered the run (push, pr, schedule, manual) */
16
20
  triggeredBy?: string;
17
21
  }
@@ -28,6 +28,10 @@ class Datadog {
28
28
  this.apiKey = options.apiKey;
29
29
  this.site = options.site ?? 'datadoghq.eu';
30
30
  this.debug = options.debug ?? false;
31
+ // Always log configuration status (helps debug setup issues)
32
+ const apiKeyStatus = this.apiKey ? `set (${this.apiKey.slice(0, 4)}...${this.apiKey.slice(-4)})` : 'NOT SET';
33
+ // eslint-disable-next-line no-console
34
+ console.log(`[Datadog] Initialized - API Key: ${apiKeyStatus}, Site: ${this.site}, Debug: ${this.debug}`);
31
35
  }
32
36
  log(message, data) {
33
37
  if (this.debug) {
@@ -39,18 +43,24 @@ class Datadog {
39
43
  * Initialize the Playwright request context for API calls
40
44
  */
41
45
  async setNativeRequestContext() {
46
+ const endpoint = getApiEndpoint(this.site);
47
+ // eslint-disable-next-line no-console
48
+ console.log(`[Datadog] Creating request context for endpoint: ${endpoint}`);
42
49
  this.request = await test_1.request.newContext({
43
- baseURL: getApiEndpoint(this.site),
50
+ baseURL: endpoint,
44
51
  extraHTTPHeaders: {
45
52
  'DD-API-KEY': this.apiKey,
46
53
  'Content-Type': 'application/json',
47
54
  },
48
55
  });
56
+ // eslint-disable-next-line no-console
57
+ console.log('[Datadog] Request context created successfully');
49
58
  }
50
59
  /**
51
60
  * Submit metrics to Datadog Metrics API v2
52
61
  * @see https://docs.datadoghq.com/api/latest/metrics/#submit-metrics
53
62
  */
63
+ // eslint-disable-next-line max-statements
54
64
  async submitMetrics(payload) {
55
65
  try {
56
66
  if (!this.request) {
@@ -58,14 +68,19 @@ class Datadog {
58
68
  console.error('[Datadog] Request context not initialized. Call setNativeRequestContext first.');
59
69
  return false;
60
70
  }
61
- this.log('[Datadog] Submitting metrics:', payload);
71
+ // eslint-disable-next-line no-console
72
+ console.log(`[Datadog] Submitting ${payload.series.length} metric series to /api/v2/series`);
73
+ this.log('[Datadog] Full payload:', payload);
62
74
  const response = await this.request.post('/api/v2/series', { data: payload });
75
+ const responseText = await response.text();
63
76
  if (!response.ok()) {
64
77
  // eslint-disable-next-line no-console
65
- console.error(`[Datadog] Failed to submit metrics: ${response.status()} - ${await response.text()}`);
78
+ console.error(`[Datadog] Failed to submit metrics: ${response.status()} - ${responseText}`);
66
79
  return false;
67
80
  }
68
- this.log(`[Datadog] Successfully submitted ${payload.series.length} metric series`);
81
+ // eslint-disable-next-line no-console
82
+ console.log(`[Datadog] Successfully submitted ${payload.series.length} metric series (status: ${response.status()})`);
83
+ this.log('[Datadog] Response:', responseText);
69
84
  return true;
70
85
  }
71
86
  catch (error) {
@@ -172,4 +172,8 @@ export interface MetricTags {
172
172
  service?: string;
173
173
  /** Product identifier */
174
174
  product?: string;
175
+ /** CI job name (e.g., 'lokalise-main/PR-123') */
176
+ jobName?: string;
177
+ /** CI build number */
178
+ buildNumber?: string;
175
179
  }
@@ -236,6 +236,8 @@ class DatadogReporter {
236
236
  env: this.options.env,
237
237
  service: this.options.service ?? 'playwright-tests',
238
238
  product: this.options.product,
239
+ jobName: this.options.ci?.jobName,
240
+ buildNumber: this.options.ci?.buildNumber,
239
241
  };
240
242
  // Build metrics payload
241
243
  const payload = (0, transform_1.buildMetricsPayload)(runMetrics, this.testMetrics, baseTags);
@@ -33,6 +33,12 @@ const formatTags = (tags) => {
33
33
  if (tags.product) {
34
34
  formattedTags.push(`product:${tags.product}`);
35
35
  }
36
+ if (tags.jobName) {
37
+ formattedTags.push(`job_name:${tags.jobName}`);
38
+ }
39
+ if (tags.buildNumber) {
40
+ formattedTags.push(`build_number:${tags.buildNumber}`);
41
+ }
36
42
  return formattedTags;
37
43
  };
38
44
  exports.formatTags = formatTags;
@@ -100,10 +106,8 @@ const transformTestRunMetrics = (runMetrics, baseTags) => {
100
106
  if (runMetrics.navigationMs > 0) {
101
107
  series.push(createDistribution('test_run.navigation_ms', runMetrics.navigationMs, timestamp, tags, 'millisecond'));
102
108
  }
103
- // Retry time
104
- if (runMetrics.retryTimeMs > 0) {
105
- series.push(createDistribution('test_run.retry_time_ms', runMetrics.retryTimeMs, timestamp, tags, 'millisecond'));
106
- }
109
+ // Retry time - always send for consistent dashboard visibility (0 means no retries)
110
+ series.push(createDistribution('test_run.retry_time_ms', runMetrics.retryTimeMs, timestamp, tags, 'millisecond'));
107
111
  // Worker count
108
112
  if (runMetrics.workerCount > 0) {
109
113
  series.push(createGauge('test_run.worker_count', runMetrics.workerCount, timestamp, tags));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lokalise/playwright-reporters",
3
- "version": "1.9.0",
3
+ "version": "1.9.2",
4
4
  "scripts": {
5
5
  "lint:eslint": "eslint --cache . --ext .js,.cjs,.ts",
6
6
  "lint:ts": "tsc --noEmit",
@@ -72,7 +72,7 @@
72
72
  "@semantic-release/npm": "13.1.3",
73
73
  "@semantic-release/release-notes-generator": "14.1.0",
74
74
  "@types/lodash": "^4.17.23",
75
- "@types/node": "^25.0.10",
75
+ "@types/node": "^25.1.0",
76
76
  "eslint-config-prettier": "^10.1.8",
77
77
  "eslint-plugin-prettier": "^5.5.5",
78
78
  "husky": "9.1.7",