react-native-test-adx 0.1.2 → 0.1.4

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.
Files changed (30) hide show
  1. package/README.md +355 -253
  2. package/lib/module/AdaxonSdk.js +51 -44
  3. package/lib/module/components/AdaxonProvider.js +13 -3
  4. package/lib/module/components/InterstitialAd.js +279 -0
  5. package/lib/module/config/ApiConstants.js +3 -1
  6. package/lib/module/config/StorageKeys.js +1 -1
  7. package/lib/module/core/AdaxonClient.js +2 -8
  8. package/lib/module/hooks/useAdaxon.js +1 -3
  9. package/lib/module/platform/app.js +44 -3
  10. package/lib/module/platform/reactNative.js +65 -70
  11. package/lib/module/services/device/DeviceInfoService.js +59 -10
  12. package/lib/module/services/event/EventBuilder.js +1 -8
  13. package/lib/module/services/event/EventService.js +7 -5
  14. package/lib/module/types/AdaxonConfig.js +1 -3
  15. package/lib/typescript/src/AdaxonSdk.d.ts +7 -7
  16. package/lib/typescript/src/components/InterstitialAd.d.ts +10 -0
  17. package/lib/typescript/src/config/ApiConstants.d.ts +2 -1
  18. package/lib/typescript/src/core/AdaxonClient.d.ts +0 -1
  19. package/lib/typescript/src/hooks/useAdaxon.d.ts +1 -3
  20. package/lib/typescript/src/index.d.ts +2 -2
  21. package/lib/typescript/src/platform/app.d.ts +2 -10
  22. package/lib/typescript/src/platform/reactNative.d.ts +1 -0
  23. package/lib/typescript/src/platform/types.d.ts +1 -0
  24. package/lib/typescript/src/services/device/DeviceInfoService.d.ts +11 -1
  25. package/lib/typescript/src/services/event/EventBuilder.d.ts +0 -5
  26. package/lib/typescript/src/types/AdaxonConfig.d.ts +0 -10
  27. package/lib/typescript/src/types/EventTypes.d.ts +0 -4
  28. package/package.json +1 -1
  29. package/lib/module/storage/AnonymousIdService.js +0 -31
  30. package/lib/typescript/src/storage/AnonymousIdService.d.ts +0 -11
@@ -1,12 +1,43 @@
1
1
  "use strict";
2
2
 
3
3
  import { Linking, NativeEventEmitter, NativeModules, Platform } from 'react-native';
4
+ export { BackHandler, Dimensions, Image, Modal, Platform, Pressable, SafeAreaView, StatusBar, StyleSheet, Text, View } from 'react-native';
4
5
  import { nonEmptyString, setIfPresent } from "../utils/strings.js";
5
6
  import { readLocaleFields } from "../utils/locale.js";
6
7
  import { appFieldsFromNative } from "./app.js";
7
8
  import { deviceFieldsFromAndroid } from "./android.js";
8
9
  import { deviceFieldsFromIos } from "./ios.js";
9
10
  import { connectionTypeFromNativeState, ipAddressFromNativeState, isOnlineFromNativeState, usableIpAddress } from "./network.js";
11
+ function expoNativeModule(name) {
12
+ try {
13
+ const expoGlobal = globalThis;
14
+ return expoGlobal.expo?.modules?.[name];
15
+ } catch {
16
+ return undefined;
17
+ }
18
+ }
19
+ function nativeModule(name) {
20
+ return (NativeModules ?? {})[name] ?? expoNativeModule(name);
21
+ }
22
+ async function callNative(method, arg) {
23
+ if (typeof method !== 'function') {
24
+ return undefined;
25
+ }
26
+ try {
27
+ return await method(arg);
28
+ } catch {
29
+ return undefined;
30
+ }
31
+ }
32
+ function safeUnsubscribe(remove) {
33
+ return () => {
34
+ try {
35
+ remove?.();
36
+ } catch {
37
+ // Native unsubscribe can throw after the module is torn down.
38
+ }
39
+ };
40
+ }
10
41
  export function detectReactNativePlatform() {
11
42
  return Platform.OS === 'ios' || Platform.OS === 'android' ? Platform.OS : 'web';
12
43
  }
