Skip to content

[sdk] reset server conf & location tracking #6012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 49 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
59bf548
feat: reset sdk configuration button
arifBurakDemiray Feb 25, 2025
8b02e97
feat: add sync icon to the reset-config button
arifBurakDemiray Feb 26, 2025
c2b139a
Merge branch 'next' into sdk_sc_changes
arifBurakDemiray Feb 28, 2025
806750a
Merge branch 'next' into sdk_sc_changes
arifBurakDemiray Mar 3, 2025
d3db4ec
feat: location tracking switch
arifBurakDemiray Mar 3, 2025
b3774be
Merge branch 'next' into sdk_sc_changes
ar2rsawseen Mar 8, 2025
b23508e
tooltip info
turtledreams Mar 12, 2025
9604d90
Merge pull request #6055 from Countly/sc-tooltips
arifBurakDemiray Mar 17, 2025
b4e20f4
Merge branch 'next' into sdk_sc_changes
arifBurakDemiray Mar 17, 2025
5c450b4
Revert "[sdk ] Tooltip SDK support information"
arifBurakDemiray Mar 17, 2025
6474f6f
Merge pull request #6062 from Countly/revert-6055-sc-tooltips
arifBurakDemiray Mar 17, 2025
2b7192f
Merge pull request #6063 from Countly/next
arifBurakDemiray Mar 17, 2025
98a2730
[sdk] Upload API
turtledreams Mar 21, 2025
c46edec
lint and test omission
turtledreams Mar 21, 2025
75b8192
more lint
turtledreams Mar 21, 2025
b5a30a8
correct lint file
turtledreams Mar 24, 2025
e401072
local tests
turtledreams Apr 1, 2025
14f030c
lint
turtledreams Apr 1, 2025
e932e40
more lint
turtledreams Apr 1, 2025
1fdcb76
Merge pull request #6065 from Countly/sc-tooltips
turtledreams Apr 2, 2025
c55d5a0
Merge branch 'next' into sdk_sc_changes
turtledreams Apr 2, 2025
beaa6b3
Merge branch 'next' into sdk-config-upload-api
turtledreams Apr 2, 2025
159d1f9
removed expect
turtledreams Apr 2, 2025
f83dac3
removed support command
turtledreams Apr 2, 2025
6ec59d0
changed title in older tests
turtledreams Apr 2, 2025
06c1061
numeric literal change
turtledreams Apr 2, 2025
3b70d07
lints, lints everywhere
turtledreams Apr 2, 2025
39cec1f
add CountlyHelpers to global
turtledreams Apr 2, 2025
228714e
Added run sdk test step into ci
can-angun Apr 2, 2025
a98be66
Added run sdk script into cypress config
can-angun Apr 2, 2025
4ca9e56
Merge pull request #6109 from Countly/add-run-sdk-tests-in-ci
can-angun Apr 2, 2025
fc9e20d
Removed space char from test step
can-angun Apr 2, 2025
e1b4ac4
Fixed syntax error
can-angun Apr 2, 2025
047963c
Fixed linter error in cypress config file
can-angun Apr 2, 2025
bf4f7cb
Sep tests
turtledreams Apr 3, 2025
793209b
removed sdk video upload
turtledreams Apr 3, 2025
2df0502
increased wait time
turtledreams Apr 3, 2025
5387eea
Merge branch 'next' into sdk_sc_changes
turtledreams Apr 4, 2025
bd1c235
More state cleaning
turtledreams Apr 7, 2025
6c1fba6
Popup removed
turtledreams Apr 7, 2025
d0ecaee
removed dropbase
turtledreams Apr 7, 2025
4e4d214
increase wait time
turtledreams Apr 8, 2025
06e897f
Merge branch 'next' into sdk_sc_changes
arifBurakDemiray Apr 9, 2025
4d2f664
dividing desc
turtledreams Apr 10, 2025
b50e5b9
Merge branch 'sdk_sc_changes' of http://github.com/Countly/countly-se…
turtledreams Apr 10, 2025
16351f9
increase timer
turtledreams Apr 11, 2025
fc35d5e
Merge branch 'next' into sdk-config-upload-api
turtledreams Apr 16, 2025
487bf52
Merge pull request #6081 from Countly/sdk-config-upload-api
turtledreams Apr 16, 2025
346c66a
SDK Behavior Settings update
turtledreams Apr 16, 2025
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
69 changes: 69 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,72 @@ jobs:
mkdir -p screenshots videos
tar zcvf "$ARTIFACT_ARCHIVE_NAME" screenshots videos
curl -o /tmp/uploader.log -u "${{ secrets.BOX_UPLOAD_AUTH }}" ${{ secrets.BOX_UPLOAD_PATH }} -T "$ARTIFACT_ARCHIVE_NAME"

