Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
leximpact-socio-fiscal-ui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
leximpact
Simulateur socio-fiscal
leximpact-socio-fiscal-ui
Commits
77a95649
Commit
77a95649
authored
Sep 18, 2023
by
Emmanuel Raviart
Browse files
Options
Downloads
Patches
Plain Diff
Don't fail when window._paq is undefined
parent
2c51f6b0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#10997
passed
Sep 18, 2023
Stage: build
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib/matomo.ts
+10
-0
10 additions, 0 deletions
src/lib/matomo.ts
src/routes/+layout.svelte
+1
-1
1 addition, 1 deletion
src/routes/+layout.svelte
with
11 additions
and
1 deletion
src/lib/matomo.ts
+
10
−
0
View file @
77a95649
...
@@ -3,6 +3,8 @@ import type { ParametricReform } from "$lib/reforms"
...
@@ -3,6 +3,8 @@ import type { ParametricReform } from "$lib/reforms"
function
trackEvent
(
category
:
string
,
action
:
string
,
name
:
string
)
{
function
trackEvent
(
category
:
string
,
action
:
string
,
name
:
string
)
{
if
(
browser
)
{
if
(
browser
)
{
// @ts-expect-error: global variable needed by Matomo.
window
.
_paq
??=
[]
// @ts-expect-error: global variable needed by Matomo.
// @ts-expect-error: global variable needed by Matomo.
const
_paq
=
window
.
_paq
const
_paq
=
window
.
_paq
_paq
.
push
([
"
trackEvent
"
,
category
,
action
,
name
])
_paq
.
push
([
"
trackEvent
"
,
category
,
action
,
name
])
...
@@ -27,6 +29,8 @@ function trackEvent(category: string, action: string, name: string) {
...
@@ -27,6 +29,8 @@ function trackEvent(category: string, action: string, name: string) {
function
trackSearch
(
query
:
string
,
category
:
string
,
resultCount
:
number
)
{
function
trackSearch
(
query
:
string
,
category
:
string
,
resultCount
:
number
)
{
if
(
browser
)
{
if
(
browser
)
{
// @ts-expect-error: global variable needed by Matomo.
window
.
_paq
??=
[]
// @ts-expect-error: global variable needed by Matomo.
// @ts-expect-error: global variable needed by Matomo.
const
_paq
=
window
.
_paq
const
_paq
=
window
.
_paq
_paq
.
push
([
_paq
.
push
([
...
@@ -42,6 +46,8 @@ function trackSearch(query: string, category: string, resultCount: number) {
...
@@ -42,6 +46,8 @@ function trackSearch(query: string, category: string, resultCount: number) {
// function trackSearchResult(category: string, resultValue: string) {
// function trackSearchResult(category: string, resultValue: string) {
// if (browser) {
// if (browser) {
// // @ts-expect-error: global variable needed by Matomo.
// // @ts-expect-error: global variable needed by Matomo.
// window._paq ??= []
// // @ts-expect-error: global variable needed by Matomo.
// const _paq = window._paq
// const _paq = window._paq
// _paq.push([
// _paq.push([
// "setCustomUrl",
// "setCustomUrl",
...
@@ -85,6 +91,8 @@ export function trackSearchVariable(
...
@@ -85,6 +91,8 @@ export function trackSearchVariable(
export
function
trackPageView
(
url
:
URL
,
prependDomain
:
boolean
|
undefined
)
{
export
function
trackPageView
(
url
:
URL
,
prependDomain
:
boolean
|
undefined
)
{
if
(
browser
)
{
if
(
browser
)
{
// @ts-expect-error: global variable needed by Matomo.
window
.
_paq
??=
[]
// @ts-expect-error: global variable needed by Matomo.
// @ts-expect-error: global variable needed by Matomo.
const
_paq
=
window
.
_paq
const
_paq
=
window
.
_paq
_paq
.
push
([
"
setCustomUrl
"
,
url
.
pathname
+
url
.
search
])
_paq
.
push
([
"
setCustomUrl
"
,
url
.
pathname
+
url
.
search
])
...
@@ -101,6 +109,8 @@ export function trackParametricReform(
...
@@ -101,6 +109,8 @@ export function trackParametricReform(
prependDomain
:
boolean
|
undefined
,
prependDomain
:
boolean
|
undefined
,
)
{
)
{
if
(
browser
)
{
if
(
browser
)
{
// @ts-expect-error: global variable needed by Matomo.
window
.
_paq
??=
[]
// @ts-expect-error: global variable needed by Matomo.
// @ts-expect-error: global variable needed by Matomo.
const
_paq
=
window
.
_paq
const
_paq
=
window
.
_paq
_paq
.
push
([
_paq
.
push
([
...
...
This diff is collapsed.
Click to expand it.
src/routes/+layout.svelte
+
1
−
1
View file @
77a95649
...
@@ -687,7 +687,7 @@
...
@@ -687,7 +687,7 @@
url
:
string
url
:
string
})
{
})
{
// @ts-expect-error: global variable needed by Matomo.
// @ts-expect-error: global variable needed by Matomo.
window
.
_paq
=
window
.
_paq
??
[]
window
.
_paq
??
=
[]
// @ts-expect-error: global variable needed by Matomo.
// @ts-expect-error: global variable needed by Matomo.
const
_paq
=
window
.
_paq
const
_paq
=
window
.
_paq
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment