-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor(types): add inizio types to the window * refactor(types): use DefinitelyTyped for Googletag * feat(third-party-tag): add inizio * test(inizio): add inizio test * fix(inizio): use name instead of sourcepointId * refactor(suggestion): make it hipster I cheated by changing the commit message :) Co-authored-by: Alex Sanders <[email protected]> * style(inizio): remove eslint ignores * refactor(types): include googletag in ESLint globals * chore(deps): update dependencies * refactor(inizio): looser check on matching * leave sourcepointID out of ThirdPartyTag Co-authored-by: Alex Sanders <[email protected]>
- Loading branch information
Showing
7 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { inizio } from './inizio'; | ||
|
||
describe('index', () => { | ||
it('should use the feature switch option', () => { | ||
const inizioInstance = inizio({ shouldRun: true }); | ||
expect(inizioInstance).toMatchObject({ | ||
shouldRun: true, | ||
url: | ||
'//cdn.brandmetrics.com/survey/script/e96d04c832084488a841a06b49b8fb2d.js', | ||
name: 'inizio', | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { GetThirdPartyTag } from '../types'; | ||
|
||
const onLoad = () => { | ||
const handleQuerySurveyDone = ( | ||
surveyAvailable: boolean, | ||
survey: { measurementId: string }, | ||
) => { | ||
if (surveyAvailable) { | ||
if (window && window.googletag) { | ||
window.googletag.cmd.push(() => { | ||
window.googletag.pubads().setTargeting('inizio', 't'); | ||
}); | ||
} | ||
console.log(`surveyAvailable: ${survey.measurementId}`); | ||
} | ||
}; | ||
window._brandmetrics ||= []; | ||
window._brandmetrics.push({ | ||
cmd: '_querySurvey', | ||
val: { | ||
callback: handleQuerySurveyDone, | ||
}, | ||
}); | ||
}; | ||
|
||
export const inizio: GetThirdPartyTag = ({ shouldRun }) => ({ | ||
shouldRun, | ||
url: | ||
'//cdn.brandmetrics.com/survey/script/e96d04c832084488a841a06b49b8fb2d.js', | ||
name: 'inizio', | ||
onLoad, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters