Currently we have a Firebase function responsible to listen for ‘xyz_event’.
When this event is sent from both Android/IOS, after the third submission we are still able to see the events (4th, 5th…) , coming on the analytics debug view. However, the event is not triggering the firebase function.
Once the function is triggered it should create a log with the payload
It just starts to trigger the function and create the logs again after 5 minutes.
Just thinking if there is a batch loading on Firebase SDK when submit the events or some setting on firebase to aggregate those events to prevent duplication.
event-functions.ts
import * as functions from 'firebase-functions';
import { Constants } from './assets/constants';
import { eventProcessor } from './event-processor';
export const screenView = functions
.runWith({
secrets: [
Constants.FUNCTIONS_SETTINGS.SECRETS.SERVICE.CLIENTKEY,
Constants.FUNCTIONS_SETTINGS.SECRETS.SERVICE.CLIENTSECRET,
],
})
.region(Constants.FUNCTIONS_SETTINGS.REGION.EUROPE)
.analytics.event('footer_click')
.onLog(async (event) => {
await eventProcessor.submitEvent(Constants.TYPE.VIEW, event);
return null;
});
event-processor.ts
import * as functions from 'firebase-functions';
import { AnalyticsEvent } from 'firebase-functions/v1/analytics';
import { buildEventRequestHandler } from './handlers/build-event-request-handler';
import { logging } from './initApp';
const log = logging.log('EventProcessor');
const METADATA = {
resource: {
type: 'cloud_function',
labels: {
function_name: 'submitEvent',
}
}
};
class EventProcessor {
public async submitEvent(eventType: string, eventPayload: AnalyticsEvent) {
const firebaseId = eventPayload?.user?.appInfo?.appInstanceId;
const user = eventPayload?.user;
const logData = {
eventType,
eventPayload
};
log.info(log.entry(METADATA, logData));
This line should create the log and after the third request it’s not being logged.
log.info(log.entry(METADATA, logData));