Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove abort-controller package in favor of built-in AbortController #2722

Merged
merged 2 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
"@segment/ajv-human-errors": "^2.14.0",
"@segment/destination-subscriptions": "^3.36.0",
"@types/node": "^18.11.15",
"abort-controller": "^3.0.0",
"aggregate-error": "^3.1.0",
"ajv": "^8.6.3",
"ajv-formats": "^2.1.1",
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/__tests__/request-client.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/no-empty-function */
import AbortController from 'abort-controller'
import createTestServer from 'create-test-server'
import createInstance from '../request-client'
import { Response } from '../fetch'
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/request-client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import AbortController from 'abort-controller'
import { CustomError } from 'ts-custom-error'
import fetch, { Headers, Request, Response } from './fetch'
import { isObject } from './real-type-of'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,141 +1,60 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AmazonAds.syncAudiencesToDSP Normalise and Hash input with extra characters and spaces 1`] = `
Object {
"afterResponse": Array [
[Function],
[Function],
[Function],
],
"beforeRequest": Array [
[Function],
],
"body": "{\\"records\\":[{\\"externalUserId\\":\\"test-kochar-01\\",\\"countryCode\\":\\"US\\",\\"action\\":\\"CREATE\\",\\"hashedPII\\":[{\\"address\\":\\"ebb357a6f604e4d893f034561b06fff712d9dbb7082c4b1808418115c5628017\\",\\"postal\\":\\"516b1543763b8b04f15897aeac07eba66f4e36fdac6945bacb6bdac57e44598a\\",\\"phone\\":\\"e1bfd73a5dc6262163ec42add4ebe0229f929db9b23644c1485dbccd05a36363\\",\\"city\\":\\"61a01e4b10bf579b267bdc16858c932339e8388537363c9c0961bcf5520c8897\\",\\"state\\":\\"7e8eea5cc60980270c9ceb75ce8c087d48d726110fd3d17921f774eefd8e18d8\\",\\"email\\":\\"c551027f06bd3f307ccd6abb61edc500def2680944c010e932ab5b27a3a8f151\\"}]}],\\"audienceId\\":379909525712777677}",
"headers": Headers {
Symbol(map): Object {
"amazon-advertising-api-clientid": Array [
"",
],
"authorization": Array [
"Bearer undefined",
],
"content-type": Array [
"application/vnd.amcaudiences.v1+json",
],
"user-agent": Array [
"Segment (Actions)",
],
},
},
"method": "POST",
"signal": AbortSignal {},
"statsContext": Object {},
"throwHttpErrors": true,
"timeout": 10000,
}
`;
exports[`AmazonAds.syncAudiencesToDSP Normalise and Hash input with extra characters and spaces 1`] = `"{\\"records\\":[{\\"externalUserId\\":\\"test-kochar-01\\",\\"countryCode\\":\\"US\\",\\"action\\":\\"CREATE\\",\\"hashedPII\\":[{\\"address\\":\\"ebb357a6f604e4d893f034561b06fff712d9dbb7082c4b1808418115c5628017\\",\\"postal\\":\\"516b1543763b8b04f15897aeac07eba66f4e36fdac6945bacb6bdac57e44598a\\",\\"phone\\":\\"e1bfd73a5dc6262163ec42add4ebe0229f929db9b23644c1485dbccd05a36363\\",\\"city\\":\\"61a01e4b10bf579b267bdc16858c932339e8388537363c9c0961bcf5520c8897\\",\\"state\\":\\"7e8eea5cc60980270c9ceb75ce8c087d48d726110fd3d17921f774eefd8e18d8\\",\\"email\\":\\"c551027f06bd3f307ccd6abb61edc500def2680944c010e932ab5b27a3a8f151\\"}]}],\\"audienceId\\":379909525712777677}"`;

exports[`AmazonAds.syncAudiencesToDSP Normalise and Hash personally-identifiable input provided with SHA-256 1`] = `
Object {
"afterResponse": Array [
[Function],
[Function],
[Function],
],
"beforeRequest": Array [
[Function],
],
"body": "{\\"records\\":[{\\"externalUserId\\":\\"test-kochar-01\\",\\"countryCode\\":\\"US\\",\\"action\\":\\"CREATE\\",\\"hashedPII\\":[{\\"firstname\\":\\"44104fcaef8476724152090d6d7bd9afa8ca5b385f6a99d3c6cf36b943b9872d\\",\\"phone\\":\\"63af7d494c194a90e1cf1db5371c13f97db650161aa803e67182c0dbaf668c7b\\",\\"state\\":\\"92db9c574d420b2437b29d898d55604f61df6c17f5163e53337f2169dd70d38d\\",\\"email\\":\\"c551027f06bd3f307ccd6abb61edc500def2680944c010e932ab5b27a3a8f151\\"}]}],\\"audienceId\\":379909525712777677}",
"headers": Headers {
Symbol(map): Object {
"amazon-advertising-api-clientid": Array [
"",
],
"authorization": Array [
"Bearer undefined",
],
"content-type": Array [
"application/vnd.amcaudiences.v1+json",
],
"user-agent": Array [
"Segment (Actions)",
],
},
Headers {
Symbol(map): Object {
"amazon-advertising-api-clientid": Array [
"",
],
"authorization": Array [
"Bearer undefined",
],
"content-type": Array [
"application/vnd.amcaudiences.v1+json",
],
"user-agent": Array [
"Segment (Actions)",
],
},
"method": "POST",
"signal": AbortSignal {},
"statsContext": Object {},
"throwHttpErrors": true,
"timeout": 10000,
}
`;

exports[`AmazonAds.syncAudiencesToDSP Should add user to audience when Event is Audience Entered 1`] = `
Object {
"afterResponse": Array [
[Function],
[Function],
[Function],
],
"beforeRequest": Array [
[Function],
],
"body": "{\\"records\\":[{\\"externalUserId\\":\\"test-kochar-01\\",\\"countryCode\\":\\"US\\",\\"action\\":\\"CREATE\\",\\"hashedPII\\":[{\\"email\\":\\"c551027f06bd3f307ccd6abb61edc500def2680944c010e932ab5b27a3a8f151\\"}]}],\\"audienceId\\":379909525712777677}",
"headers": Headers {
Symbol(map): Object {
"amazon-advertising-api-clientid": Array [
"",
],
"authorization": Array [
"Bearer undefined",
],
"content-type": Array [
"application/vnd.amcaudiences.v1+json",
],
"user-agent": Array [
"Segment (Actions)",
],
},
Headers {
Symbol(map): Object {
"amazon-advertising-api-clientid": Array [
"",
],
"authorization": Array [
"Bearer undefined",
],
"content-type": Array [
"application/vnd.amcaudiences.v1+json",
],
"user-agent": Array [
"Segment (Actions)",
],
},
"method": "POST",
"signal": AbortSignal {},
"statsContext": Object {},
"throwHttpErrors": true,
"timeout": 10000,
}
`;

exports[`AmazonAds.syncAudiencesToDSP Should delete user from audience when Event is Audience Exited 1`] = `
Object {
"afterResponse": Array [
[Function],
[Function],
[Function],
],
"beforeRequest": Array [
[Function],
],
"body": "{\\"records\\":[{\\"externalUserId\\":\\"test-kochar-01\\",\\"countryCode\\":\\"US\\",\\"action\\":\\"DELETE\\",\\"hashedPII\\":[{\\"email\\":\\"c551027f06bd3f307ccd6abb61edc500def2680944c010e932ab5b27a3a8f151\\"}]}],\\"audienceId\\":379909525712777677}",
"headers": Headers {
Symbol(map): Object {
"amazon-advertising-api-clientid": Array [
"",
],
"authorization": Array [
"Bearer undefined",
],
"content-type": Array [
"application/vnd.amcaudiences.v1+json",
],
"user-agent": Array [
"Segment (Actions)",
],
},
Headers {
Symbol(map): Object {
"amazon-advertising-api-clientid": Array [
"",
],
"authorization": Array [
"Bearer undefined",
],
"content-type": Array [
"application/vnd.amcaudiences.v1+json",
],
"user-agent": Array [
"Segment (Actions)",
],
},
"method": "POST",
"signal": AbortSignal {},
"statsContext": Object {},
"throwHttpErrors": true,
"timeout": 10000,
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
expect(response[0].options.body).toBe(
'{"records":[{"externalUserId":"test-kochar-01","countryCode":"US","action":"CREATE","hashedPII":[{"email":"c551027f06bd3f307ccd6abb61edc500def2680944c010e932ab5b27a3a8f151"}]}],"audienceId":379909525712777677}'
)
expect(response[0].options).toMatchSnapshot()
expect(response[0].options.headers).toMatchSnapshot()
})

it('Normalise and Hash personally-identifiable input provided with SHA-256', async () => {
Expand Down Expand Up @@ -168,7 +168,7 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
expect(response[0].options.body).toBe(
'{"records":[{"externalUserId":"test-kochar-01","countryCode":"US","action":"CREATE","hashedPII":[{"firstname":"44104fcaef8476724152090d6d7bd9afa8ca5b385f6a99d3c6cf36b943b9872d","phone":"63af7d494c194a90e1cf1db5371c13f97db650161aa803e67182c0dbaf668c7b","state":"92db9c574d420b2437b29d898d55604f61df6c17f5163e53337f2169dd70d38d","email":"c551027f06bd3f307ccd6abb61edc500def2680944c010e932ab5b27a3a8f151"}]}],"audienceId":379909525712777677}'
)
expect(response[0].options).toMatchSnapshot()
expect(response[0].options.headers).toMatchSnapshot()
})

it('Normalise and Hash input with extra characters and spaces', async () => {
Expand Down Expand Up @@ -204,7 +204,7 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
expect(response[0].options.body).toBe(
'{"records":[{"externalUserId":"test-kochar-01","countryCode":"US","action":"CREATE","hashedPII":[{"address":"ebb357a6f604e4d893f034561b06fff712d9dbb7082c4b1808418115c5628017","postal":"516b1543763b8b04f15897aeac07eba66f4e36fdac6945bacb6bdac57e44598a","phone":"e1bfd73a5dc6262163ec42add4ebe0229f929db9b23644c1485dbccd05a36363","city":"61a01e4b10bf579b267bdc16858c932339e8388537363c9c0961bcf5520c8897","state":"7e8eea5cc60980270c9ceb75ce8c087d48d726110fd3d17921f774eefd8e18d8","email":"c551027f06bd3f307ccd6abb61edc500def2680944c010e932ab5b27a3a8f151"}]}],"audienceId":379909525712777677}'
)
expect(response[0].options).toMatchSnapshot()
expect(response[0].options.body).toMatchSnapshot()
})

it('Should delete user from audience when Event is Audience Exited', async () => {
Expand All @@ -228,7 +228,7 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
expect(response[0].options.body).toBe(
'{"records":[{"externalUserId":"test-kochar-01","countryCode":"US","action":"DELETE","hashedPII":[{"email":"c551027f06bd3f307ccd6abb61edc500def2680944c010e932ab5b27a3a8f151"}]}],"audienceId":379909525712777677}'
)
expect(response[0].options).toMatchSnapshot()
expect(response[0].options.headers).toMatchSnapshot()
})
it('should throw an error when an event has invalid externalUserId', async () => {
await expect(
Expand Down
Loading
Loading