Skip to content

Commit

Permalink
Fix telemetry consumption: new components from @ember namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
lolmaus committed Feb 8, 2024
1 parent 37c3bce commit 208d697
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
18 changes: 17 additions & 1 deletion transforms/angle-brackets/telemetry/invokable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,23 @@ const HELPER = 'Helper';
const COMPONENT = 'Component';

function invokableName(name, type) {
let invokePath = type === HELPER ? '/helpers/' : '/components/';
let invokePath;

if (name.startsWith('@ember/component/')) {
invokePath = '@ember/component/';
} else if (name.startsWith('@ember/routing/')) {
invokePath = '@ember/routing/';
} else if (type === HELPER) {
invokePath = '/helpers/';
} else {
invokePath = '/components/';
}

console.log({
name,
invokePath,
result: name.substring(name.lastIndexOf(invokePath) + invokePath.length, name.length),
});
return name.substring(name.lastIndexOf(invokePath) + invokePath.length, name.length);
}

Expand Down
17 changes: 7 additions & 10 deletions transforms/angle-brackets/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,13 @@ function isKnownHelper(fullName, config, invokableData) {
if (isComponent) {
return false;
}
} else {
let mergedHelpers = [...KNOWN_HELPERS, ...(helpers || [])];
let isHelper = mergedHelpers.includes(name) || config.helpers.includes(name);
let isComponent = [...(components || []), ...BUILT_IN_COMPONENTS].includes(name);
let strName = `${name}`; // coerce boolean and number to string
return (isHelper || !isComponent) && !strName.includes('.');
}

let mergedHelpers = [...KNOWN_HELPERS, ...(helpers || [])];
let isHelper = mergedHelpers.includes(name) || config.helpers.includes(name);
let isComponent = [...(components || []), ...BUILT_IN_COMPONENTS].includes(name);
let strName = `${name}`; // coerce boolean and number to string
return (isHelper || (!config.unambiguousHelpers && !isComponent)) && !strName.includes('.');
} else {
return KNOWN_HELPERS.includes(name) || config.helpers.includes(name);
}
Expand Down Expand Up @@ -483,10 +483,7 @@ function transformToAngleBracket(fileInfo, config, invokableData) {
const isTagKnownHelper = isKnownHelper(tagName, config, invokableData);

// Don't change attribute statements
const isValidMustacheComponent = config.unambiguousHelpers
? node.loc.source !== '(synthetic)' && !isTagKnownHelper
: node.loc.source !== '(synthetic)' && !isKnownHelper(tagName, config, invokableData);

const isValidMustacheComponent = node.loc.source !== '(synthetic)' && !isTagKnownHelper;
const isNestedComponent = isNestedComponentTagName(tagName);

if (
Expand Down

0 comments on commit 208d697

Please sign in to comment.