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

channels-1094 #2024

Closed
wants to merge 73 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
28db0aa
refactor: Refactoring the name for dataFeedCache to be
cogwizzle May 3, 2024
cf0b33d
fix: Changing the variable name back.
cogwizzle May 3, 2024
5496895
chore: Linter.
cogwizzle May 9, 2024
b792860
chore: Minor tweak to syntax to make it more clear.
cogwizzle May 9, 2024
4899aeb
feat: Adding cache logic to message send performer.
cogwizzle May 9, 2024
8ee70f6
refactor: Renaming maxResponseSizeBytes to maxValueSizeBytes.
cogwizzle May 15, 2024
b478bf1
refactor: Only storing status code instead of full response.
cogwizzle May 15, 2024
255dba8
feat: Adding property retry to CustomError.
cogwizzle May 16, 2024
837380f
feat: Changing the downstream logic to support partial DA successes.
cogwizzle May 16, 2024
a616a3f
fix: Type mismatch.
cogwizzle May 21, 2024
e758ce1
Merge branch 'main' of ssh://github.com/segmentio/action-destinations…
cogwizzle May 31, 2024
631df68
fix: Fixing construction of the EngageActionPerformer.
cogwizzle Jun 6, 2024
3244334
fix: Attempt to update type issue.
cogwizzle Jun 6, 2024
7ddc631
Merge branch 'main' of ssh://github.com/segmentio/action-destinations…
cogwizzle Jun 17, 2024
522a103
fix: Fixing type issue.
cogwizzle Jun 17, 2024
2d5c75f
chore: Updating the core version.
cogwizzle Jun 17, 2024
b8a48fd
Merge branch 'main' of ssh://github.com/segmentio/action-destinations…
cogwizzle Jun 26, 2024
3221f34
feat: Updating the actions-core package.
cogwizzle Jun 26, 2024
761b0b9
Merge branch 'main' of ssh://github.com/segmentio/action-destinations…
cogwizzle Jun 27, 2024
f5a2997
feat: Creating a canary script so that publishing canary versions of the
cogwizzle Jun 27, 2024
6f55f20
Merge branch 'main' of ssh://github.com/segmentio/action-destinations…
cogwizzle Jun 27, 2024
26faeb8
feat: Updating test utilities to be easier to use.
cogwizzle Jun 27, 2024
f7cc09c
fix: Adding engageDestinationCache that won't break the test.
cogwizzle Jun 27, 2024
1a7fcab
fix: Updating the max bundle size.
cogwizzle Jun 28, 2024
e6d18de
feat: Increasing the size limit.
cogwizzle Jun 28, 2024
5c86514
fix: Updating broken test.
cogwizzle Jun 28, 2024
7982eb9
feat: Implementing a more simple serialization than JSON as to not block
cogwizzle Jul 8, 2024
47e6208
feat: Adding an info message that tracks if the cache was able to find
cogwizzle Jul 8, 2024
121afa9
Merge branch 'main' of ssh://github.com/segmentio/action-destinations…
cogwizzle Jul 8, 2024
605cd2f
fix: Fixing a type issue with the MessageSendPerformer and the
cogwizzle Jul 8, 2024
fcb020b
feat: Updating yarn file.
cogwizzle Jul 8, 2024
83a201b
feat: Adding logging for caching and reloading from the cache.
cogwizzle Jul 10, 2024
72217d7
fix: Fixing dependency.
cogwizzle Jul 10, 2024
3eb5fda
Merge branch 'main' of ssh://github.com/segmentio/action-destinations…
cogwizzle Jul 16, 2024
516921b
chore: Updating package.
cogwizzle Jul 16, 2024
4ea3d45
chore: canary.
cogwizzle Jul 16, 2024
779c533
feat: Updating the actions-core to new canary build.
cogwizzle Jul 16, 2024
4572060
fix: Attempting to update dependencies.
cogwizzle Jul 17, 2024
a54ae36
fix: Revering change.
cogwizzle Jul 17, 2024
e8e52e6
feat: Updating the shared package.
cogwizzle Jul 17, 2024
5e59f18
Merge branch 'main' of ssh://github.com/segmentio/action-destinations…
cogwizzle Jul 18, 2024
b22ecf5
feat: Yarn.lock.
cogwizzle Jul 18, 2024
cccddf9
fix: Empty message. I hate lerna.
cogwizzle Jul 18, 2024
7ef8179
Merge branch 'main' of ssh://github.com/segmentio/action-destinations…
cogwizzle Jul 22, 2024
8b77355
chore: Updating version of core.
cogwizzle Jul 22, 2024
5357d3f
fix: Fixing serialization bugs so that the cache works as expected.
cogwizzle Jul 24, 2024
a9d8806
chore: Updating version.
cogwizzle Jul 24, 2024
d970343
Merge branch 'main' of ssh://github.com/segmentio/action-destinations…
cogwizzle Jul 24, 2024
f960e80
chore: Updating verison.
cogwizzle Jul 24, 2024
745cf43
chore: Updating core.
cogwizzle Jul 24, 2024
1aa9695
chore: Updating lock.
cogwizzle Jul 24, 2024
0adc2ac
refactor: Updating plain text.
cogwizzle Jul 24, 2024
8ce1549
chore: Adding logging for better debugging.
cogwizzle Jul 24, 2024
c1d40d2
chore: Updating packages.
cogwizzle Jul 24, 2024
0d450e2
Merge branch 'main' of ssh://github.com/segmentio/action-destinations…
cogwizzle Jul 26, 2024
90ee709
feat: Adding additional logging.
cogwizzle Jul 26, 2024
04c4575
chore: Update the version.
cogwizzle Jul 26, 2024
c76c722
Merge remote-tracking branch 'origin/main' into channels-1094
cogwizzle Aug 20, 2024
3df6a9b
channels-1200 fixing stats for Channels-1094 (#2316)
pmunin Aug 20, 2024
79518a7
fix: Reverting package.json.
cogwizzle Aug 20, 2024
2bc39ce
Merge branch 'channels-1094' of ssh://github.com/segmentio/action-des…
cogwizzle Aug 20, 2024
c0a27d4
fix: Fixing duplicate commands.
cogwizzle Aug 20, 2024
c7b272e
fix: Reverting webpack change.
cogwizzle Aug 20, 2024
42da15a
fix: Reverting change.
cogwizzle Aug 20, 2024
591c5b9
reverting irrelevant changes
pmunin Aug 15, 2024
f60d4e2
Merge remote-tracking branch 'refs/remotes/origin/channels-1094' into…
pmunin Aug 20, 2024
41c9de1
reverting irrelevant changes
pmunin Aug 15, 2024
ad7298c
fix: Reverting changes.
cogwizzle Aug 20, 2024
e0e4c4c
Merge branch 'channels-1094' of ssh://github.com/segmentio/action-des…
cogwizzle Aug 20, 2024
5222383
fix: Reverting changes.
cogwizzle Aug 20, 2024
133d08a
fix: Reverting changes.
cogwizzle Aug 20, 2024
b6ada52
fix: Reverting changes.
cogwizzle Aug 20, 2024
55225b0
Merge remote-tracking branch 'origin/main' into channels-1094
pmunin Aug 21, 2024
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ The `perform` method accepts two arguments, (1) the request client instance (ext
- `features` - The features available in the request based on the customer's sourceID. Features can only be enabled and/or used by internal Twilio/Segment employees. Features cannot be used for Partner builds.
- `statsContext` - An object, containing a `statsClient` and `tags`. Stats can only be used by internal Twilio/Segment employees. Stats cannot be used for Partner builds.
- `logger` - Logger can only be used by internal Twilio/Segment employees. Logger cannot be used for Partner builds.
- `dataFeedCache` - DataFeedCache can only be used by internal Twilio/Segment employees. DataFeedCache cannot be used for Partner builds.
- `engageDestinationCache` - EngageDestinationCache can only be used by internal Twilio/Segment employees. EngageDestinationCache should not be used for Partner builds.
- `transactionContext` - An object, containing transaction variables and a method to update transaction variables which are required for few segment developed actions. Transaction Context cannot be used for Partner builds.
- `stateContext` - An object, containing context variables and a method to get and set context variables which are required for few segment developed actions. State Context cannot be used for Partner builds.

Expand Down
22 changes: 12 additions & 10 deletions packages/core/src/create-test-integration.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createTestEvent } from './create-test-event'
import { StateContext, Destination, TransactionContext } from './destination-kit'
import { mapValues } from './map-values'
import type { DestinationDefinition, StatsContext, Logger, DataFeedCache, RequestFn } from './destination-kit'
import type { DestinationDefinition, StatsContext, Logger, EngageDestinationCache, RequestFn } from './destination-kit'
import type { JSONObject } from './json-object'
import type { SegmentEvent } from './segment-event'
import { AuthTokens } from './destination-kit/parse-settings'
Expand Down Expand Up @@ -36,15 +36,17 @@ interface InputData<Settings> {
*/
useDefaultMappings?: boolean
auth?: AuthTokens
/**
* The features available in the request based on the customer's sourceID;
* `features`, `stats`, `logger`, `dataFeedCache`, and `transactionContext` and `stateContext` are for internal Twilio/Segment use only.
*/
/** Engage internal use only. DO NOT USE. */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broke this comment apart so that we could get language server support for using each property in the shape of this object.

features?: Features
/** Engage internal use only. DO NOT USE. */
statsContext?: StatsContext
/** Engage internal use only. DO NOT USE. */
logger?: Logger
dataFeedCache?: DataFeedCache
/** Engage internal use only. DO NOT USE. */
engageDestinationCache?: EngageDestinationCache
/** Engage internal use only. DO NOT USE. */
transactionContext?: TransactionContext
/** Engage internal use only. DO NOT USE. */
stateContext?: StateContext
}

Expand Down Expand Up @@ -77,7 +79,7 @@ class TestDestination<T, AudienceSettings = any> extends Destination<T, Audience
features,
statsContext,
logger,
dataFeedCache,
engageDestinationCache,
transactionContext,
stateContext
}: InputData<T>
Expand All @@ -99,7 +101,7 @@ class TestDestination<T, AudienceSettings = any> extends Destination<T, Audience
features: features ?? {},
statsContext: statsContext ?? ({} as StatsContext),
logger: logger ?? ({ info: noop, error: noop } as Logger),
dataFeedCache: dataFeedCache ?? ({} as DataFeedCache),
engageDestinationCache: engageDestinationCache ?? ({} as EngageDestinationCache),
transactionContext: transactionContext ?? ({} as TransactionContext),
stateContext: stateContext ?? ({} as StateContext)
})
Expand All @@ -121,7 +123,7 @@ class TestDestination<T, AudienceSettings = any> extends Destination<T, Audience
features,
statsContext,
logger,
dataFeedCache,
engageDestinationCache,
transactionContext,
stateContext
}: Omit<InputData<T>, 'event'> & { events?: SegmentEvent[] }
Expand All @@ -147,7 +149,7 @@ class TestDestination<T, AudienceSettings = any> extends Destination<T, Audience
features: features ?? {},
statsContext: statsContext ?? ({} as StatsContext),
logger: logger ?? ({} as Logger),
dataFeedCache: dataFeedCache ?? ({} as DataFeedCache),
engageDestinationCache: engageDestinationCache ?? ({} as EngageDestinationCache),
transactionContext: transactionContext ?? ({} as TransactionContext),
stateContext: stateContext ?? ({} as StateContext)
})
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/destination-kit/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { validateSchema } from '../schema-validation'
import { AuthTokens } from './parse-settings'
import { IntegrationError } from '../errors'
import { removeEmptyValues } from '../remove-empty-values'
import { Logger, StatsContext, TransactionContext, StateContext, DataFeedCache } from './index'
import { Logger, StatsContext, TransactionContext, StateContext, EngageDestinationCache } from './index'

