---
name: native-app-configure-event-sharing
description: "Configure event sharing for a Snowflake Native App: set up event accounts per region, create event tables, add telemetry event definitions to the manifest, and query shared consumer telemetry. Triggers: event sharing, event accounts, event sharing setup, SYSTEM$SET_EVENT_SHARING_ACCOUNT_FOR_REGION, provider event table, event account region, configure event sharing, receive consumer telemetry."
parent_skill: native-app-provider
---

# Event Sharing

## When to Load

From the root `native-app` skill when user wants to:
- Set up event accounts to receive shared consumer telemetry
- Create or manage event tables in a provider event account
- Add or update telemetry event definitions in the manifest for event sharing
- Query shared events received from consumers in the provider event table
- Verify end-to-end event sharing configuration

## Guard Rails

- **Do NOT** modify telemetry levels (`log_level`, `trace_level`, `metric_level`) in the manifest — that is handled by `configure-telemetry-event-and-health-update/SKILL.md` Path A. This skill assumes those are already set or will be set separately.
- **Do NOT** add health status reporting (`SYSTEM$REPORT_HEALTH_STATUS`) — that is handled by `configure-telemetry-event-and-health-update/SKILL.md` Path C.
- **Do NOT** configure consumer-side event sharing enablement — consumers manage that themselves via Snowsight or SQL (`ALTER APPLICATION ... SET AUTHORIZE_TELEMETRY_EVENT_SHARING` and `SET SHARED TELEMETRY EVENTS`).
- **ORGADMIN role is required** for `SYSTEM$SET_EVENT_SHARING_ACCOUNT_FOR_REGION`. Check the user's available roles before running these commands.
- **Do NOT** modify setup scripts without presenting changes to the user first.

## Prerequisites

- An application package exists (or will be created via `deploy-test/SKILL.md`).
- The provider has at least one Snowflake account to use as a destination for shared events.
- The user has access to a role with ORGADMIN privileges (for event account system functions).
- Telemetry levels (`log_level`, `trace_level`) should be configured in the manifest. If not, recommend the user first load `configure-telemetry-event-and-health-update/SKILL.md` Path A.

## Workflow

```
Start → Step 1: Detect intent & confirm task list
  ├─→ Path A: Add telemetry event definitions to manifest
  ├─→ Path B: Set up event accounts per region
  ├─→ Path C: Summarize event sharing configuration
  └─→ Path D: Query shared events in provider event table
```

Multiple paths may apply. For a full setup, process paths in order (A → B → C). Path D is used after consumers have installed the app and enabled event sharing.

---

### Step 1: Detect Intent and Confirm Task List

Map the user's request to one or more paths:

- **A** — Event definitions (manifest `telemetry_event_definitions`) — "what to share", "manifest sharing"
- **B** — Event accounts (SYSTEM$ functions per region) — "event account", "per region"
- **C** — Summarize configuration — "verify", "status", "check configuration"
- **D** — Query shared events — "query events", "see consumer telemetry"
- **Full setup** / first time → **A + B + C**

Present a numbered task list of applicable paths, then **STOP** for confirmation.

---

### Path A: Add Telemetry Event Definitions to Manifest

Event definitions specify what telemetry consumers share **back to the provider**. The manifest must have `log_level` and/or `trace_level` set to a non-OFF value first (see `configure-telemetry-event-and-health-update/SKILL.md` Path A).

**Before modifying**, read the existing `manifest.yml` — if `telemetry_event_definitions` already exists, show it to the user and ask whether to keep, modify, or replace.

Add `telemetry_event_definitions` under `configuration:` in `manifest.yml`:

```yaml
configuration:
  log_level: INFO
  trace_level: OFF
  telemetry_event_definitions:
    - type: ERRORS_AND_WARNINGS
      sharing: MANDATORY
    - type: USAGE_LOGS
      sharing: OPTIONAL
```

**Load** `references/event-definitions-reference.md` for the full list of supported event definitions, sharing modes, recommendations, and SPCS limitations.

> If any event definition uses `sharing: MANDATORY`, the `CREATE APPLICATION` statement must include `AUTHORIZE_TELEMETRY_EVENT_SHARING = TRUE` or the install will fail.

**STOP**: Present the manifest changes to the user for review before writing the file.

---

### Path B: Set Up Event Accounts Per Region

