MCPcopy Create free account
hub / github.com/DavidWells/analytics / renderRelevantMethods

Function renderRelevantMethods

scripts/docs.js:553–612  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

551}
552
553function renderRelevantMethods(data) {
554 // console.log('data', data)
555 const exposedFunctions = getExposedFunctions(data)
556 // console.log('exposedFunctions', exposedFunctions)
557 let page = ''
558 if (exposedFunctions.includes('page')) {
559 const hasCustom = data.jsdoc.find((doc) => doc.longname === 'page')
560 if (hasCustom && hasCustom.examples) {
561 page = `
562 /* Track a page view */
563 ${hasCustom.examples[0]}
564 `
565 } else {
566 page = `
567 /* Track a page view */
568 analytics.page()
569 `
570 }
571 }
572 let track = ''
573 if (exposedFunctions.includes('track')) {
574 const hasCustom = data.jsdoc.find((doc) => doc.longname === 'track')
575 if (hasCustom && hasCustom.examples) {
576 track = `
577 /* Track a custom event */
578 ${hasCustom.examples[0]}
579 `
580 } else {
581 track = `
582 /* Track a custom event */
583 analytics.track('cartCheckout', {
584 item: 'pink socks',
585 price: 20
586 })
587 `
588 }
589 }
590
591 let identify = ''
592 if (exposedFunctions.includes('identify')) {
593 const hasCustom = data.jsdoc.find((doc) => doc.longname === 'identify')
594 if (hasCustom && hasCustom.examples) {
595 identify = `
596 /* Identify a visitor */
597 ${hasCustom.examples[0]}
598 `
599 } else {
600 identify = `
601 /* Identify a visitor */
602 analytics.identify('user-id-xyz', {
603 firstName: 'bill',
604 lastName: 'murray',
605 })`
606 }
607 }
608
609 // TODO add .reset
610

Callers 5

mainUsageBlockFunction · 0.85
es6UsageFunction · 0.85
nodeUsageFunction · 0.85
browserStandaloneUsageFunction · 0.85
browserESMUsageFunction · 0.85

Calls 1

getExposedFunctionsFunction · 0.85

Tested by

no test coverage detected