fixed bug with telemetry config loader
All checks were successful
armco-org/analytics/pipeline/head This commit looks good
All checks were successful
armco-org/analytics/pipeline/head This commit looks good
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@armco/analytics",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.1",
|
||||
"description": "Universal Analytics Library for Browser and Node.js",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
||||
@@ -17,9 +17,11 @@ import type {
|
||||
/**
|
||||
* Configuration schema
|
||||
*/
|
||||
const endpointConfigSchema = z.record(z.string(), z.string().url());
|
||||
|
||||
const configSchema = z.object({
|
||||
apiKey: z.string().optional(),
|
||||
endpoint: z.string().url().optional(),
|
||||
endpoint: z.union([z.string().url(), endpointConfigSchema]).optional(),
|
||||
hostProjectName: z.string().optional(),
|
||||
trackEvents: z.array(z.string()).optional(),
|
||||
submissionStrategy: z.enum(["ONEVENT", "DEFER"]).optional(),
|
||||
@@ -91,7 +93,7 @@ const errorEventSchema = z.object({
|
||||
*/
|
||||
export function validateConfig(config: unknown): AnalyticsConfig {
|
||||
try {
|
||||
return configSchema.parse(config);
|
||||
return configSchema.parse(config) as AnalyticsConfig;
|
||||
} catch (error) {
|
||||
if (error instanceof z.ZodError) {
|
||||
const messages = error.issues.map((err) => `${err.path.join(".")}: ${err.message}`);
|
||||
|
||||
Reference in New Issue
Block a user