@affiliateo/react-native 1.1.0 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@affiliateo/react-native",
3
- "version": "1.1.0",
4
- "description": "Affiliateo SDK for React Native — mobile affiliate attribution and screen tracking",
3
+ "version": "1.1.5",
4
+ "description": "Affiliateo SDK for React Native — mobile affiliate attribution and session tracking",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
7
7
  "scripts": {
package/src/index.ts CHANGED
@@ -1,8 +1,8 @@
1
- export { AffiliateoProvider, useAffiliateRef } from './provider'
2
- export type {
3
- AffiliateoConfig,
4
- AffiliateoContextValue,
5
- DeviceInfo,
6
- IdentifyResponse,
7
- MobileEvent,
8
- } from './types'
1
+ export { AffiliateoProvider, useAffiliateRef } from './provider'
2
+ export type {
3
+ AffiliateoConfig,
4
+ AffiliateoContextValue,
5
+ DeviceInfo,
6
+ IdentifyResponse,
7
+ MobileEvent,
8
+ } from './types'
package/src/provider.tsx CHANGED
@@ -79,8 +79,6 @@ export const AffiliateoContext = createContext<AffiliateoContextValue>({
79
79
  isMatched: false,
80
80
  isLoading: true,
81
81
  visitorId: null,
82
- trackScreen: noop,
83
- trackEvent: noop,
84
82
  })
85
83
 
86
84
  /**
@@ -95,7 +93,7 @@ export function AffiliateoProvider({
95
93
  apiUrl,
96
94
  children,
97
95
  }: AffiliateoConfig & { children: React.ReactNode }) {
98
- const [state, setState] = useState<Omit<AffiliateoContextValue, 'trackScreen' | 'trackEvent'>>({
96
+ const [state, setState] = useState<AffiliateoContextValue>({
99
97
  refCode: null,
100
98
  isMatched: false,
101
99
  isLoading: true,
@@ -169,30 +167,8 @@ export function AffiliateoProvider({
169
167
  }
170
168
  }, [campaignId, apiUrl])
171
169
 
172
- const trackScreen = useCallback((screenName: string) => {
173
- const deviceId = deviceIdRef.current
174
- if (!deviceId) return
175
- clientRef.current.sendEvents(campaignId, deviceId, [
176
- { type: 'screen_view', screen: screenName, timestamp: new Date().toISOString() },
177
- ]).catch(() => {})
178
- }, [campaignId])
179
-
180
- const trackEvent = useCallback((eventName: string, metadata?: Record<string, unknown>) => {
181
- const deviceId = deviceIdRef.current
182
- if (!deviceId) return
183
- clientRef.current.sendEvents(campaignId, deviceId, [
184
- { type: 'custom', screen: eventName, timestamp: new Date().toISOString(), metadata },
185
- ]).catch(() => {})
186
- }, [campaignId])
187
-
188
- const contextValue: AffiliateoContextValue = {
189
- ...state,
190
- trackScreen,
191
- trackEvent,
192
- }
193
-
194
170
  return (
195
- <AffiliateoContext.Provider value={contextValue}>
171
+ <AffiliateoContext.Provider value={state}>
196
172
  {children}
197
173
  </AffiliateoContext.Provider>
198
174
  )
package/src/types.ts CHANGED
@@ -1,38 +1,34 @@
1
- export interface AffiliateoConfig {
2
- campaignId: string
3
- /** Base URL for the API. Defaults to https://affiliateo.com */
4
- apiUrl?: string
5
- }
6
-
7
- export interface DeviceInfo {
8
- device_model: string
9
- os: string
10
- os_version: string
11
- app_version: string
12
- screen_width: number
13
- screen_height: number
14
- timezone: string
15
- language: string
16
- }
17
-
18
- export interface IdentifyResponse {
19
- visitor_id: string
20
- ref_code: string | null
21
- matched: boolean
22
- }
23
-
24
- export interface MobileEvent {
25
- type: 'screen_view' | 'session_start' | 'session_end' | 'custom'
26
- screen?: string
27
- timestamp: string
28
- metadata?: Record<string, unknown>
29
- }
30
-
31
- export interface AffiliateoContextValue {
32
- refCode: string | null
33
- isMatched: boolean
34
- isLoading: boolean
35
- visitorId: string | null
36
- trackScreen: (screenName: string) => void
37
- trackEvent: (eventName: string, metadata?: Record<string, unknown>) => void
38
- }
1
+ export interface AffiliateoConfig {
2
+ campaignId: string
3
+ /** Base URL for the API. Defaults to https://affiliateo.com */
4
+ apiUrl?: string
5
+ }
6
+
7
+ export interface DeviceInfo {
8
+ device_model: string
9
+ os: string
10
+ os_version: string
11
+ app_version: string
12
+ screen_width: number
13
+ screen_height: number
14
+ timezone: string
15
+ language: string
16
+ }
17
+
18
+ export interface IdentifyResponse {
19
+ visitor_id: string
20
+ ref_code: string | null
21
+ matched: boolean
22
+ }
23
+
24
+ export interface MobileEvent {
25
+ type: 'session_start' | 'session_end'
26
+ timestamp: string
27
+ }
28
+
29
+ export interface AffiliateoContextValue {
30
+ refCode: string | null
31
+ isMatched: boolean
32
+ isLoading: boolean
33
+ visitorId: string | null
34
+ }