Skip to content

Commit

Permalink
Fix eventAt field
Browse files Browse the repository at this point in the history
  • Loading branch information
Bukashk0zzz committed Aug 28, 2024
1 parent 2687b47 commit 41fee6a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions template.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const parseUrl = require('parseUrl');
const decodeUriComponent = require('decodeUriComponent');
const getType = require('getType');
const getTimestampMillis = require('getTimestampMillis');
const Math = require('Math');
const makeNumber = require('makeNumber');
const makeString = require('makeString');
const encodeUriComponent = require('encodeUriComponent');
Expand Down Expand Up @@ -113,10 +112,15 @@ if (data.useOptimisticScenario) {

function mapEvent(eventData, data) {
let mappedData = {
event_type: eventType,
event_at: data.eventAt ? data.eventAt : Math.round(getTimestampMillis() / 1000)
event_type: eventType
};

if (data.eventAt) {
mappedData.event_at = data.eventAt;
} else {
mappedData.event_at_ms = getTimestampMillis();
}

if (data.clickId) {
mappedData.click_id = data.clickId;
} else if (rdtcid) {
Expand Down
10 changes: 7 additions & 3 deletions template.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ const parseUrl = require('parseUrl');
const decodeUriComponent = require('decodeUriComponent');
const getType = require('getType');
const getTimestampMillis = require('getTimestampMillis');
const Math = require('Math');
const makeNumber = require('makeNumber');
const makeString = require('makeString');
const encodeUriComponent = require('encodeUriComponent');
Expand Down Expand Up @@ -447,10 +446,15 @@ if (data.useOptimisticScenario) {

function mapEvent(eventData, data) {
let mappedData = {
event_type: eventType,
event_at: data.eventAt ? data.eventAt : Math.round(getTimestampMillis() / 1000)
event_type: eventType
};

if (data.eventAt) {
mappedData.event_at = data.eventAt;
} else {
mappedData.event_at_ms = getTimestampMillis();
}

if (data.clickId) {
mappedData.click_id = data.clickId;
} else if (rdtcid) {
Expand Down

0 comments on commit 41fee6a

Please sign in to comment.