diff --git a/packages/google-cloud-serverless/src/gcpfunction/general.ts b/packages/google-cloud-serverless/src/gcpfunction/general.ts index f819bd5aaaf3..cae27ee6c2ee 100644 --- a/packages/google-cloud-serverless/src/gcpfunction/general.ts +++ b/packages/google-cloud-serverless/src/gcpfunction/general.ts @@ -29,10 +29,10 @@ export interface CloudFunctionsContext { export interface CloudEventsContext { [key: string]: any; // eslint-disable-line @typescript-eslint/no-explicit-any + id: string; + specversion: string; type?: string; - specversion?: string; source?: string; - id?: string; time?: string; schemaurl?: string; contenttype?: string; diff --git a/packages/google-cloud-serverless/test/gcpfunction/cloud_event.test.ts b/packages/google-cloud-serverless/test/gcpfunction/cloud_event.test.ts index 758b37c0253b..4d34e630814c 100644 --- a/packages/google-cloud-serverless/test/gcpfunction/cloud_event.test.ts +++ b/packages/google-cloud-serverless/test/gcpfunction/cloud_event.test.ts @@ -45,6 +45,8 @@ describe('wrapCloudEventFunction', () => { function handleCloudEvent(fn: CloudEventFunctionWithCallback): Promise { return new Promise((resolve, reject) => { const context = { + id: 'test-event-id', + specversion: '1.0', type: 'event.type', }; @@ -232,6 +234,10 @@ describe('wrapCloudEventFunction', () => { const handler: CloudEventFunction = _context => 42; const wrappedHandler = wrapCloudEventFunction(handler); await handleCloudEvent(wrappedHandler); - expect(mockScope.setContext).toBeCalledWith('gcp.function.context', { type: 'event.type' }); + expect(mockScope.setContext).toBeCalledWith('gcp.function.context', { + id: 'test-event-id', + specversion: '1.0', + type: 'event.type', + }); }); });