Skip to content

Commit

Permalink
fix tests and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-astra-via committed Jan 25, 2024
1 parent e281455 commit 406e7fe
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,47 @@ Find out more about Managed Components [here](https://blog.cloudflare.com/zaraz-
### TID `string` _required_

`tid` Pixel Tag ID - The Pinterest Tag ID is the unique identifier of your Pinterest tag. [Learn more](https://help.pinterest.com/en/business/article/track-conversions-with-pinterest-tag).
Sure, I'll remove the "Pixel Tag ID" field and update the "Fields Description" section accordingly.

---

## Fields Description

Fields are properties that can/must be sent with certain events.

### Required Fields

#### Event Name `string` _required_

`event` - The name of the tracking event to be sent to Pinterest.

### Optional Fields

#### User Defined Event `string` _optional_

`ude` - Specify a custom event name for audience targeting purposes. Spaces in the event name will be removed. [Learn more](https://help.pinterest.com/en/business/article/add-event-codes).

#### Partner Data Email `string` _optional_

`pdem` - Specifies the email address associated with the partner data, if applicable.

#### Tag Manager `string` _optional_

`tm` - Indicates the Tag Manager used, defaults to 'pinterest-mc' if not specified.

#### Lead Type `string` _optional_

`lead_type` - Describes the type of lead being tracked, such as 'Newsletter', 'Signup', etc.

#### Video Title `string` _optional_

`video_title` - The title of the video for tracking specific video events.

#### E-commerce Tracking `boolean` _optional_

`ecommerce` - Enables or disables the forwarding of Zaraz E-commerce API events to Pinterest. This includes events like Search, AddToCart, and Checkout. [Learn more](https://help.pinterest.com/en-gb/business/article/add-event-codes).

---

## 📝 License

Expand Down
8 changes: 2 additions & 6 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('Pinterest MC sends correct request', () => {
'pd[tm]': 'pinterest-mc',
ed: '{"timestamp":1670409810,"event":"pagevisit"}',
}
const requestUrl = getRequestUrl(rawRequestBody, mockEvent, settings)
const requestUrl = getRequestUrl(rawRequestBody)
const requestUrlDecoded = decodeURI(requestUrl)

const expectedUrl = `https://ct.pinterest.com/v3/?ad={"loc"%3A"https%3A%2F%2F127.0.0.1%3A1337%2F"%2C"ref"%3A"https%3A%2F%2F127.0.0.1%3A1337%2Fsomewhere-else.html"%2C"if"%3Afalse%2C"mh"%3A"2424edb5"}&cb=1671006315874&tid=xyz&event=pagevisit&pd[tm]=pinterest-mc&ed={"timestamp"%3A1670409810%2C"event"%3A"pagevisit"}`
Expand All @@ -78,10 +78,6 @@ describe('Pinterest MC sends correct request', () => {
})

it('Handler invokes fetch correctly', () => {
const arr = []
handler('pageview', mockEvent, settings, (...args) => {
arr.push(args)
})
expect(arr.length).toBe(1)
expect(() => handler(mockEvent, settings)).not.toThrow()
})
})

0 comments on commit 406e7fe

Please sign in to comment.