snowplow-tracker-core
Advanced tools
Comparing version 0.8.0 to 0.9.0-beta.1
{ | ||
"name": "snowplow-tracker-core", | ||
"version": "0.8.0", | ||
"devDependencies": { | ||
"@types/es6-shim": "0.31.34", | ||
"@types/node": "^9.6.7", | ||
"dts-generator": "^2.0.0", | ||
"grunt": "0.4.5", | ||
"grunt-ts": "5.5.1", | ||
"intern": "3.3.2", | ||
"typescript": "2.2.2" | ||
"version": "0.9.0-beta.1", | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/esm/index.js", | ||
"types": "dist/esm/index.d.ts", | ||
"scripts": { | ||
"build": "rollup -c", | ||
"dev": "rollup -c -w", | ||
"test": "ava" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"dependencies": { | ||
"@types/uuid": "^2.0.29", | ||
"lodash": "^4.17.11", | ||
"uuid": "2.0.3" | ||
"lodash": "^4.17.20", | ||
"uuid": "^3.3.3" | ||
}, | ||
"devDependencies": { | ||
"@types/lodash": "^4.14.160", | ||
"@types/node": "^14.6.0", | ||
"@types/uuid": "^3.4.6", | ||
"@typescript-eslint/eslint-plugin": "^3.10.0", | ||
"@typescript-eslint/parser": "^3.10.0", | ||
"@wessberg/rollup-plugin-ts": "^1.3.3", | ||
"ava": "^3.12.1", | ||
"eslint": "^7.7.0", | ||
"rollup": "^2.26.5", | ||
"ts-node": "^9.0.0", | ||
"tslib": "^2.0.1", | ||
"typescript": "^3.9.7" | ||
}, | ||
"contributors": [ | ||
"Alex Dean", | ||
"Simon Andersson", | ||
"Fred Blundun" | ||
"Fred Blundun", | ||
"Paul Boocock" | ||
], | ||
"types": "./main.d.ts", | ||
"description": "Core functionality for the Snowplow JavaScript trackers (browser JavaScript; Node.js; Segment.io server-side)", | ||
"description": "Core functionality for the Snowplow JavaScript trackers (Browser, Node.js)", | ||
"repository": { | ||
@@ -36,3 +51,11 @@ "type": "git", | ||
], | ||
"license": "Apache-2.0" | ||
"license": "Apache-2.0", | ||
"ava": { | ||
"extensions": [ | ||
"ts" | ||
], | ||
"require": [ | ||
"ts-node/register" | ||
] | ||
} | ||
} |
143
README.md
@@ -1,5 +0,46 @@ | ||
# Snowplow JavaScript Tracker Core [![npm version][npm-image]][npm-url] | ||
# Snowplow JavaScript Tracker Core | ||
Core module to be used by all Snowplow JavaScript trackers. | ||
[![npm version][npm-image]][npm-url] | ||
Core module to be used by Snowplow JavaScript based trackers. | ||
## Developer quickstart | ||
Can be built, tested and packed locally directly with [Node](https://nodejs.org/en/) (10+) and `npm`. | ||
Use `npm install`, `npm run build`, `npm run test` and `npm pack` | ||
Below instructions assume git and [Docker][docker-install] installed. | ||
### Clone repository | ||
```bash | ||
host$ git clone https://github.com/snowplow/snowplow-javascript-tracker.git | ||
``` | ||
### Building Tracker Core | ||
```bash | ||
host$ cd snowplow-javascript-tracker/core | ||
host$ docker build -t core . | ||
host$ docker run -v "$(pwd)":"/code" core npm run build | ||
``` | ||
### Running tests | ||
```bash | ||
host$ docker run core npm run test | ||
``` | ||
### Create NPM Package locally | ||
```bash | ||
host$ docker run -v "$(pwd)":"/code" core npm pack | ||
``` | ||
For testing, the resulting tarball `snowplow-tracker-core-x.x.x.tgz` can be installed locally into another application (such as the Snowplow JavaScript Tracker). | ||
```bash | ||
host$ npm install snowplow-tracker-core-x.x.x.tgz | ||
``` | ||
## Installation | ||
@@ -13,10 +54,23 @@ | ||
## Example | ||
### CommonJS Example | ||
```js | ||
var core = require('snowplow-tracker-core').trackerCore; | ||
const core = require('snowplow-tracker-core').trackerCore; | ||
// Create an instance with base 64 encoding set to false (it defaults to true) | ||
var coreInstance = core(false); | ||
const coreInstance = core(false); | ||
``` | ||
### ES Module Example | ||
```js | ||
import { trackerCore } from 'snowplow-tracker-core'; | ||
// Create an instance with base 64 encoding set to false (it defaults to true) | ||
const coreInstance = trackerCore(false) | ||
``` | ||
### Example | ||
```js | ||
// Add a name-value pair to all payloads | ||
@@ -27,4 +81,4 @@ coreInstance.addPayloadPair('vid', 2); | ||
coreInstance.addPayloadDict({ | ||
'ds': '1160x620', | ||
'fp': 4070134789 | ||
'ds': '1160x620', | ||
'fp': 4070134789 | ||
}); | ||
@@ -41,3 +95,3 @@ | ||
// Track a page view with URL and title | ||
var pageViewPayload = coreInstance.trackPageView('http://www.example.com', 'landing page'); | ||
const pageViewPayload = coreInstance.trackPageView('http://www.example.com', 'landing page'); | ||
@@ -47,16 +101,16 @@ console.log(pageViewPayload.build()); | ||
{ | ||
'e': 'pv', | ||
'url': 'http://www.example.com', | ||
'page': 'landing page', | ||
'uid': 'user-321', | ||
'vd': 2, | ||
'ds': '1160x620', | ||
'fp': 4070134789 | ||
'tv': 'js-3.0.0', | ||
'p': 'web', | ||
'cd': 24, | ||
'vp': '600x400', | ||
'ua': 'Snowplow/0.0.1', | ||
'dtm': 1406879959702, // timestamp | ||
'eid': '0718a85a-45dc-4f71-a949-27870442ed7d' // UUID | ||
'e': 'pv', | ||
'url': 'http://www.example.com', | ||
'page': 'landing page', | ||
'uid': 'user-321', | ||
'vd': 2, | ||
'ds': '1160x620', | ||
'fp': 4070134789 | ||
'tv': 'js-3.0.0', | ||
'p': 'web', | ||
'cd': 24, | ||
'vp': '600x400', | ||
'ua': 'Snowplow/0.0.1', | ||
'dtm': 1406879959702, // timestamp | ||
'eid': '0718a85a-45dc-4f71-a949-27870442ed7d' // UUID | ||
} | ||
@@ -69,8 +123,8 @@ */ | ||
// Track an unstructured event | ||
var unstructEventPayload = coreInstance.trackUnstructEvent({ | ||
'schema': 'iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-0', | ||
'data': { | ||
'targetUrl': 'http://www.destination.com', | ||
'elementId': 'bannerLink' | ||
} | ||
const unstructEventPayload = coreInstance.trackUnstructEvent({ | ||
'schema': 'iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-0', | ||
'data': { | ||
'targetUrl': 'http://www.destination.com', | ||
'elementId': 'bannerLink' | ||
} | ||
}); | ||
@@ -81,15 +135,15 @@ | ||
{ | ||
'e': 'ue', | ||
'ue_pr': { | ||
'schema': 'iglu:com.snowplowanalytics.snowplow/unstruct_even/jsonschema/1-0-0', | ||
'data': { | ||
'schema': 'iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-0', | ||
'data': { | ||
'targetUrl': 'http://www.destination.com', | ||
'elementId': 'bannerLink' | ||
} | ||
} | ||
}, | ||
'dtm': 1406879973439, | ||
'eid': '956c6670-cbf6-460b-9f96-143e0320fdf6' | ||
'e': 'ue', | ||
'ue_pr': { | ||
'schema': 'iglu:com.snowplowanalytics.snowplow/unstruct_even/jsonschema/1-0-0', | ||
'data': { | ||
'schema': 'iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-0', | ||
'data': { | ||
'targetUrl': 'http://www.destination.com', | ||
'elementId': 'bannerLink' | ||
} | ||
} | ||
}, | ||
'dtm': 1406879973439, | ||
'eid': '956c6670-cbf6-460b-9f96-143e0320fdf6' | ||
} | ||
@@ -104,3 +158,3 @@ */ | ||
```js | ||
var coreInstance = core(true, console.log); | ||
const coreInstance = core(true, console.log); | ||
``` | ||
@@ -113,6 +167,4 @@ | ||
```js | ||
var core = require('snowplow-tracker-core'); | ||
const coreInstance = core(); // Base 64 encoding on by default | ||
var coreInstance = core(); // Base 64 encoding on by default | ||
coreInstance.setBase64Encoding(false); // Base 64 encoding is now off | ||
@@ -143,1 +195,2 @@ ``` | ||
[wiki]: https://github.com/snowplow/snowplow/wiki/Javascript-Tracker-Core | ||
[docker-install]: https://docs.docker.com/install/ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
NPM Shrinkwrap
Supply chain riskPackage contains a shrinkwrap file. This may allow the package to bypass normal install procedures.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 3 instances in 1 package
296747
2
0
100
0
188
0
12
9
1977
1
+ Addeduuid@3.4.0(transitive)
- Removed@types/uuid@^2.0.29
- Removed@types/node@22.12.0(transitive)
- Removed@types/uuid@2.0.35(transitive)
- Removedundici-types@6.20.0(transitive)
- Removeduuid@2.0.3(transitive)
Updatedlodash@^4.17.20
Updateduuid@^3.3.3