# lib/social-earn

> Source: https://devdocs.joy.so/joy-headless-api/sdk-reference/hydrogen/lib/social-earn/ · Last updated: 2026-11-24

## Variables

### SOCIAL_EARN_EVENT_KEYS

```ts
const SOCIAL_EARN_EVENT_KEYS: ReadonlySet<string>;
```

Client-side mirror of the 13 social earning events the Headless API's
`POST /customer/earn/social` accepts.

Kept client-side for the same "zero-import" reason `lib/program-icons.tsx`
keeps its event→icon map client-side: every card that renders these
programs already bundles this list, so there is no reason to round-trip to
the server just to ask "is this program social?". An unknown or stale key
simply degrades to the plain link `joy-ways-to-earn` rendered before this
feature existed — the server rejects anything outside the list anyway, so
drift here can only under-claim, never over-grant.

Note the Facebook follow event is `like_facebook`, NOT `follow_facebook` —
the same gotcha `program-icons.tsx` documents.

## Functions

### isLineFollowOaProgram()

```ts
function isLineFollowOaProgram(program): boolean;
```

A `join_line` program the merchant configured as `follow_oa`: LINE Login
OAuth, not a click.

Note `join_line` deliberately STAYS in [SOCIAL_EARN_EVENT_KEYS](#social_earn_event_keys) above.
A `join_link` program is claim-on-click like every other social event, and
that set is also the list deciding whether an already-earned social card
keeps its CTA ([isRepeatableSocialProgram](#isrepeatablesocialprogram)'s neighbours) — taking the
key out to express "follow_oa is different" would change both. What differs
for `follow_oa` is only the route: its card opens the LINE modal
(`earn-modals/kinds.ts`) instead of claiming, because

- earning requires a linked account AND a current OA follow, and
- the OAuth callback awards points only if follow is already confirmed;
  otherwise the LINE follow webhook awards them later, once only.

A successful link alone is not an earned state. Popup consumers must use the
optional `followed` / `awarded` flags on `joy-line-link` messages (missing
flags mean false), retain the Follow OA CTA, and refresh customer data after
the webhook confirms the follow.

`lineJoinType` is never null on a `join_line` program — a missing or legacy
value is presented as `'join_link'` — so an
absent field here can only under-route to claim-on-click, never over-claim.

#### Parameters

| Parameter               | Type                                                      |
| ----------------------- | --------------------------------------------------------- |
| `program`               | { `key`: `string`; `lineJoinType?`: `string` \| `null`; } |
| `program.key`           | `string`                                                  |
| `program.lineJoinType?` | `string` \| `null`                                        |

#### Returns

`boolean`

***

### isRepeatableSocialProgram()

```ts
function isRepeatableSocialProgram(program): boolean;
```

Whether an already-earned social program keeps its claim CTA — see above.

#### Parameters

| Parameter     | Type                 |
| ------------- | -------------------- |
| `program`     | { `key`: `string`; } |
| `program.key` | `string`             |

#### Returns

`boolean`

***

### isSocialEarnProgram()

```ts
function isSocialEarnProgram(program): boolean;
```

Whether a program's event key is one of the 13 social-claim events.

#### Parameters

| Parameter     | Type                 |
| ------------- | -------------------- |
| `program`     | { `key`: `string`; } |
| `program.key` | `string`             |

#### Returns

`boolean`
