@drevops/axel 0.1.1 → 0.3.0
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/README.md +52 -11
- package/package.json +9 -7
- /package/{build → dist}/axel.drupal.gtag.js +0 -0
- /package/{build → dist}/axel.drupal.gtag.min.js +0 -0
- /package/{build → dist}/axel.drupal.gtm.js +0 -0
- /package/{build → dist}/axel.drupal.gtm.min.js +0 -0
- /package/{build → dist}/axel.drupal.js +0 -0
- /package/{build → dist}/axel.drupal.min.js +0 -0
- /package/{build → dist}/axel.esm.js +0 -0
- /package/{build → dist}/axel.gtag.js +0 -0
- /package/{build → dist}/axel.gtag.min.js +0 -0
- /package/{build → dist}/axel.gtm.js +0 -0
- /package/{build → dist}/axel.gtm.min.js +0 -0
- /package/{build → dist}/axel.js +0 -0
- /package/{build → dist}/axel.min.js +0 -0
package/README.md
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|

|
|
17
17
|

|
|
18
18
|
[](https://scorecard.dev/viewer/?uri=github.com/drevops/axel)
|
|
19
|
+
[](https://www.npmjs.com/package/@drevops/axel)
|
|
20
|
+
[](https://www.jsdelivr.com/package/npm/@drevops/axel)
|
|
19
21
|
|
|
20
22
|
</div>
|
|
21
23
|
|
|
@@ -164,7 +166,7 @@ Enhanced Measurement covers events Axel doesn't send, such as scrolls, site sear
|
|
|
164
166
|
|
|
165
167
|
## 📦 Installation
|
|
166
168
|
|
|
167
|
-
|
|
169
|
+
Axel ships 1 ready-made bundle per setup. Pick the bundle that matches how your site starts scripts and where your events go:
|
|
168
170
|
|
|
169
171
|
| Bundle | Starts | Sends events to |
|
|
170
172
|
|-------------------------|------------------------------------------|--------------------------------------------------|
|
|
@@ -178,41 +180,80 @@ Every [release](https://github.com/drevops/axel/releases/latest) attaches 1 read
|
|
|
178
180
|
|
|
179
181
|
Each bundle also comes minified, such as `axel.gtm.min.js`. A bundle holds only its own adapter, so `axel.gtm.min.js` carries no Google tag code.
|
|
180
182
|
|
|
181
|
-
###
|
|
183
|
+
### Where to get the bundles
|
|
182
184
|
|
|
183
|
-
|
|
185
|
+
Load the bundles from [jsDelivr](https://www.jsdelivr.com/package/npm/@drevops/axel), which serves every file of every release:
|
|
184
186
|
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
+
```text
|
|
188
|
+
https://cdn.jsdelivr.net/npm/@drevops/axel@VERSION/dist/FILE
|
|
187
189
|
```
|
|
188
190
|
|
|
189
|
-
The
|
|
191
|
+
The same files are in the `dist/` folder of the [`@drevops/axel`](https://www.npmjs.com/package/@drevops/axel) npm package, and in the assets of each [GitHub release](https://github.com/drevops/axel/releases/latest).
|
|
192
|
+
|
|
193
|
+
Pin an exact version such as `0.3.0`. A range such as `@0` or `@latest` serves a different file after the next release, so its Subresource Integrity hash stops matching and the browser blocks the script. The notes of each release list the jsDelivr URL and hash of every bundle, plus a ready-made `<script>` tag. [`SECURITY.md`](SECURITY.md#verify-a-bundle) explains how to verify a file you downloaded.
|
|
190
194
|
|
|
191
|
-
|
|
195
|
+
### Plain page
|
|
196
|
+
|
|
197
|
+
To load the bundle from jsDelivr, add it with its Subresource Integrity hash. The browser then refuses to run a file that differs from the release:
|
|
192
198
|
|
|
193
199
|
```html
|
|
194
200
|
<script
|
|
195
|
-
src="https://cdn.jsdelivr.net/npm/@drevops/axel@VERSION/
|
|
201
|
+
src="https://cdn.jsdelivr.net/npm/@drevops/axel@VERSION/dist/axel.gtm.min.js"
|
|
196
202
|
integrity="sha384-HASH"
|
|
197
203
|
crossorigin="anonymous"
|
|
198
204
|
></script>
|
|
199
205
|
```
|
|
200
206
|
|
|
201
|
-
Replace `VERSION` with a release version such as `0.
|
|
207
|
+
Replace `VERSION` with a release version such as `0.3.0`. Replace `sha384-HASH` with the bundle's hash from that release's notes.
|
|
208
|
+
|
|
209
|
+
To serve the bundle from your own site, copy it from `node_modules/@drevops/axel/dist/` after `npm install @drevops/axel`, or from the GitHub release. Then add it to your pages:
|
|
210
|
+
|
|
211
|
+
```html
|
|
212
|
+
<script src="/path/to/axel.gtm.min.js"></script>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
The script starts tracking as soon as it loads. Its listeners sit on `document`, so it can load in `<head>` before the rest of the page. To change the defaults, see [Settings](#settings).
|
|
202
216
|
|
|
203
217
|
### Drupal
|
|
204
218
|
|
|
205
|
-
|
|
219
|
+
To load the bundle from jsDelivr, define a library in your module or theme that points at the CDN, with the bundle's hash:
|
|
206
220
|
|
|
207
221
|
```yaml
|
|
208
222
|
axel:
|
|
209
223
|
js:
|
|
210
|
-
|
|
224
|
+
https://cdn.jsdelivr.net/npm/@drevops/axel@VERSION/dist/axel.drupal.gtm.min.js:
|
|
225
|
+
type: external
|
|
226
|
+
minified: true
|
|
227
|
+
attributes:
|
|
228
|
+
integrity: sha384-HASH
|
|
229
|
+
crossorigin: anonymous
|
|
211
230
|
dependencies:
|
|
212
231
|
- core/drupal
|
|
213
232
|
- core/drupalSettings
|
|
214
233
|
```
|
|
215
234
|
|
|
235
|
+
To serve the bundle from your own site instead, install it with Composer. [Asset Packagist](https://asset-packagist.org) offers npm packages as Composer packages, and `@drevops/axel` is `npm-asset/drevops--axel` there. To install it into `web/libraries`:
|
|
236
|
+
|
|
237
|
+
1. Add Asset Packagist as a repository and require the package:
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
composer config repositories.asset-packagist composer https://asset-packagist.org
|
|
241
|
+
composer require oomphinc/composer-installers-extender npm-asset/drevops--axel
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
2. In `composer.json`, add `npm-asset` to `extra.installer-types` and add `"type:npm-asset"` to the `web/libraries/{$name}` entry in `extra.installer-paths`. Then run `composer install`. The bundles land in `web/libraries/drevops--axel/dist/`.
|
|
245
|
+
|
|
246
|
+
3. Define a library in your module or theme that loads a Drupal bundle:
|
|
247
|
+
|
|
248
|
+
```yaml
|
|
249
|
+
axel:
|
|
250
|
+
js:
|
|
251
|
+
/libraries/drevops--axel/dist/axel.drupal.gtm.min.js: { minified: true }
|
|
252
|
+
dependencies:
|
|
253
|
+
- core/drupal
|
|
254
|
+
- core/drupalSettings
|
|
255
|
+
```
|
|
256
|
+
|
|
216
257
|
The bundle registers the `axel` behavior. The behavior starts tracking when it first attaches and reads its settings from `drupalSettings.axel`. Later attaches, such as after an AJAX request, change nothing.
|
|
217
258
|
|
|
218
259
|
### ES module
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drevops/axel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Turns clicks and form interactions on elements marked with data-axel-* attributes into analytics events.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -16,14 +16,16 @@
|
|
|
16
16
|
"homepage": "https://github.com/drevops/axel#readme",
|
|
17
17
|
"bugs": "https://github.com/drevops/axel/issues",
|
|
18
18
|
"type": "module",
|
|
19
|
-
"main": "
|
|
20
|
-
"module": "
|
|
19
|
+
"main": "dist/axel.esm.js",
|
|
20
|
+
"module": "dist/axel.esm.js",
|
|
21
21
|
"exports": {
|
|
22
|
-
".": "./
|
|
23
|
-
"./
|
|
22
|
+
".": "./dist/axel.esm.js",
|
|
23
|
+
"./dist/*": "./dist/*"
|
|
24
24
|
},
|
|
25
|
+
"jsdelivr": "dist/axel.gtm.min.js",
|
|
26
|
+
"unpkg": "dist/axel.gtm.min.js",
|
|
25
27
|
"files": [
|
|
26
|
-
"
|
|
28
|
+
"dist",
|
|
27
29
|
"src"
|
|
28
30
|
],
|
|
29
31
|
"publishConfig": {
|
|
@@ -42,7 +44,7 @@
|
|
|
42
44
|
"test-coverage": "vitest run --coverage",
|
|
43
45
|
"pretest-functional": "npm run build",
|
|
44
46
|
"test-functional": "playwright test",
|
|
45
|
-
"reset": "rm -Rf node_modules
|
|
47
|
+
"reset": "rm -Rf node_modules dist .logs"
|
|
46
48
|
},
|
|
47
49
|
"engines": {
|
|
48
50
|
"npm": ">=10",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{build → dist}/axel.js
RENAMED
|
File without changes
|
|
File without changes
|