@alertsamurai/sdk-js 0.0.5 → 0.0.6
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/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -2
- package/dist/index.mjs +7 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -16,6 +16,8 @@ interface AlertSamuraiConfig {
|
|
|
16
16
|
* When false, warnings/errors are logged to console
|
|
17
17
|
*/
|
|
18
18
|
silent?: boolean;
|
|
19
|
+
/** Default environment name (e.g., "production", "staging") - used if not specified per-call */
|
|
20
|
+
environment?: string;
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
21
23
|
* Options for sending a metric
|
|
@@ -111,6 +113,7 @@ declare class AlertSamuraiClient {
|
|
|
111
113
|
private retries;
|
|
112
114
|
private enabled;
|
|
113
115
|
private silent;
|
|
116
|
+
private environment?;
|
|
114
117
|
constructor(config?: AlertSamuraiConfig | null);
|
|
115
118
|
/**
|
|
116
119
|
* Check if the client is enabled and configured properly
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ interface AlertSamuraiConfig {
|
|
|
16
16
|
* When false, warnings/errors are logged to console
|
|
17
17
|
*/
|
|
18
18
|
silent?: boolean;
|
|
19
|
+
/** Default environment name (e.g., "production", "staging") - used if not specified per-call */
|
|
20
|
+
environment?: string;
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
21
23
|
* Options for sending a metric
|
|
@@ -111,6 +113,7 @@ declare class AlertSamuraiClient {
|
|
|
111
113
|
private retries;
|
|
112
114
|
private enabled;
|
|
113
115
|
private silent;
|
|
116
|
+
private environment?;
|
|
114
117
|
constructor(config?: AlertSamuraiConfig | null);
|
|
115
118
|
/**
|
|
116
119
|
* Check if the client is enabled and configured properly
|
package/dist/index.js
CHANGED
|
@@ -108,6 +108,7 @@ var AlertSamuraiClient = class {
|
|
|
108
108
|
this.timeout = config.timeout || DEFAULT_TIMEOUT;
|
|
109
109
|
this.retries = config.retries ?? DEFAULT_RETRIES;
|
|
110
110
|
this.silent = config.silent ?? true;
|
|
111
|
+
this.environment = config.environment;
|
|
111
112
|
}
|
|
112
113
|
/**
|
|
113
114
|
* Check if the client is enabled and configured properly
|
|
@@ -142,7 +143,7 @@ var AlertSamuraiClient = class {
|
|
|
142
143
|
metricType: options.metricType,
|
|
143
144
|
value: options.value,
|
|
144
145
|
unit: options.unit,
|
|
145
|
-
environment: options.environment,
|
|
146
|
+
environment: options.environment ?? this.environment,
|
|
146
147
|
metadata: options.metadata,
|
|
147
148
|
timestamp: this.normalizeTimestamp(options.timestamp)
|
|
148
149
|
};
|
|
@@ -179,7 +180,11 @@ var AlertSamuraiClient = class {
|
|
|
179
180
|
}
|
|
180
181
|
try {
|
|
181
182
|
this.validateAlert(options);
|
|
182
|
-
|
|
183
|
+
const body = {
|
|
184
|
+
...options,
|
|
185
|
+
environment: options.environment ?? this.environment
|
|
186
|
+
};
|
|
187
|
+
return this.request("/api/alerts", body);
|
|
183
188
|
} catch (error) {
|
|
184
189
|
if (!this.silent) {
|
|
185
190
|
console.error("[AlertSamurai] sendAlert failed:", error);
|
package/dist/index.mjs
CHANGED
|
@@ -78,6 +78,7 @@ var AlertSamuraiClient = class {
|
|
|
78
78
|
this.timeout = config.timeout || DEFAULT_TIMEOUT;
|
|
79
79
|
this.retries = config.retries ?? DEFAULT_RETRIES;
|
|
80
80
|
this.silent = config.silent ?? true;
|
|
81
|
+
this.environment = config.environment;
|
|
81
82
|
}
|
|
82
83
|
/**
|
|
83
84
|
* Check if the client is enabled and configured properly
|
|
@@ -112,7 +113,7 @@ var AlertSamuraiClient = class {
|
|
|
112
113
|
metricType: options.metricType,
|
|
113
114
|
value: options.value,
|
|
114
115
|
unit: options.unit,
|
|
115
|
-
environment: options.environment,
|
|
116
|
+
environment: options.environment ?? this.environment,
|
|
116
117
|
metadata: options.metadata,
|
|
117
118
|
timestamp: this.normalizeTimestamp(options.timestamp)
|
|
118
119
|
};
|
|
@@ -149,7 +150,11 @@ var AlertSamuraiClient = class {
|
|
|
149
150
|
}
|
|
150
151
|
try {
|
|
151
152
|
this.validateAlert(options);
|
|
152
|
-
|
|
153
|
+
const body = {
|
|
154
|
+
...options,
|
|
155
|
+
environment: options.environment ?? this.environment
|
|
156
|
+
};
|
|
157
|
+
return this.request("/api/alerts", body);
|
|
153
158
|
} catch (error) {
|
|
154
159
|
if (!this.silent) {
|
|
155
160
|
console.error("[AlertSamurai] sendAlert failed:", error);
|