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

Function whatThisEnablesText

scripts/docs.js:489–511  ·  view source on GitHub ↗
(name, provider, methods)

Source from the content-addressed store, hash-verified

487
488const DATA_METHODS = ['page', 'track', 'identify']
489function whatThisEnablesText(name, provider, methods) {
490 const dataMethods = methods.filter((x) => DATA_METHODS.includes(x))
491 if (!dataMethods.length) {
492 return ''
493 }
494 const dataMethodText = dataMethods
495 .map((x) => {
496 const link = SRC_LINKS[x]
497 const linkText = (link) ? `[analytics.${x}](${link})` : `\`analytics.${x}\``
498 return linkText
499 })
500 .reduce((acc, curr, i) => {
501 if ((dataMethods.length - 1) === i) {
502 acc = `${acc}or ${curr}`
503 return acc
504 }
505 acc = `${acc}${curr}, `
506 return acc
507 }, '')
508 return `
509After initializing \`analytics\` with the \`${name}\` plugin, data will be sent into ${provider} whenever ${dataMethodText} are called.
510`
511}
512
513function generateImportStatement(name, pkgName) {
514 return `import Analytics from 'analytics'

Callers 1

mainUsageBlockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected