@apolitical/gtm 1.0.0-rc.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/CHANGELOG.md +14 -0
- package/README.md +60 -0
- package/build/index.js +1 -0
- package/package.json +98 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.1] - 2021-02-22
|
|
9
|
+
### Fixed
|
|
10
|
+
- Initial setup
|
|
11
|
+
|
|
12
|
+
## [0.1.0] - 2021-02-22
|
|
13
|
+
### Added
|
|
14
|
+
- Initial setup
|
package/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Apolitical GTM
|
|
2
|
+
|
|
3
|
+
Browser library to interact with Google Tag Manager (GTM)
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
Requires the following to run:
|
|
8
|
+
|
|
9
|
+
- [node.js][node] 16.13.0+
|
|
10
|
+
- [yarn][yarn]
|
|
11
|
+
|
|
12
|
+
[node]: https://nodejs.org/en/download/
|
|
13
|
+
[yarn]: https://classic.yarnpkg.com/en/docs/install
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Install with `yarn`:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
yarn add @apolitical/gtm
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Available Scripts
|
|
24
|
+
|
|
25
|
+
In the project directory, you can run:
|
|
26
|
+
### `yarn run test`
|
|
27
|
+
|
|
28
|
+
Runs the test (and the interactive mode can be enabled with `--watchAll`).
|
|
29
|
+
|
|
30
|
+
### `yarn build`
|
|
31
|
+
|
|
32
|
+
Builds the library for production to the `build` folder.
|
|
33
|
+
It correctly bundles the code on production mode and optimizes the build for the best performance.
|
|
34
|
+
|
|
35
|
+
### `yarn publish`
|
|
36
|
+
|
|
37
|
+
Publishes the library to NPM.
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
The recommended way to use `@apolitical/gtm` is to set the context with the appropriate parameters:
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
const { setContext, runExample } = require('@apolitical/gtm');
|
|
45
|
+
|
|
46
|
+
setContext({ origin: 'some-url' });
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
And then, you can query Contentful as you like:
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
runExample();
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Troubleshooting
|
|
56
|
+
|
|
57
|
+
### Usage of other libraries within your library
|
|
58
|
+
|
|
59
|
+
- Add the library as a dependency in `package.json` (effectively requiring the calling project to provide this dependency)
|
|
60
|
+
- Add the Contentful library as a dependency in `package.json`. By default, only the library code is published, meaning that the Contentful library needs to be installed separately
|
package/build/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ApoliticalGTM=t():e.ApoliticalGTM=t()}(this,(function(){return function(){"use strict";var e={d:function(t,o){for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{runExample:function(){return a},setContext:function(){return i}});const{APOLITICAL:{WEBSITES:o,ENVIRONMENTS:n}}={APOLITICAL:{WEBSITES:{BETA:"https://beta.apolitical.co",BETA_2:"https://beta-2.apolitical.co",LIVE:"https://apolitical.co",RC:"https://rc.apolitical.co"},ENVIRONMENTS:{BETA:"beta",BETA_2:"beta",RC:"rc",LIVE:"master"}}};let r={environment:null};const i=({environment:e,origin:t=null})=>{r.environment=e||(e=>{let t,r=null;switch(r="undefined"!=typeof window?window.origin||window.location.origin:e,r){case o.BETA:t=n.BETA;break;case o.BETA_2:t=n.BETA_2;break;case o.LIVE:t=n.LIVE;break;case o.RC:t=n.RC;break;default:t=n.BETA}return t})(t)},c=()=>r,a=()=>{const e=c();return console.warn(e),!0};return t}()}));
|
package/package.json
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@apolitical/gtm",
|
|
3
|
+
"version": "1.0.0-rc.0",
|
|
4
|
+
"description": "Browser library to interact with Google Tag Manager (GTM)",
|
|
5
|
+
"author": "Apolitical Group Limited <engineering@apolitical.co>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "build/index.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"build/**"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "jest --runInBand",
|
|
13
|
+
"unit-test": "jest test/unit/* --bail --runInBand --passWithNoTests",
|
|
14
|
+
"integration-test": "jest test/integration/* --bail --runInBand --passWithNoTests",
|
|
15
|
+
"build": "webpack --config webpack.config.js",
|
|
16
|
+
"lint": "eslint --ext .js ./lib",
|
|
17
|
+
"format": "prettier --write 'lib/**/*.+(js|json)'",
|
|
18
|
+
"lint-format": "lint-staged",
|
|
19
|
+
"prepare": "husky install",
|
|
20
|
+
"prepack": "yarn build"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"JavaScript",
|
|
24
|
+
"Library",
|
|
25
|
+
"Template"
|
|
26
|
+
],
|
|
27
|
+
"dependencies": {},
|
|
28
|
+
"peerDependencies": {},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@apolitical/eslint-config": "1.0.2",
|
|
31
|
+
"@babel/core": "7.16.12",
|
|
32
|
+
"@babel/eslint-parser": "7.16.5",
|
|
33
|
+
"@babel/plugin-transform-runtime": "7.16.10",
|
|
34
|
+
"@babel/preset-env": "7.16.11",
|
|
35
|
+
"husky": "7.0.4",
|
|
36
|
+
"jest": "27.4.7",
|
|
37
|
+
"jest-junit": "13.0.0",
|
|
38
|
+
"lint-staged": "12.3.2",
|
|
39
|
+
"webpack": "5.67.0",
|
|
40
|
+
"webpack-cli": "4.9.2"
|
|
41
|
+
},
|
|
42
|
+
"eslintConfig": {
|
|
43
|
+
"extends": [
|
|
44
|
+
"@apolitical/eslint-config/base.config"
|
|
45
|
+
],
|
|
46
|
+
"env": {
|
|
47
|
+
"browser": true
|
|
48
|
+
},
|
|
49
|
+
"parser": "@babel/eslint-parser"
|
|
50
|
+
},
|
|
51
|
+
"prettier": "@apolitical/eslint-config/prettier.config",
|
|
52
|
+
"browserslist": {
|
|
53
|
+
"production": [
|
|
54
|
+
">0.2%",
|
|
55
|
+
"not dead",
|
|
56
|
+
"not op_mini all",
|
|
57
|
+
"ie 11"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"jest": {
|
|
61
|
+
"bail": true,
|
|
62
|
+
"clearMocks": true,
|
|
63
|
+
"collectCoverage": true,
|
|
64
|
+
"collectCoverageFrom": [
|
|
65
|
+
"<rootDir>/lib/**/*.js"
|
|
66
|
+
],
|
|
67
|
+
"coveragePathIgnorePatterns": [
|
|
68
|
+
"<rootDir>/node_modules/"
|
|
69
|
+
],
|
|
70
|
+
"setupFiles": [
|
|
71
|
+
"./test/setupTests.js"
|
|
72
|
+
],
|
|
73
|
+
"reporters": [
|
|
74
|
+
"default",
|
|
75
|
+
"jest-junit"
|
|
76
|
+
],
|
|
77
|
+
"testResultsProcessor": "jest-junit"
|
|
78
|
+
},
|
|
79
|
+
"babel": {
|
|
80
|
+
"presets": [
|
|
81
|
+
"@babel/preset-env"
|
|
82
|
+
],
|
|
83
|
+
"env": {
|
|
84
|
+
"test": {
|
|
85
|
+
"plugins": [
|
|
86
|
+
"@babel/plugin-transform-runtime"
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"engines": {
|
|
92
|
+
"node": ">=16.13.0"
|
|
93
|
+
},
|
|
94
|
+
"lint-staged": {
|
|
95
|
+
"*.js": "eslint --cache --fix --ignore-path .gitignore",
|
|
96
|
+
"*.+(js|json)": "prettier --write --ignore-path .gitignore"
|
|
97
|
+
}
|
|
98
|
+
}
|