Skip to content

Commit

Permalink
[DevRev]: Add event_id to streamEvent (#1721)
Browse files Browse the repository at this point in the history
* Add even_id to streamEvent

* User messageId for eventId when available
  • Loading branch information
Nandy-006 authored Nov 15, 2023
1 parent deedca7 commit 9ff5a04
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports[`Testing snapshot for Devrev's streamEvent destination action: all field
Object {
"events_list": Array [
Object {
"event_id": "sZcTM%n(kDC3tsz4iK5h",
"event_time": "2021-02-01T00:00:00.000Z",
"name": "sZcTM%n(kDC3tsz4iK5h",
"payload": Object {
Expand Down Expand Up @@ -33,6 +34,7 @@ exports[`Testing snapshot for Devrev's streamEvent destination action: required
Object {
"events_list": Array [
Object {
"event_id": "test-event-id",
"event_time": "2021-02-01T00:00:00.000Z",
"name": "sZcTM%n(kDC3tsz4iK5h",
"payload": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe('Devrev.streamEvent', () => {
events_list: [
{
name: testEventPayload.event as string,
event_id: testMessageId,
event_time: testEventPayload.timestamp as string,
payload: {
eventName: testEventPayload.event,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { generateTestData } from '../../../../lib/test-data'
import destination from '../../index'
import nock from 'nock'

jest.mock('@lukeed/uuid', () => ({
v4: jest.fn(() => 'test-event-id')
}))

const testDestination = createTestIntegration(destination)
const actionSlug = 'streamEvent'
const destinationSlug = 'Devrev'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Settings } from '../generated-types'
import type { Payload } from './generated-types'
import { TrackEventsPublishBody, devrevApiPaths, getBaseUrl } from '../utils'
import { RequestOptions } from '@segment/actions-core'
import { v4 as uuidv4 } from '@lukeed/uuid'

const action: ActionDefinition<Settings, Payload> = {
title: 'Stream Event',
Expand Down Expand Up @@ -122,6 +123,7 @@ const action: ActionDefinition<Settings, Payload> = {
{
name: eventName,
event_time: timestamp.toString(),
event_id: payload.messageId || uuidv4(),
payload: {
// add mapped data to payload
...payload,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export interface CreateAccountBody {
}

export interface TraceEvent {
event_id: string
event_time: string
name: string
payload: object
Expand Down

0 comments on commit 9ff5a04

Please sign in to comment.