Skip to content

Commit 367659f

Browse files
committed
Added type definitions
1 parent 9dcac83 commit 367659f

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

index.d.ts

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
declare module 'react-native-analytics-segment-io' {
2+
3+
export enum AnalyticsConstants {
4+
enableAdvertisingTracking = 'enableAdvertisingTracking',
5+
flushAt = 'flushAt',
6+
recordScreenViews = 'recordScreenViews',
7+
shouldUseBluetooth = 'shouldUseBluetooth',
8+
shouldUseLocationServices = 'shouldUseLocationServices',
9+
trackApplicationLifecycleEvents = 'trackApplicationLifecycleEvents',
10+
trackAttributionData = 'trackAttributionData',
11+
trackDeepLinks = 'trackDeepLinks',
12+
debug = 'debug',
13+
}
14+
15+
/**
16+
* Initialize Segment with the write key
17+
* @param {string} key The writable key for segment
18+
* @param {{string: any}} options Parameters to initalize segment with, see AnalyticsConstants
19+
* @return {Promise} Returns true when initialization has started
20+
*/
21+
export function setup(key: string, options: any ) : Promise<boolean>;
22+
23+
/**
24+
* Identify the current user
25+
* @param {string} userID UserID
26+
* @param {{string: any}} traits Traits identifying the user
27+
*/
28+
export function identify(userId: string, traits: any): void;
29+
30+
/**
31+
* Track an event
32+
* @param {string} event Event Name
33+
* @param {{string: any}} properties Properties for the current event
34+
*/
35+
export function track(event: string, properties: any): void;
36+
37+
/**
38+
* Track a screen change event
39+
* @param {string} name Name of the screen
40+
* @param {{string: any}} properties Properties for the current screen
41+
*/
42+
export function screen(name: string, properties: any): void;
43+
44+
/**
45+
* Track a group
46+
* @param {string} groupID ID of the current users group
47+
* @param {{string: any}} traits Traits for this group
48+
*/
49+
export function group(groupID: string, traits: any): void;
50+
51+
/**
52+
* Set an alias for the user
53+
* @param {string} alias Alias of the user
54+
*/
55+
export function alias(alias: string): void;
56+
57+
/**
58+
* Reset internal current Segment cache
59+
* Useful to call during login/logout operations after calling flush
60+
*/
61+
export function reset(): void;
62+
63+
/**
64+
* Flush all segment data to server.
65+
* Note: By default segment caches 20 events before sending data to server
66+
*/
67+
export function flush(): void;
68+
69+
/**
70+
* Enable tracking for this user
71+
* This function allows users to opt-in/opt-out of analytics tracking
72+
*/
73+
export function enable(): void;
74+
75+
/**
76+
* Disable tracking for this user
77+
* This function allows users to opt-in/opt-out of analytics tracking
78+
*/
79+
export function disable(): void;
80+
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"type": "git",
1111
"url": "git+https://github.com/leoilab/react-native-analytics-segment-io.git"
1212
},
13+
"typings": "index.d.ts",
1314
"keywords": [
1415
"react-native",
1516
"segment",

0 commit comments

Comments
 (0)