type MaybePromise<T> = T | Promise<T>
type RequestClient = ReturnType<typeof createRequestClient>
Expand Down Expand Up @@ -166,7 +166,7 @@ interface ExecuteBundle<T = unknown, Data = unknown, AudienceSettings = any, Act
features?: Features | undefined
statsContext?: StatsContext | undefined
logger?: Logger | undefined
dataFeedCache?: DataFeedCache | undefined
engageDestinationCache?: EngageDestinationCache | undefined
transactionContext?: TransactionContext
stateContext?: StateContext
}
Expand Down Expand Up @@ -274,7 +274,7 @@ export class Action<Settings, Payload extends JSONLikeObject, AudienceSettings =
features: bundle.features,
statsContext: bundle.statsContext,
logger: bundle.logger,
dataFeedCache: bundle.dataFeedCache,
engageDestinationCache: bundle.engageDestinationCache,
transactionContext: bundle.transactionContext,
stateContext: bundle.stateContext,
audienceSettings: bundle.audienceSettings,
Expand Down Expand Up @@ -339,7 +339,7 @@ export class Action<Settings, Payload extends JSONLikeObject, AudienceSettings =
features: bundle.features,
statsContext: bundle.statsContext,
logger: bundle.logger,
dataFeedCache: bundle.dataFeedCache,
engageDestinationCache: bundle.engageDestinationCache,
transactionContext: bundle.transactionContext,
stateContext: bundle.stateContext,
hookOutputs
Expand Down
30 changes: 17 additions & 13 deletions packages/core/src/destination-kit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ interface EventInput<Settings> {
readonly features?: Features
readonly statsContext?: StatsContext
readonly logger?: Logger
readonly dataFeedCache?: DataFeedCache
/** Engage internal use only. DO NOT USE. */
readonly engageDestinationCache?: EngageDestinationCache
readonly transactionContext?: TransactionContext
readonly stateContext?: StateContext
}
Expand All @@ -294,7 +295,8 @@ interface BatchEventInput<Settings> {
readonly features?: Features
readonly statsContext?: StatsContext
readonly logger?: Logger
readonly dataFeedCache?: DataFeedCache
/** Engage internal use only. DO NOT USE. */
readonly engageDestinationCache?: EngageDestinationCache
readonly transactionContext?: TransactionContext
readonly stateContext?: StateContext
}
Expand All @@ -310,7 +312,8 @@ interface OnEventOptions {
features?: Features
statsContext?: StatsContext
logger?: Logger
readonly dataFeedCache?: DataFeedCache
/** Engage internal use only. DO NOT USE. */
readonly engageDestinationCache?: EngageDestinationCache
transactionContext?: TransactionContext
stateContext?: StateContext
/** Handler to perform synchronization. If set, the refresh access token method will be synchronized across
Expand Down Expand Up @@ -364,11 +367,11 @@ export interface Logger {
withTags(extraTags: any): void
}

export interface DataFeedCache {
setRequestResponse(requestId: string, response: string, expiryInSeconds: number): Promise<void>
getRequestResponse(requestId: string): Promise<string | null>
maxResponseSizeBytes: number
maxExpirySeconds: number
export interface EngageDestinationCache {
getByKey: (key: string) => Promise<string | null>
readonly maxExpirySeconds: number
readonly maxResponseSizeBytes: number
setByKey: (key: string, value: string, expiryInSeconds?: number) => Promise<void>
}

export class Destination<Settings = JSONObject, AudienceSettings = JSONObject> {
Expand Down Expand Up @@ -547,7 +550,7 @@ export class Destination<Settings = JSONObject, AudienceSettings = JSONObject> {
features,
statsContext,
logger,
dataFeedCache,
engageDestinationCache,
transactionContext,
stateContext
}: EventInput<Settings>
Expand All @@ -571,7 +574,7 @@ export class Destination<Settings = JSONObject, AudienceSettings = JSONObject> {
features,
statsContext,
logger,
dataFeedCache,
engageDestinationCache,
transactionContext,
stateContext
})
Expand All @@ -587,7 +590,7 @@ export class Destination<Settings = JSONObject, AudienceSettings = JSONObject> {
features,
statsContext,
logger,
dataFeedCache,
engageDestinationCache,
transactionContext,
stateContext
}: BatchEventInput<Settings>
Expand All @@ -612,7 +615,7 @@ export class Destination<Settings = JSONObject, AudienceSettings = JSONObject> {
features,
statsContext,
logger,
dataFeedCache,
engageDestinationCache,
transactionContext,
stateContext
})
Expand Down Expand Up @@ -651,7 +654,8 @@ export class Destination<Settings = JSONObject, AudienceSettings = JSONObject> {
features: options?.features || {},
statsContext: options?.statsContext || ({} as StatsContext),
logger: options?.logger,
dataFeedCache: options?.dataFeedCache,
/** Engage internal use only. DO NOT USE. */
engageDestinationCache: options?.engageDestinationCache,
transactionContext: options?.transactionContext,
stateContext: options?.stateContext
}
Expand Down
16 changes: 10 additions & 6 deletions packages/core/src/destination-kit/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StateContext, Logger, StatsContext, TransactionContext, DataFeedCache, ActionHookType } from './index'
import { StateContext, Logger, StatsContext, TransactionContext, EngageDestinationCache, ActionHookType } from './index'
import type { RequestOptions } from '../request-client'
import type { JSONObject } from '../json-object'
import { AuthTokens } from './parse-settings'
Expand All @@ -20,7 +20,9 @@ export interface ExecuteInput<
Settings,
Payload,
AudienceSettings = unknown,
/* eslint-disable-next-line @typescript-eslint/no-explicit-any -- Expected any. */
ActionHookInputs = any,
/* eslint-disable-next-line @typescript-eslint/no-explicit-any -- Expected any. */
ActionHookOutputs = any
> {
/** The subscription mapping definition */
Expand All @@ -39,15 +41,17 @@ export interface ExecuteInput<
page?: string
/** The data needed in OAuth requests */
readonly auth?: AuthTokens
/**
* The features available in the request based on the customer's sourceID;
* `features`,`stats`, `logger` , `transactionContext` and `stateContext` are for internal Twilio/Segment use only.
*/
/** Engage internal use only. DO NOT USE. */
readonly features?: Features
Comment on lines -55 to +57
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broke this comment apart so that we could get language server support for using each property in the shape of this object.

/** Engage internal use only. DO NOT USE. */
readonly statsContext?: StatsContext
/** Engage internal use only. DO NOT USE. */
readonly logger?: Logger
readonly dataFeedCache?: DataFeedCache
/** Engage internal use only. DO NOT USE. */
readonly engageDestinationCache?: EngageDestinationCache
/** Engage internal use only. DO NOT USE. */
readonly transactionContext?: TransactionContext
/** Engage internal use only. DO NOT USE. */
readonly stateContext?: StateContext
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ export class SendEmailPerformer extends MessageSendPerformer<Settings, Payload>
this.tags,
this.settings,
this.logger.loggerClient,
this.dataFeedCache
this.engageDestinationCache
)
return { name: apiLookup.name, data }
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import truncate from 'lodash/truncate'
export abstract class EngageActionPerformer<TSettings = any, TPayload = any, TReturn = any> {
readonly logger: EngageLogger = new EngageLogger(this)
readonly statsClient: EngageStats = new EngageStats(this)
readonly dataFeedCache = this.executeInput.dataFeedCache
readonly engageDestinationCache = this.executeInput.engageDestinationCache
readonly currentOperation: OperationContext | undefined

readonly payload: TPayload
Expand Down
Loading
Loading