Skip to content

Commit

Permalink
Pass along version and client ID (you cowards)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Slotsky committed Mar 19, 2020
1 parent ff6c680 commit f4e404b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/v0/__tests__/analytics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ describe('analytics', () => {
});

it('metric', async () => {
const componentVersion = '1.2.3';
const analytics = createAnalytics({
env: 'prod',
element: document.createElement('manifold-product'),
componentVersion: '1.2.3',
componentVersion,
});
await analytics.track(metric);
const res = fetchMock.calls()[0][1];
Expand All @@ -104,16 +105,18 @@ describe('analytics', () => {
properties: {
...metric.properties,
componentName: 'MANIFOLD-PRODUCT',
version: componentVersion,
duration: '123', // numbers should submit as strings
},
});
});

it('track', async () => {
const componentVersion = '1.2.3';
const analytics = createAnalytics({
env: 'prod',
element: document.createElement('manifold-product'),
componentVersion: '1.2.3',
componentVersion,
});
await analytics.track(track);
const res = fetchMock.calls()[0][1];
Expand All @@ -123,6 +126,7 @@ describe('analytics', () => {
properties: {
...track.properties,
componentName: 'MANIFOLD-PRODUCT',
version: componentVersion,
planId: '1234', // numbers should submit as strings
},
});
Expand Down
6 changes: 5 additions & 1 deletion src/v0/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ export default function createAnalytics(args: CreateAnalytics) {
source: args.element.tagName,
properties: Object.entries(evt.properties).reduce(
(properties, [key, value]) => ({ ...properties, [key]: `${value}` }),
{ componentName: args.element.tagName }
{
componentName: args.element.tagName,
version: args.componentVersion,
clientId: args.clientId,
}
),
};
}
Expand Down

0 comments on commit f4e404b

Please sign in to comment.