Skip to content

Commit a23d403

Browse files
author
Robert-Jan Huijsman
authored
Remove the Analytics shim that compensated for a broken timestamp. (#144)
The backend now sends a correct timestamp, making this additional shim obsolete.
1 parent b256b17 commit a23d403

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

spec/providers/analytics.spec.input.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,15 @@ export const fullPayload = JSON.parse(`{
121121
"eventId": "1486080145623867projects/analytics-integration-fd82a/events/i_made_this_upproviders/google.firebase.analytics/eventTypes/event.sendprojects/f949d1bb9ef782579-tp/topics/cloud-functions-u54ejabpzs4prfjh7433eklhae",
122122
"eventType": "providers/google.firebase.analytics/eventTypes/event.send",
123123
"resource": "projects/analytics-integration-fd82a/events/i_made_this_up",
124-
"timestamp": "1969-12-31T23:59:59.986371388Z"
124+
"timestamp": "2017-03-29T23:59:59.986371388Z"
125125
}`);
126126

127127
// The event data that we expect would be constructed if the payload above were to arrive.
128128
export const fullEvent: Event<AnalyticsEvent> = {
129129
eventId: '1486080145623867projects/analytics-integration-fd82a/events/i_made_this_upproviders/google.firebase.analytics/eventTypes/event.sendprojects/f949d1bb9ef782579-tp/topics/cloud-functions-u54ejabpzs4prfjh7433eklhae',
130130
eventType: 'providers/google.firebase.analytics/eventTypes/event.send',
131131
resource: 'projects/analytics-integration-fd82a/events/i_made_this_up',
132-
timestamp: '2017-02-02T23:06:26.124Z',
132+
timestamp: '2017-03-29T23:59:59.986371388Z',
133133
params: {},
134134
data: {
135135
reportingDate: '20170202',

src/providers/analytics.ts

+1-15
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,9 @@ export class AnalyticsEventBuilder {
6565
const dataConstructor = (raw: Event<any>) => {
6666
return new AnalyticsEvent(raw.data);
6767
};
68-
const attemptTimestampFix = (event: Event<AnalyticsEvent>) => {
69-
// This is a temporary shim, to mask an issue in which Analytics events may carry an
70-
// incorrect Event.timestamp. Often there's a correct timestamp present in
71-
// Event.data.logTime, so until the production backend sends correct top-level timestamps
72-
// we can pull a timestamp from there.
73-
// BUG(36001921).
74-
if (event.timestamp && (event.timestamp.substr(0, 4) === '1969' || event.timestamp.substr(0, 4) === '1970')) {
75-
event.timestamp = undefined; // If we don't have a good timestamp, prefer no timestamp at all.
76-
if (event.data && event.data.logTime) {
77-
event.timestamp = event.data.logTime;
78-
}
79-
}
80-
return handler(event);
81-
};
8268
return makeCloudFunction({
8369
provider,
84-
handler: attemptTimestampFix,
70+
handler,
8571
eventType: 'event.log',
8672
resource: this.resource,
8773
dataConstructor,

0 commit comments

Comments
 (0)