Skip to content

Commit 48e084e

Browse files
hmajorostylerturdenpants
authored andcommitted
fix wallstreet integration with telemetry data (#205)
1 parent d3089bd commit 48e084e

3 files changed

Lines changed: 43 additions & 7 deletions

File tree

transforms/angle-brackets/telemetry/mock-invokables.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,13 @@ module.exports = {
9292
'app/components/foo-bar': {
9393
type: 'Component',
9494
},
95+
'app/components/baz-bang/foo-bar/bang': {
96+
type: 'Component',
97+
},
98+
'app/helpers/helper-1': {
99+
type: 'Helper',
100+
},
101+
'app/helpers/nested/helper': {
102+
type: 'Helper',
103+
},
95104
};

transforms/angle-brackets/transform.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,19 @@ function getNonDataAttributesFromParams(params) {
270270
return params.filter(p => !(p.original && `${p.original}`.startsWith('data-')));
271271
}
272272

273-
function shouldIgnoreMustacheStatement(name, config, invokableData) {
273+
function shouldIgnoreMustacheStatement(fullName, config, invokableData) {
274274
let { helpers, components } = invokableData;
275275
let isTelemetryData = !!(helpers || components);
276+
277+
let name = fullName;
278+
// replace `::` with `/`, and ignore the path before $
279+
if (isWallStreet(name)) {
280+
name = name
281+
.split('$')
282+
.pop()
283+
.replace('::', '/');
284+
}
285+
276286
if (isTelemetryData) {
277287
let mergedHelpers = [...KNOWN_HELPERS, ...(helpers || [])];
278288
let isHelper = mergedHelpers.includes(name) || config.helpers.includes(name);
@@ -405,9 +415,6 @@ function transformToAngleBracket(fileInfo, config, invokableData) {
405415
) {
406416
return transformNode(node, fileInfo, config);
407417
}
408-
if (isWallStreet(tagName)) {
409-
return transformNode(node, fileInfo, config);
410-
}
411418
},
412419
BlockStatement(node) {
413420
let tagName = `${node.path.original}`;

transforms/angle-brackets/transform.test.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,12 +1049,12 @@ test('hyphens with nested usage', () => {
10491049

10501050
test('wallstreet', () => {
10511051
let input = `
1052-
{{#foo-bar$baz-bang/foo-bar::bang}}
1052+
{{#foo-bar$baz-bang/foo-bar/bang}}
10531053
<div ...attributes>
10541054
{{foo bar="baz"}}
10551055
</div>
1056-
{{/foo-bar$baz-bang/foo-bar::bang}}
1057-
{{foo-bar$baz-bang/foo-bar::bang}}
1056+
{{/foo-bar$baz-bang/foo-bar/bang}}
1057+
{{foo-bar$baz-bang/foo-bar/bang}}
10581058
`;
10591059

10601060
expect(runTest('wallstreet.hbs', input)).toMatchInlineSnapshot(`
@@ -1069,6 +1069,26 @@ test('wallstreet', () => {
10691069
`);
10701070
});
10711071

1072+
test('wallstreet-telemetry', () => {
1073+
let input = `
1074+
{{nested$helper}}
1075+
{{nested::helper}}
1076+
{{nested$helper param="cool!"}}
1077+
{{nested::helper param="yeah!"}}
1078+
{{helper-1}}
1079+
`;
1080+
1081+
expect(runTest('wallstreet-telemetry.hbs', input)).toMatchInlineSnapshot(`
1082+
"
1083+
{{nested$helper}}
1084+
{{nested::helper}}
1085+
{{nested$helper param=\\"cool!\\"}}
1086+
{{nested::helper param=\\"yeah!\\"}}
1087+
{{helper-1}}
1088+
"
1089+
`);
1090+
});
1091+
10721092
test('attr-space', () => {
10731093
let input = `
10741094
<MyComp::Test @color={{"custom-2"}} @visible={{Group.item.isNew}} />

0 commit comments

Comments
 (0)