{
  "name": "@snowplow/tracker-core",
  "version": "3.23.1",
  "description": "Core functionality for Snowplow JavaScript trackers",
  "keywords": [
    "tracking",
    "web analytics",
    "events",
    "open source"
  ],
  "homepage": "http://bit.ly/sp-js",
  "bugs": "https://github.com/snowplow/snowplow-javascript-tracker/issues",
  "repository": {
    "type": "git",
    "url": "https://github.com/snowplow/snowplow-javascript-tracker.git"
  },
  "license": "BSD-3-Clause",
  "contributors": [
    "Alex Dean",
    "Simon Andersson",
    "Fred Blundun",
    "Paul Boocock"
  ],
  "sideEffects": false,
  "main": "./dist/index.js",
  "umd:main": "./dist/index.js",
  "jsdelivr": "./dist/index.umd.js",
  "unpkg": "./dist/index.umd.js",
  "module": "./dist/index.module.js",
  "types": "./dist/index.module.d.ts",
  "files": [
    "dist"
  ],
  "ava": {
    "extensions": [
      "ts"
    ],
    "require": [
      "ts-node/register"
    ]
  },
  "dependencies": {
    "tslib": "^2.3.1",
    "uuid": "^3.4.0"
  },
  "devDependencies": {
    "@ampproject/rollup-plugin-closure-compiler": "~0.27.0",
    "@rollup/plugin-commonjs": "~21.0.2",
    "@rollup/plugin-json": "~4.1.0",
    "@rollup/plugin-node-resolve": "~13.1.3",
    "@types/node": "~14.6.0",
    "@types/uuid": "~3.4.6",
    "@typescript-eslint/eslint-plugin": "~5.15.0",
    "@typescript-eslint/parser": "~5.15.0",
    "ava": "~4.1.0",
    "eslint": "~8.11.0",
    "jest-standard-reporter": "~2.0.0",
    "rollup": "~2.70.1",
    "rollup-plugin-cleanup": "~3.2.1",
    "rollup-plugin-license": "~2.6.1",
    "rollup-plugin-terser": "~7.0.2",
    "rollup-plugin-ts": "~2.0.5",
    "ts-node": "~10.9.1",
    "typescript": "~4.6.2"
  },
  "scripts": {
    "build": "rollup -c --silent --failAfterWarnings",
    "test": "ava"
  },
  "readme": "# Snowplow Tracker Core\n\n[![npm version][npm-image]][npm-url]\n[![License][license-image]](LICENSE)\n\nCore module to be used by Snowplow JavaScript based trackers.\n\n## Maintainer quick start\n\nPart of the Snowplow JavaScript Tracker monorepo.  \nBuild with [Node.js](https://nodejs.org/en/) (14 or 16) and [Rush](https://rushjs.io/).\n\n### Setup repository\n\n```bash\nnpm install -g @microsoft/rush \ngit clone https://github.com/snowplow/snowplow-javascript-tracker.git\nrush update\n```\n\n### Building Tracker Core\n\n```bash\ncd libraries/tracker-core\nrushx build\n```\n\n### Running tests\n\n```bash\nrushx test\n```\n\n## Package Installation\n\nWith npm:\n\n```bash\nnpm install @snowplow/tracker-core\n```\n\n## Usage\n\n### CommonJS Example\n\n```js\nconst trackerCore = require('@snowplow/tracker-core').trackerCore;\n\n// Create an instance with base 64 encoding set to false (it defaults to true)\nconst core = trackerCore({\n    base64: false\n});\n```\n\n### ES Module Example\n\n```js\nimport { trackerCore } from '@snowplow/tracker-core';\n\n// Create an instance with base 64 encoding set to false (it defaults to true)\nconst core = trackerCore({\n    base64: false\n})\n```\n\n### Example\n\n```js\n// Add a name-value pair to all payloads\ncore.addPayloadPair('vid', 2);\n\n// Add each name-value pair in a dictionary to all payloads\ncore.addPayloadDict({\n    'ds': '1160x620',\n    'fp': 4070134789\n});\n\n// Add name-value pairs to all payloads using convenience methods\ncore.setTrackerVersion('js-3.6.0');\ncore.setPlatform('web');\ncore.setUserId('user-321');\ncore.setColorDepth('24');\ncore.setViewport('600', '400');\ncore.setUseragent('Snowplow/0.0.1');\n\n// Track a page view with URL and title\nconst pageViewPayload = core.track(\n    buildPageView({\n        pageUrl: 'http://www.example.com',\n        pageTitle: 'landing page',\n    })\n);\n\nconsole.log(pageViewPayload);\n/*\n{\n    'e': 'pv',\n    'url': 'http://www.example.com',\n    'page': 'landing page',\n    'uid': 'user-321',\n    'vid': 2,\n    'ds': '1160x620',\n    'fp': 4070134789,\n    'tv': 'js-3.6.0',\n    'p': 'web',\n    'cd': '24',\n    'vp': '600x400',\n    'ua': 'Snowplow/0.0.1',\n    'dtm': '1406879959702',                          // timestamp\n    'eid': 'cd39f493-dd3c-4838-b096-6e6f31015409'    // UUID\n}\n*/\n\n// Stop automatically adding tv, p, and dtm to the payload.\ncore.resetPayloadPairs({});\n\n// Track an unstructured event\nconst selfDescribingEventPayload = core.track(\n    buildSelfDescribingEvent({\n        event: {\n            'schema': 'iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-0',\n            'data': {\n                'targetUrl': 'http://www.destination.com',\n                'elementId': 'bannerLink'\n            }\n        }\n    })\n);\n\nconsole.log(selfDescribingEventPayload);\n/*\n{\n    'e': 'ue',\n    'eid': '4ed5da6b-7fff-4f24-a8a9-21bc749881c6',\n    'dtm': '1659086693634',\n    'ue_pr': \"{\\\"schema\\\":\\\"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0\\\",\\\"data\\\":{\\\"schema\\\":\\\"iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-0\\\",\\\"data\\\":{\\\"targetUrl\\\":\\\"http://www.destination.com\\\",\\\"elementId\\\":\\\"bannerLink\\\"}}}\"\n}\n*/\n```\n\n## Other features\n\nCore instances can be initialized with a configuration object. `base64` Determines whether custom contexts and unstructured events will be base 64 encoded.  `corePlugins` are used to intercept payload creation and add contexts on every event. `callback` is an optional callback function which gets applied to every payload created by the instance.\n\n```js\nconst core = trackerCore({\n    base64: true,\n    corePlugins: [/* Your plugins here*/],\n    callback: console.log\n});\n```\n\nThe above example would base 64 encode all unstructured events and custom contexts and would log each payload to the console.\n\nUse the `setBase64Encoding` method to turn base 64 encoding on or off after initializing a core instance:\n\n```js\nconst core = trackerCore(); // Base 64 encoding on by default\n\ncore.setBase64Encoding(false); // Base 64 encoding is now off\n```\n\n## Documentation\n\nFor more information on the Snowplow JavaScript Tracker Core's API, view its [docs page][docs].\n\n## Copyright and license\n\nLicensed and distributed under the [BSD 3-Clause License](LICENSE) ([An OSI Approved License][osi]).\n\nCopyright (c) 2022 Snowplow Analytics Ltd, 2010 Anthon Pang.\n\nAll rights reserved.\n\n[npm-url]: https://www.npmjs.com/package/@snowplow/tracker-core\n[npm-image]: https://img.shields.io/npm/v/@snowplow/tracker-core\n[docs]: https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/node-js-tracker/javascript-tracker-core/\n[osi]: https://opensource.org/licenses/BSD-3-Clause\n[license-image]: https://img.shields.io/npm/l/@snowplow/tracker-core\n"
}