@@ -27,45 +58,14 @@ function collectFromReactNative(platform) {
27
58
  Object.assign(device, readLocaleFields());
28
59
  return device;
29
60
  }
30
- export const reactNativeDeviceReader = {
31
- readDeviceInfo: collectFromReactNative
32
- };
33
- export const reactNativeAppInfoReader = {
34
- readAppInfo: () => appFieldsFromNative(readNativeAppConstants())
35
- };
36
- export const reactNativeNetworkInfoReader = {
37
- readNetworkInfo: collectFromNativeNetwork
38
- };
39
- export const reactNativeNetworkStatusReader = {
40
- getIsOnline: readIsOnlineFromNative,
41
- subscribe: subscribeNativeNetworkStatus
42
- };
43
- export const reactNativeUrlOpener = Linking;
44
- function readNativeAppConstants() {
45
- const modules = NativeModules ?? {};
46
- const expoApp = modules.ExpoApplication;
47
- const expoConstants = modules.ExponentConstants;
48
- const deviceInfo = modules.RNDeviceInfo;
49
- return {
50
- ...deviceInfo,
51
- ...expoConstants,
52
- ...expoApp
53
- };
61
+ async function readUniqueIdFromNative() {
62
+ const deviceInfo = nativeModule('RNDeviceInfo');
63
+ return nonEmptyString(await callNative(deviceInfo?.getUniqueId)) ?? '';
54
64
  }
55
65
  function nativeNetworkModules() {
56
- const modules = NativeModules ?? {};
57
66
  return {
58
- netInfo: modules.RNCNetInfo,
59
- expoNetwork: modules.ExpoNetwork
60
- };
61
- }
62
- function safeUnsubscribe(remove) {
63
- return () => {
64
- try {
65
- remove?.();
66
- } catch {
67
- // Native unsubscribe can throw after the module is torn down.
68
- }
67
+ netInfo: nativeModule('RNCNetInfo'),
68
+ expoNetwork: nativeModule('ExpoNetwork')
69
69
  };
70
70
  }
71
71
  async function readIsOnlineFromNative() {
@@ -73,18 +73,11 @@ async function readIsOnlineFromNative() {
73
73
  netInfo,
74
74
  expoNetwork
75
75
  } = nativeNetworkModules();
76
- const getCurrentState = netInfo?.getCurrentState;
77
- if (typeof getCurrentState === 'function') {
78
- const online = isOnlineFromNativeState(await readOptionalNative(() => getCurrentState(null)));
79
- if (online !== null) {
80
- return online;
81
- }
82
- }
83
- const getNetworkState = expoNetwork?.getNetworkStateAsync;
84
- if (typeof getNetworkState === 'function') {
85
- return isOnlineFromNativeState(await readOptionalNative(getNetworkState));
76
+ const fromNetInfo = isOnlineFromNativeState(await callNative(netInfo?.getCurrentState, null));
77
+ if (fromNetInfo !== null) {
78
+ return fromNetInfo;
86
79
  }
87
- return null;
80
+ return isOnlineFromNativeState(await callNative(expoNetwork?.getNetworkStateAsync));
88
81
  }
89
82
  function subscribeNativeNetworkStatus(listener) {
90
83
  const {
@@ -99,9 +92,8 @@ function subscribeNativeNetworkStatus(listener) {
99
92
  const subscription = new NativeEventEmitter(NativeModules.RNCNetInfo).addListener('netInfo.networkStatusDidChange', onState);
100
93
  return safeUnsubscribe(() => subscription.remove());
101
94
  }
102
- const addListener = expoNetwork?.addListener;
103
- if (typeof addListener === 'function') {
104
- const subscription = addListener.call(expoNetwork, 'onNetworkStateChanged', onState);
95
+ if (expoNetwork && typeof expoNetwork.addListener === 'function') {
96
+ const subscription = expoNetwork.addListener('onNetworkStateChanged', onState);
105
97
  return safeUnsubscribe(() => subscription?.remove?.());
106
98
  }
107
99
  } catch (error) {
@@ -109,32 +101,35 @@ function subscribeNativeNetworkStatus(listener) {
109
101
  }
110
102
  return () => undefined;
111
103
  }
112
- async function readOptionalNative(read) {
113
- try {
114
- return await read();
115
- } catch {
116
- return undefined;
117
- }
118
- }
119
104
  async function collectFromNativeNetwork() {
120
105
  const network = {};
121
106
  const {
122
107
  netInfo,
123
108
  expoNetwork
124
109
  } = nativeNetworkModules();
125
- const getCurrentState = netInfo?.getCurrentState;
126
- if (typeof getCurrentState === 'function') {
127
- const state = await readOptionalNative(() => getCurrentState(null));
128
- setIfPresent(network, 'connection_type', connectionTypeFromNativeState(state));
129
- setIfPresent(network, 'ip_address', ipAddressFromNativeState(state));
130
- }
131
- const getNetworkState = expoNetwork?.getNetworkStateAsync;
132
- if (!network.connection_type && typeof getNetworkState === 'function') {
133
- setIfPresent(network, 'connection_type', connectionTypeFromNativeState(await readOptionalNative(getNetworkState)));
110
+ const state = await callNative(netInfo?.getCurrentState, null);
111
+ setIfPresent(network, 'connection_type', connectionTypeFromNativeState(state));
112
+ setIfPresent(network, 'ip_address', ipAddressFromNativeState(state));
113
+ if (!network.connection_type) {
114
+ setIfPresent(network, 'connection_type', connectionTypeFromNativeState(await callNative(expoNetwork?.getNetworkStateAsync)));
134
115
  }
135
- const getIpAddress = expoNetwork?.getIpAddressAsync;
136
- if (!network.ip_address && typeof getIpAddress === 'function') {
137
- setIfPresent(network, 'ip_address', usableIpAddress(nonEmptyString(await readOptionalNative(getIpAddress))));
116
+ if (!network.ip_address) {
117
+ setIfPresent(network, 'ip_address', usableIpAddress(nonEmptyString(await callNative(expoNetwork?.getIpAddressAsync))));
138
118
  }
139
119
  return network;
140
- }
120
+ }
121
+ export const reactNativeDeviceReader = {
122
+ readDeviceInfo: collectFromReactNative,
123
+ getUniqueId: readUniqueIdFromNative
124
+ };
125
+ export const reactNativeAppInfoReader = {
126
+ readAppInfo: () => appFieldsFromNative(nativeModule('RNDeviceInfo'), nativeModule('ExponentConstants'), nativeModule('ExpoApplication'))
127
+ };
128
+ export const reactNativeNetworkInfoReader = {
129
+ readNetworkInfo: collectFromNativeNetwork
130
+ };
131
+ export const reactNativeNetworkStatusReader = {
132
+ getIsOnline: readIsOnlineFromNative,
133
+ subscribe: subscribeNativeNetworkStatus
134
+ };
135
+ export const reactNativeUrlOpener = Linking;
@@ -1,22 +1,71 @@
1
1
  "use strict";
2
2
 
3
+ import { ANONYMOUS_ID_KEY_PREFIX, sanitizeStorageId } from "../../config/StorageKeys.js";
4
+ import { nonEmptyString } from "../../utils/strings.js";
5
+ import { createUuid } from "../../utils/uuid.js";
3
6
  export class DeviceInfoService {
4
- constructor(platform, reader) {
7
+ constructor(platform, reader, storage, appId) {
5
8
  this.platform = platform;
6
9
  this.reader = reader;
10
+ this.storage = storage;
11
+ this.anonymousIdKey = storage && appId ? `${ANONYMOUS_ID_KEY_PREFIX}${sanitizeStorageId(appId)}` : undefined;
7
12
  }
8
13
  getDeviceInfo() {
9
14
  if (!this.cached) {
10
- try {
11
- this.cached = this.reader?.readDeviceInfo(this.platform) ?? {
12
- platform: this.platform
13
- };
14
- } catch {
15
- this.cached = {
16
- platform: this.platform
17
- };
18
- }
15
+ this.cached = this.readDeviceInfo();
19
16
  }
20
17
  return this.cached;
21
18
  }
19
+ getUniqueId() {
20
+ if (!this.uniqueIdPromise) {
21
+ this.uniqueIdPromise = this.resolveUniqueId();
22
+ }
23
+ return this.uniqueIdPromise;
24
+ }
25
+ readDeviceInfo() {
26
+ const fallback = {
27
+ platform: this.platform
28
+ };
29
+ try {
30
+ return this.reader?.readDeviceInfo(this.platform) ?? fallback;
31
+ } catch {
32
+ return fallback;
33
+ }
34
+ }
35
+ async resolveUniqueId() {
36
+ const stored = await this.readStoredId();
37
+ if (stored) {
38
+ return stored;
39
+ }
40
+ const uniqueId = (await this.readNativeId()) ?? createUuid();
41
+ await this.writeStoredId(uniqueId);
42
+ return uniqueId;
43
+ }
44
+ async readNativeId() {
45
+ try {
46
+ return nonEmptyString(await this.reader?.getUniqueId?.());
47
+ } catch {
48
+ return undefined;
49
+ }
50
+ }
51
+ async readStoredId() {
52
+ if (!this.storage || !this.anonymousIdKey) {
53
+ return undefined;
54
+ }
55
+ try {
56
+ return nonEmptyString(await this.storage.getItem(this.anonymousIdKey));
57
+ } catch {
58
+ return undefined;
59
+ }
60
+ }
61
+ async writeStoredId(uniqueId) {
62
+ if (!this.storage || !this.anonymousIdKey) {
63
+ return;
64
+ }
65
+ try {
66
+ await this.storage.setItem(this.anonymousIdKey, uniqueId);
67
+ } catch {
68
+ // Persistence must not block tracking.
69
+ }
70
+ }
22
71
  }
@@ -1,30 +1,23 @@
1
1
  "use strict";
2
2
 
3
3
  import { createUuid } from "../../utils/uuid.js";
4
- import { nonEmptyString, setIfPresent } from "../../utils/strings.js";
5
4
  export class EventBuilder {
6
5
  sessionId = createUuid();
7
6
  constructor(config) {
8
7
  this.config = config;
9
- this.externalUserId = config.externalUserId;
10
- }
11
- setExternalUserId(externalUserId) {
12
- this.externalUserId = externalUserId;
13
8
  }
14
9
  async build(input) {
15
10
  const {
16
11
  validator,
17
12
  appId,
18
- anonymousId,
19
13
  deviceInfo,
20
14
  appInfo,
21
15
  networkInfo
22
16
  } = this.config;
23
17
  validator.validateTrackInput(input);
24
18
  const user = {
25
- anonymous_id: await anonymousId.getAnonymousId()
19
+ anonymous_id: await deviceInfo.getUniqueId()
26
20
  };
27
- setIfPresent(user, 'external_user_id', nonEmptyString(this.externalUserId));
28
21
  return {
29
22
  event_id: input.eventId ?? createUuid(),
30
23
  event_name: input.eventName,
@@ -19,11 +19,13 @@ export class EventService {
19
19
  }
20
20
  async getRecommendations(input) {
21
21
  const eventPayload = await this.builder.build(input);
22
- const payload = {
23
- ...eventPayload,
24
- event_type: 'recommendation'
25
- };
26
- const response = await this.api.post(RECOMMENDATIONS_PATH, payload);
22
+ await this.postEvents([eventPayload]);
23
+ const response = await this.api.post(RECOMMENDATIONS_PATH, {
24
+ app_id: eventPayload.app_id,
25
+ device: {
26
+ platform: eventPayload.device.platform
27
+ }
28
+ });
27
29
  if (!Array.isArray(response.offers)) {
28
30
  throw new AdaxonSdkError('HTTP_ERROR', 'Adaxon recommendation response is missing the offers array.');
29
31
  }
@@ -1,3 +1 @@
1
- "use strict";
2
-
3
- export {};
1
+ "use strict";
@@ -1,13 +1,12 @@
1
1
  import { type TrackAddToCartParams, type TrackCompleteRegistrationParams, type TrackLoginParams, type TrackPurchaseParams } from './services/event/normalizeProperties.js';
2
- import type { AdaxonInitializationConfiguration, AdaxonInitializationListener, AdaxonOfferShowListener, AdaxonRecommendationLoadListener } from './types/AdaxonConfig.js';
3
- import type { EventIngestionResponse, RecommendationOffer } from './types/ApiTypes.js';
2
+ import type { AdaxonInitializationConfiguration, AdaxonInitializationListener } from './types/AdaxonConfig.js';
3
+ import type { EventIngestionResponse } from './types/ApiTypes.js';
4
4
  import type { EventProperties, TrackEventInput, TrackEventOptions } from './types/EventTypes.js';
5
5
  import type { BatchProcessResult } from './types/QueuedEvent.js';
6
6
  export declare class AdaxonSdk {
7
- private static readonly sharedInstance;
7
+ static readonly shared: AdaxonSdk;
8
8
  private client;
9
9
  private testMode;
10
- static get shared(): AdaxonSdk;
11
10
  isInitialized(): boolean;
12
11
  initialize(configuration: AdaxonInitializationConfiguration, listener?: AdaxonInitializationListener): Promise<void>;
13
12
  track(eventName: string, properties?: EventProperties, options?: TrackEventOptions): Promise<EventIngestionResponse>;
@@ -19,11 +18,12 @@ export declare class AdaxonSdk {
19
18
  trackAddToCart(params: TrackAddToCartParams, options?: TrackEventOptions): Promise<EventIngestionResponse>;
20
19
  trackLogin(params?: TrackLoginParams, options?: TrackEventOptions): Promise<EventIngestionResponse>;
21
20
  trackCompleteRegistration(params?: TrackCompleteRegistrationParams, options?: TrackEventOptions): Promise<EventIngestionResponse>;
22
- loadRecommendations(eventName: string, properties?: EventProperties, listener?: AdaxonRecommendationLoadListener): Promise<RecommendationOffer[]>;
23
- showOffer(offer: RecommendationOffer, listener?: AdaxonOfferShowListener): Promise<void>;
24
- setExternalUserId(externalUserId?: string): void;
21
+ showAd(): Promise<void>;
25
22
  isNetworkAvailable(): boolean;
26
23
  destroy(): void;
24
+ private loadRecommendations;
25
+ private displayInterstitial;
26
+ private openOfferUrl;
27
27
  private requireClient;
28
28
  }
29
29
  //# sourceMappingURL=AdaxonSdk.d.ts.map
@@ -0,0 +1,10 @@
1
+ import type { RecommendationOffer } from '../types/ApiTypes.js';
2
+ interface InterstitialAdSession {
3
+ offer: RecommendationOffer;
4
+ interact: () => void;
5
+ }
6
+ export declare function presentInterstitial(session: InterstitialAdSession): boolean;
7
+ export declare function dismissInterstitial(): void;
8
+ export declare function InterstitialAd(): import("react").JSX.Element | null;
9
+ export {};
10
+ //# sourceMappingURL=InterstitialAd.d.ts.map
@@ -1,10 +1,11 @@
1
- export declare const SDK_VERSION = "0.1.2";
1
+ export declare const SDK_VERSION: string;
2
2
  export declare const MEDIATION_PROVIDER = "mts";
3
3
  export declare const BASE_URL = "http://localhost:3002";
4
4
  export declare const EVENT_TRACKING_PATH = "/event/tracking";
5
5
  export declare const RECOMMENDATIONS_PATH = "/api/mts/recommendations";
6
6
  export declare const CLICK_TRACKING_PATH = "/click/tracking";
7
7
  export declare const OFFER_OPENED_EVENT = "offer_opened";
8
+ export declare const RECOMMENDATION_VIEW_EVENT = "recommendation_view";
8
9
  export declare const DEFAULT_TIMEOUT_MS = 10000;
9
10
  export declare const PUBLIC_IP_LOOKUP_URL = "https://api.ipify.org?format=json";
10
11
  export declare const PUBLIC_IP_LOOKUP_TIMEOUT_MS = 2000;
@@ -28,7 +28,6 @@ export declare class AdaxonClient {
28
28
  processPendingEvents(): Promise<BatchProcessResult>;
29
29
  getRecommendations(input: TrackEventInput): Promise<RecommendationResponse>;
30
30
  createClickUrl(attribution: ClickAttribution): string;
31
- setExternalUserId(externalUserId?: string): void;
32
31
  private toQueryString;
33
32
  }
34
33
  export {};
@@ -11,9 +11,7 @@ export interface UseAdaxonResult {
11
11
  trackAddToCart: AdaxonSdk['trackAddToCart'];
12
12
  trackLogin: AdaxonSdk['trackLogin'];
13
13
  trackCompleteRegistration: AdaxonSdk['trackCompleteRegistration'];
14
- loadRecommendations: AdaxonSdk['loadRecommendations'];
15
- showOffer: AdaxonSdk['showOffer'];
16
- setExternalUserId: AdaxonSdk['setExternalUserId'];
14
+ showAd: AdaxonSdk['showAd'];
17
15
  }
18
16
  export declare function useAdaxon(): UseAdaxonResult;
19
17
  //# sourceMappingURL=useAdaxon.d.ts.map
@@ -9,9 +9,9 @@ export type { AdaxonSdkErrorCode } from './errors/AdaxonSdkError.js';
9
9
  export { AdxEvent, AdxParam } from './services/event/predefined.js';
10
10
  export type { AdxEventName, AdxParamName } from './services/event/predefined.js';
11
11
  export type { TrackAddToCartParams, TrackCompleteRegistrationParams, TrackLoginParams, TrackPurchaseParams, } from './services/event/normalizeProperties.js';
12
- export type { AdaxonInitializationConfiguration, AdaxonInitializationErrorCode, AdaxonInitializationListener, AdaxonOfferShowListener, AdaxonRecommendationLoadListener, AdaxonSdkConfig, AdaxonStorageAdapter, } from './types/AdaxonConfig.js';
12
+ export type { AdaxonInitializationConfiguration, AdaxonInitializationErrorCode, AdaxonInitializationListener, AdaxonSdkConfig, AdaxonStorageAdapter, } from './types/AdaxonConfig.js';
13
13
  export type { ClickAttribution, EventProperties, EventPropertyValue, AdaxonPlatform, TrackEventInput, TrackEventOptions, } from './types/EventTypes.js';
14
- export type { EventIngestionResponse, RecommendationOffer, RecommendationResponse, } from './types/ApiTypes.js';
14
+ export type { EventIngestionResponse } from './types/ApiTypes.js';
15
15
  export type { BatchProcessResult } from './types/QueuedEvent.js';
16
16
  export type { AppInfoReader, DeviceInfoReader } from './platform/types.js';
17
17
  export declare const Adaxon: AdaxonSdk;
@@ -1,14 +1,6 @@
1
1
  import type { AdaxonAppContext } from '../types/EventTypes.js';
2
- export interface NativeAppConstants {
3
- applicationId?: string | null;
4
- androidPackage?: string | null;
5
- iosBundleIdentifier?: string | null;
6
- bundleId?: string | null;
7
- nativeApplicationVersion?: string | null;
8
- nativeAppVersion?: string | null;
9
- appVersion?: string | null;
10
- }
11
2
  type NativeAppFields = Pick<AdaxonAppContext, 'package_name' | 'app_version'>;
12
- export declare function appFieldsFromNative(constants: NativeAppConstants): NativeAppFields;
3
+ type NativeSource = object | null | undefined;
4
+ export declare function appFieldsFromNative(...sources: NativeSource[]): NativeAppFields;
13
5
  export {};
14
6
  //# sourceMappingURL=app.d.ts.map
@@ -1,3 +1,4 @@
1
+ export { BackHandler, Dimensions, Image, Modal, Platform, Pressable, SafeAreaView, StatusBar, StyleSheet, Text, View, } from 'react-native';
1
2
  import type { AdaxonPlatform } from '../types/EventTypes.js';
2
3
  import type { AppInfoReader, DeviceInfoReader, NetworkInfoReader, NetworkStatusReader, UrlOpener } from './types.js';
3
4
  export declare function detectReactNativePlatform(): AdaxonPlatform;
@@ -1,6 +1,7 @@
1
1
  import type { AdaxonAppContext, AdaxonDeviceContext, AdaxonNetworkContext, AdaxonPlatform } from '../types/EventTypes.js';
2
2
  export interface DeviceInfoReader {
3
3
  readDeviceInfo(platform: AdaxonPlatform): AdaxonDeviceContext;
4
+ getUniqueId?(): Promise<string>;
4
5
  }
5
6
  export interface AppInfoReader {
6
7
  readAppInfo(): AdaxonAppContext;
@@ -1,10 +1,20 @@
1
1
  import type { DeviceInfoReader } from '../../platform/types.js';
2
+ import type { AdaxonStorageAdapter } from '../../types/AdaxonConfig.js';
2
3
  import type { AdaxonDeviceContext, AdaxonPlatform } from '../../types/EventTypes.js';
3
4
  export declare class DeviceInfoService {
4
5
  private readonly platform;
5
6
  private readonly reader?;
7
+ private readonly storage?;
6
8
  private cached?;
7
- constructor(platform: AdaxonPlatform, reader?: DeviceInfoReader | undefined);
9
+ private uniqueIdPromise?;
10
+ private readonly anonymousIdKey?;
11
+ constructor(platform: AdaxonPlatform, reader?: DeviceInfoReader | undefined, storage?: AdaxonStorageAdapter | undefined, appId?: string);
8
12
  getDeviceInfo(): AdaxonDeviceContext;
13
+ getUniqueId(): Promise<string>;
14
+ private readDeviceInfo;
15
+ private resolveUniqueId;
16
+ private readNativeId;
17
+ private readStoredId;
18
+ private writeStoredId;
9
19
  }
10
20
  //# sourceMappingURL=DeviceInfoService.d.ts.map
@@ -1,7 +1,6 @@
1
1
  import type { AppInfoService } from '../app/AppInfoService.js';
2
2
  import type { DeviceInfoService } from '../device/DeviceInfoService.js';
3
3
  import type { NetworkInfoService } from '../network/NetworkInfoService.js';
4
- import type { AnonymousIdService } from '../../storage/AnonymousIdService.js';
5
4
  import type { EventPayload, TrackEventInput } from '../../types/EventTypes.js';
6
5
  import type { EventValidator } from '../../validation/EventValidator.js';
7
6
  interface EventBuilderConfig {
@@ -9,16 +8,12 @@ interface EventBuilderConfig {
9
8
  deviceInfo: DeviceInfoService;
10
9
  appInfo: AppInfoService;
11
10
  networkInfo: NetworkInfoService;
12
- anonymousId: AnonymousIdService;
13
11
  validator: EventValidator;
14
- externalUserId?: string;
15
12
  }
16
13
  export declare class EventBuilder {
17
14
  private readonly config;
18
15
  private readonly sessionId;
19
- private externalUserId?;
20
16
  constructor(config: EventBuilderConfig);
21
- setExternalUserId(externalUserId?: string): void;
22
17
  build(input: TrackEventInput): Promise<EventPayload>;
23
18
  }
24
19
  export {};
@@ -1,4 +1,3 @@
1
- import type { RecommendationOffer } from './ApiTypes.js';
2
1
  export interface AdaxonStorageAdapter {
3
2
  getItem(key: string): Promise<string | null>;
4
3
  setItem(key: string, value: string): Promise<void>;
@@ -7,7 +6,6 @@ export interface AdaxonStorageAdapter {
7
6
  export interface AdaxonSdkConfig {
8
7
  appId: string;
9
8
  sdkKey: string;
10
- externalUserId?: string;
11
9
  storage?: AdaxonStorageAdapter;
12
10
  timeoutMs?: number;
13
11
  fetch?: typeof globalThis.fetch;
@@ -19,12 +17,4 @@ export interface AdaxonInitializationListener {
19
17
  onInitializationComplete(): void;
20
18
  onInitializationFailed(error: AdaxonInitializationErrorCode, message: string): void;
21
19
  }
22
- export interface AdaxonRecommendationLoadListener {
23
- onRecommendationsLoaded(offers: RecommendationOffer[]): void;
24
- onRecommendationsFailedToLoad(message: string, code?: string): void;
25
- }
26
- export interface AdaxonOfferShowListener {
27
- onOfferOpened(offer: RecommendationOffer): void;
28
- onOfferFailedToOpen(offer: RecommendationOffer, message: string): void;
29
- }
30
20
  //# sourceMappingURL=AdaxonConfig.d.ts.map
@@ -2,7 +2,6 @@ export type AdaxonPlatform = 'android' | 'ios' | 'web';
2
2
  export type EventPropertyValue = string | number | boolean | null;
3
3
  export type EventProperties = Record<string, EventPropertyValue>;
4
4
  export interface AdaxonUserContext {
5
- external_user_id?: string;
6
5
  anonymous_id: string;
7
6
  }
8
7
  export interface AdaxonDeviceContext {
@@ -47,9 +46,6 @@ export interface EventPayload {
47
46
  session: AdaxonSessionContext;
48
47
  network: AdaxonNetworkContext;
49
48
  }
50
- export interface RecommendationPayload extends EventPayload {
51
- event_type: 'recommendation';
52
- }
53
49
  export interface ClickAttribution {
54
50
  offerId: number;
55
51
  affiliateId: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-test-adx",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Adaxon React Native / Expo SDK for event tracking and offer recommendations.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- import { ANONYMOUS_ID_KEY_PREFIX, sanitizeStorageId } from "../config/StorageKeys.js";
4
- import { createUuid } from "../utils/uuid.js";
5
- export class AnonymousIdService {
6
- constructor(appId, storage) {
7
- this.appId = appId;
8
- this.storage = storage;
9
- }
10
- getAnonymousId() {
11
- if (!this.anonymousIdPromise) {
12
- this.anonymousIdPromise = this.loadOrCreate().catch(error => {
13
- this.anonymousIdPromise = undefined;
14
- throw error;
15
- });
16
- }
17
- return this.anonymousIdPromise;
18
- }
19
- get storageKey() {
20
- return `${ANONYMOUS_ID_KEY_PREFIX}${sanitizeStorageId(this.appId)}`;
21
- }
22
- async loadOrCreate() {
23
- const stored = await this.storage?.getItem(this.storageKey);
24
- if (stored) {
25
- return stored;
26
- }
27
- const anonymousId = createUuid();
28
- await this.storage?.setItem(this.storageKey, anonymousId);
29
- return anonymousId;
30
- }
31
- }
@@ -1,11 +0,0 @@
1
- import type { AdaxonStorageAdapter } from '../types/AdaxonConfig.js';
2
- export declare class AnonymousIdService {
3
- private readonly appId;
4
- private readonly storage?;
5
- private anonymousIdPromise?;
6
- constructor(appId: string, storage?: AdaxonStorageAdapter | undefined);
7
- getAnonymousId(): Promise<string>;
8
- private get storageKey();
9
- private loadOrCreate;
10
- }
11
- //# sourceMappingURL=AnonymousIdService.d.ts.map