@@ -59,24 +59,23 @@ function getTelemetryEventNames(
5959function buildInMemorySource (
6060 originalSource : ts . SourceFile ,
6161 eventTypeNames : string [ ] ,
62- identifyTraitsName : string ,
6362 commonPropertiesName ?: string ,
6463) : ts . SourceFile {
6564 // Appends "Resolved*" type aliases that flatten intersections and type references
6665 // into basic types. The TypeChecker then emits fully-expanded, readable types
6766 // for each event property in the tracking plan.
67+ // All events (including identity events) must have a `payload` field.
6868 const resolvedEvents = eventTypeNames
6969 . map (
7070 ( name ) => `
7171type Resolved${ name } = {
7272 name: ${ name } ['name'];
73- payload: ResolveType<${ name } extends { payload: infer P } ? P : Record<string, never> >;
73+ payload: ResolveType<${ name } [' payload'] >;
7474};` ,
7575 )
7676 . join ( '\n' ) ;
7777
7878 const resolvedSections = [
79- `type Resolved${ identifyTraitsName } = ResolveType<${ identifyTraitsName } >;` ,
8079 commonPropertiesName
8180 ? `type Resolved${ commonPropertiesName } = ResolveType<${ commonPropertiesName } >;`
8281 : '' ,
@@ -305,7 +304,6 @@ function renderSection(
305304function generateMarkdown (
306305 config : GenerateTrackingPlanConfig ,
307306 events : EventInfo [ ] ,
308- identifyTraits : SectionInfo ,
309307 commonProperties ?: SectionInfo ,
310308) : string {
311309 const lines : string [ ] = [ ] ;
@@ -333,7 +331,6 @@ function generateMarkdown(
333331 if ( commonProperties ) {
334332 lines . push ( '- [Common Properties](#common-properties)' ) ;
335333 }
336- lines . push ( '- [Identity](#identity)' ) ;
337334 for ( const cat of sortedCategories ) {
338335 lines . push ( `- [${ cat } ](#${ slugify ( cat ) } )` ) ;
339336 for ( const event of byCategory . get ( cat ) ! ) {
@@ -346,8 +343,6 @@ function generateMarkdown(
346343 renderSection ( 'Common Properties' , commonProperties , lines ) ;
347344 }
348345
349- renderSection ( 'Identity' , identifyTraits , lines ) ;
350-
351346 for ( const cat of sortedCategories ) {
352347 lines . push ( '' ) ;
353348 lines . push ( `## ${ cat } ` ) ;
@@ -378,22 +373,15 @@ export function generateTrackingPlan(
378373 ) ;
379374
380375 const unionTypeName = 'TelemetryEvent' ;
381- const identifyTraitsName = 'IdentifyTraits' ;
382376 const commonPropertiesName = 'CommonEventProperties' ;
383377 const eventTypeNames = getTelemetryEventNames ( originalSource , unionTypeName ) ;
384378 const inMemorySource = buildInMemorySource (
385379 originalSource ,
386380 eventTypeNames ,
387- identifyTraitsName ,
388381 commonPropertiesName ,
389382 ) ;
390383 const checker = createChecker ( inMemorySource ) ;
391384
392- const identifyTraits = parseSectionType (
393- identifyTraitsName ,
394- inMemorySource ,
395- checker ,
396- ) ;
397385 const hasCommonProperties = originalSource . statements . some (
398386 ( n ) =>
399387 ( ts . isTypeAliasDeclaration ( n ) || ts . isInterfaceDeclaration ( n ) ) &&
@@ -407,5 +395,5 @@ export function generateTrackingPlan(
407395 parseTelemetryEvent ( name , inMemorySource , checker ) ,
408396 ) ;
409397
410- return generateMarkdown ( config , events , identifyTraits , commonProperties ) ;
398+ return generateMarkdown ( config , events , commonProperties ) ;
411399}
0 commit comments