Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/internal/base-component/__tests__/metrics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ describe('Client Metrics support', () => {
v: testCase[1][1],
a: 'used',
s: 'DummyComponentName',
p: 'pkg',
c: { props: {} },
});
});
Expand All @@ -293,6 +294,7 @@ describe('Client Metrics support', () => {
v: '1.0',
a: 'used',
s: 'DummyComponentName',
p: 'dummy-package',
c: { props: {} },
});
});
Expand All @@ -306,6 +308,7 @@ describe('Client Metrics support', () => {
v: '1.0',
a: 'used',
s: 'DummyComponentName',
p: 'dummy-package',
c: { props: { variant: 'primary' }, metadata: { isMobile: true } },
});
});
Expand All @@ -322,6 +325,7 @@ describe('Client Metrics support', () => {
v: '1.0',
a: 'used',
s: 'DummyComponentName',
p: 'dummy-package',
c: { props: {}, metadata: { nullValue: null } },
});
});
Expand All @@ -337,6 +341,7 @@ describe('Client Metrics support', () => {
v: '1.0',
a: 'used',
s: 'DummyComponentName',
p: 'dummy-package',
c: { props: { count: 123, notANumber: 'NaN', maxSize: 'Infinity' } },
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ describe('useComponentMetrics', () => {
v: '3.0.0',
a: 'used',
s: 'test-component-1',
p: 'toolkit',
c: { props: {} },
})
);
Expand All @@ -113,6 +114,7 @@ describe('useComponentMetrics', () => {
v: '3.0.0',
a: 'used',
s: 'test-component-2',
p: 'toolkit',
c: { props: {} },
})
);
Expand All @@ -133,6 +135,7 @@ describe('useComponentMetrics', () => {
v: '3.0.0',
a: 'used',
s: 'test-component-with-props',
p: 'toolkit',
};
expect(window.AWSC.Clog.log).toHaveBeenCalledTimes(1);
expect(window.AWSC.Clog.log).toHaveBeenCalledWith(
Expand Down Expand Up @@ -165,6 +168,7 @@ describe('useComponentMetrics', () => {
v: '3.0.0',
a: 'used',
s: 'test-component-1',
p: 'toolkit',
c: { props: {} },
})
);
Expand Down
3 changes: 2 additions & 1 deletion src/internal/base-component/metrics/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ export function buildMetricDetail(detail: JSONObject, context: PackageSettings):
}

export function buildComponentMetricDetail(
{ componentName, action, configuration }: ComponentMetricDetail,
{ componentName, action, configuration, packageSource }: ComponentMetricDetail,
context: PackageSettings
): string {
return buildMetricDetail(
{
a: action,
s: componentName,
p: packageSource,
c: configuration as JSONObject | undefined,
},
context
Expand Down
3 changes: 3 additions & 0 deletions src/internal/base-component/metrics/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface ComponentMetricDetail {
// "used" – individual component used
action: 'loaded' | 'used';
configuration?: ComponentConfiguration;
packageSource?: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it called packageSource instead of sourcePackage or just package?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the existing context.packageSource, but I don't have a strong preference.

Could also be packageName for consistency with componentName.

Let's call it package for simplicity?

}

export interface ComponentMetricMinified {
Expand All @@ -44,4 +45,6 @@ export interface ComponentMetricMinified {
v: string;
// component configuration
c?: JSONObject;
// package name
p?: string;
}
1 change: 1 addition & 0 deletions src/internal/base-component/metrics/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class Metrics {
action: 'used',
componentName,
configuration,
packageSource: this.context.packageSource,
});
}
}
Expand Down
Loading