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

feat(types): generated type declarations #366

Open
wants to merge 1 commit into
base: v8.x
Choose a base branch
from
Open
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
Empty file added types/amplitude-snippet.d.ts
Empty file.
9 changes: 9 additions & 0 deletions types/base-cookie.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
declare namespace _default {
export { set };
export { get };
export { areCookiesEnabled };
}
export default _default;
declare function set(name: any, value: any, opts: any): void;
declare function get(name: any): string;
declare function areCookiesEnabled(opts?: {}): boolean;
8 changes: 8 additions & 0 deletions types/base64.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default Base64;
declare namespace Base64 {
const _keyStr: string;
function encode(input: any): string;
function _encode(input: any): string;
function decode(input: any): string;
function _decode(input: any): string;
}
2 changes: 2 additions & 0 deletions types/base64Id.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export default base64Id;
declare function base64Id(): string;
37 changes: 37 additions & 0 deletions types/constants.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
declare namespace _default {
const DEFAULT_INSTANCE: string;
const API_VERSION: number;
const MAX_STRING_LENGTH: number;
const MAX_PROPERTY_KEYS: number;
const IDENTIFY_EVENT: string;
const GROUP_IDENTIFY_EVENT: string;
const LAST_EVENT_ID: string;
const LAST_EVENT_TIME: string;
const LAST_IDENTIFY_ID: string;
const LAST_SEQUENCE_NUMBER: string;
const SESSION_ID: string;
const DEVICE_ID: string;
const OPT_OUT: string;
const USER_ID: string;
const COOKIE_TEST_PREFIX: string;
const COOKIE_PREFIX: string;
const STORAGE_DEFAULT: string;
const STORAGE_COOKIES: string;
const STORAGE_NONE: string;
const STORAGE_LOCAL: string;
const STORAGE_SESSION: string;
const REVENUE_EVENT: string;
const REVENUE_PRODUCT_ID: string;
const REVENUE_QUANTITY: string;
const REVENUE_PRICE: string;
const REVENUE_REVENUE_TYPE: string;
const AMP_DEVICE_ID_PARAM: string;
const REFERRER: string;
const UTM_SOURCE: string;
const UTM_MEDIUM: string;
const UTM_CAMPAIGN: string;
const UTM_TERM: string;
const UTM_CONTENT: string;
const ATTRIBUTION_EVENT: string;
}
export default _default;
20 changes: 20 additions & 0 deletions types/cookie.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
declare namespace _default {
export { reset };
export { options };
export { get };
export { set };
export { remove };
export { setRaw };
export { getRaw };
}
export default _default;
declare function reset(): void;
declare function options(opts: any, ...args: any[]): {
expirationDays: any;
domain: any;
};
declare function get(name: any): any;
declare function set(name: any, value: any): boolean;
declare function remove(name: any): boolean;
declare function setRaw(name: any, value: any): boolean;
declare function getRaw(name: any): string;
2 changes: 2 additions & 0 deletions types/get-host.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export default getHost;
declare function getHost(url: any): string;
2 changes: 2 additions & 0 deletions types/get-location.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export default getLocation;
declare function getLocation(): Location;
11 changes: 11 additions & 0 deletions types/identify.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default Identify;
declare class Identify {
public add(property: string, value: number | string): Identify;
public append(property: string, value: number | string | any | object): Identify;
private clearAll;
public prepend(property: string, value: number | string | any | object): Identify;
public set(property: string, value: number | string | any | boolean | object): Identify;
public setOnce(property: string, value: number | string | any | boolean | object): Identify;
public unset(property: string): Identify;
private _addOperation;
}
5 changes: 5 additions & 0 deletions types/language.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare namespace _default {
export { getLanguage };
}
export default _default;
declare function getLanguage(): any;
2 changes: 2 additions & 0 deletions types/localstorage.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export default localStorage;
declare var localStorage: any;
47 changes: 47 additions & 0 deletions types/metadata-storage.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
export default MetadataStorage;
/**
* MetadataStorage involves SDK data persistance
* storage priority: cookies -> localStorage -> in memory
* This priority can be overriden by setting the storage options.
* if in localStorage, unable track users between subdomains
* if in memory, then memory can't be shared between different tabs
*/
declare class MetadataStorage {
constructor({ storageKey, disableCookies, domain, secure, sameSite, expirationDays, storage }: {
storageKey: any;
disableCookies: any;
domain: any;
secure: any;
sameSite: any;
expirationDays: any;
storage: any;
});
storageKey: any;
domain: any;
secure: any;
sameSite: any;
expirationDays: any;
cookieDomain: any;
storage: any;
getCookieStorageKey(): any;
save({ deviceId, userId, optOut, sessionId, lastEventTime, eventId, identifyId, sequenceNumber }: {
deviceId: any;
userId: any;
optOut: any;
sessionId: any;
lastEventTime: any;
eventId: any;
identifyId: any;
sequenceNumber: any;
}): void;
load(): {
deviceId: any;
userId: string;
optOut: boolean;
sessionId: number;
lastEventTime: number;
eventId: number;
identifyId: number;
sequenceNumber: number;
};
}
199 changes: 199 additions & 0 deletions types/options.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
declare namespace _default {
export const apiEndpoint: string;
export const batchEvents: boolean;
export const cookieExpiration: number;
export const cookieName: string;
export const sameSiteCookie: string;
export const cookieForceUpgrade: boolean;
export const deferInitialization: boolean;
export const disableCookies: boolean;
export const deviceIdFromUrlParam: boolean;
export const domain: string;
export const eventUploadPeriodMillis: number;
export const eventUploadThreshold: number;
export const forceHttps: boolean;
export const includeFbclid: boolean;
export const includeGclid: boolean;
export const includeReferrer: boolean;
export const includeUtm: boolean;
export const language: any;
export const logLevel: string;
export const logAttributionCapturedEvent: boolean;
export const optOut: boolean;
export function onError(): void;
export { platform };
export const savedMaxCount: number;
export const saveEvents: boolean;
export const saveParamsReferrerOncePerSession: boolean;
export const secureCookie: boolean;
export const sessionTimeout: number;
export const storage: string;
export namespace trackingOptions {
export const city: boolean;
export const country: boolean;
export const carrier: boolean;
export const device_manufacturer: boolean;
export const device_model: boolean;
export const dma: boolean;
export const ip_address: boolean;
const language_1: boolean;
export { language_1 as language };
export const os_name: boolean;
export const os_version: boolean;
const platform_1: boolean;
export { platform_1 as platform };
export const region: boolean;
export const version_name: boolean;
}
export const unsetParamsReferrerOnNewSession: boolean;
export const unsentKey: string;
export const unsentIdentifyKey: string;
export const uploadBatchSize: number;
}
export default _default;
/**
* Options used when initializing Amplitude
*/
export type Options = {
/**
* - Endpoint to send amplitude event requests to.
*/
apiEndpoint?: string;
/**
* - If `true`, then events are batched together and uploaded only when the number of unsent events is greater than or equal to eventUploadThreshold or after eventUploadPeriodMillis milliseconds have passed since the first unsent event was logged.
*/
batchEvents?: boolean;
/**
* - The number of days after which the Amplitude cookie will expire. 12 months is for GDPR compliance.
*/
cookieExpiration?: number;
/**
* - *DEPRECATED*
*/
cookieName?: string;
/**
* - Sets the SameSite flag on the amplitude cookie. Decides cookie privacy policy.
*/
sameSiteCookie?: string;
/**
* - Forces pre-v6.0.0 instances to adopt post-v6.0.0 compat cookie formats.
*/
cookieForceUpgrade?: boolean;
/**
* - If `true`, disables the core functionality of the sdk, including saving a cookie and all logging, until explicitly enabled. To enable tracking, please call `amplitude.getInstance().enableTracking()` *Note: This will not affect users who already have an amplitude cookie. The decision to track events is determined by whether or not a user has an amplitude analytics cookie. If the `cookieExpiration</code> is manually defined to be a short lifespan, you may need to run `amplitude.getInstance().enableTracking()` upon the cookie expiring or upon logging in.*
*/
deferInitialization?: boolean;
/**
* - Disable Ampllitude cookies altogether.
*/
disableCookies?: boolean;
/**
* randomly generated UUID.] - The custom Device ID to set. *Note: This is not recommended unless you know what you are doing (e.g. you have your own system for tracking user devices).*
*/
deviceId?: string;
/**
* - If `true`, then the SDK will parse Device ID values from the URL parameter amp_device_id if available. Device IDs defined in the configuration options during init will take priority over Device IDs from URL parameters.
*/
deviceIdFromUrlParam?: boolean;
/**
* top domain of the current page's URL. ('https://amplitude.com')] - Set a custom domain for the Amplitude cookie. To include subdomains, add a preceding period, eg: `.amplitude.com`.
*/
domain?: string;
/**
* - Amount of time in milliseconds that the SDK waits before uploading events if batchEvents is true.
*/
eventUploadPeriodMillis?: number;
/**
* - Minimum number of events to batch together per request if batchEvents is true.
*/
eventUploadThreshold?: number;
/**
* - If `true`, the events will always be uploaded to HTTPS endpoint. Otherwise, it will use the embedding site's protocol.
*/
forceHttps?: boolean;
/**
* - If `true`, captures the fbclid URL parameter as well as the user's initial_fbclid via a setOnce operation.
*/
includeFbclid?: boolean;
/**
* - If `true`, captures the gclid URL parameter as well as the user's initial_gclid via a setOnce operation.
*/
includeGclid?: boolean;
/**
* - If `true`, captures the referrer and referring_domain for each session, as well as the user's initial_referrer and initial_referring_domain via a setOnce operation.
*/
includeReferrer?: boolean;
/**
* - If `true`, finds UTM parameters in the query string or the _utmz cookie, parses, and includes them as user properties on all events uploaded. This also captures initial UTM parameters for each session via a setOnce operation.
*/
includeUtm?: boolean;
/**
* language determined by the browser] - Custom language to set.
*/
language?: string;
/**
* - Level of logs to be printed in the developer console. Valid values are 'DISABLE', 'ERROR', 'WARN', 'INFO'. To learn more about the different options, see below.
*/
logLevel?: string;
/**
* - If `true`, the SDK will log an Amplitude event anytime new attribution values are captured from the user. **Note: These events count towards your event volume.** Event name being logged: [Amplitude] Attribution Captured. Event Properties that can be logged: `utm_source`, `utm_medium`, `utm_campaign`, `utm_term`, `utm_content`, `referrer`, `referring_domain`, `gclid`, `fbclid`. For UTM properties to be logged, `includeUtm` must be set to `true`. For the `referrer` and `referring_domain` properties to be logged, `includeReferrer` must be set to `true`. For the `gclid` property to be logged, `includeGclid` must be set to `true`. For the `fbclid` property to be logged, `includeFbclid` must be set to `true`.
*/
logAttributionCapturedEvent?: boolean;
/**
* - Whether or not to disable tracking for the current user.
*/
optOut?: boolean;
/**
* - Function to call on error.
*/
onError?: Function;
/**
* - Platform device is running on. `Web` is a browser (including mobile browsers). `iOS` and `Android` are relevant only for react-native apps.
*/
platform?: string;
/**
* - Maximum number of events to save in localStorage. If more events are logged while offline, then old events are removed.
*/
savedMaxCount?: number;
/**
* - If `true`, saves events to localStorage and removes them upon successful upload. *Note: Without saving events, events may be lost if the user navigates to another page before the events are uploaded.*
*/
saveEvents?: boolean;
/**
* - If `true`, then includeGclid, includeFbclid, includeReferrer, and includeUtm will only track their respective properties once per session. New values that come in during the middle of the user's session will be ignored. Set to false to always capture new values.
*/
saveParamsReferrerOncePerSession?: boolean;
/**
* - If `true`, the amplitude cookie will be set with the Secure flag.
*/
secureCookie?: boolean;
/**
* - The time between logged events before a new session starts in milliseconds.
*/
sessionTimeout?: number;
/**
* - Sets storage strategy. Options are 'cookies', 'localStorage', 'sessionStorage', or `none`. Will override `disableCookies` option
*/
storage?: string[];
/**
* - Type of data associated with a user.
*/
trackingOptions?: any;
/**
* - If `false`, the existing `referrer` and `utm_parameter` values will be carried through each new session. If set to `true`, the `referrer` and `utm_parameter` user properties, which include `referrer`, `utm_source`, `utm_medium`, `utm_campaign`, `utm_term`, and `utm_content`, will be set to `null` upon instantiating a new session. Note: This only works if `includeReferrer` or `includeUtm` is set to `true`.
*/
unsetParamsReferrerOnNewSession?: boolean;
/**
* - localStorage key that stores unsent events.
*/
unsentKey?: string;
/**
* - localStorage key that stores unsent identifies.
*/
unsentIdentifyKey?: string;
/**
* - The maximum number of events to send to the server per request.
*/
uploadBatchSize?: number;
};
declare let platform: string;
15 changes: 15 additions & 0 deletions types/revenue.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default Revenue;
declare class Revenue {
public setProductId(productId: string): Revenue;
_productId: string;
public setQuantity(quantity: number): Revenue;
_quantity: number;
public setPrice(price: number): Revenue;
_price: number;
public setRevenueType(revenueType: string): Revenue;
_revenueType: string;
public setEventProperties(eventProperties: object): Revenue;
_properties: {};
private _isValidRevenue;
private _toJSONObject;
}
2 changes: 2 additions & 0 deletions types/top-domain.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export default topDomain;
declare function topDomain(url: any): string;
8 changes: 8 additions & 0 deletions types/type.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Return the type of `val`.
* @private
* @param {Mixed} val
* @return {String}
* @api public
*/
export default function _default(val: any): string;
5 changes: 5 additions & 0 deletions types/utf8.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default UTF8;
declare namespace UTF8 {
function encode(s: any): string;
function decode(utftext: any): string;
}
Loading
Oops, something went wrong.