react-native-marketap-sdk 0.1.0-beta.2 → 0.1.0-beta.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 (43) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/com/marketapsdk/MarketapSdkModule.kt +60 -3
  3. package/ios/MarketapSdk.m +9 -0
  4. package/ios/MarketapSdk.swift +46 -5
  5. package/lib/commonjs/MarketapWebBridge.js +82 -0
  6. package/lib/commonjs/MarketapWebBridge.js.map +1 -0
  7. package/lib/commonjs/NativeMarketapSdk.js.map +1 -1
  8. package/lib/commonjs/index.js +97 -31
  9. package/lib/commonjs/index.js.map +1 -1
  10. package/lib/commonjs/types.js +5 -5
  11. package/lib/commonjs/version.js +9 -0
  12. package/lib/commonjs/version.js.map +1 -0
  13. package/lib/module/MarketapWebBridge.js +76 -0
  14. package/lib/module/MarketapWebBridge.js.map +1 -0
  15. package/lib/module/NativeMarketapSdk.js.map +1 -1
  16. package/lib/module/index.js +87 -30
  17. package/lib/module/index.js.map +1 -1
  18. package/lib/module/types.js.map +0 -1
  19. package/lib/module/version.js +3 -0
  20. package/lib/module/version.js.map +1 -0
  21. package/lib/typescript/MarketapWebBridge.d.ts +13 -0
  22. package/lib/typescript/MarketapWebBridge.d.ts.map +1 -0
  23. package/lib/typescript/{src/NativeMarketapSdk.d.ts → NativeMarketapSdk.d.ts} +1 -0
  24. package/lib/typescript/NativeMarketapSdk.d.ts.map +1 -0
  25. package/lib/typescript/{src/index.d.ts → index.d.ts} +11 -2
  26. package/lib/typescript/index.d.ts.map +1 -0
  27. package/lib/typescript/{src/types.d.ts → types.d.ts} +1 -0
  28. package/lib/typescript/types.d.ts.map +1 -0
  29. package/lib/typescript/version.d.ts +2 -0
  30. package/lib/typescript/version.d.ts.map +1 -0
  31. package/package.json +19 -11
  32. package/react-native-marketap-sdk.podspec +1 -1
  33. package/lib/typescript/MarketapSDKExample/App.d.ts +0 -4
  34. package/lib/typescript/MarketapSDKExample/App.d.ts.map +0 -1
  35. package/lib/typescript/src/NativeMarketapSdk.d.ts.map +0 -1
  36. package/lib/typescript/src/index.d.ts.map +0 -1
  37. package/lib/typescript/src/types.d.ts.map +0 -1
  38. package/src/NativeMarketapSdk.js +0 -2
  39. package/src/NativeMarketapSdk.ts +0 -43
  40. package/src/index.js +0 -105
  41. package/src/index.tsx +0 -172
  42. package/src/types.js +0 -5
  43. package/src/types.ts +0 -47
