Skip to content

Commit

Permalink
improve types for airgap event listening
Browse files Browse the repository at this point in the history
  • Loading branch information
csmccarthy committed Nov 14, 2023
1 parent 7cf7bf5 commit 88d40a1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Transcend Inc.",
"name": "@transcend-io/airgap.js-types",
"description": "TypeScript types for airgap.js interoperability with custom consent UIs",
"version": "10.7.5",
"version": "10.7.6",
"homepage": "https://github.com/transcend-io/airgap.js-types",
"repository": {
"type": "git",
Expand Down
24 changes: 20 additions & 4 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,22 +208,38 @@ export type AirgapAPI = Readonly<{
getPrivacySignals(): Set<UserPrivacySignal>;
/** airgap.js version number */
version: string;
/** override the event listener signature for consent change events */
addEventListener: (
type: AirgapConsentEventType,
callback: ((evt: ConsentChangeEventDetails) => void) | null,
options?: boolean | AddEventListenerOptions | undefined,
) => void;
}> &
EventTarget;

/**
* Airgap event types that send the ConsentChangeEventDetails object with them
*/
export type AirgapConsentEventType =
| 'consent-change'
| 'sync'
| 'consent-resolution';

/**
* airgap.js event type
*/
export type AirgapEventType = 'consent-change' | 'purpose-map-load';
export type AirgapEventType = AirgapConsentEventType | 'purpose-map-load';

/** 'consent-change' custom event details */
export type ConsentChangeEventDetails = {
/** The old tracking consent */
oldConsent: TrackingConsentDetails;
oldConsent: TrackingConsentDetails | null;
/** The new tracking consent */
consent: TrackingConsentDetails;
consent: TrackingConsentDetails | null;
/** The tracking consent diff (what's changed in the new consent) */
changes: ConsentChange | null;
changes: Record<string, boolean> | null;
/** Applicable privacy signals contributing to this consent change event */
signals?: Set<UserPrivacySignal> | null;
};

/** Removable process (can remove watchers, overrides, and protections) */
Expand Down

0 comments on commit 88d40a1

Please sign in to comment.