This repository has been archived by the owner on Dec 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #993 from Shinsina/track-route-components
Add tracking components for User and Static Routes
- Loading branch information
Showing
3 changed files
with
48 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
20 changes: 20 additions & 0 deletions
20
packages/marko-web-p1-events/components/track-static-route-view.marko
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,20 @@ | ||
import ns from "../utils/create-namespace"; | ||
|
||
$ const { site } = out.global; | ||
$ const { path } = input; | ||
$ const config = site.getAsObject("p1events"); | ||
|
||
<if(config.enabled)> | ||
$ const entity = { | ||
id: path.replace(/^\//, ""), | ||
ns: ns("static-route"), | ||
}; | ||
$ const data = { | ||
action: 'View', | ||
category: 'Static Route', | ||
entity, | ||
}; | ||
<script> | ||
p1events('track', ${JSON.stringify(data)}); | ||
</script> | ||
</if> |
20 changes: 20 additions & 0 deletions
20
packages/marko-web-p1-events/components/track-user-route-view.marko
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,20 @@ | ||
import ns from "../utils/create-namespace"; | ||
|
||
$ const { site } = out.global; | ||
$ const { path } = input; | ||
$ const config = site.getAsObject("p1events"); | ||
|
||
<if(config.enabled)> | ||
$ const entity = { | ||
id: path.replace(/^\//, ""), | ||
ns: ns("user-route"), | ||
}; | ||
$ const data = { | ||
action: 'View', | ||
category: 'User Route', | ||
entity, | ||
}; | ||
<script> | ||
p1events('track', ${JSON.stringify(data)}); | ||
</script> | ||
</if> |