Skip to content

Commit 4dcafe2

Browse files
authored
Merge pull request #604 from Countly/sdk-info
SDK info methods
2 parents 02f0dc7 + a3eb511 commit 4dcafe2

File tree

8 files changed

+232
-161
lines changed

8 files changed

+232
-161
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 25.4.5
2+
3+
- Added SDK info methods:
4+
- `Countly.sdk_version()` for retrieving current SDK version
5+
- `Countly.sdk_name()` for retrieving the SDK name
6+
17
## 25.4.4
28

39
- Improved user property recording order with respect to sessions and events.

cypress/e2e/bridged_utils.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function initMain(name, version) {
1515
}
1616

1717
const SDK_NAME = "javascript_native_web";
18-
const SDK_VERSION = "25.4.4";
18+
const SDK_VERSION = "25.4.5";
1919

2020
// tests
2121
describe("Bridged SDK Utilities Tests", () => {

cypress/e2e/sdk_info.cy.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* eslint-disable cypress/no-unnecessary-waiting */
2+
/* eslint-disable require-jsdoc */
3+
var Countly = require("../../lib/countly");
4+
var hp = require("../support/helper.js");
5+
const SDK_NAME = "javascript_native_web";
6+
const SDK_VERSION = "25.4.5";
7+
8+
function initMain(name, version) {
9+
Countly.init({
10+
app_key: "YOUR_APP_KEY",
11+
url: "https://your.domain.count.ly",
12+
test_mode: true,
13+
debug: true,
14+
sdk_name: name,
15+
sdk_version: version
16+
});
17+
}
18+
19+
describe("SDK name and version methods", () => {
20+
it("sdk_name and sdk_version return default values when not overridden", () => {
21+
hp.haltAndClearStorage(() => {
22+
initMain(undefined, undefined);
23+
const name = Countly.sdk_name();
24+
const version = Countly.sdk_version();
25+
expect(name).to.equal(SDK_NAME);
26+
expect(version).to.equal(SDK_VERSION);
27+
});
28+
});
29+
30+
it("sdk_name and sdk_version return overridden values", () => {
31+
hp.haltAndClearStorage(() => {
32+
initMain("custom_sdk_name", "1.2.3");
33+
const name = Countly.sdk_name();
34+
const version = Countly.sdk_version();
35+
expect(name).to.equal("custom_sdk_name");
36+
expect(version).to.equal("1.2.3");
37+
});
38+
});
39+
});

lib/countly.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ declare module "countly-sdk-web" {
7575
*/
7676
function get_device_id(): string;
7777

78+
/**
79+
* Returns the SDK version string currently in use
80+
* @returns {string} sdk version
81+
*/
82+
function sdk_version(): string;
83+
84+
/**
85+
* Returns the SDK name string currently in use
86+
* @returns {string} sdk name
87+
*/
88+
function sdk_name(): string;
89+
7890
/**
7991
* Add consent for specific feature, meaning, user allowed to track that data (either core feature or from custom feature group)
8092
* @param {string | string[]} feature - name of the feature, possible values: "sessions", "events", "views", "scrolls", "clicks", "forms", "crashes", "attribution", "users", etc. or custom provided through {@link Countly.group_features}

lib/countly.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@
217217
backoffCount: "cly_hc_backoff_count",
218218
consecutiveBackoffCount: "cly_hc_consecutive_backoff_count"
219219
});
220-
var SDK_VERSION = "25.4.4";
220+
var SDK_VERSION = "25.4.5";
221221
var SDK_NAME = "javascript_native_web";
222222

223223
// Using this on document.referrer would return an array with 17 elements in it. The 12th element (array[11]) would be the path we are looking for. Others would be things like password and such (use https://regex101.com/ to check more)
@@ -1780,6 +1780,20 @@
17801780
_classPrivateFieldSet2(_SCLimitStackTraceLinesPerThread, _this, undefined);
17811781
_classPrivateFieldSet2(_SCLimitStackTraceLineLength, _this, undefined);
17821782
});
1783+
/**
1784+
* Returns the SDK version string currently in use
1785+
* @returns {string} sdk version
1786+
*/
1787+
_defineProperty(this, "sdk_version", function () {
1788+
return _classPrivateFieldGet2(_sdkVersion, _this);
1789+
});
1790+
/**
1791+
* Returns the SDK name string currently in use
1792+
* @returns {string} sdk name
1793+
*/
1794+
_defineProperty(this, "sdk_name", function () {
1795+
return _classPrivateFieldGet2(_sdkName, _this);
1796+
});
17831797
/**
17841798
* Modify feature groups for consent management. Allows you to group multiple features under one feature group
17851799
* @param {object} features - object to define feature name as key and core features as value

lib/countly.min.js

Lines changed: 156 additions & 156 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "countly-sdk-web",
3-
"version": "25.4.4",
3+
"version": "25.4.5",
44
"description": "Countly Web SDK",
55
"main": "lib/countly.js",
66
"types": "lib/countly.d.ts",

0 commit comments

Comments
 (0)