Skip to content

Commit

Permalink
Merge pull request #4 from stape-io/added-fallback-for-site-id
Browse files Browse the repository at this point in the history
  • Loading branch information
Bukashk0zzz authored Mar 22, 2024
2 parents 551cbbc + 1ef3650 commit 5e49baa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
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

0 comments on commit 5e49baa

Please sign in to comment.