use toInt

This commit is contained in:
Sasha 2024-11-13 15:03:57 +07:00
parent fcddeafddd
commit 3603672d53
No known key found for this signature in database
3 changed files with 24 additions and 20 deletions

View File

@ -13,7 +13,7 @@ import { useWaku } from '@waku/react';
import { LightNode } from '@waku/sdk';
import { createMessage, encoder } from '@/lib/waku';
import { useWalletPrompt } from '@/hooks/useWalletPrompt';
import { fromLightPush, Telemetry, TelemetryType, buildExtraData } from '@/lib/telemetry';
import { fromLightPush, Telemetry, TelemetryType, buildExtraData, toInt } from '@/lib/telemetry';
interface FormData {
title: string;
@ -75,9 +75,9 @@ const ChainCreationForm: React.FC = () => {
Telemetry.push([{
type: TelemetryType.LIGHT_PUSH_FILTER,
protocol: "lightPush",
timestamp: timestamp,
createdAt: timestamp,
seenTimestamp: timestamp,
timestamp: toInt(timestamp),
createdAt: toInt(timestamp),
seenTimestamp: toInt(timestamp),
peerId: node.peerId.toString(),
contentTopic: encoder.contentTopic,
pubsubTopic: encoder.pubsubTopic,

View File

@ -182,9 +182,9 @@ export const fromFilter = (data: FromFilter): TelemetryPushFilter[] => {
telemetry.push({
type: TelemetryType.LIGHT_PUSH_FILTER,
protocol: "filter",
timestamp: data.timestamp,
createdAt: data.timestamp,
seenTimestamp: data.timestamp,
timestamp: toInt(data.timestamp),
createdAt: toInt(data.timestamp),
seenTimestamp: toInt(data.timestamp),
peerId: data.node.peerId.toString(),
contentTopic: data.decoder.contentTopic,
pubsubTopic: data.decoder.pubsubTopic,
@ -199,9 +199,9 @@ export const fromFilter = (data: FromFilter): TelemetryPushFilter[] => {
telemetry.push({
type: TelemetryType.LIGHT_PUSH_FILTER,
protocol: "filter",
timestamp: data.timestamp,
createdAt: data.timestamp,
seenTimestamp: data.timestamp,
timestamp: toInt(data.timestamp),
createdAt: toInt(data.timestamp),
seenTimestamp: toInt(data.timestamp),
peerId: fail?.peerId?.toString() || "",
contentTopic: data.decoder.contentTopic,
pubsubTopic: data.decoder.pubsubTopic,
@ -216,9 +216,9 @@ export const fromFilter = (data: FromFilter): TelemetryPushFilter[] => {
telemetry.push({
type: TelemetryType.LIGHT_PUSH_FILTER,
protocol: "filter",
timestamp: data.timestamp,
createdAt: data.timestamp,
seenTimestamp: data.timestamp,
timestamp: toInt(data.timestamp),
createdAt: toInt(data.timestamp),
seenTimestamp: toInt(data.timestamp),
peerId: success.toString(),
contentTopic: data.decoder.contentTopic,
pubsubTopic: data.decoder.pubsubTopic,
@ -243,9 +243,9 @@ export const fromStore = (data: FromStore): TelemetryPushFilter[] => {
return [{
type: TelemetryType.LIGHT_PUSH_FILTER,
protocol: "filter",
timestamp: data.timestamp,
createdAt: data.timestamp,
seenTimestamp: data.timestamp,
timestamp: toInt(data.timestamp),
createdAt: toInt(data.timestamp),
seenTimestamp: toInt(data.timestamp),
peerId: data.node.peerId.toString(),
contentTopic: data.decoder.contentTopic,
pubsubTopic: data.decoder.pubsubTopic,
@ -257,3 +257,7 @@ export const fromStore = (data: FromStore): TelemetryPushFilter[] => {
}),
}];
};
export function toInt(v: any): number {
return parseInt(v);
}

View File

@ -2,7 +2,7 @@ import { createEncoder, createDecoder, type LightNode } from "@waku/sdk";
import { type CreateWakuNodeOptions } from "@waku/sdk";
import protobuf from 'protobufjs';
import { v4 as uuidv4 } from 'uuid';
import { Telemetry, fromFilter, fromStore, TelemetryType, buildExtraData } from "./telemetry";
import { Telemetry, fromFilter, fromStore, TelemetryType, buildExtraData, toInt } from "./telemetry";
export const WAKU_NODE_OPTIONS: CreateWakuNodeOptions = {
defaultBootstrap: true,
@ -99,9 +99,9 @@ export async function* getMessagesFromStore(node: LightNode) {
Telemetry.push([{
type: TelemetryType.LIGHT_PUSH_FILTER,
protocol: "lightPush",
timestamp: startTime,
createdAt: startTime,
seenTimestamp: startTime,
timestamp: toInt(startTime),
createdAt: toInt(startTime),
seenTimestamp: toInt(startTime),
peerId: node.peerId.toString(),
contentTopic: encoder.contentTopic,
pubsubTopic: encoder.pubsubTopic,