Skip to content

Commit a2dd15a

Browse files
committed
workflow update
1 parent 2baba4f commit a2dd15a

3 files changed

Lines changed: 26 additions & 22 deletions

File tree

.github/workflows/node.js.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
node: [14, 16, 17]
18+
node: [14, 16, 18, 20, 22, 23]
1919
steps:
20-
- uses: actions/checkout@v2
21-
- name: Use Node.js ${{ matrix.node-version }}
22-
uses: actions/setup-node@v2
20+
- uses: actions/checkout@v4
21+
- name: Use Node.js ${{ matrix.node }}
22+
uses: actions/setup-node@v4
2323
with:
2424
node-version: ${{ matrix.node }}
25+
cache: 'npm'
2526
- run: npm install
2627
- run: npm run build --if-present
2728
- run: npm test
@@ -30,11 +31,12 @@ jobs:
3031
runs-on: ubuntu-latest
3132
needs: build
3233
steps:
33-
- uses: actions/checkout@v2
34-
- name: Use Node.js ${{ matrix.node-version }}
35-
uses: actions/setup-node@v2
34+
- uses: actions/checkout@v4
35+
- name: Use Node.js 20.x
36+
uses: actions/setup-node@v4
3637
with:
37-
node-version: 16.x
38+
node-version: 20.x
39+
cache: 'npm'
3840
- run: npm install
3941
- name: Deploy documentation
4042
shell: bash

examples/example.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ var Countly = require("../lib/countly.js");
1212
Countly.init({
1313
app_key: COUNTLY_APP_KEY,
1414
url: COUNTLY_SERVER_KEY, //your server goes here
15-
debug: true
15+
debug: true,
16+
clear_stored_device_id: true, //just for testing purposes
17+
device_id: "id_" + Math.floor(Math.random() * 1000000) //just for testing purposes
1618
});
1719

1820
Countly.begin_session();

lib/countly.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,27 +1658,27 @@ Countly.Bulk = Bulk;
16581658
var fileName = path.basename(filePath);
16591659
var ext = (fileName.split('.').pop() || '').toLowerCase();
16601660
var contentType = 'application/octet-stream';
1661-
if (ext === 'png') {
1661+
if (ext === 'png') {
16621662
contentType = 'image/png';
1663-
} else if (ext === 'jpg' || ext === 'jpeg') {
1663+
}
1664+
else if (ext === 'jpg' || ext === 'jpeg') {
16641665
contentType = 'image/jpeg';
1665-
} else if (ext === 'gif') {
1666+
}
1667+
else if (ext === 'gif') {
16661668
contentType = 'image/gif';
16671669
}
16681670

1669-
var boundary = 'FormBoundary' + Math.random().toString(16).slice(2);
1671+
var boundary = `FormBoundary${Math.random().toString(16).slice(2)}`;
16701672
var bodyParts = [];
16711673

16721674
for (var p in params) {
1673-
if (!Object.prototype.hasOwnProperty.call(params, p)) continue;
1674-
if (p === 'picturePath') {
1675-
continue;
1675+
if (typeof params[p] !== "undefined" && p !== 'picturePath') {
1676+
var value = params[p];
1677+
bodyParts.push(Buffer.from(`--${boundary}\r\n`));
1678+
bodyParts.push(Buffer.from(`Content-Disposition: form-data; name="${p}"\r\n\r\n`));
1679+
bodyParts.push(Buffer.from(String(value)));
1680+
bodyParts.push(Buffer.from('\r\n'));
16761681
}
1677-
var value = params[p];
1678-
bodyParts.push(Buffer.from(`--${boundary}\r\n`));
1679-
bodyParts.push(Buffer.from(`Content-Disposition: form-data; name="${p}"\r\n\r\n`));
1680-
bodyParts.push(Buffer.from(String(value)));
1681-
bodyParts.push(Buffer.from('\r\n'));
16821682
}
16831683

16841684
bodyParts.push(Buffer.from(`--${boundary}\r\n`));
@@ -1704,7 +1704,7 @@ Countly.Bulk = Bulk;
17041704
delete params.picturePath;
17051705
}
17061706
}
1707-
1707+
17081708
if (!data) {
17091709
data = prepareParams(params);
17101710
options.path = `${api}?${data}`;

0 commit comments

Comments
 (0)