You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* Optional, adds alarms and dashboards but also raises the cost */
75
+
observability: {
76
+
dashboard: true,
77
+
alarms: {
78
+
alarmTopic,
79
+
alarmTypes: AllAlarmTypes
80
+
},
73
81
}
74
82
});
75
83
@@ -96,13 +104,35 @@ Quick option rundown:
96
104
create the DNS records in the specified Route53 hosted zone. If not specified, it uses the default autogenerated
97
105
CloudFront(`cloudfront.net`) and Cognito(`auth.us-east-1.amazoncognito.com`) domains. You can read the website URL
98
106
from the stack output.
107
+
-`observability`: Adds a CloudWatch Dashboard and Alarms if specified.
99
108
100
109
For a full list of options see the [API.md](https://github.com/rehanvdm/serverless-website-analytics/blob/main/docs/API.md#api-reference-) docs.
101
110
102
111
You can see an example implementation of the demo site [here](https://github.com/rehanvdm/serverless-website-analytics-test)
103
112
104
113
### Client side setup
105
114
115
+
There are **two ways to use the client**:
116
+
-**Standalone import script** - Single line, standard JS script in your HTML.
117
+
-**SDK client** - Import the SDK client into your project and use in any SPA.
118
+
119
+
#### Standalone Import Script Usage
120
+
121
+
Then include the standalone script in your HTML:
122
+
```html
123
+
<htmllang="en">
124
+
<head> ... </head>
125
+
<body>
126
+
...
127
+
<scriptsrc="<YOUR BACKEND ORIGIN>/cdn/client-script.js"site="<THE SITE YOU ARE TRACKING>"></script>
128
+
</body>
129
+
</html>
130
+
```
131
+
132
+
See the [client-side library](https://www.npmjs.com/package/serverless-website-analytics-client) for more options.
133
+
134
+
#### SDK Client Usage
135
+
106
136
Install the [client-side library](https://www.npmjs.com/package/serverless-website-analytics-client):
107
137
```
108
138
npm install serverless-website-analytics-client
@@ -116,7 +146,7 @@ Irrelevant of the framework, you have to do the following to track page views on
116
146
2. On each route change call the `analyticsPageChange` function with the name of the new page.
117
147
118
148
The following sections show you how to do it in Vue, see [the readme of the client](https://github.com/rehanvdm/serverless-website-analytics-client-development#usage)
119
-
for various framework setups.
149
+
for React and Svelte usage, but again the SDK allows for usage in **ANY framework**.
120
150
121
151
#### Vue
122
152
@@ -141,6 +171,8 @@ router.afterEach((event) => {
141
171
app.mount('#app');
142
172
```
143
173
174
+
..Any other framework
175
+
144
176
## What's in the box
145
177
146
178
The architecture consists of four components: frontend, backend, ingestion API and the client JS library.
/* Optional, adds alarms and dashboards but also raises the cost */
75
+
observability: {
76
+
dashboard: true,
77
+
alarms: {
78
+
alarmTopic,
79
+
alarmTypes: AllAlarmTypes
80
+
},
73
81
}
74
82
});
75
83
@@ -96,13 +104,35 @@ Quick option rundown:
96
104
create the DNS records in the specified Route53 hosted zone. If not specified, it uses the default autogenerated
97
105
CloudFront(`cloudfront.net`) and Cognito(`auth.us-east-1.amazoncognito.com`) domains. You can read the website URL
98
106
from the stack output.
107
+
-`observability`: Adds a CloudWatch Dashboard and Alarms if specified.
99
108
100
109
For a full list of options see the [API.md](https://github.com/rehanvdm/serverless-website-analytics/blob/main/docs/API.md#api-reference-) docs.
101
110
102
111
You can see an example implementation of the demo site [here](https://github.com/rehanvdm/serverless-website-analytics-test)
103
112
104
113
### Client side setup
105
114
115
+
There are **two ways to use the client**:
116
+
-**Standalone import script** - Single line, standard JS script in your HTML.
117
+
-**SDK client** - Import the SDK client into your project and use in any SPA.
118
+
119
+
#### Standalone Import Script Usage
120
+
121
+
Then include the standalone script in your HTML:
122
+
```html
123
+
<htmllang="en">
124
+
<head> ... </head>
125
+
<body>
126
+
...
127
+
<scriptsrc="<YOUR BACKEND ORIGIN>/cdn/client-script.js"site="<THE SITE YOU ARE TRACKING>"></script>
128
+
</body>
129
+
</html>
130
+
```
131
+
132
+
See the [client-side library](https://www.npmjs.com/package/serverless-website-analytics-client) for more options.
133
+
134
+
#### SDK Client Usage
135
+
106
136
Install the [client-side library](https://www.npmjs.com/package/serverless-website-analytics-client):
107
137
```
108
138
npm install serverless-website-analytics-client
@@ -116,7 +146,7 @@ Irrelevant of the framework, you have to do the following to track page views on
116
146
2. On each route change call the `analyticsPageChange` function with the name of the new page.
117
147
118
148
The following sections show you how to do it in Vue, see [the readme of the client](https://github.com/rehanvdm/serverless-website-analytics-client-development#usage)
119
-
for various framework setups.
149
+
for React and Svelte usage, but again the SDK allows for usage in **ANY framework**.
120
150
121
151
#### Vue
122
152
@@ -141,6 +171,8 @@ router.afterEach((event) => {
141
171
app.mount('#app');
142
172
```
143
173
174
+
..Any other framework
175
+
144
176
## What's in the box
145
177
146
178
The architecture consists of four components: frontend, backend, ingestion API and the client JS library.
0 commit comments