countly-sdk-web 22.2.2 → 22.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +17 -17
- package/.eslintrc.js +215 -215
- package/.github/dependabot.yml +20 -20
- package/.github/workflows/codeql-analysis.yml +71 -71
- package/.github/workflows/documentation.yml +24 -0
- package/.github/workflows/node.js.yml +25 -41
- package/CHANGELOG.md +241 -237
- package/LICENSE +19 -19
- package/README.md +86 -122
- package/SECURITY.md +3 -3
- package/bower.json +29 -29
- package/cypress/.eslintrc.js +22 -22
- package/cypress/fixtures/base.html +8 -0
- package/cypress/fixtures/scroll_test.html +60 -0
- package/cypress/fixtures/scroll_test_2.html +48 -0
- package/cypress/fixtures/scroll_test_3.html +72 -0
- package/cypress/fixtures/session_test_auto.html +51 -0
- package/cypress/fixtures/session_test_manual_1.html +58 -0
- package/cypress/fixtures/session_test_manual_2.html +54 -0
- package/cypress/fixtures/user_agent.html +20 -0
- package/cypress/integration/consents.js +165 -165
- package/cypress/integration/device_id.js +1085 -830
- package/cypress/integration/events.js +65 -65
- package/cypress/integration/heatmaps.js +52 -0
- package/cypress/integration/internal_limits.js +153 -153
- package/cypress/integration/reponse_validation.js +170 -170
- package/cypress/integration/sessions.js +196 -60
- package/cypress/integration/user_agent.js +63 -0
- package/cypress/integration/user_details.js +40 -40
- package/cypress/integration/utm.js +236 -236
- package/cypress/integration/views.js +62 -62
- package/cypress/plugins/index.js +22 -22
- package/cypress/support/commands.js +322 -298
- package/cypress/support/helper.js +59 -59
- package/cypress/support/index.js +2 -2
- package/cypress/support/integration_helper.js +17 -0
- package/cypress.json +3 -1
- package/examples/example_apm.html +51 -51
- package/examples/example_fb.html +50 -50
- package/examples/example_formdata.html +47 -47
- package/examples/example_ga_adapter.html +173 -173
- package/examples/example_gdpr.html +82 -82
- package/examples/example_internal_limits.html +184 -184
- package/examples/example_multiple_instances.html +52 -52
- package/examples/example_rating_widgets.html +80 -80
- package/examples/example_remote_config.html +38 -38
- package/examples/example_sync.html +36 -36
- package/examples/examples_feedback_widgets.html +81 -81
- package/examples/mpa/boomerang/boomerang-1.0.0.js +22871 -22871
- package/examples/mpa/boomerang/countly_boomerang.js +138 -138
- package/examples/mpa/index.html +816 -816
- package/examples/react/README.md +35 -35
- package/examples/react/package.json +37 -37
- package/examples/react/public/index.html +19 -19
- package/examples/react/public/manifest.json +25 -25
- package/examples/react/public/robots.txt +3 -3
- package/examples/react/src/App-WithEffect.js +33 -33
- package/examples/react/src/App-WithRouter.js +46 -46
- package/examples/react/src/App.test.js +9 -9
- package/examples/react/src/Components/Contact.js +28 -28
- package/examples/react/src/Components/Header.js +88 -88
- package/examples/react/src/Components/Home.js +23 -23
- package/examples/react/src/Components/Users.js +43 -43
- package/examples/react/src/Components/styles.css +25 -25
- package/examples/react/src/ErrorBoundary.js +28 -28
- package/examples/react/src/Location-WithEffect.js +27 -27
- package/examples/react/src/Location-WithRouter.js +23 -23
- package/examples/react/src/index.css +5 -5
- package/examples/react/src/index.js +68 -68
- package/examples/react/src/serviceWorker.js +141 -141
- package/examples/react/src/setupTests.js +5 -5
- package/examples/symbolication/.babelrc +11 -11
- package/examples/symbolication/.editorconfig +8 -8
- package/examples/symbolication/.yo-rc.json +53 -53
- package/examples/symbolication/README.md +33 -33
- package/examples/symbolication/package.json +22 -22
- package/examples/symbolication/src/index.js +47 -47
- package/examples/symbolication/static/index.html +21 -21
- package/examples/symbolication/webpack.config.js +27 -27
- package/generateDocs.sh +80 -79
- package/inch.json +6 -6
- package/jsdoc_conf.json +4 -2
- package/lib/countly.js +4625 -4416
- package/lib/countly.min.js +126 -117
- package/package.json +57 -57
- package/plugin/boomerang/boomerang.min.js +10 -10
- package/plugin/boomerang/countly_boomerang.js +150 -150
- package/plugin/ga_adapter/doc.md +73 -73
- package/plugin/ga_adapter/ga_adapter.js +451 -451
- package/webpack.config.js +12 -12
- package/countly-sdk-web-22.2.2.tgz +0 -0
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import Users from './Users';
|
|
4
|
-
import countlyImage from './countly.jpg';
|
|
5
|
-
|
|
6
|
-
function Home() {
|
|
7
|
-
let userIndex = localStorage.getItem("clydemo-user");
|
|
8
|
-
let user = {};
|
|
9
|
-
|
|
10
|
-
if (userIndex !== undefined && userIndex !== null) {
|
|
11
|
-
user = Users[userIndex] || {};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<div>
|
|
16
|
-
<center>
|
|
17
|
-
<img src={countlyImage} alt="Home"></img>
|
|
18
|
-
<h1>Welcome {user.name}</h1>
|
|
19
|
-
</center>
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import Users from './Users';
|
|
4
|
+
import countlyImage from './countly.jpg';
|
|
5
|
+
|
|
6
|
+
function Home() {
|
|
7
|
+
let userIndex = localStorage.getItem("clydemo-user");
|
|
8
|
+
let user = {};
|
|
9
|
+
|
|
10
|
+
if (userIndex !== undefined && userIndex !== null) {
|
|
11
|
+
user = Users[userIndex] || {};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div>
|
|
16
|
+
<center>
|
|
17
|
+
<img src={countlyImage} alt="Home"></img>
|
|
18
|
+
<h1>Welcome {user.name}</h1>
|
|
19
|
+
</center>
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
24
|
export default Home;
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
const Users = [
|
|
2
|
-
{
|
|
3
|
-
"device_id": "prikshit",
|
|
4
|
-
"name": "Prikshit",
|
|
5
|
-
"username": "prikshit",
|
|
6
|
-
"email": "prikshit@cly.com",
|
|
7
|
-
"organization": "Google",
|
|
8
|
-
"phone": "+919882201994",
|
|
9
|
-
"gender": "M",
|
|
10
|
-
"byear": "1994"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"device_id": "alex",
|
|
14
|
-
"name": "Alex",
|
|
15
|
-
"username": "alex",
|
|
16
|
-
"email": "alex@cly.com",
|
|
17
|
-
"organization": "Amazom",
|
|
18
|
-
"phone": "+919882202010",
|
|
19
|
-
"gender": "M",
|
|
20
|
-
"byear": "2010"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"device_id": "hannah",
|
|
24
|
-
"name": "Hannah",
|
|
25
|
-
"username": "hannah",
|
|
26
|
-
"email": "hannah@cly.com",
|
|
27
|
-
"organization": "Facebook",
|
|
28
|
-
"phone": "+919882202000",
|
|
29
|
-
"gender": "F",
|
|
30
|
-
"byear": "2000"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"device_id": "jarvis",
|
|
34
|
-
"name": "Jarvis",
|
|
35
|
-
"username": "jarvis",
|
|
36
|
-
"email": "jarvis@cly.com",
|
|
37
|
-
"organization": "Tony Stark corp",
|
|
38
|
-
"phone": "+919882202013",
|
|
39
|
-
"gender": "F",
|
|
40
|
-
"byear": "2013"
|
|
41
|
-
},
|
|
42
|
-
];
|
|
43
|
-
|
|
1
|
+
const Users = [
|
|
2
|
+
{
|
|
3
|
+
"device_id": "prikshit",
|
|
4
|
+
"name": "Prikshit",
|
|
5
|
+
"username": "prikshit",
|
|
6
|
+
"email": "prikshit@cly.com",
|
|
7
|
+
"organization": "Google",
|
|
8
|
+
"phone": "+919882201994",
|
|
9
|
+
"gender": "M",
|
|
10
|
+
"byear": "1994"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"device_id": "alex",
|
|
14
|
+
"name": "Alex",
|
|
15
|
+
"username": "alex",
|
|
16
|
+
"email": "alex@cly.com",
|
|
17
|
+
"organization": "Amazom",
|
|
18
|
+
"phone": "+919882202010",
|
|
19
|
+
"gender": "M",
|
|
20
|
+
"byear": "2010"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"device_id": "hannah",
|
|
24
|
+
"name": "Hannah",
|
|
25
|
+
"username": "hannah",
|
|
26
|
+
"email": "hannah@cly.com",
|
|
27
|
+
"organization": "Facebook",
|
|
28
|
+
"phone": "+919882202000",
|
|
29
|
+
"gender": "F",
|
|
30
|
+
"byear": "2000"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"device_id": "jarvis",
|
|
34
|
+
"name": "Jarvis",
|
|
35
|
+
"username": "jarvis",
|
|
36
|
+
"email": "jarvis@cly.com",
|
|
37
|
+
"organization": "Tony Stark corp",
|
|
38
|
+
"phone": "+919882202013",
|
|
39
|
+
"gender": "F",
|
|
40
|
+
"byear": "2013"
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
|
|
44
44
|
export default Users;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
.link {
|
|
2
|
-
text-decoration: none;
|
|
3
|
-
padding: 20px;
|
|
4
|
-
color: #000;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.contact {
|
|
8
|
-
text-align: center;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.header {
|
|
12
|
-
width: 100%;
|
|
13
|
-
height: 100px;
|
|
14
|
-
display: flex;
|
|
15
|
-
justify-content: space-between;
|
|
16
|
-
align-items: center;
|
|
17
|
-
background-color: #cff96b;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.email-us {
|
|
21
|
-
padding: 20px;
|
|
22
|
-
font-size: 20px;
|
|
23
|
-
background-color: #cff96b;
|
|
24
|
-
border: none;
|
|
25
|
-
border-radius: 2px;
|
|
1
|
+
.link {
|
|
2
|
+
text-decoration: none;
|
|
3
|
+
padding: 20px;
|
|
4
|
+
color: #000;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.contact {
|
|
8
|
+
text-align: center;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.header {
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100px;
|
|
14
|
+
display: flex;
|
|
15
|
+
justify-content: space-between;
|
|
16
|
+
align-items: center;
|
|
17
|
+
background-color: #cff96b;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.email-us {
|
|
21
|
+
padding: 20px;
|
|
22
|
+
font-size: 20px;
|
|
23
|
+
background-color: #cff96b;
|
|
24
|
+
border: none;
|
|
25
|
+
border-radius: 2px;
|
|
26
26
|
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import Countly from "countly-sdk-web";
|
|
3
|
-
|
|
4
|
-
// Error boundaries only apply to errors that happen during rendering.
|
|
5
|
-
// So errors originating anywhere else will not trigger this mechanism.
|
|
6
|
-
// This includes errors in event handlers, and errors in async calls (e.g. setTimeout(...) and similar).
|
|
7
|
-
|
|
8
|
-
// Production and development builds of React slightly differ in the way componentDidCatch() handles errors.
|
|
9
|
-
|
|
10
|
-
// On development, the errors will bubble up to window, this means that any window.onerror or
|
|
11
|
-
// window.addEventListener('error', callback) will intercept the errors that have been caught by componentDidCatch().
|
|
12
|
-
|
|
13
|
-
// On production, instead, the errors will not bubble up, which means any ancestor error handler will
|
|
14
|
-
// only receive errors not explicitly caught by componentDidCatch().
|
|
15
|
-
|
|
16
|
-
class ErrorBoundary extends React.Component {
|
|
17
|
-
componentDidCatch(error, errorInfo) {
|
|
18
|
-
//You can provide your own segments here too.
|
|
19
|
-
let segments = {};
|
|
20
|
-
Countly.q.push(["log_error", error, segments]);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
render() {
|
|
24
|
-
return this.props.children;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default ErrorBoundary;
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Countly from "countly-sdk-web";
|
|
3
|
+
|
|
4
|
+
// Error boundaries only apply to errors that happen during rendering.
|
|
5
|
+
// So errors originating anywhere else will not trigger this mechanism.
|
|
6
|
+
// This includes errors in event handlers, and errors in async calls (e.g. setTimeout(...) and similar).
|
|
7
|
+
|
|
8
|
+
// Production and development builds of React slightly differ in the way componentDidCatch() handles errors.
|
|
9
|
+
|
|
10
|
+
// On development, the errors will bubble up to window, this means that any window.onerror or
|
|
11
|
+
// window.addEventListener('error', callback) will intercept the errors that have been caught by componentDidCatch().
|
|
12
|
+
|
|
13
|
+
// On production, instead, the errors will not bubble up, which means any ancestor error handler will
|
|
14
|
+
// only receive errors not explicitly caught by componentDidCatch().
|
|
15
|
+
|
|
16
|
+
class ErrorBoundary extends React.Component {
|
|
17
|
+
componentDidCatch(error, errorInfo) {
|
|
18
|
+
//You can provide your own segments here too.
|
|
19
|
+
let segments = {};
|
|
20
|
+
Countly.q.push(["log_error", error, segments]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
render() {
|
|
24
|
+
return this.props.children;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default ErrorBoundary;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
useLocation
|
|
4
|
-
} from "react-router-dom";
|
|
5
|
-
|
|
6
|
-
import Countly from 'countly-sdk-web';
|
|
7
|
-
|
|
8
|
-
const Location = (props) => {
|
|
9
|
-
const location = useLocation();
|
|
10
|
-
|
|
11
|
-
React.useEffect(() => {
|
|
12
|
-
//You can also check for page redirect logic or going back/forward from the browser logic here
|
|
13
|
-
//Check if pathname is not changing dont track the view
|
|
14
|
-
//So that you dont end up tracking the same view again and again
|
|
15
|
-
Countly.q.push(['track_pageview', location.pathname]);
|
|
16
|
-
// Initialize rating widget popup by current page/pathname
|
|
17
|
-
Countly.q.push(['initializeRatingWidgets']);
|
|
18
|
-
}, [location]);
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<React.Fragment>
|
|
22
|
-
{props.children}
|
|
23
|
-
</React.Fragment>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default Location;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
useLocation
|
|
4
|
+
} from "react-router-dom";
|
|
5
|
+
|
|
6
|
+
import Countly from 'countly-sdk-web';
|
|
7
|
+
|
|
8
|
+
const Location = (props) => {
|
|
9
|
+
const location = useLocation();
|
|
10
|
+
|
|
11
|
+
React.useEffect(() => {
|
|
12
|
+
//You can also check for page redirect logic or going back/forward from the browser logic here
|
|
13
|
+
//Check if pathname is not changing dont track the view
|
|
14
|
+
//So that you dont end up tracking the same view again and again
|
|
15
|
+
Countly.q.push(['track_pageview', location.pathname]);
|
|
16
|
+
// Initialize rating widget popup by current page/pathname
|
|
17
|
+
Countly.q.push(['initializeRatingWidgets']);
|
|
18
|
+
}, [location]);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<React.Fragment>
|
|
22
|
+
{props.children}
|
|
23
|
+
</React.Fragment>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default Location;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
withRouter
|
|
4
|
-
} from "react-router-dom";
|
|
5
|
-
|
|
6
|
-
import Countly from 'countly-sdk-web';
|
|
7
|
-
|
|
8
|
-
class Location extends React.Component {
|
|
9
|
-
componentDidUpdate(prevProps) {
|
|
10
|
-
if (this.props.location.pathname !== prevProps.location.pathname) {
|
|
11
|
-
Countly.q.push(["track_pageview", this.props.location.pathname]);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
render () {
|
|
16
|
-
return (
|
|
17
|
-
<React.Fragment>
|
|
18
|
-
{this.props.children}
|
|
19
|
-
</React.Fragment>
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
withRouter
|
|
4
|
+
} from "react-router-dom";
|
|
5
|
+
|
|
6
|
+
import Countly from 'countly-sdk-web';
|
|
7
|
+
|
|
8
|
+
class Location extends React.Component {
|
|
9
|
+
componentDidUpdate(prevProps) {
|
|
10
|
+
if (this.props.location.pathname !== prevProps.location.pathname) {
|
|
11
|
+
Countly.q.push(["track_pageview", this.props.location.pathname]);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
render () {
|
|
16
|
+
return (
|
|
17
|
+
<React.Fragment>
|
|
18
|
+
{this.props.children}
|
|
19
|
+
</React.Fragment>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
24
|
export default withRouter(Location);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
body {
|
|
2
|
-
margin: 0;
|
|
3
|
-
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
|
|
4
|
-
-webkit-font-smoothing: antialiased;
|
|
5
|
-
-moz-osx-font-smoothing: grayscale;
|
|
1
|
+
body {
|
|
2
|
+
margin: 0;
|
|
3
|
+
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
|
|
4
|
+
-webkit-font-smoothing: antialiased;
|
|
5
|
+
-moz-osx-font-smoothing: grayscale;
|
|
6
6
|
}
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
import './index.css';
|
|
4
|
-
import App from './App-WithEffect';
|
|
5
|
-
import * as serviceWorker from './serviceWorker';
|
|
6
|
-
import Countly from 'countly-sdk-web';
|
|
7
|
-
|
|
8
|
-
//Exposing Countly to the DOM as a global variable
|
|
9
|
-
//Usecase - Heatmaps
|
|
10
|
-
window.Countly = Countly;
|
|
11
|
-
Countly.init({
|
|
12
|
-
app_key: 'YOUR_APP_KEY',
|
|
13
|
-
url: 'YOUR_SERVER_URL',
|
|
14
|
-
session_update: 10,
|
|
15
|
-
use_session_cookie: true,
|
|
16
|
-
debug: false,
|
|
17
|
-
require_consent: true,
|
|
18
|
-
namespace: "react-demo",
|
|
19
|
-
inactivity_time: 1,
|
|
20
|
-
offline_mode: false,
|
|
21
|
-
// device_id: "cly-device-demo-id" //Set only if you want dont want to use countly generated device_id
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
//Since Countly is loaded and available, you can use synchronus or asynchronus calls, does not matter
|
|
25
|
-
Countly.q.push(['group_features', {
|
|
26
|
-
activity: ["sessions", "events", "views", "location"],
|
|
27
|
-
interaction: ["scrolls", "clicks", "crashes"],
|
|
28
|
-
whereabouts: ["users"]
|
|
29
|
-
}]);
|
|
30
|
-
|
|
31
|
-
if (typeof(localStorage) !== "undefined") {
|
|
32
|
-
var consents = localStorage.getItem("consents");
|
|
33
|
-
|
|
34
|
-
if(consents){
|
|
35
|
-
Countly.q.push(['add_consent', JSON.parse(consents)]);
|
|
36
|
-
}
|
|
37
|
-
else{
|
|
38
|
-
var consent = window.confirm("We are going to track you. Do you give your consent ?");
|
|
39
|
-
consents = ["activity", "interaction", "whereabouts"];
|
|
40
|
-
if(consent) {
|
|
41
|
-
Countly.q.push(['add_consent', consents]);
|
|
42
|
-
localStorage.setItem("consents", JSON.stringify(consents));
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
Countly.q.push(['remove_consent', consents]);
|
|
46
|
-
localStorage.removeItem("consents");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
Countly.q.push(['enableRatingWidgets', {'widgets': ['widget-id-1','widget-id-2']}]);
|
|
52
|
-
Countly.q.push(['track_sessions']);
|
|
53
|
-
Countly.q.push(['track_scrolls']);
|
|
54
|
-
Countly.q.push(['track_clicks']);
|
|
55
|
-
Countly.q.push(['track_links']);
|
|
56
|
-
Countly.q.push(["track_errors"]);
|
|
57
|
-
|
|
58
|
-
ReactDOM.render(
|
|
59
|
-
<React.StrictMode>
|
|
60
|
-
<App />
|
|
61
|
-
</React.StrictMode>,
|
|
62
|
-
document.getElementById('root')
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
// If you want your app to work offline and load faster, you can change
|
|
66
|
-
// unregister() to register() below. Note this comes with some pitfalls.
|
|
67
|
-
// Learn more about service workers: https://bit.ly/CRA-PWA
|
|
68
|
-
serviceWorker.unregister();
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import './index.css';
|
|
4
|
+
import App from './App-WithEffect';
|
|
5
|
+
import * as serviceWorker from './serviceWorker';
|
|
6
|
+
import Countly from 'countly-sdk-web';
|
|
7
|
+
|
|
8
|
+
//Exposing Countly to the DOM as a global variable
|
|
9
|
+
//Usecase - Heatmaps
|
|
10
|
+
window.Countly = Countly;
|
|
11
|
+
Countly.init({
|
|
12
|
+
app_key: 'YOUR_APP_KEY',
|
|
13
|
+
url: 'YOUR_SERVER_URL',
|
|
14
|
+
session_update: 10,
|
|
15
|
+
use_session_cookie: true,
|
|
16
|
+
debug: false,
|
|
17
|
+
require_consent: true,
|
|
18
|
+
namespace: "react-demo",
|
|
19
|
+
inactivity_time: 1,
|
|
20
|
+
offline_mode: false,
|
|
21
|
+
// device_id: "cly-device-demo-id" //Set only if you want dont want to use countly generated device_id
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
//Since Countly is loaded and available, you can use synchronus or asynchronus calls, does not matter
|
|
25
|
+
Countly.q.push(['group_features', {
|
|
26
|
+
activity: ["sessions", "events", "views", "location"],
|
|
27
|
+
interaction: ["scrolls", "clicks", "crashes"],
|
|
28
|
+
whereabouts: ["users"]
|
|
29
|
+
}]);
|
|
30
|
+
|
|
31
|
+
if (typeof(localStorage) !== "undefined") {
|
|
32
|
+
var consents = localStorage.getItem("consents");
|
|
33
|
+
|
|
34
|
+
if(consents){
|
|
35
|
+
Countly.q.push(['add_consent', JSON.parse(consents)]);
|
|
36
|
+
}
|
|
37
|
+
else{
|
|
38
|
+
var consent = window.confirm("We are going to track you. Do you give your consent ?");
|
|
39
|
+
consents = ["activity", "interaction", "whereabouts"];
|
|
40
|
+
if(consent) {
|
|
41
|
+
Countly.q.push(['add_consent', consents]);
|
|
42
|
+
localStorage.setItem("consents", JSON.stringify(consents));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
Countly.q.push(['remove_consent', consents]);
|
|
46
|
+
localStorage.removeItem("consents");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
Countly.q.push(['enableRatingWidgets', {'widgets': ['widget-id-1','widget-id-2']}]);
|
|
52
|
+
Countly.q.push(['track_sessions']);
|
|
53
|
+
Countly.q.push(['track_scrolls']);
|
|
54
|
+
Countly.q.push(['track_clicks']);
|
|
55
|
+
Countly.q.push(['track_links']);
|
|
56
|
+
Countly.q.push(["track_errors"]);
|
|
57
|
+
|
|
58
|
+
ReactDOM.render(
|
|
59
|
+
<React.StrictMode>
|
|
60
|
+
<App />
|
|
61
|
+
</React.StrictMode>,
|
|
62
|
+
document.getElementById('root')
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
// If you want your app to work offline and load faster, you can change
|
|
66
|
+
// unregister() to register() below. Note this comes with some pitfalls.
|
|
67
|
+
// Learn more about service workers: https://bit.ly/CRA-PWA
|
|
68
|
+
serviceWorker.unregister();
|