最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin5PV0评论

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));
Post a comment

comment list (0)

  1. No comments so far