mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
🤖 Merge PR #65777 [Mixpanel] Update types of register methods by @PeterShershov
* Update types of register methods - added test for the days and options object - added tests for unregister method signature in mixpanel-browser * formatting * make persistent optional in the mixpanel package
This commit is contained in:
20
types/mixpanel-browser/index.d.ts
vendored
20
types/mixpanel-browser/index.d.ts
vendored
@@ -48,6 +48,10 @@ export interface OutTrackingOptions extends ClearOptOutInOutOptions {
|
||||
delete_user: boolean;
|
||||
}
|
||||
|
||||
export interface RegisterOptions {
|
||||
persistent: boolean;
|
||||
}
|
||||
|
||||
export interface Config {
|
||||
api_host: string;
|
||||
api_method: string;
|
||||
@@ -158,8 +162,8 @@ export interface Mixpanel {
|
||||
opt_in_tracking(options?: Partial<InTrackingOptions>): void;
|
||||
opt_out_tracking(options?: Partial<OutTrackingOptions>): void;
|
||||
push(item: PushItem): void;
|
||||
register(props: Dict, days?: number): void;
|
||||
register_once(props: Dict, default_value?: any, days?: number): void;
|
||||
register(props: Dict, days_or_options?: number | Partial<RegisterOptions>): void;
|
||||
register_once(props: Dict, default_value?: any, days_or_options?: number | Partial<RegisterOptions>): void;
|
||||
remove_group(group_key: string, group_ids: string | string[] | number | number[], callback?: Callback): void;
|
||||
reset(): void;
|
||||
set_config(config: Partial<Config>): void;
|
||||
@@ -174,7 +178,7 @@ export interface Mixpanel {
|
||||
track_forms(query: Query, event_name: string, properties?: Dict | (() => void)): void;
|
||||
track_links(query: Query, event_name: string, properties?: Dict | (() => void)): void;
|
||||
track_with_groups(event_name: string, properties: Dict, groups: Dict, callback?: Callback): void;
|
||||
unregister(property: string): void;
|
||||
unregister(property: string, options?: Partial<RegisterOptions>): void;
|
||||
people: People;
|
||||
}
|
||||
|
||||
@@ -199,8 +203,12 @@ export function init(token: string, config?: Partial<Config>): undefined;
|
||||
export function opt_in_tracking(options?: Partial<InTrackingOptions>): void;
|
||||
export function opt_out_tracking(options?: Partial<OutTrackingOptions>): void;
|
||||
export function push(item: PushItem): void;
|
||||
export function register(props: Dict, days?: number): void;
|
||||
export function register_once(props: Dict, default_value?: any, days?: number): void;
|
||||
export function register(props: Dict, days_or_options?: number | Partial<RegisterOptions>): void;
|
||||
export function register_once(
|
||||
props: Dict,
|
||||
default_value?: any,
|
||||
days_or_options?: number | Partial<RegisterOptions>,
|
||||
): void;
|
||||
export function remove_group(
|
||||
group_key: string,
|
||||
group_ids: string | string[] | number | number[],
|
||||
@@ -223,7 +231,7 @@ export function track(
|
||||
export function track_forms(query: Query, event_name: string, properties?: Dict | (() => void)): void;
|
||||
export function track_links(query: Query, event_name: string, properties?: Dict | (() => void)): void;
|
||||
export function track_with_groups(event_name: string, properties: Dict, groups: Dict, callback?: Callback): void;
|
||||
export function unregister(property: string): void;
|
||||
export function unregister(property: string, options?: Partial<RegisterOptions>): void;
|
||||
export const people: People;
|
||||
|
||||
declare const mixpanel: OverridedMixpanel;
|
||||
|
||||
@@ -34,9 +34,24 @@ mixpanel.register({
|
||||
Email: 'jdoe@example.com',
|
||||
'Account Type': 'Free',
|
||||
});
|
||||
mixpanel.register({
|
||||
Email: 'jdoe@example.com',
|
||||
}, 3);
|
||||
mixpanel.register({
|
||||
Email: 'jdoe@example.com',
|
||||
}, { persistent: false });
|
||||
mixpanel.register_once({
|
||||
'First Login Date': new Date().toISOString(),
|
||||
});
|
||||
mixpanel.register_once({
|
||||
'First Login Date': new Date().toISOString(),
|
||||
}, 3);
|
||||
mixpanel.register_once({
|
||||
'First Login Date': new Date().toISOString(),
|
||||
}, { persistent: false });
|
||||
|
||||
mixpanel.unregister('First Login Date');
|
||||
mixpanel.unregister('First Login Date', { persistent: false });
|
||||
mixpanel.init('YOUR PROJECT TOKEN', {
|
||||
loaded: mixpanel => {
|
||||
const distinct_id = mixpanel.get_distinct_id();
|
||||
|
||||
15
types/mixpanel/index.d.ts
vendored
15
types/mixpanel/index.d.ts
vendored
@@ -191,9 +191,9 @@ interface Mixpanel {
|
||||
* });
|
||||
*
|
||||
* @param properties An associative array of properties to store about the user
|
||||
* @param days How many days since the user's last visit to store the super properties
|
||||
* @param daysOrOptions How many days since the user's last visit to store the super properties or the options object which controls persistence
|
||||
*/
|
||||
register(properties: { [index: string]: any }, days?: number): void;
|
||||
register(properties: { [index: string]: any }, daysOrOptions?: number | { persistent?: boolean }): void;
|
||||
|
||||
/**
|
||||
* Register a set of super properties only once. This will not
|
||||
@@ -213,16 +213,21 @@ interface Mixpanel {
|
||||
*
|
||||
* @param properties An associative array of properties to store about the user
|
||||
* @param defaultValue Value to override if already set in super properties (ex: 'False') Default: 'None'
|
||||
* @param days How many days since the users last visit to store the super properties
|
||||
* @param daysOrOptions How many days since the users last visit to store the super properties or the options object which controls persistence
|
||||
*/
|
||||
register_once(properties: { [index: string]: any }, defaultValue?: string, days?: number): void;
|
||||
register_once(
|
||||
properties: { [index: string]: any },
|
||||
defaultValue?: string,
|
||||
daysOrOptions?: number | { persistent?: boolean },
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Delete a super property stored with the current user.
|
||||
*
|
||||
* @param propertyName The name of the super property to remove
|
||||
* @param options The options object which controls persistence
|
||||
*/
|
||||
unregister(propertyName: string): void;
|
||||
unregister(propertyName: string, options?: { persistent?: boolean }): void;
|
||||
|
||||
/**
|
||||
* Identify a user with a unique ID. All subsequent
|
||||
|
||||
@@ -38,11 +38,14 @@ function mixpanel_base() {
|
||||
|
||||
mixpanel.register({ device: 'android', version: '4.0.1' });
|
||||
mixpanel.register({ device: 'android', version: '4.0.1' }, 5);
|
||||
mixpanel.register({ device: 'android', version: '4.0.1' }, { persistent: false });
|
||||
|
||||
mixpanel.register_once({ device: 'android', version: '4.0.1' });
|
||||
mixpanel.register_once({ device: 'android', version: '4.0.1' }, 'default', 4);
|
||||
mixpanel.register_once({ device: 'android', version: '4.0.1' }, 'default', { persistent: false });
|
||||
|
||||
mixpanel.unregister('device');
|
||||
mixpanel.unregister('device', { persistent: false });
|
||||
|
||||
mixpanel.identify();
|
||||
mixpanel.identify('234234sdfdsf');
|
||||
|
||||
Reference in New Issue
Block a user