A provider can collect shared events **only in the same region** where a consumer installs the app. Set up an event account in every target region.

> **Important**: If no event account and active event table exist in a region before the consumer installs, shared events are **permanently discarded**.

> **Note**: For dev mode apps, the package account is automatically used as the event account — no manual setup needed.

#### B1: Check ORGADMIN Role

Event account commands require ORGADMIN. Verify with `SELECT CURRENT_AVAILABLE_ROLES();`. **STOP** if ORGADMIN is unavailable.

#### B2: Identify Target Regions

Ask the user which regions consumers will install in (e.g., `AWS_US_WEST_2`, `AZURE_WESTUS2`) and which accounts to use as event accounts. Use `SELECT CURRENT_REGION()` and `SELECT CURRENT_ACCOUNT_NAME()` as helpers.

#### B3: Confirm Active Event Table in Each Event Account

Before setting event accounts, each target account must have an **active event table** — otherwise shared events are silently discarded. **Prompt the provider** to confirm this: in each event account, `SHOW PARAMETERS LIKE 'EVENT_TABLE' IN ACCOUNT;` should return a configured table. If not, they need to create and activate one first (standard Snowflake telemetry setup, not specific to Native Apps).

**STOP**: Do not proceed until the provider confirms.

#### B4: Set Event Accounts

Restrictions: ORGADMIN required, account must have an active event table, cannot be locked/suspended/reader/trial/managed, one event account per region (replaces previous), use account **name** not locator.

```sql
USE ROLE ORGADMIN;

SELECT SYSTEM$SET_EVENT_SHARING_ACCOUNT_FOR_REGION(
  '<snowflake_region>',   -- e.g. AWS_US_WEST_2
  '<region_group>',       -- e.g. PUBLIC
  '<account_name>'
);
```

**STOP**: Confirm regions and accounts with the user before executing.

---

### Path C: Summarize Event Sharing Configuration

After completing Paths A–B, present a routing summary to the provider.

1. **Event accounts**: `USE ROLE ORGADMIN; SELECT SYSTEM$SHOW_EVENT_SHARING_ACCOUNTS();` — present a region → account mapping.
2. **Event definitions**: `SHOW VERSIONS IN APPLICATION PACKAGE <app_pkg>;` — confirm log/trace levels are set.
3. **Event tables**: Ask the provider to confirm each event account has an active event table (`SHOW PARAMETERS LIKE 'EVENT_TABLE' IN ACCOUNT;`).

**STOP**: Present the summary and flag any gaps (missing event accounts, no active event table, telemetry levels OFF).

---

### Path D: Query Shared Events in Provider Event Table

After consumers install the app and enable event sharing (or mandatory definitions auto-enable), shared events appear in the provider's event table.

**Load** `references/shared-event-query-reference.md` for full query templates, filter fields, and privacy/redaction details.

Key filter fields for shared events:
- `RESOURCE_ATTRIBUTES:"snow.application.package.name"` — filter by your app package
- `RESOURCE_ATTRIBUTES:"snow.application.consumer.organization"` — filter by consumer org
- `RESOURCE_ATTRIBUTES:"snow.application.consumer.name"` — filter by consumer account
- `RECORD_TYPE` — `'LOG'` for log messages, `'EVENT'` for lifecycle/telemetry events

---

## Output

After completing the relevant paths, the user should have:

- `manifest.yml` with `telemetry_event_definitions` under `configuration:`
- Event accounts designated per region via `SYSTEM$SET_EVENT_SHARING_ACCOUNT_FOR_REGION`
- Active event table in each event account
- Configuration summary confirming all pieces are in place

**Key guardrails to verify**: `telemetry_event_definitions` is nested under `configuration:` (not top-level); any `sharing: MANDATORY` definition requires `AUTHORIZE_TELEMETRY_EVENT_SHARING = TRUE` on `CREATE APPLICATION`; manifest files re-uploaded to stage after changes.

**Next steps**: Publish the updated app version (`app-version-release/SKILL.md`), deploy and test (`deploy-test/SKILL.md`), or configure telemetry levels (`configure-telemetry-event-and-health-update/SKILL.md`).

To remove an event account:

```sql
USE ROLE ORGADMIN;
SELECT SYSTEM$UNSET_EVENT_SHARING_ACCOUNT_FOR_REGION('<snowflake_region>', '<region_group>', '<account_name>');
```
