Skip to content
This repository was archived by the owner on Sep 2, 2022. It is now read-only.

Commit 10d0ae1

Browse files
authored
Merge pull request #21 from apilytics/send-os
Add platform name to sent Apilytics version info
2 parents afa636b + cbc12f4 commit 10d0ae1

5 files changed

Lines changed: 20 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add platform name to sent Apilytics version info.
13+
1014
## [1.4.0] - 2022-02-15
1115

1216
### Added

packages/core/__tests__/index.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ describe('sendApilyticsMetrics()', () => {
8686

8787
expect(APILYTICS_VERSION).toBeTruthy();
8888
expect(process.versions.node).toBeTruthy();
89+
expect(process.platform).toBeTruthy();
8990

9091
expect(requestSpy).toHaveBeenLastCalledWith({
9192
hostname: 'www.apilytics.io',
@@ -96,7 +97,7 @@ describe('sendApilyticsMetrics()', () => {
9697
'Content-Type': 'application/json',
9798
'Content-Length': expect.any(Number),
9899
'X-API-Key': apiKey,
99-
'Apilytics-Version': `apilytics-node-core/${APILYTICS_VERSION};node/${process.versions.node}`,
100+
'Apilytics-Version': `apilytics-node-core/${APILYTICS_VERSION};node/${process.versions.node};;${process.platform}`,
100101
},
101102
});
102103

@@ -137,7 +138,7 @@ describe('sendApilyticsMetrics()', () => {
137138
'Content-Type': 'application/json',
138139
'Content-Length': expect.any(Number),
139140
'X-API-Key': apiKey,
140-
'Apilytics-Version': `dummy/${APILYTICS_VERSION};node/${process.versions.node};lib/1.2.3`,
141+
'Apilytics-Version': `dummy/${APILYTICS_VERSION};node/${process.versions.node};lib/1.2.3;${process.platform}`,
141142
},
142143
});
143144
});

packages/core/src/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,12 @@ export const sendApilyticsMetrics = ({
9191
memoryTotal,
9292
timeMillis,
9393
});
94-
let apilyticsVersion = `${
95-
apilyticsIntegration ?? 'apilytics-node-core'
96-
}/${APILYTICS_VERSION};node/${process.versions.node}`;
9794

98-
if (integratedLibrary) {
99-
apilyticsVersion += `;${integratedLibrary}`;
100-
}
95+
const apilyticsVersion = `${
96+
apilyticsIntegration ?? 'apilytics-node-core'
97+
}/${APILYTICS_VERSION};node/${process.versions.node};${
98+
integratedLibrary ?? ''
99+
};${process.platform}`;
101100

102101
const options = {
103102
hostname: 'www.apilytics.io',

packages/express/__tests__/index.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ describe('apilyticsMiddleware()', () => {
9292
expect(APILYTICS_VERSION).toBeTruthy();
9393
expect(process.versions.node).toBeTruthy();
9494
expect(EXPRESS_VERSION).toBeTruthy();
95+
expect(process.platform).toBeTruthy();
9596

9697
expect(requestSpy).toHaveBeenLastCalledWith({
9798
hostname: 'www.apilytics.io',
@@ -102,7 +103,7 @@ describe('apilyticsMiddleware()', () => {
102103
'Content-Type': 'application/json',
103104
'Content-Length': expect.any(Number),
104105
'X-API-Key': apiKey,
105-
'Apilytics-Version': `apilytics-node-express/${APILYTICS_VERSION};node/${process.versions.node};express/${EXPRESS_VERSION}`,
106+
'Apilytics-Version': `apilytics-node-express/${APILYTICS_VERSION};node/${process.versions.node};express/${EXPRESS_VERSION};${process.platform}`,
106107
},
107108
});
108109

@@ -142,7 +143,7 @@ describe('apilyticsMiddleware()', () => {
142143
'Content-Type': 'application/json',
143144
'Content-Length': expect.any(Number),
144145
'X-API-Key': apiKey,
145-
'Apilytics-Version': `apilytics-node-express/${APILYTICS_VERSION};node/${process.versions.node};express/${EXPRESS_VERSION}`,
146+
'Apilytics-Version': `apilytics-node-express/${APILYTICS_VERSION};node/${process.versions.node};express/${EXPRESS_VERSION};${process.platform}`,
146147
},
147148
});
148149

@@ -275,7 +276,7 @@ describe('apilyticsMiddleware()', () => {
275276
expect(requestSpy).toHaveBeenLastCalledWith(
276277
expect.objectContaining({
277278
headers: expect.objectContaining({
278-
'Apilytics-Version': `apilytics-node-express/${APILYTICS_VERSION};node/${process.versions.node}`,
279+
'Apilytics-Version': `apilytics-node-express/${APILYTICS_VERSION};node/${process.versions.node};;${process.platform}`,
279280
}),
280281
}),
281282
);

packages/next/__tests__/index.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ describe('withApilytics()', () => {
112112
expect(APILYTICS_VERSION).toBeTruthy();
113113
expect(process.versions.node).toBeTruthy();
114114
expect(NEXT_VERSION).toBeTruthy();
115+
expect(process.platform).toBeTruthy();
115116

116117
expect(requestSpy).toHaveBeenLastCalledWith({
117118
hostname: 'www.apilytics.io',
@@ -122,7 +123,7 @@ describe('withApilytics()', () => {
122123
'Content-Type': 'application/json',
123124
'Content-Length': expect.any(Number),
124125
'X-API-Key': apiKey,
125-
'Apilytics-Version': `apilytics-node-next/${APILYTICS_VERSION};node/${process.versions.node};next/${NEXT_VERSION}`,
126+
'Apilytics-Version': `apilytics-node-next/${APILYTICS_VERSION};node/${process.versions.node};next/${NEXT_VERSION};${process.platform}`,
126127
},
127128
});
128129

@@ -162,7 +163,7 @@ describe('withApilytics()', () => {
162163
'Content-Type': 'application/json',
163164
'Content-Length': expect.any(Number),
164165
'X-API-Key': apiKey,
165-
'Apilytics-Version': `apilytics-node-next/${APILYTICS_VERSION};node/${process.versions.node};next/${NEXT_VERSION}`,
166+
'Apilytics-Version': `apilytics-node-next/${APILYTICS_VERSION};node/${process.versions.node};next/${NEXT_VERSION};${process.platform}`,
166167
},
167168
});
168169

@@ -314,7 +315,7 @@ describe('withApilytics()', () => {
314315
expect(requestSpy).toHaveBeenLastCalledWith(
315316
expect.objectContaining({
316317
headers: expect.objectContaining({
317-
'Apilytics-Version': `apilytics-node-next/${APILYTICS_VERSION};node/${process.versions.node}`,
318+
'Apilytics-Version': `apilytics-node-next/${APILYTICS_VERSION};node/${process.versions.node};;${process.platform}`,
318319
}),
319320
}),
320321
);

0 commit comments

Comments
 (0)