ui-test-sdk:
runs-on: ubuntu-latest

services:
mongodb:
image: mongo:8.0
options: >-
--health-cmd mongosh
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 27017:27017

container:
image: countly/countly-core:pipelines-${{ inputs.custom_tag || github.base_ref || github.ref_name }}
env:
COUNTLY_CONFIG__MONGODB_HOST: mongodb
COUNTLY_CONFIG_API_PREVENT_JOBS: true

steps:
- uses: actions/checkout@v2

- name: Install Chrome
shell: bash
run: |
apt update
apt install -y libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb wget
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -O /tmp/chrome.deb
apt install -y /tmp/chrome.deb

- name: Copy code
shell: bash
run: cp -rf ./* /opt/countly

- name: Prepare files to use correct MongoDB host
shell: bash
run: "sed -i 's/mongosh --quiet/mongosh --host mongodb --quiet/' /opt/countly/bin/backup/import_events.sh && sed -i 's/mongoimport --db/mongoimport --host mongodb --db/' /opt/countly/bin/backup/import_events.sh"

- name: NPM install
shell: bash
working-directory: /opt/countly
run: npm install

- name: Prepare environment
shell: bash
working-directory: /opt/countly
run: |
sed -i 's/port: 3001,/port: 3001, workers: 1,/' /opt/countly/api/config.js
cp "./plugins/plugins.default.json" "/opt/countly/plugins/plugins.json"
npm install
sudo countly task dist-all
bash bin/scripts/countly.prepare.ce.tests.sh
cd ui-tests
echo '{"username": "${{ secrets.CYPRESS_USER_USERNAME }}","email": "${{ secrets.CYPRESS_USER_EMAIL }}","password": "${{ secrets.CYPRESS_USER_PASSWORD }}"}' > cypress/fixtures/user.json
sed -i 's/00000000-0000-0000-0000-000000000000/${{ secrets.CYPRESS_KEY }}/g' package.json
cp cypress.config.sample.js cypress.config.js
sed -i 's/000000/${{ secrets.CYPRESS_PROJECT_ID }}/g' cypress.config.js

- name: Run UI tests
shell: bash
working-directory: /opt/countly
run: |
/sbin/my_init &
cd ui-tests
npm install
xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" \
npm run cy:run:sdk
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,10 @@
placement: {
type: String,
default: 'auto'
},
tooltipClass: {
type: String,
default: ''
}
},
computed: {
Expand All @@ -415,7 +419,7 @@
};
}
},
template: '<i v-if="tooltip" :class="\'cly-vue-tooltip-icon \' + icon" v-tooltip="tooltipConf"></i>'
template: '<i v-if="tooltip" :class="\'cly-vue-tooltip-icon \' + icon + \' \' + tooltipClass" v-tooltip="tooltipConf"></i>'
}));

Vue.component("cly-remover", countlyBaseComponent.extend({
Expand Down
150 changes: 126 additions & 24 deletions plugins/sdk/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,49 @@ plugins.register("/permissions/features", function(ob) {

(function() {

/**
* @api {get} /o/sdk?method=sc Get SDK config
* @apiName GetSDKConfig
* @apiGroup SDK Config
* @apiPermission app
* @apiDescription Get SDK configuration for this SDK and this user
*
* @apiQuery {String} app_key Application key
*
* @apiSuccess {Object} v - version
* @apiSuccess {Object} t - timestamp
* @apiSuccess {Object} c - sdk config
*
* @apiSuccessExample {json} Success-Response:
* {
"v":1,
"t":1682328445330,
"c":{
"tracking":true,
"networking":true,
"crt":true,
"vt":true,
"st":true,
"cet":true,
"ecz":true,
"cr":true,
"sui":true,
"eqs":true,
"rqs":true,
"czi":true,
"dort":true,
"scui":true,
"lkl":true,
"lvs":true,
"lsv":true,
"lbc":true,
"ltlpt":true,
"ltl":true,
"lt":true,
"rcz":true
}
* }
*/
plugins.register("/o/sdk", function(ob) {
var params = ob.params;
if (params.qstring.method !== "sc") {
Expand All @@ -36,36 +79,24 @@ plugins.register("/permissions/features", function(ob) {
});

/**
* @api {get} /o?method=sc Get SDK config
* @apiName GetSDKConfig
* @api {get} /o?method=config-upload Save SDK config
* @apiName SaveSDKConfig
* @apiGroup SDK Config
* @apiPermission app
* @apiDescription Get SDK configuration for this SDK and this user
*
* @apiQuery {String} app_key Application key
*
* @apiSuccess {Object} v - version
* @apiSuccess {Object} t - timestamp
* @apiSuccess {Object} c - sdk config
*
* @apiSuccessExample {json} Success-Response:
* @apiPermission admin
* @apiDescription Save SDK configuration for the given app
*
* @apiQuery {String} app_id Application ID
* @apiQuery {String} config SDK config object
*
* @apiSuccess {json} Success-Response:
* {
"v":1,
"t":1682328445330,
"c":{
"tracking":false,
"networking":false,
"crashes":false,
"views":false,
"heartbeat":61,
"event_queue":11,
"request_queue":1001
}
* "result": "Success"
* }
*/
plugins.register("/o", function(ob) {
var params = ob.params;

// returns server config for the given app
if (params.qstring.method === "sdk-config") {
validateRead(params, FEATURE_NAME, function() {
getSDKConfig(params).then(function(res) {
Expand All @@ -78,6 +109,77 @@ plugins.register("/permissions/features", function(ob) {

return true;
}

// saves the given server configuration for the given app
if (params.qstring.method === "config-upload") {
return new Promise(function(resolve) {
validateUpdate(params, FEATURE_NAME, function() {
var uploadConfig = params.qstring.config;
if (uploadConfig && typeof uploadConfig === "string") {
try {
uploadConfig = JSON.parse(uploadConfig);
}
catch (ex) {
common.returnMessage(params, 400, 'Invalid config format');
return resolve();
}
}

if (!uploadConfig || typeof uploadConfig !== "object") {
common.returnMessage(params, 400, 'Config must be a valid object');
return resolve();
}

var configToSave = uploadConfig.c || uploadConfig; // incase they provide the config object directly
var validOptions = [
"tracking",
"networking",
"crt",
"vt",
"st",
"cet",
"ecz",
"cr",
"sui",
"eqs",
"rqs",
"czi",
"dort",
"scui",
"lkl",
"lvs",
"lsv",
"lbc",
"ltlpt",
"ltl",
"lt",
"rcz"
];
for (var key in configToSave) {
if (validOptions.indexOf(key) === -1) {
delete configToSave[key];
}
}

common.outDb.collection('sdk_configs').updateOne(
{_id: params.qstring.app_id + ""},
{$set: {config: configToSave}},
{upsert: true},
function(err) {
if (err) {
common.returnMessage(params, 500, 'Error saving config to database');
}
else {
common.returnOutput(params, {result: 'Success'});
}
resolve();
}
);
});
});
}

return false;
});

plugins.register("/i/sdk-config", function(ob) {
Expand Down Expand Up @@ -359,7 +461,7 @@ plugins.register("/permissions/features", function(ob) {
});

/**
* Updated SDK config
* Updates SDK config (used internally when configuration is changed in the dashboard)
* @param {params} params - request params
* @returns {void}
*/
Expand Down
Loading
Loading