javascript - Firebase Functions - Missing events logging after third request - Stack Overflow

Currently we have a Firebase function responsible to listen for ‘xyz_event’.When this event is sent fr

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));

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745602494a4635482.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信