Skip to content

Commit

Permalink
Merge branch 'release/2.7.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
elgorditosalsero committed Apr 28, 2023
2 parents 4de79ca + c353b4f commit 74f4f41
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 31 deletions.
19 changes: 19 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,25 @@
"code",
"doc"
]
},
{
"login": "pkulcsarnr",
"name": "pkulcsarnr",
"avatar_url": "https://avatars.githubusercontent.com/u/84968286?v=4",
"profile": "https://github.com/pkulcsarnr",
"contributions": [
"code",
"doc"
]
},
{
"login": "sin-to-jin",
"name": "sin",
"avatar_url": "https://avatars.githubusercontent.com/u/5368888?v=4",
"profile": "https://github.com/sin-to-jin",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
- name: Begin CI...
uses: actions/checkout@v2

- name: Use Node 12
- name: Use Node 16
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 16.x

- name: Use cached node_modules
uses: actions/cache@v1
Expand Down
34 changes: 19 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ You can see this lib live on the dedicated [site](https://elgorditosalsero-react
## Contributors ✨

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Expand All @@ -193,20 +193,24 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://www.linkedin.com/in/guidoporcaro/"><img src="https://avatars2.githubusercontent.com/u/65770455?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Guido Porcaro</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=elgorditosalsero" title="Code">💻</a> <a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=elgorditosalsero" title="Documentation">📖</a></td>
<td align="center"><a href="https://benyap.com"><img src="https://avatars3.githubusercontent.com/u/19235373?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ben Yap</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=benyap" title="Code">💻</a> <a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=benyap" title="Documentation">📖</a> <a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=benyap" title="Tests">⚠️</a></td>
<td align="center"><a href="https://cristianlivella.com/"><img src="https://avatars.githubusercontent.com/u/27968888?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Cristian Livella</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=cristianlivella" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/jafin"><img src="https://avatars.githubusercontent.com/u/127927?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jason Finch</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=jafin" title="Code">💻</a></td>
<td align="center"><a href="https://segredo.dev/"><img src="https://avatars.githubusercontent.com/u/11761170?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Italo</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=iaurg" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/thecoder93"><img src="https://avatars.githubusercontent.com/u/3246694?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gianluca La Manna</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=thecoder93" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/daisy1754"><img src="https://avatars.githubusercontent.com/u/980077?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kazuki</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=daisy1754" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/perfectial-stepan-mandryka"><img src="https://avatars.githubusercontent.com/u/95344107?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stepan Mandryka</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=perfectial-stepan-mandryka" title="Code">💻</a></td>
<td align="center"><a href="http://simonsmith.io/"><img src="https://avatars.githubusercontent.com/u/360703?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Simon Smith</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=simonsmith" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/listiani13"><img src="https://avatars.githubusercontent.com/u/24470609?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Listiani</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=listiani13" title="Code">💻</a> <a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=listiani13" title="Documentation">📖</a></td>
</tr>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/guidoporcaro/"><img src="https://avatars2.githubusercontent.com/u/65770455?v=4?s=100" width="100px;" alt="Guido Porcaro"/><br /><sub><b>Guido Porcaro</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=elgorditosalsero" title="Code">💻</a> <a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=elgorditosalsero" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://benyap.com"><img src="https://avatars3.githubusercontent.com/u/19235373?v=4?s=100" width="100px;" alt="Ben Yap"/><br /><sub><b>Ben Yap</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=benyap" title="Code">💻</a> <a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=benyap" title="Documentation">📖</a> <a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=benyap" title="Tests">⚠️</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://cristianlivella.com/"><img src="https://avatars.githubusercontent.com/u/27968888?v=4?s=100" width="100px;" alt="Cristian Livella"/><br /><sub><b>Cristian Livella</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=cristianlivella" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/jafin"><img src="https://avatars.githubusercontent.com/u/127927?v=4?s=100" width="100px;" alt="Jason Finch"/><br /><sub><b>Jason Finch</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=jafin" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://segredo.dev/"><img src="https://avatars.githubusercontent.com/u/11761170?v=4?s=100" width="100px;" alt="Italo"/><br /><sub><b>Italo</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=iaurg" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/thecoder93"><img src="https://avatars.githubusercontent.com/u/3246694?v=4?s=100" width="100px;" alt="Gianluca La Manna"/><br /><sub><b>Gianluca La Manna</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=thecoder93" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/daisy1754"><img src="https://avatars.githubusercontent.com/u/980077?v=4?s=100" width="100px;" alt="Kazuki"/><br /><sub><b>Kazuki</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=daisy1754" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/perfectial-stepan-mandryka"><img src="https://avatars.githubusercontent.com/u/95344107?v=4?s=100" width="100px;" alt="Stepan Mandryka"/><br /><sub><b>Stepan Mandryka</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=perfectial-stepan-mandryka" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://simonsmith.io/"><img src="https://avatars.githubusercontent.com/u/360703?v=4?s=100" width="100px;" alt="Simon Smith"/><br /><sub><b>Simon Smith</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=simonsmith" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/listiani13"><img src="https://avatars.githubusercontent.com/u/24470609?v=4?s=100" width="100px;" alt="Listiani"/><br /><sub><b>Listiani</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=listiani13" title="Code">💻</a> <a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=listiani13" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/pkulcsarnr"><img src="https://avatars.githubusercontent.com/u/84968286?v=4?s=100" width="100px;" alt="pkulcsarnr"/><br /><sub><b>pkulcsarnr</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=pkulcsarnr" title="Code">💻</a> <a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=pkulcsarnr" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sin-to-jin"><img src="https://avatars.githubusercontent.com/u/5368888?v=4?s=100" width="100px;" alt="sin"/><br /><sub><b>sin</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=sin-to-jin" title="Code">💻</a></td>
</tr>
</tbody>
</table>

<!-- markdownlint-restore -->
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"react"
],
"description": "Easily manage the Google Tag Manager via Hook",
"version": "2.7.0",
"version": "2.7.1",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/react-gtm-hook.esm.js",
Expand Down Expand Up @@ -39,6 +39,7 @@
"all-contributors-cli": "^6.20.0",
"babel-jest": "^27.5.1",
"babel-plugin-module-resolver": "^4.1.0",
"eslint-plugin-prettier": "3.4.1",
"husky": "^7.0.4",
"prettier": "^2.6.1",
"react": "^17.0.2",
Expand Down
18 changes: 16 additions & 2 deletions src/utils/GoogleTagManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ const setupGTM = (params: ISnippetsParams): ISetupGTM => {
if (params.nonce) {
script.setAttribute('nonce', params.nonce)
}
script.innerHTML = getGTMScript(params.dataLayerName, params.id, params.environment, params.customDomain, params.customScriptName)
script.innerHTML = getGTMScript(
params.dataLayerName,
params.id,
params.environment,
params.customDomain,
params.customScriptName
)
return script
}

Expand All @@ -45,7 +51,15 @@ const setupGTM = (params: ISnippetsParams): ISetupGTM => {
* @param nonce - Server-generated nonce
* @param id - The ID of the GTM
*/
export const initGTM = ({ dataLayer, dataLayerName, environment, nonce, id, customDomain, customScriptName }: ISnippetsParams): void => {
export const initGTM = ({
dataLayer,
dataLayerName,
environment,
nonce,
id,
customDomain,
customScriptName
}: ISnippetsParams): void => {
const gtm = setupGTM({
dataLayer,
dataLayerName,
Expand Down
6 changes: 3 additions & 3 deletions src/utils/snippets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ICustomEnvironmentParams, IDataLayer, ISnippets, ISnippetsParams} from '../models/GoogleTagManager'
import { ICustomEnvironmentParams, IDataLayer, ISnippets, ISnippetsParams } from '../models/GoogleTagManager'

export const DEFAULT_DOMAIN = 'https://www.googletagmanager.com'
export const DEFAULT_SCRIPT_NAME = 'gtm.js'
Expand Down Expand Up @@ -28,7 +28,7 @@ export const getIframeSnippet = (
) => {
let params = ``
if (environment) {
const {gtm_auth, gtm_preview} = environment
const { gtm_auth, gtm_preview } = environment
params = `&gtm_auth=${gtm_auth}&gtm_preview=${gtm_preview}&gtm_cookies_win=x`
}
return `<iframe src="${customDomain}/ns.html?id=${id}${params}" height="0" width="0" style="display:none;visibility:hidden" id="tag-manager"></iframe>`
Expand All @@ -51,7 +51,7 @@ export const getGTMScript = (
) => {
let params = ``
if (environment) {
const {gtm_auth, gtm_preview} = environment
const { gtm_auth, gtm_preview } = environment
params = `+"&gtm_auth=${gtm_auth}&gtm_preview=${gtm_preview}&gtm_cookies_win=x"`
}
return `
Expand Down
14 changes: 7 additions & 7 deletions test/snippets.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {DEFAULT_DOMAIN, getDataLayerSnippet, getGTMScript, getIframeSnippet} from '../src/utils/snippets'
import {ISnippetsParams} from '../src/models/GoogleTagManager'
import { DEFAULT_DOMAIN, getDataLayerSnippet, getGTMScript, getIframeSnippet } from '../src/utils/snippets'
import { ISnippetsParams } from '../src/models/GoogleTagManager'

describe('Suite of snippets functions', () => {
describe('Suite of getDataLayerSnippet', () => {
let dataLayer: Object
let dataLayerName: string

beforeEach(() => {
dataLayer = {user: 'testUser'}
dataLayer = { user: 'testUser' }
dataLayerName = 'customDataLayer'
})

Expand Down Expand Up @@ -35,12 +35,12 @@ describe('Suite of snippets functions', () => {
let params: ISnippetsParams

beforeEach(() => {
params = {id: 'GTM-custom-name'}
params = { id: 'GTM-custom-name' }
})

it('should return the script with the default dataLayerName', () => {
const customDataLayerName = 'customDL'
params = {...params, dataLayerName: customDataLayerName}
params = { ...params, dataLayerName: customDataLayerName }

const gtmSnippet = getGTMScript(params.dataLayerName, params.id)

Expand All @@ -54,7 +54,7 @@ describe('Suite of snippets functions', () => {
it('should return the script with the custom domain', () => {
const customDomain = 'https://www.example.com'
const customDataLayerName = 'customDL'
params = {...params, dataLayerName: customDataLayerName, customDomain: customDomain}
params = { ...params, dataLayerName: customDataLayerName, customDomain: customDomain }

const gtmSnippet = getGTMScript(params.dataLayerName, params.id, undefined, params.customDomain)

Expand Down Expand Up @@ -92,7 +92,7 @@ describe('Suite of snippets functions', () => {
let params: ISnippetsParams

beforeEach(() => {
params = {id: 'GTM-iframe'}
params = { id: 'GTM-iframe' }
})

it('should return the iframe snippet with the passed id', () => {
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2840,7 +2840,7 @@ eslint-plugin-jsx-a11y@^6.2.3:
object.fromentries "^2.0.6"
semver "^6.3.0"

eslint-plugin-prettier@^3.1.0:
eslint-plugin-prettier@3.4.1, eslint-plugin-prettier@^3.1.0:
version "3.4.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.4.1.tgz#e9ddb200efb6f3d05ffe83b1665a716af4a387e5"
integrity sha512-htg25EUYUeIhKHXjOinK4BgCcDwtLHjqaxCDsMy5nbnUMkKFvIhMVCp+5GFUXQ4Nr8lBsPqtGAqBenbpFqAA2g==
Expand Down

0 comments on commit 74f4f41

Please sign in to comment.