Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit a35506f

Browse files
crdgonzalezcadraffensperger
authored andcommitted
Setup InteractionTracker to log when a click occurs. (#85)
1 parent 6811634 commit a35506f

File tree

17 files changed

+2304
-280
lines changed

17 files changed

+2304
-280
lines changed

examples/user_interaction/client/package-lock.json

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

examples/user_interaction/client/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
"metrics"
1313
],
1414
"dependencies": {
15+
"@opencensus/web-all": "^0.0.2",
1516
"react": "^16.8.6",
1617
"react-dom": "^16.8.6",
1718
"react-scripts": "3.0.1",
18-
"@opencensus/web-all": "^0.0.2"
19+
"zone.js": "^0.9.1"
1920
},
2021
"scripts": {
2122
"start": "react-scripts start",

examples/user_interaction/client/src/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import React from 'react';
1818
import ReactDOM from 'react-dom';
1919
import App from './App';
2020
import { exportRootSpanAfterLoadEvent } from '@opencensus/web-all';
21+
import { startInteractionTracker } from '@opencensus/web-instrumentation-zone';
22+
23+
// Necessary import for @opencensus/web-instrumentation-zone
24+
import { Zone, ZoneType, Task } from 'zone.js';
2125

2226
ReactDOM.render(<App />, document.getElementById('root'));
2327

@@ -27,3 +31,5 @@ window.ocSampleRate = 1.0; // Sample at 100% for test only. Default is 1/10000.
2731
// Send the root span and child spans for the initial page load to the
2832
// OpenCensus agent if this request was sampled for trace.
2933
exportRootSpanAfterLoadEvent();
34+
35+
startInteractionTracker();

examples/user_interaction/server/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function handleRequest(request, response) {
7171
request.on('data', chunk => body.push(chunk));
7272

7373
// Necessary headers because the Node.js and React dev servers run in different ports.
74-
response.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000');
74+
response.setHeader('Access-Control-Allow-Origin', '*');
7575
response.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
7676
response.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
7777
response.setHeader('Access-Control-Allow-Credentials', true);

packages/opencensus-web-instrumentation-zone/package-lock.json

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

packages/opencensus-web-instrumentation-zone/package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"main": "build/src/index.js",
66
"types": "build/src/index.d.ts",
77
"scripts": {
8+
"build:prod": "webpack --config ./webpack/prod-bundles.config.js",
9+
"build:dev": "webpack --config ./webpack/dev-bundles.config.js",
810
"build": "webpack",
11+
"start:webpack-server": "webpack-dev-server --config ./webpack/dev-bundles.config.js",
912
"codecov": "codecov -f coverage/*.json",
1013
"clean": "rimraf build/*",
1114
"check": "gts check",
@@ -56,11 +59,16 @@
5659
"rimraf": "^2.6.2",
5760
"ts-loader": "^6.0.0",
5861
"typescript": "^3.1.6",
59-
"webpack": "^4.18.0",
60-
"webpack-cli": "^3.1.0"
62+
"webpack": "^4.32.2",
63+
"webpack-cli": "^3.3.2",
64+
"webpack-dev-server": "^3.4.1",
65+
"zone.js": "~0.9.1"
6166
},
6267
"dependencies": {
6368
"@opencensus/web-core": "^0.0.2"
6469
},
70+
"peerDependencies": {
71+
"zone.js": "~0.9.1"
72+
},
6573
"sideEffects": false
6674
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Entrypoints for OpenCensus Web JS Bundles
2+
3+
This folder contains the top-level entrypoints for JS script bundles for
4+
the OpenCensus Web project.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Copyright 2019, OpenCensus Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { startInteractionTracker } from '../export-initial-load';
18+
19+
startInteractionTracker();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Copyright 2019, OpenCensus Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import './export-initial-load';
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Copyright 2019, OpenCensus Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { InteractionTracker } from './interaction-tracker';
18+
19+
export function startInteractionTracker() {
20+
return new InteractionTracker();
21+
}

0 commit comments

Comments
 (0)