Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choice field enums are not namespaced (for TypeScript at least) #93

Open
PeterJCLaw opened this issue Dec 11, 2024 · 1 comment
Open

Comments

@PeterJCLaw
Copy link

If a Tracking Plan features the same choice field in multiple events (or possibly different choice fields with the same name) then two enums are generated with the same name.

Plan
{
	"createdAt": "2024-11-27T17:21:37.112Z",
	"creationType": "Template",
	"id": "redacted",
	"name": "Demo tracking plan",
	"rules": {
		"events": [
			{
				"description": "When a visitor completes a step in the checkout funnel",
				"eventType": "track",
				"name": "Checkout Step Completed",
				"rules": {
					"$schema": "http://json-schema.org/draft-07/schema#",
					"description": "When a visitor completes a step in the checkout funnel",
					"properties": {
						"properties": {
							"additionalProperties": false,
							"properties": {
								"checkout_id": {
									"type": [
										"string"
									]
								},
								"payment_method": {
									"type": [
										"string"
									]
								},
								"shipping_method": {
									"enum": [
										"fedex",
										"dhl",
										"royal_mail",
										"carrier_pigeon"
									],
									"type": [
										"string"
									]
								},
								"step": {
									"type": [
										"number"
									]
								}
							},
							"required": [
								"checkout_id",
								"step"
							],
							"type": "object"
						}
					},
					"type": "object"
				}
			},
			{
				"description": "When a visitor views a step in the checkout funnel. Event description content on another line",
				"eventType": "track",
				"name": "Checkout Step Viewed",
				"rules": {
					"$defs": {
					},
					"$schema": "http://json-schema.org/draft-07/schema#",
					"description": "When a visitor views a step in the checkout funnel",
					"properties": {
						"properties": {
							"additionalProperties": false,
							"properties": {
								"checkout_id": {
									"type": [
										"string"
									]
								},
								"payment_method": {
									"type": [
										"string"
									]
								},
								"shipping_method": {
									"description": "Contains the information associated with the chosen shipping method.",
									"enum": [
										"fedex",
										"dhl",
										"royal_mail",
										"carrier_pigeon"
									],
									"type": [
										"string"
									]
								},
								"step": {
									"type": [
										"number"
									]
								}
							},
							"required": [
								"step"
							],
							"type": "object"
						}
					},
					"type": "object"
				}
			}
		]
	},
	"updatedAt": "2024-11-27T17:21:37.112Z",
	"version": 17,
	"workspaceId": "redacted"
}

Results in (snippet):

export enum Shipping_method {
  S_FEDEX = 'fedex',
  S_DHL = 'dhl',
  S_ROYAL_MAIL = 'royal_mail',
  S_CARRIER_PIGEON = 'carrier_pigeon',
}

export interface CheckoutStepCompleted {
  checkout_id: string
  payment_method?: string
  shipping_method?: Shipping_method
  step: number
}

export enum Shipping_method {
  S_FEDEX = 'fedex',
  S_DHL = 'dhl',
  S_ROYAL_MAIL = 'royal_mail',
  S_CARRIER_PIGEON = 'carrier_pigeon',
}

export interface CheckoutStepViewed {
  checkout_id?: string
  payment_method?: string
  /**
		* Contains the information associated with the chosen shipping method.
		*/
  shipping_method?: Shipping_method
  step: number
}
@contributor-support
Copy link

Thanks for opening this issue! We'll get back to you shortly. If it is a bug, please make sure to add steps to reproduce the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant