Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fallback for site id #4

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
homepage: "https://stape.io/"
versions:
- sha: bc3ef477cb3fc0ca8d916001868312ef4cc3166d
changeNotes: Added fallback for site id.
- sha: 570e9421198fb4520e2ed3ab83f63c98e3193aa8
changeNotes: Fix permissions
- sha: 26985535c165dee99b0f4f2c6aed4ec05ca4f15a
Expand Down
10 changes: 8 additions & 2 deletions template.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if (data.type === 'page_view') {
const ranMidValue = parseUrl(url).searchParams.ranMID;
const ranEaidValue = parseUrl(url).searchParams.ranEAID;
const ranSiteIdValue = parseUrl(url).searchParams.ranSiteID;
const rakutenSiteIdValue = siteIdValue || ranSiteIdValue;

const options = {
domain: 'auto',
Expand All @@ -35,8 +36,13 @@ if (data.type === 'page_view') {
'max-age': 63072000, // 2 years
};

if (siteIdValue) {
setCookie('rakuten_site_id', makeString(siteIdValue), options, false);
if (rakutenSiteIdValue) {
setCookie(
'rakuten_site_id',
makeString(rakutenSiteIdValue),
options,
false
);
setCookie(
'rakuten_time_entered',
makeString(Math.round(getTimestampMillis() / 1000)),
Expand Down
5 changes: 3 additions & 2 deletions template.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ if (data.type === 'page_view') {
const ranMidValue = parseUrl(url).searchParams.ranMID;
const ranEaidValue = parseUrl(url).searchParams.ranEAID;
const ranSiteIdValue = parseUrl(url).searchParams.ranSiteID;
const rakutenSiteIdValue = siteIdValue || ranSiteIdValue;

const options = {
domain: 'auto',
Expand All @@ -254,8 +255,8 @@ if (data.type === 'page_view') {
'max-age': 63072000, // 2 years
};

if (siteIdValue) {
setCookie('rakuten_site_id', makeString(siteIdValue), options, false);
if (rakutenSiteIdValue) {
setCookie('rakuten_site_id', makeString(rakutenSiteIdValue), options, false);
setCookie(
'rakuten_time_entered',
makeString(Math.round(getTimestampMillis() / 1000)),
Expand Down
Loading