> Part of the walkerOS documentation. Project overview and full index: <https://www.walkeros.io/llms.txt>

<!-- -->

[Server](#)[ ](https://github.com/elbwalker/walkerOS/tree/main/packages/server/sources/gcp)

<!-- -->

[Source code](https://github.com/elbwalker/walkerOS/tree/main/packages/server/sources/gcp)[ ](https://www.npmjs.com/package/@walkeros/server-source-gcp)

<!-- -->

[Package](https://www.npmjs.com/package/@walkeros/server-source-gcp)

# GCP Cloud Functions

Google Cloud Functions source for walkerOS. Lightweight runtime adapter with plug-and-play assignment to a Cloud Functions handler, support for the shared [event envelope](https://www.walkeros.io/docs/sources/envelope.md) including batches, a GET tracking pixel, and configurable CORS. The `@walkeros/server-source-gcp` package also ships [`sourcePubSubPull` and `sourcePubSubPush`](https://www.walkeros.io/docs/sources/server/pubsub.md) for ingesting from Pub/Sub topics; this page covers the Cloud Functions handler only.

<!-- -->

Where this fits

The GCP Cloud Functions source is a **server source** in the walkerOS flow:

It receives events via HTTP and forwards them to your destinations.

## Installation[​](#installation "Direct link to Installation")

```
npm install @walkeros/server-source-gcp @google-cloud/functions-framework
```

* Integrated
* Bundled

```
import { sourceCloudFunction } from '@walkeros/server-source-gcp';
import { startFlow } from '@walkeros/collector';
import { http } from '@google-cloud/functions-framework';

const { sources } = await startFlow({
  sources: {
    gcp: {
      code: sourceCloudFunction,
      config: {
        settings: { cors: true },
      },
    },
  },
  destinations: {
    // Your destinations
  },
});

// Plug-and-play: source.push IS the Cloud Function handler
http('walkerHandler', sources.gcp.push);
```

Add to your `flow.json` sources:

```
"sources": {
  "gcp": {
    "package": "@walkeros/server-source-gcp",
    "config": {
      "settings": {
        "cors": true,
      }
    }
  }
}
```

Server sources require platform-specific handlers. For containerized deployments, see [Docker](https://www.walkeros.io/docs/apps/docker.md).

[See bundled mode setup](https://www.walkeros.io/docs/getting-started/modes/bundled.md) | [CLI reference](https://www.walkeros.io/docs/apps/cli.md)

## Configuration[​](#configuration "Direct link to Configuration")

This <!-- -->source<!-- --> uses the standard <!-- -->source<!-- --> config wrapper (consent, data, env, id, ...). For the shared fields see [source<!-- --> configuration](https://www.walkeros.io/docs/sources.md#configuration). Package-specific fields live under `config.settings` and are listed below.

## Settings[​](#settings "Direct link to Settings")

| Property              | Type                | Description                                                                                   | More |
| --------------------- | ------------------- | --------------------------------------------------------------------------------------------- | ---- |
| `cors`                | `boolean \| object` | CORS configuration: false = disabled, true = allow all origins, object = custom configuration |      |
| `maxBatchSize`        | `integer`           | Maximum number of events accepted in a single batch request                                   |      |
| `enablePixelTracking` | `boolean`           | Serve a tracking pixel for GET requests                                                       |      |
| `timeout`             | `integer`           | Request timeout in milliseconds (max: 540000 for GCP)                                         |      |

## Mapping[​](#mapping "Direct link to Mapping")

This package does not define custom rule-level settings. For the standard rule fields (consent, condition, data, batch, name, policy) see [mapping](https://www.walkeros.io/docs/mapping.md).

## Examples

### POST with provenance

A POST body carrying a source map is forwarded in full, so release and trace provenance survive the crossing.

Event

```
{
  "method": "POST",
  "body": {
    "name": "page view",
    "data": {
      "title": "Home"
    },
    "source": {
      "release": {
        "web": "r1"
      }
    }
  },
  "headers": {
    "content-type": "application/json"
  }
}
```

Out

```
elb({
  "name": "page view",
  "data": {
    "title": "Home"
  },
  "source": {
    "release": {
      "web": "r1"
    }
  }
})
```

### Order POST

A Cloud Function HTTP POST carrying an order payload becomes a walker order complete event.

Event

```
{
  "method": "POST",
  "body": {
    "name": "order complete",
    "data": {
      "id": "ORD-700",
      "total": 99.99,
      "currency": "EUR"
    }
  },
  "headers": {
    "content-type": "application/json"
  }
}
```

Out

```
elb({
  "name": "order complete",
  "data": {
    "id": "ORD-700",
    "total": 99.99,
    "currency": "EUR"
  }
})
```

### POST event

A GCP Cloud Function HTTP POST with a JSON body becomes a single walker elb event.

Event

```
{
  "method": "POST",
  "body": {
    "name": "page view",
    "data": {
      "title": "Home",
      "url": "https://example.com/"
    }
  },
  "headers": {
    "content-type": "application/json"
  }
}
```

Out

```
elb({
  "name": "page view",
  "data": {
    "title": "Home",
    "url": "https://example.com/"
  }
})
```

## Request format[​](#request-format "Direct link to Request format")

The event name field is `name`. Every other field of the body is forwarded to the collector as-is, so `source` (carrying `release` and `trace` provenance) rides through instead of being dropped.

### Single event[​](#single-event "Direct link to Single event")

```
{
  "name": "page view",
  "data": {
    "title": "Home Page",
    "path": "/"
  }
}
```

### Batch events[​](#batch-events "Direct link to Batch events")

Send several events in one request with the shared envelope. See [Event Envelope](https://www.walkeros.io/docs/sources/envelope.md) for the accepted forms, the `maxBatchSize` cap and the 207 partial-failure response.

```
{
  "batch": [
    { "name": "page view", "data": { "title": "Page 1" } },
    { "name": "button click", "data": { "id": "btn1" } }
  ]
}
```

## Responses[​](#responses "Direct link to Responses")

| Status | Meaning                                                                                                                                      |
| ------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
| 200    | Event processed                                                                                                                              |
| 400    | Rejected client input: the pipeline declared the event invalid. The body echoes the validation message, for example `Event name is required` |
| 500    | The pipeline failed to process a valid event, or an unexpected server fault                                                                  |

Invalid input is counted on `collector.status.sources.<id>.rejected` rather than inflating `status.failed`, and is logged at warn with the reason instead of as an error with a stack trace.

## Ingest metadata[​](#ingest-metadata "Direct link to Ingest metadata")

Extract request metadata and forward it through the pipeline.

`config.ingest` must use the `map` operator. Keys are output field names; values are direct field paths on the request scope (no `req.` prefix). A bare object like `{ ip: 'ip' }` is silently inert: without the `map` operator the source passes the whole request through and no field is extracted.

```
const { sources } = await startFlow({
  sources: {
    gcp: {
      code: sourceCloudFunction,
      config: {
        settings: { cors: true },
        ingest: {
          map: {
            ip: { key: 'ip' },
            ua: { key: 'headers.user-agent' },
            origin: { key: 'headers.origin' },
          },
        },
      },
    },
  },
});
```

### Available ingest paths[​](#available-ingest-paths "Direct link to Available ingest paths")

| Path        | Description                             |
| ----------- | --------------------------------------- |
| `ip`        | Client IP address                       |
| `headers.*` | HTTP headers (user-agent, origin, etc.) |
| `method`    | HTTP method                             |
| `hostname`  | Request hostname                        |

## Pub/Sub[​](#pubsub "Direct link to Pub/Sub")

The same `@walkeros/server-source-gcp` package also exports `sourcePubSubPull` (streaming pull subscriber) and `sourcePubSubPush` (HTTP webhook handler) for ingesting events from a Pub/Sub topic. See the [Pub/Sub source page](https://www.walkeros.io/docs/sources/server/pubsub.md) for full settings, lifecycle, decoders, OIDC verification, and setup reference.