package/src/index.tsx DELETED
@@ -1,172 +0,0 @@
1
- import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
2
- import type {
3
- MarketapClickEvent,
4
- MarketapClickHandler,
5
- MarketapSDKInterface,
6
- } from './types';
7
-
8
- const LINKING_ERROR =
9
- `The package 'react-native-marketap-sdk' doesn't seem to be linked. Make sure: \n\n` +
10
- Platform.select({
11
- ios: "- You have run 'cd ios && pod install'\n",
12
- default: '',
13
- }) +
14
- '- You rebuilt the app after installing the package\n' +
15
- '- You are not using Expo Go\n';
16
-
17
- // Force use legacy bridge for now - TurboModule implementation incomplete
18
- const MarketapSdkModule = NativeModules.MarketapSdk;
19
-
20
- if (!MarketapSdkModule) {
21
- throw new Error(
22
- `react-native-marketap-sdk: Native module not found (MarketapSdk). ` +
23
- `Did you run pod install (iOS) / rebuild? Platform=${Platform.OS}`
24
- );
25
- }
26
-
27
- const MarketapSdk = MarketapSdkModule
28
- ? MarketapSdkModule
29
- : new Proxy(
30
- {},
31
- {
32
- get() {
33
- throw new Error(LINKING_ERROR);
34
- },
35
- }
36
- );
37
-
38
- const eventEmitter = new NativeEventEmitter(MarketapSdk);
39
-
40
- class MarketapSDK implements MarketapSDKInterface {
41
- private clickHandler?: MarketapClickHandler;
42
- private isInitialized = false;
43
-
44
- constructor() {
45
- this.setupEventListeners();
46
- }
47
-
48
- private setupEventListeners(): void {
49
- eventEmitter.addListener(
50
- 'MarketapClickEvent',
51
- (event: MarketapClickEvent) => {
52
- if (this.clickHandler) {
53
- this.clickHandler(event);
54
- }
55
- }
56
- );
57
- }
58
-
59
- async initialize(projectId: string): Promise<void> {
60
- await MarketapSdk.initialize(projectId);
61
- this.isInitialized = true;
62
- }
63
-
64
- async signup(params: {
65
- userId: string;
66
- userProperties?: Record<string, any>;
67
- eventProperties?: Record<string, any>;
68
- persistUser?: boolean;
69
- }): Promise<void> {
70
- this.checkInitialized();
71
- return MarketapSdk.signup(
72
- params.userId,
73
- params.userProperties,
74
- params.eventProperties,
75
- params.persistUser
76
- );
77
- }
78
-
79
- async login(params: {
80
- userId: string;
81
- userProperties?: Record<string, any>;
82
- eventProperties?: Record<string, any>;
83
- }): Promise<void> {
84
- this.checkInitialized();
85
- return MarketapSdk.login(
86
- params.userId,
87
- params.userProperties,
88
- params.eventProperties
89
- );
90
- }
91
-
92
- async logout(eventProperties?: Record<string, any>): Promise<void> {
93
- this.checkInitialized();
94
- return MarketapSdk.logout(eventProperties);
95
- }
96
-
97
- async track(
98
- eventName: string,
99
- eventProperties?: Record<string, any>
100
- ): Promise<void> {
101
- this.checkInitialized();
102
- return MarketapSdk.track(eventName, eventProperties);
103
- }
104
-
105
- async trackPurchase(
106
- revenue: number,
107
- eventProperties?: Record<string, any>
108
- ): Promise<void> {
109
- this.checkInitialized();
110
- return MarketapSdk.trackPurchase(revenue, eventProperties);
111
- }
112
-
113
- async trackRevenue(
114
- eventName: string,
115
- revenue: number,
116
- eventProperties?: Record<string, any>
117
- ): Promise<void> {
118
- this.checkInitialized();
119
- return MarketapSdk.trackRevenue(eventName, revenue, eventProperties);
120
- }
121
-
122
- async trackPageView(eventProperties?: Record<string, any>): Promise<void> {
123
- this.checkInitialized();
124
- return MarketapSdk.trackPageView(eventProperties);
125
- }
126
-
127
- async identify(
128
- userId: string,
129
- userProperties?: Record<string, any>
130
- ): Promise<void> {
131
- this.checkInitialized();
132
- return MarketapSdk.identify(userId, userProperties);
133
- }
134
-
135
- async resetIdentity(): Promise<void> {
136
- this.checkInitialized();
137
- return MarketapSdk.resetIdentity();
138
- }
139
-
140
- async setClickHandler(handler: MarketapClickHandler): Promise<void> {
141
- this.clickHandler = handler;
142
- return MarketapSdk.setClickHandler();
143
- }
144
-
145
- async requestAuthorizationForPushNotifications(): Promise<void> {
146
- return MarketapSdk.requestAuthorizationForPushNotifications();
147
- }
148
-
149
- async setPushToken(token: string): Promise<void> {
150
- this.checkInitialized();
151
- if (Platform.OS === 'android') {
152
- console.warn(
153
- 'setPushToken is not needed on Android - MarketapFirebaseMessagingService handles push notifications automatically'
154
- );
155
- return Promise.resolve();
156
- }
157
- return MarketapSdk.setPushToken(token);
158
- }
159
-
160
- private checkInitialized(): void {
161
- if (!this.isInitialized) {
162
- throw new Error(
163
- 'MarketapSDK must be initialized before calling this method'
164
- );
165
- }
166
- }
167
- }
168
-
169
- const Marketap = new MarketapSDK();
170
-
171
- export default Marketap;
172
- export * from './types';
package/src/types.js DELETED
@@ -1,5 +0,0 @@
1
- export var MarketapCampaignType;
2
- (function (MarketapCampaignType) {
3
- MarketapCampaignType.PUSH = 'push';
4
- MarketapCampaignType.IN_APP_MESSAGE = 'inAppMessage';
5
- })(MarketapCampaignType || (MarketapCampaignType = {}));
package/src/types.ts DELETED
@@ -1,47 +0,0 @@
1
- export interface MarketapClickEvent {
2
- campaignType: MarketapCampaignType;
3
- campaignId: string;
4
- url?: string;
5
- }
6
-
7
- export enum MarketapCampaignType {
8
- PUSH = 'push',
9
- IN_APP_MESSAGE = 'inAppMessage',
10
- }
11
-
12
- export type MarketapClickHandler = (event: MarketapClickEvent) => void;
13
-
14
- export interface MarketapSDKInterface {
15
- initialize(projectId: string): Promise<void>;
16
- signup(params: {
17
- userId: string;
18
- userProperties?: Record<string, any>;
19
- eventProperties?: Record<string, any>;
20
- persistUser?: boolean;
21
- }): Promise<void>;
22
- login(params: {
23
- userId: string;
24
- userProperties?: Record<string, any>;
25
- eventProperties?: Record<string, any>;
26
- }): Promise<void>;
27
- logout(eventProperties?: Record<string, any>): Promise<void>;
28
- track(
29
- eventName: string,
30
- eventProperties?: Record<string, any>
31
- ): Promise<void>;
32
- trackPurchase(
33
- revenue: number,
34
- eventProperties?: Record<string, any>
35
- ): Promise<void>;
36
- trackRevenue(
37
- eventName: string,
38
- revenue: number,
39
- eventProperties?: Record<string, any>
40
- ): Promise<void>;
41
- trackPageView(eventProperties?: Record<string, any>): Promise<void>;
42
- identify(userId: string, userProperties?: Record<string, any>): Promise<void>;
43
- resetIdentity(): Promise<void>;
44
- setClickHandler(handler: MarketapClickHandler): Promise<void>;
45
- requestAuthorizationForPushNotifications(): Promise<void>;
46
- setPushToken(token: string): Promise<void>;
47
- }