Skip to content

Commit

Permalink
Merge branch 'release/1.4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
m.zuccaroli committed Jun 19, 2021
2 parents 1069061 + 3265a19 commit 2751627
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 12 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [1.4.2] - 2021-06-19

### Added
- Optional CSP nonce
### Changed
### Removed

## [1.4.1] - 2021-06-05

### Added
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ You can pass _gtm_preview_ and _gtm_auth_ optional variables to your GTM by prov
{provide: 'googleTagManagerId', useValue: YOUR_GTM_ID},
{provide: 'googleTagManagerAuth', useValue: YOUR_GTM_AUTH},
{provide: 'googleTagManagerPreview', useValue: YOUR_GTM_ENV},
{provide: 'googleTagManagerResourcePath', useValue: YOUR_GTM_RESOURCE_PATH}
{provide: 'googleTagManagerResourcePath', useValue: YOUR_GTM_RESOURCE_PATH},
{provide: 'googleTagManagerCSPNonce', useValue: YOUR_CSP_NONCE}
],
```

Expand Down
4 changes: 2 additions & 2 deletions demo-application/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "demo-application",
"version": "1.4.1",
"version": "1.4.2",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand All @@ -17,7 +17,7 @@
"@angular/platform-browser": "~12.0.3",
"@angular/platform-browser-dynamic": "~12.0.3",
"@angular/router": "~12.0.3",
"angular-google-tag-manager": "^1.4.1",
"angular-google-tag-manager": "^1.4.2",
"core-js": "^2.5.4",
"rxjs": "~6.5.4",
"tslib": "^2.0.0",
Expand Down
9 changes: 5 additions & 4 deletions demo-application/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ const routes: Routes = [
// gtm_preview: YOUR_GTM_ENV
})
],
// OLD PROVIDER VERSION
// providers: [
// { provide: 'googleTagManagerId', useValue: 'GTM-PV8586C' }
// ],
providers: [
{ provide: 'googleTagManagerCSPNonce', useValue: 'CSP-NONCE' },
// OLD PROVIDER VERSION
// { provide: 'googleTagManagerId', useValue: 'GTM-PV8586C' }
],
bootstrap: [AppComponent]
})
export class AppModule { }
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-google-tag-manager",
"version": "1.4.1",
"version": "1.4.2",
"license": "MIT",
"repository": {
"type": "git",
Expand All @@ -15,7 +15,8 @@
"Jason Gravell <https://github.com/GravlLift>",
"Michael Doyle <[email protected]>",
"Mathieu Maes <[email protected]>",
"Stefano Cestari <https://github.com/stefanocestari>"
"Stefano Cestari <https://github.com/stefanocestari>",
"LE LAY Olivier <https://github.com/liollury>"
],
"scripts": {
"ng": "ng",
Expand Down
5 changes: 3 additions & 2 deletions projects/angular-google-tag-manager/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-google-tag-manager",
"version": "1.4.1",
"version": "1.4.2",
"license": "MIT",
"repository": {
"type": "git",
Expand All @@ -15,7 +15,8 @@
"Jason Gravell <https://github.com/GravlLift>",
"Michael Doyle <[email protected]>",
"Mathieu Maes <[email protected]>",
"Stefano Cestari <https://github.com/stefanocestari>"
"Stefano Cestari <https://github.com/stefanocestari>",
"LE LAY Olivier <https://github.com/liollury>"
],
"peerDependencies": {
"@angular/common": "^12.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export class GoogleTagManagerService {
public googleTagManagerPreview: string,
@Optional()
@Inject('googleTagManagerResourcePath')
public googleTagManagerResourcePath: string
public googleTagManagerResourcePath: string,
@Optional()
@Inject('googleTagManagerCSPNonce')
public googleTagManagerCSPNonce: string
) {
if (this.config == null) {
this.config = { id: null };
Expand Down Expand Up @@ -81,6 +84,9 @@ export class GoogleTagManagerService {
gtmScript.addEventListener('error', () => {
return reject(false);
});
if (this.googleTagManagerCSPNonce) {
gtmScript.setAttribute('nonce', this.googleTagManagerCSPNonce);
}
doc.head.insertBefore(gtmScript, doc.head.firstChild);
});
}
Expand Down

0 comments on commit 2751627

Please sign in to comment.