Skip to content

Commit d725146

Browse files
authored
Merge pull request #122 from Countly/image-upload
Picture upload
2 parents c6bd01d + 57e61ad commit d725146

File tree

13 files changed

+3763
-42
lines changed

13 files changed

+3763
-42
lines changed

.eslintrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ module.exports = {
8383
"always"
8484
],
8585
"no-multi-spaces": [
86-
"error"
86+
"warn"
8787
],
8888
"no-trailing-spaces": [
89-
"error",
89+
"warn",
9090
{
9191
"ignoreComments": true
9292
}

.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

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
**/node_modules
33
bulk_data/**
44
**/data
5-
package-lock.json

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 24.10.3
2+
- Added support for uploading user images by providing path to the local image using `picturePath` parameter in `user_details` method (non-bulk)
3+
- Reduced SDK log verbosity
4+
15
## 24.10.2
26
- Added timezone support for server
37

examples/bulk_import_example.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ server.start(function() {
2424
});
2525

2626

27-
var user = server.add_user({device_id: "my_device_id"});
27+
var user = server.add_user({ device_id: "my_device_id_1" });
28+
var user2 = server.add_user({ device_id: "my_device_id_2" });
2829

2930
user.begin_session({_os: "Android", _os_version: "7", _app_version: "1.0"}, 240, 1500645060)
3031
.add_event({key: "Test1", timestamp: 1500645060})
@@ -44,4 +45,10 @@ user.begin_session({_os: "Android", _os_version: "7", _app_version: "1.0"}, 240,
4445
.custom_min("min", 10)
4546
.custom_push("check", "a")
4647
.custom_push_unique("tags", "morning")
47-
.custom_save();
48+
.custom_save();
49+
50+
user2.begin_session({ _os: "iOS", _os_version: "10", _app_version: "1.0" }, 300, 1500645060)
51+
.add_event({ key: "Test1", timestamp: 1500645060 })
52+
.add_event({ key: "Test2", timestamp: 1500645060 })
53+
.add_event({ key: "Test3", timestamp: 1500645060 })
54+
.user_details({ name: "Test user2", email: "[email protected]" })

examples/example.js

Lines changed: 11 additions & 9 deletions
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();
@@ -27,22 +29,22 @@ setTimeout(function() {
2729
"dur": 1000,
2830
"segmentation": {
2931
"app_version": "1.0",
30-
"country": "Turkey"
32+
"country": "GB"
3133
}
3234
});
3335
}, 5000);
3436

3537
setTimeout(function() {
3638
Countly.user_details({
37-
"name": "Arturs Sosins",
38-
"username": "ar2rsawseen",
39+
"name": "User name",
40+
"username": "User nickname",
3941
"email": "[email protected]",
4042
"organization": "Countly",
41-
"phone": "+37112345678",
42-
//Web URL to picture
43-
"picture": "https://pbs.twimg.com/profile_images/1442562237/012_n_400x400.jpg",
43+
"phone": "+37144345678",
44+
// "picture": "http://www.gravatar.com/avatar/9b8f4f4c3b9b0f2e7f5f4e4e4e4e4e4e",
45+
"picturePath": "./logo.png",
4446
"gender": "M",
45-
"byear": 1987, //birth year
47+
"byear": 1987,
4648
"custom": {
4749
"key1": "value1",
4850
"key2": "value2",
@@ -73,7 +75,7 @@ setTimeout(function() {
7375
"count": 1,
7476
"segmentation": {
7577
"app_version": "1.0",
76-
"country": "Turkey"
78+
"country": "GB"
7779
}
7880
});
7981
}, 50000);

examples/logo.png

2.45 KB
Loading

lib/countly-bulk.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ CountlyBulk.StorageTypes = cc.storageTypeEnums;
5959
* });
6060
*/
6161
function CountlyBulk(conf) {
62-
var SDK_VERSION = "24.10.2";
62+
var SDK_VERSION = "24.10.3";
6363
var SDK_NAME = "javascript_native_nodejs_bulk";
6464

6565
var empty_queue_callback = null;
@@ -197,7 +197,7 @@ function CountlyBulk(conf) {
197197
query.hour = query.hour || date.getHours();
198198
query.dow = query.dow || date.getDay();
199199
query.tz = query.tz || -date.getTimezoneOffset();
200-
cc.log(cc.logLevelEnums.INFO, "CountlyBulk add_bulk_request, adding the request into queue.");
200+
cc.log(cc.logLevelEnums.INFO, `CountlyBulk add_bulk_request, adding the request into queue: [${JSON.stringify(query)}]`);
201201
requestQueue.push(query);
202202
}
203203
CountlyStorage.storeSet("cly_req_queue", requestQueue);

lib/countly-common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ var cc = {
245245
isResponseValidBroad: function isResponseValidBroad(statusCode, str) {
246246
// status code and response format check
247247
if (!(statusCode >= 200 && statusCode < 300)) {
248-
this.log(this.logLevelEnums.ERROR, `isResponseValidBroad, The server status code is not within the expected range: [${statusCode}]`);
248+
this.log(this.logLevelEnums.ERROR, `isResponseValidBroad, The server status code is not within the expected range: [${statusCode}] with: [${str}]`);
249249
return false;
250250
}
251251

lib/countly-storage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const memoryStorage = {
5757
*/
5858
storeSet: function(key, value, callback) {
5959
if (key) {
60-
cc.log(cc.logLevelEnums.DEBUG, `storeSet, Setting key: [${key}] & value: [${value}]!`);
60+
// cc.log(cc.logLevelEnums.VERBOSE, `storeSet, Setting key: [${key}] & value: [${value}]!`);
6161
__cache[key] = value;
6262
if (typeof callback === "function") {
6363
callback(null);
@@ -74,7 +74,7 @@ const memoryStorage = {
7474
* @returns {varies} value for the key
7575
*/
7676
storeGet: function(key, def) {
77-
cc.log(cc.logLevelEnums.DEBUG, `storeGet, Fetching item from memory with key: [${key}].`);
77+
// cc.log(cc.logLevelEnums.VERBOSE, `storeGet, Fetching item from memory with key: [${key}].`);
7878
return typeof __cache[key] !== "undefined" ? __cache[key] : def;
7979
},
8080
/**

0 commit comments

Comments
 (0)