(data)
| 551 | } |
| 552 | |
| 553 | function 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 |
no test coverage detected