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

Unable to let server set timestamps #916

Closed
gmhewett opened this issue Sep 11, 2024 · 1 comment
Closed

Unable to let server set timestamps #916

gmhewett opened this issue Sep 11, 2024 · 1 comment

Comments

@gmhewett
Copy link

Motivation

When working with the web SDK, it would be nice to allow the server to set the timestamps for the events. Based on the mParticle docs:

Thetimestamp_unixtime_ms represents the timestamp of event. The current server time will be used if not specified.

However, this is not currently possible with the web sdk.

Current State

From my understanding, as of now the event timestamps are set as follows in src/serverModel.ts:

First, the dateLastEventSent is set via new Date() (link):

if (event.messageType !== Types.MessageType.SessionEnd) {
    mpInstance._Store.dateLastEventSent = new Date();
}

Then, the event timestamp is set using this value (link):

uploadObject.Timestamp = mpInstance._Store.dateLastEventSent.getTime();

Because of this, manually setting timestamp_unixtime_ms in an event has no effect.

Suggested changes

The issue I have is that it's not possible to get a "ground truth" timestamp for when the event hit the server. If the user's system clock is off, then the timestamps will be off. To support this, it would be nice to have either

  1. A config option for using client-based timestamps, or
  2. The ability to manually set the timestamp_unixtime_ms value to null or undefined to ensure it's not overwritten by the SDK.

Thanks in advance for taking a look!

@alexs-mparticle
Copy link
Collaborator

alexs-mparticle commented Nov 27, 2024

Closing this ticket as workaround has been identified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants