-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a5e4ff
commit b52a34f
Showing
104 changed files
with
15,543 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Cypress Tests with Dependency and Artifact Caching | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
install: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Cypress install | ||
uses: cypress-io/github-action@v6 | ||
with: | ||
# Disable running of tests within install job | ||
runTests: false | ||
build: npm run build | ||
|
||
- name: Save build folder | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: build | ||
if-no-files-found: error | ||
path: build | ||
|
||
cypress-run: | ||
runs-on: ubuntu-22.04 | ||
needs: install | ||
strategy: | ||
# don't fail the entire matrix on failure | ||
fail-fast: false | ||
matrix: | ||
# run copies of the current job in parallel | ||
containers: [1, 2, 3] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download the build folder | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: build | ||
path: build | ||
|
||
- name: Cypress run | ||
uses: cypress-io/github-action@v6 | ||
with: | ||
start: npm start | ||
parallel: true | ||
group: 'UI-Chrome' | ||
browser: chrome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules/ | ||
dist/ | ||
package-lock.json | ||
rollup.config.js | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 23.10.0 | ||
|
||
* Modularized the Web SDK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
import CountlyClass from "./modules/CountlyClass.js"; | ||
import { featureEnums, DeviceIdTypeInternalEnums, CDN } from "./modules/Constants.js"; | ||
import { checkIfLoggingIsOn } from "./modules/Utils.js"; | ||
import { isBrowser, Countly } from "./modules/Platform.js"; | ||
|
||
var apmLibrariesNotLoaded = true; // used to prevent loading apm scripts multiple times. | ||
|
||
Countly.features = [featureEnums.APM, featureEnums.ATTRIBUTION, featureEnums.CLICKS, featureEnums.CRASHES, featureEnums.EVENTS, featureEnums.FEEDBACK, featureEnums.FORMS, featureEnums.LOCATION, featureEnums.REMOTE_CONFIG, featureEnums.SCROLLS, featureEnums.SESSIONS, featureEnums.STAR_RATING, featureEnums.USERS, featureEnums.VIEWS]; | ||
Countly.q = Countly.q || []; | ||
Countly.onload = Countly.onload || []; | ||
Countly.CountlyClass = CountlyClass; | ||
|
||
Countly.init = function (conf) { | ||
conf = conf || {}; | ||
if (Countly.loadAPMScriptsAsync && apmLibrariesNotLoaded) { | ||
apmLibrariesNotLoaded = false; | ||
initAfterLoadingAPM(conf); | ||
return; | ||
} | ||
var appKey = conf.app_key || Countly.app_key; | ||
if (!Countly.i || !Countly.i[appKey]) { | ||
var inst = new CountlyClass(conf); | ||
if (!Countly.i) { | ||
Countly.i = {}; | ||
for (var key in inst) { | ||
Countly[key] = inst[key]; | ||
} | ||
} | ||
Countly.i[appKey] = inst; | ||
} | ||
return Countly.i[appKey]; | ||
}; | ||
|
||
function initAfterLoadingAPM(conf) { | ||
// TODO: We assume we are in browser context. If browser context checks at top are removed this code should have its own check. | ||
// TODO: We already have a loadFile and loadJS functions but they are not used here. If readability would improve that way, they can also be considered here. | ||
|
||
// Create boomerang script | ||
var boomerangScript = document.createElement("script"); | ||
var countlyBoomerangScript = document.createElement("script"); | ||
|
||
// Set boomerang script attributes | ||
boomerangScript.async = true; | ||
countlyBoomerangScript.async = true; | ||
|
||
// Set boomerang script source | ||
boomerangScript.src = Countly.customSourceBoomerang || CDN.BOOMERANG_SRC; | ||
countlyBoomerangScript.src = Countly.customSourceCountlyBoomerang || CDN.CLY_BOOMERANG_SRC; | ||
|
||
// Append boomerang script to the head | ||
document.getElementsByTagName("head")[0].appendChild(boomerangScript); | ||
document.getElementsByTagName("head")[0].appendChild(countlyBoomerangScript); | ||
|
||
var boomLoaded = false; | ||
var countlyBoomLoaded = false; | ||
boomerangScript.onload = function () { | ||
boomLoaded = true; | ||
}; | ||
countlyBoomerangScript.onload = function () { | ||
countlyBoomLoaded = true; | ||
}; | ||
|
||
var timeoutCounter = 0; | ||
var intervalDuration = 50; | ||
var timeoutLimit = 1500; // TODO: Configurable? Mb with Countly.apmScriptLoadTimeout? | ||
// init Countly only after boomerang is loaded | ||
var intervalID = setInterval(function () { | ||
timeoutCounter += intervalDuration; | ||
if ((boomLoaded && countlyBoomLoaded) || (timeoutCounter >= timeoutLimit)) { | ||
if (Countly.debug) { | ||
var message = "BoomerangJS loaded:[" + boomLoaded + "], countly_boomerang loaded:[" + countlyBoomLoaded + "]."; | ||
if (boomLoaded && countlyBoomLoaded) { | ||
message = "[DEBUG] " + message; | ||
// eslint-disable-next-line no-console | ||
console.log(message); | ||
} | ||
else { | ||
message = "[WARNING] " + message + " Initializing without APM."; | ||
// eslint-disable-next-line no-console | ||
console.warn(message); | ||
} | ||
} | ||
Countly.init(conf); | ||
clearInterval(intervalID); | ||
} | ||
}, intervalDuration); | ||
} | ||
|
||
/** | ||
* Overwrite serialization function for extending SDK with encryption, etc | ||
* @param {any} value - value to serialize | ||
* @return {string} serialized value | ||
* */ | ||
Countly.serialize = function (value) { | ||
// Convert object values to JSON | ||
if (typeof value === "object") { | ||
value = JSON.stringify(value); | ||
} | ||
return value; | ||
}; | ||
|
||
/** | ||
* Overwrite deserialization function for extending SDK with encryption, etc | ||
* @param {string} data - value to deserialize | ||
* @return {varies} deserialized value | ||
* */ | ||
Countly.deserialize = function (data) { | ||
if (data === "") { // we expect string or null only. Empty sting would throw an error. | ||
return data; | ||
} | ||
// Try to parse JSON... | ||
try { | ||
data = JSON.parse(data); | ||
} | ||
catch (e) { | ||
if (checkIfLoggingIsOn()) { | ||
// eslint-disable-next-line no-console | ||
console.warn("[WARNING] [Countly] deserialize, Could not parse the file:[" + data + "], error: " + e); | ||
} | ||
} | ||
|
||
return data; | ||
}; | ||
|
||
/** | ||
* Overwrite a way to retrieve view name | ||
* @return {string} view name | ||
* */ | ||
Countly.getViewName = function () { | ||
if (!isBrowser) { | ||
return "web_worker"; | ||
} | ||
return window.location.pathname; | ||
}; | ||
|
||
/** | ||
* Overwrite a way to retrieve view url | ||
* @return {string} view url | ||
* */ | ||
Countly.getViewUrl = function () { | ||
if (!isBrowser) { | ||
return "web_worker"; | ||
} | ||
return window.location.pathname; | ||
}; | ||
|
||
/** | ||
* Overwrite a way to get search query | ||
* @return {string} view url | ||
* */ | ||
Countly.getSearchQuery = function () { | ||
if (!isBrowser) { | ||
return; | ||
} | ||
return window.location.search; | ||
}; | ||
|
||
/** | ||
* Possible device Id types are: DEVELOPER_SUPPLIED, SDK_GENERATED, TEMPORARY_ID | ||
* @enum DeviceIdType | ||
* */ | ||
Countly.DeviceIdType = { | ||
DEVELOPER_SUPPLIED: DeviceIdTypeInternalEnums.DEVELOPER_SUPPLIED, | ||
SDK_GENERATED: DeviceIdTypeInternalEnums.SDK_GENERATED, | ||
TEMPORARY_ID: DeviceIdTypeInternalEnums.TEMPORARY_ID | ||
}; | ||
|
||
/** | ||
* Monitor parallel storage changes like other opened tabs | ||
*/ | ||
if (isBrowser) { | ||
window.addEventListener("storage", function (e) { | ||
var parts = (e.key + "").split("/"); | ||
var key = parts.pop(); | ||
var appKey = parts.pop(); | ||
if (Countly.i && Countly.i[appKey]) { | ||
Countly.i[appKey].onStorageChange(key, e.newValue); | ||
} | ||
}); | ||
} | ||
|
||
export default Countly; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2012, 2013 Countly | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,51 @@ | ||
# countly-sdk-js | ||
# Countly JavaScript SDK | ||
|
||
This repository contains the Countly JS SDK, which can be integrated into websites, web workers and web applications. The Countly JS SDK is intended to be used with [Countly Lite](https://countly.com/lite), [Countly Flex](https://countly.com/flex) [Countly Enterprise](https://countly.com/enterprise). | ||
|
||
## What is Countly? | ||
|
||
[Countly](https://countly.com) is a product analytics solution and innovation enabler that helps teams track product performance and customer journey and behavior across [mobile](https://countly.com/mobile-analytics), [web](https://countly.com/web-analytics), | ||
and [desktop](https://countly.com/desktop-analytics) applications. [Ensuring privacy by design](https://countly.com/privacy-by-design), Countly allows you to innovate and enhance your products to provide personalized and customized customer experiences, and meet key business and revenue goals. | ||
|
||
Track, measure, and take action - all without leaving Countly. | ||
|
||
* **Questions or feature requests?** [Join the Countly Community on Discord](https://discord.gg/countly) | ||
* **Looking for the Countly Server?** [Countly Server repository](https://github.com/Countly/countly-server) | ||
* **Looking for other Countly SDKs?** [An overview of all Countly SDKs for mobile, web and desktop](https://support.count.ly/hc/en-us/articles/360037236571-Downloading-and-Installing-SDKs#officially-supported-sdks) | ||
|
||
## Integrating Countly SDK in your projects | ||
|
||
This SDK supports the following features: | ||
|
||
* [Analytics](https://support.count.ly/hc/en-us/articles/4431589003545-Analytics) | ||
* [User Profiles](https://support.count.ly/hc/en-us/articles/4403281285913-User-Profiles) | ||
* [Crash Reports](https://support.count.ly/hc/en-us/articles/4404213566105-Crashes-Errors) | ||
* [A/B Testing](https://support.count.ly/hc/en-us/articles/4416496362393-A-B-Testing-) | ||
* [Performance Monitoring](https://support.count.ly/hc/en-us/articles/4734457847705-Performance) | ||
* [Feedback Widgets](https://support.count.ly/hc/en-us/articles/4652903481753-Feedback-Surveys-NPS-and-Ratings-) | ||
|
||
## Security | ||
|
||
Security is very important to us. If you discover any issue regarding security, please disclose the information responsibly by sending an email to <[email protected]> and **not by creating a GitHub issue**. | ||
|
||
## Badges | ||
|
||
If you like Countly, [why not use one of our badges](https://countly.com/brand-guidelines) and give a link back to us so others know about this wonderful platform? | ||
|
||
<a href="https://countly.com/f/badge" rel="nofollow"><img style="width:145px;height:60px" src="https://countly.com/badges/dark.svg?v2" alt="Countly - Product Analytics" /></a> | ||
|
||
```JS | ||
<a href="https://countly.com/f/badge" rel="nofollow"><img style="width:145px;height:60px" src="https://countly.com/badges/dark.svg" alt="Countly - Product Analytics" /></a> | ||
``` | ||
|
||
<a href="https://countly.com/f/badge" rel="nofollow"><img style="width:145px;height:60px" src="https://countly.com/badges/light.svg?v2" alt="Countly - Product Analytics" /></a> | ||
|
||
```JS | ||
<a href="https://countly.com/f/badge" rel="nofollow"><img style="width:145px;height:60px" src="https://countly.com/badges/light.svg" alt="Countly - Product Analytics" /></a> | ||
``` | ||
|
||
## How can I help you with your efforts? | ||
|
||
Glad you asked! For community support, feature requests, and engaging with the Countly Community, please join us at [our Discord Server](https://discord.gg/countly). We're excited to have you there! | ||
|
||
Also, we are on [Twitter](https://twitter.com/gocountly) and [LinkedIn](https://www.linkedin.com/company/countly) if you would like to keep up with Countly related updates. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Security Policy | ||
|
||
Security is very important to us. If you discover any issue regarding security, please disclose the information responsibly by sending an email to [email protected] and not by creating a GitHub issue. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { defineConfig } from "cypress"; | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
setupNodeEvents(on, config) { | ||
// implement node event listeners here | ||
}, | ||
}, | ||
userAgent: "abcd", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module.exports = { | ||
plugins: [ | ||
"cypress" | ||
], | ||
parserOptions: { | ||
ecmaVersion: 6 | ||
}, | ||
rules: { | ||
"cypress/no-assigning-return-values": "error", | ||
"cypress/no-unnecessary-waiting": "off", | ||
"cypress/assertion-before-screenshot": "warn", | ||
"cypress/unsafe-to-chain-command": "off", | ||
"cypress/no-force": "warn", | ||
"cypress/no-async-tests": "error", | ||
"cypress/no-pause": "error", | ||
"comma-dangle": ["error", "never"], | ||
"no-multiple-empty-lines": [2, { max: 1, maxEOF: 0 }] | ||
}, | ||
env: { | ||
"cypress/globals": true | ||
}, | ||
extends: [ | ||
"plugin:cypress/recommended", | ||
"plugin:chai-friendly/recommended" | ||
] | ||
}; |
Oops, something went wrong.