appsprint-react-native 0.2.0

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 (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +173 -0
  3. package/android/build.gradle +39 -0
  4. package/android/libs/appsprint-sdk.aar +0 -0
  5. package/android/src/main/AndroidManifest.xml +3 -0
  6. package/android/src/main/kotlin/com/appsprint/AppSprintBridgeModule.kt +182 -0
  7. package/android/src/main/kotlin/com/appsprint/AppSprintPackage.kt +16 -0
  8. package/app.plugin.js +3 -0
  9. package/appsprint-react-native.podspec +23 -0
  10. package/ios/AppSprintBridge.m +59 -0
  11. package/ios/AppSprintBridge.swift +210 -0
  12. package/ios/AppSprintSDK.xcframework/Info.plist +44 -0
  13. package/ios/AppSprintSDK.xcframework/ios-arm64/AppSprintSDK.framework/AppSprintSDK +0 -0
  14. package/ios/AppSprintSDK.xcframework/ios-arm64/AppSprintSDK.framework/Headers/AppSprintSDK-Swift.h +3 -0
  15. package/ios/AppSprintSDK.xcframework/ios-arm64/AppSprintSDK.framework/Info.plist +0 -0
  16. package/ios/AppSprintSDK.xcframework/ios-arm64/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios.abi.json +4952 -0
  17. package/ios/AppSprintSDK.xcframework/ios-arm64/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios.package.swiftinterface +165 -0
  18. package/ios/AppSprintSDK.xcframework/ios-arm64/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +165 -0
  19. package/ios/AppSprintSDK.xcframework/ios-arm64/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  20. package/ios/AppSprintSDK.xcframework/ios-arm64/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios.swiftinterface +165 -0
  21. package/ios/AppSprintSDK.xcframework/ios-arm64/AppSprintSDK.framework/Modules/module.modulemap +4 -0
  22. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/AppSprintSDK +0 -0
  23. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Headers/AppSprintSDK-Swift.h +3 -0
  24. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Info.plist +0 -0
  25. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +4952 -0
  26. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios-simulator.package.swiftinterface +165 -0
  27. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +165 -0
  28. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  29. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +165 -0
  30. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +4952 -0
  31. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/x86_64-apple-ios-simulator.package.swiftinterface +165 -0
  32. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +165 -0
  33. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  34. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +165 -0
  35. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/module.modulemap +4 -0
  36. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/_CodeSignature/CodeResources +101 -0
  37. package/lib/commonjs/AppSprint.js +50 -0
  38. package/lib/commonjs/NativeAppSprint.js +50 -0
  39. package/lib/commonjs/index.js +20 -0
  40. package/lib/commonjs/package.json +1 -0
  41. package/lib/commonjs/types.js +2 -0
  42. package/lib/module/AppSprint.js +46 -0
  43. package/lib/module/NativeAppSprint.js +47 -0
  44. package/lib/module/index.js +5 -0
  45. package/lib/module/package.json +1 -0
  46. package/lib/module/types.js +2 -0
  47. package/lib/typescript/AppSprint.d.ts +18 -0
  48. package/lib/typescript/NativeAppSprint.d.ts +4 -0
  49. package/lib/typescript/index.d.ts +4 -0
  50. package/lib/typescript/types.d.ts +60 -0
  51. package/package.json +56 -0
  52. package/plugin/build/index.d.ts +10 -0
  53. package/plugin/build/index.js +22 -0
  54. package/plugin/src/index.ts +27 -0
  55. package/src/AppSprint.ts +74 -0
  56. package/src/NativeAppSprint.ts +52 -0
  57. package/src/index.ts +13 -0
  58. package/src/types.ts +93 -0
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NativeAppSprint = void 0;
7
+ var _reactNative = require("react-native");
8
+ const LINKING_ERROR = "The package 'appsprint-react-native' doesn't seem to be linked. " + "Make sure you have run 'pod install' and rebuilt the app.";
9
+ const unsupportedPlatformModule = {
10
+ async configure() {},
11
+ async sendEvent() {},
12
+ async sendTestEvent() {
13
+ return {
14
+ success: false,
15
+ message: "Unsupported platform"
16
+ };
17
+ },
18
+ async flush() {},
19
+ async clearData() {},
20
+ async setCustomerUserId() {},
21
+ async enableAppleAdsAttribution() {},
22
+ async getAppSprintId() {
23
+ return null;
24
+ },
25
+ async getAttribution() {
26
+ return null;
27
+ },
28
+ async isInitialized() {
29
+ return false;
30
+ },
31
+ async isSdkDisabled() {
32
+ return false;
33
+ },
34
+ async destroy() {},
35
+ async getDeviceInfo() {
36
+ return {};
37
+ },
38
+ async getAdServicesToken() {
39
+ return null;
40
+ },
41
+ async requestTrackingAuthorization() {
42
+ return false;
43
+ }
44
+ };
45
+ const NativeAppSprint = exports.NativeAppSprint = _reactNative.Platform.OS === "ios" || _reactNative.Platform.OS === "android" ? _reactNative.NativeModules.AppSprintModule ?? new Proxy({}, {
46
+ get() {
47
+ throw new Error(LINKING_ERROR);
48
+ }
49
+ }) : unsupportedPlatformModule;
50
+ //# sourceMappingURL=NativeAppSprint.js.map
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "AppSprint", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _AppSprint.AppSprint;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "NativeAppSprint", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _NativeAppSprint.NativeAppSprint;
16
+ }
17
+ });
18
+ var _AppSprint = require("./AppSprint");
19
+ var _NativeAppSprint = require("./NativeAppSprint");
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ import { NativeAppSprint } from "./NativeAppSprint";
4
+ class AppSprintSDK {
5
+ async configure(config) {
6
+ if (typeof config.apiKey !== "string" || config.apiKey.trim().length === 0) {
7
+ throw new Error("AppSprint.configure requires a non-empty apiKey.");
8
+ }
9
+ await NativeAppSprint.configure(config);
10
+ }
11
+ async sendEvent(eventType, name, params) {
12
+ await NativeAppSprint.sendEvent(eventType, name ?? null, params?.revenue ?? null, params?.currency ?? null, params ?? null);
13
+ }
14
+ async sendTestEvent() {
15
+ return NativeAppSprint.sendTestEvent();
16
+ }
17
+ async flush() {
18
+ await NativeAppSprint.flush();
19
+ }
20
+ async clearData() {
21
+ await NativeAppSprint.clearData();
22
+ }
23
+ async setCustomerUserId(userId) {
24
+ await NativeAppSprint.setCustomerUserId(userId);
25
+ }
26
+ async enableAppleAdsAttribution() {
27
+ await NativeAppSprint.enableAppleAdsAttribution();
28
+ }
29
+ async getAppSprintId() {
30
+ return NativeAppSprint.getAppSprintId();
31
+ }
32
+ async getAttribution() {
33
+ return NativeAppSprint.getAttribution();
34
+ }
35
+ async isInitialized() {
36
+ return NativeAppSprint.isInitialized();
37
+ }
38
+ async isSdkDisabled() {
39
+ return NativeAppSprint.isSdkDisabled();
40
+ }
41
+ async destroy() {
42
+ await NativeAppSprint.destroy();
43
+ }
44
+ }
45
+ export const AppSprint = new AppSprintSDK();
46
+ //# sourceMappingURL=AppSprint.js.map
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ import { NativeModules, Platform } from "react-native";
4
+ const LINKING_ERROR = "The package 'appsprint-react-native' doesn't seem to be linked. " + "Make sure you have run 'pod install' and rebuilt the app.";
5
+ const unsupportedPlatformModule = {
6
+ async configure() {},
7
+ async sendEvent() {},
8
+ async sendTestEvent() {
9
+ return {
10
+ success: false,
11
+ message: "Unsupported platform"
12
+ };
13
+ },
14
+ async flush() {},
15
+ async clearData() {},
16
+ async setCustomerUserId() {},
17
+ async enableAppleAdsAttribution() {},
18
+ async getAppSprintId() {
19
+ return null;
20
+ },
21
+ async getAttribution() {
22
+ return null;
23
+ },
24
+ async isInitialized() {
25
+ return false;
26
+ },
27
+ async isSdkDisabled() {
28
+ return false;
29
+ },
30
+ async destroy() {},
31
+ async getDeviceInfo() {
32
+ return {};
33
+ },
34
+ async getAdServicesToken() {
35
+ return null;
36
+ },
37
+ async requestTrackingAuthorization() {
38
+ return false;
39
+ }
40
+ };
41
+ const NativeAppSprint = Platform.OS === "ios" || Platform.OS === "android" ? NativeModules.AppSprintModule ?? new Proxy({}, {
42
+ get() {
43
+ throw new Error(LINKING_ERROR);
44
+ }
45
+ }) : unsupportedPlatformModule;
46
+ export { NativeAppSprint };
47
+ //# sourceMappingURL=NativeAppSprint.js.map
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ export { AppSprint } from "./AppSprint";
4
+ export { NativeAppSprint } from "./NativeAppSprint";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,18 @@
1
+ import type { AppSprintConfig, AttributionResult, EventParams, EventType, TestEventResult } from "./types";
2
+ declare class AppSprintSDK {
3
+ configure(config: AppSprintConfig): Promise<void>;
4
+ sendEvent(eventType: EventType, name?: string | null, params?: EventParams): Promise<void>;
5
+ sendTestEvent(): Promise<TestEventResult>;
6
+ flush(): Promise<void>;
7
+ clearData(): Promise<void>;
8
+ setCustomerUserId(userId: string): Promise<void>;
9
+ enableAppleAdsAttribution(): Promise<void>;
10
+ getAppSprintId(): Promise<string | null>;
11
+ getAttribution(): Promise<AttributionResult | null>;
12
+ isInitialized(): Promise<boolean>;
13
+ isSdkDisabled(): Promise<boolean>;
14
+ destroy(): Promise<void>;
15
+ }
16
+ export declare const AppSprint: AppSprintSDK;
17
+ export {};
18
+ //# sourceMappingURL=AppSprint.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { NativeAppSprintModule } from "./types";
2
+ declare const NativeAppSprint: NativeAppSprintModule;
3
+ export { NativeAppSprint };
4
+ //# sourceMappingURL=NativeAppSprint.d.ts.map
@@ -0,0 +1,4 @@
1
+ export { AppSprint } from "./AppSprint";
2
+ export { NativeAppSprint } from "./NativeAppSprint";
3
+ export type { AppSprintConfig, EventType, EventParams, AttributionResult, InstallResponse, DeviceInfo, LogLevel, TestEventResult, NativeAppSprintModule, } from "./types";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,60 @@
1
+ export interface AppSprintConfig {
2
+ apiKey: string;
3
+ apiUrl?: string;
4
+ enableAppleAdsAttribution?: boolean;
5
+ isDebug?: boolean;
6
+ logLevel?: 0 | 1 | 2 | 3;
7
+ customerUserId?: string | null;
8
+ }
9
+ export type LogLevel = 0 | 1 | 2 | 3;
10
+ export type EventType = "login" | "sign_up" | "register" | "purchase" | "subscribe" | "start_trial" | "add_to_cart" | "add_to_wishlist" | "initiate_checkout" | "view_content" | "view_item" | "search" | "share" | "tutorial_complete" | "level_start" | "level_complete" | "custom";
11
+ export interface EventParams {
12
+ revenue?: number;
13
+ currency?: string;
14
+ [key: string]: unknown;
15
+ }
16
+ export interface AttributionResult {
17
+ source: "apple_ads" | "fingerprint" | "organic";
18
+ confidence: number;
19
+ campaignName?: string;
20
+ utmSource?: string;
21
+ utmMedium?: string;
22
+ utmCampaign?: string;
23
+ }
24
+ export interface InstallResponse {
25
+ appsprintId: string;
26
+ attribution: AttributionResult;
27
+ }
28
+ export interface TestEventResult {
29
+ success: boolean;
30
+ message: string;
31
+ }
32
+ export interface DeviceInfo {
33
+ deviceModel?: string;
34
+ screenWidth?: number;
35
+ screenHeight?: number;
36
+ locale?: string;
37
+ timezone?: string;
38
+ osVersion?: string;
39
+ idfv?: string;
40
+ idfa?: string;
41
+ adServicesToken?: string;
42
+ }
43
+ export interface NativeAppSprintModule {
44
+ configure(config: Record<string, unknown>): Promise<void>;
45
+ sendEvent(eventType: string, name: string | null, revenue: number | null, currency: string | null, parameters: Record<string, unknown> | null): Promise<void>;
46
+ sendTestEvent(): Promise<TestEventResult>;
47
+ flush(): Promise<void>;
48
+ clearData(): Promise<void>;
49
+ setCustomerUserId(userId: string): Promise<void>;
50
+ enableAppleAdsAttribution(): Promise<void>;
51
+ getAppSprintId(): Promise<string | null>;
52
+ getAttribution(): Promise<AttributionResult | null>;
53
+ isInitialized(): Promise<boolean>;
54
+ isSdkDisabled(): Promise<boolean>;
55
+ destroy(): Promise<void>;
56
+ getDeviceInfo(): Promise<DeviceInfo>;
57
+ getAdServicesToken(): Promise<string | null>;
58
+ requestTrackingAuthorization(): Promise<boolean>;
59
+ }
60
+ //# sourceMappingURL=types.d.ts.map
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "appsprint-react-native",
3
+ "version": "0.2.0",
4
+ "description": "AppSprint mobile attribution SDK for React Native",
5
+ "main": "lib/commonjs/index.js",
6
+ "module": "lib/module/index.js",
7
+ "types": "lib/typescript/index.d.ts",
8
+ "react-native": "src/index.ts",
9
+ "source": "src/index.ts",
10
+ "files": [
11
+ "src",
12
+ "lib",
13
+ "ios",
14
+ "android",
15
+ "plugin",
16
+ "app.plugin.js",
17
+ "appsprint-react-native.podspec",
18
+ "!**/__tests__",
19
+ "!lib/**/*.map",
20
+ "!ios/build",
21
+ "!android/build",
22
+ "!android/.gradle"
23
+ ],
24
+ "scripts": {
25
+ "test": "node --test test/appsprint-sdk.test.cjs test/release-artifacts.test.cjs",
26
+ "typecheck": "tsc --noEmit",
27
+ "build": "bob build",
28
+ "prepare": "bob build",
29
+ "validate:release": "node scripts/validate-release-artifacts.cjs",
30
+ "prepack": "npm run validate:release"
31
+ },
32
+ "keywords": ["react-native", "attribution", "mobile", "analytics", "appsprint"],
33
+ "repository": "https://github.com/app-sprint/appsprint-react-native",
34
+ "author": "AppSprint",
35
+ "license": "MIT",
36
+ "homepage": "https://appsprint.app",
37
+ "peerDependencies": {
38
+ "react": ">=18.0.0",
39
+ "react-native": ">=0.71.0"
40
+ },
41
+ "devDependencies": {
42
+ "react-native-builder-bob": "^0.35.0",
43
+ "typescript": "^5.7.0",
44
+ "react": "^18.2.0",
45
+ "react-native": "^0.76.0"
46
+ },
47
+ "dependencies": {},
48
+ "react-native-builder-bob": {
49
+ "source": "src",
50
+ "output": "lib",
51
+ "targets": ["commonjs", "module", "typescript"]
52
+ },
53
+ "expo": {
54
+ "plugins": ["./app.plugin.js"]
55
+ }
56
+ }
@@ -0,0 +1,10 @@
1
+ import type { ConfigPlugin } from "@expo/config-plugins";
2
+
3
+ export interface AppSprintExpoPluginProps {
4
+ trackingDescription?: string;
5
+ advertisingAttributionEndpoint?: string;
6
+ }
7
+
8
+ declare const withAppSprint: ConfigPlugin<AppSprintExpoPluginProps | void>;
9
+
10
+ export default withAppSprint;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ const { withInfoPlist } = require("@expo/config-plugins");
4
+
5
+ const DEFAULT_TRACKING_DESCRIPTION =
6
+ "This identifier will be used to deliver personalized ads to you.";
7
+
8
+ const withAppSprint = (config, props) =>
9
+ withInfoPlist(config, (expoConfig) => {
10
+ expoConfig.modResults.NSUserTrackingUsageDescription =
11
+ props?.trackingDescription ?? DEFAULT_TRACKING_DESCRIPTION;
12
+
13
+ if (props?.advertisingAttributionEndpoint) {
14
+ expoConfig.modResults.NSAdvertisingAttributionReportEndpoint =
15
+ props.advertisingAttributionEndpoint;
16
+ }
17
+
18
+ return expoConfig;
19
+ });
20
+
21
+ module.exports = withAppSprint;
22
+ module.exports.default = withAppSprint;
@@ -0,0 +1,27 @@
1
+ import { ConfigPlugin, withInfoPlist } from "@expo/config-plugins";
2
+
3
+ const withAppSprint: ConfigPlugin<{
4
+ trackingDescription?: string;
5
+ advertisingAttributionEndpoint?: string;
6
+ } | void> = (config, props) => {
7
+ const description =
8
+ props?.trackingDescription ??
9
+ "This identifier will be used to deliver personalized ads to you.";
10
+
11
+ config = withInfoPlist(config, (config) => {
12
+ // Add ATT usage description
13
+ config.modResults.NSUserTrackingUsageDescription = description;
14
+
15
+ // Add advertising attribution report endpoint
16
+ if (props?.advertisingAttributionEndpoint) {
17
+ config.modResults.NSAdvertisingAttributionReportEndpoint =
18
+ props.advertisingAttributionEndpoint;
19
+ }
20
+
21
+ return config;
22
+ });
23
+
24
+ return config;
25
+ };
26
+
27
+ export default withAppSprint;
@@ -0,0 +1,74 @@
1
+ import { NativeAppSprint } from "./NativeAppSprint";
2
+ import type {
3
+ AppSprintConfig,
4
+ AttributionResult,
5
+ EventParams,
6
+ EventType,
7
+ TestEventResult,
8
+ } from "./types";
9
+
10
+ class AppSprintSDK {
11
+ async configure(config: AppSprintConfig): Promise<void> {
12
+ if (typeof config.apiKey !== "string" || config.apiKey.trim().length === 0) {
13
+ throw new Error("AppSprint.configure requires a non-empty apiKey.");
14
+ }
15
+
16
+ await NativeAppSprint.configure(config as unknown as Record<string, unknown>);
17
+ }
18
+
19
+ async sendEvent(
20
+ eventType: EventType,
21
+ name?: string | null,
22
+ params?: EventParams
23
+ ): Promise<void> {
24
+ await NativeAppSprint.sendEvent(
25
+ eventType,
26
+ name ?? null,
27
+ params?.revenue ?? null,
28
+ params?.currency ?? null,
29
+ params ?? null
30
+ );
31
+ }
32
+
33
+ async sendTestEvent(): Promise<TestEventResult> {
34
+ return NativeAppSprint.sendTestEvent();
35
+ }
36
+
37
+ async flush(): Promise<void> {
38
+ await NativeAppSprint.flush();
39
+ }
40
+
41
+ async clearData(): Promise<void> {
42
+ await NativeAppSprint.clearData();
43
+ }
44
+
45
+ async setCustomerUserId(userId: string): Promise<void> {
46
+ await NativeAppSprint.setCustomerUserId(userId);
47
+ }
48
+
49
+ async enableAppleAdsAttribution(): Promise<void> {
50
+ await NativeAppSprint.enableAppleAdsAttribution();
51
+ }
52
+
53
+ async getAppSprintId(): Promise<string | null> {
54
+ return NativeAppSprint.getAppSprintId();
55
+ }
56
+
57
+ async getAttribution(): Promise<AttributionResult | null> {
58
+ return NativeAppSprint.getAttribution();
59
+ }
60
+
61
+ async isInitialized(): Promise<boolean> {
62
+ return NativeAppSprint.isInitialized();
63
+ }
64
+
65
+ async isSdkDisabled(): Promise<boolean> {
66
+ return NativeAppSprint.isSdkDisabled();
67
+ }
68
+
69
+ async destroy(): Promise<void> {
70
+ await NativeAppSprint.destroy();
71
+ }
72
+ }
73
+
74
+ export const AppSprint = new AppSprintSDK();
@@ -0,0 +1,52 @@
1
+ import { NativeModules, Platform } from "react-native";
2
+ import type { NativeAppSprintModule } from "./types";
3
+
4
+ const LINKING_ERROR =
5
+ "The package 'appsprint-react-native' doesn't seem to be linked. " +
6
+ "Make sure you have run 'pod install' and rebuilt the app.";
7
+
8
+ const unsupportedPlatformModule: NativeAppSprintModule = {
9
+ async configure() {},
10
+ async sendEvent() {},
11
+ async sendTestEvent() {
12
+ return { success: false, message: "Unsupported platform" };
13
+ },
14
+ async flush() {},
15
+ async clearData() {},
16
+ async setCustomerUserId() {},
17
+ async enableAppleAdsAttribution() {},
18
+ async getAppSprintId() {
19
+ return null;
20
+ },
21
+ async getAttribution() {
22
+ return null;
23
+ },
24
+ async isInitialized() {
25
+ return false;
26
+ },
27
+ async isSdkDisabled() {
28
+ return false;
29
+ },
30
+ async destroy() {},
31
+ async getDeviceInfo() {
32
+ return {};
33
+ },
34
+ async getAdServicesToken() {
35
+ return null;
36
+ },
37
+ async requestTrackingAuthorization() {
38
+ return false;
39
+ },
40
+ };
41
+
42
+ const NativeAppSprint: NativeAppSprintModule =
43
+ Platform.OS === "ios" || Platform.OS === "android"
44
+ ? NativeModules.AppSprintModule ??
45
+ new Proxy({} as NativeAppSprintModule, {
46
+ get() {
47
+ throw new Error(LINKING_ERROR);
48
+ },
49
+ })
50
+ : unsupportedPlatformModule;
51
+
52
+ export { NativeAppSprint };
package/src/index.ts ADDED
@@ -0,0 +1,13 @@
1
+ export { AppSprint } from "./AppSprint";
2
+ export { NativeAppSprint } from "./NativeAppSprint";
3
+ export type {
4
+ AppSprintConfig,
5
+ EventType,
6
+ EventParams,
7
+ AttributionResult,
8
+ InstallResponse,
9
+ DeviceInfo,
10
+ LogLevel,
11
+ TestEventResult,
12
+ NativeAppSprintModule,
13
+ } from "./types";
package/src/types.ts ADDED
@@ -0,0 +1,93 @@
1
+ export interface AppSprintConfig {
2
+ apiKey: string;
3
+ apiUrl?: string; // defaults to https://api.appsprint.app
4
+ enableAppleAdsAttribution?: boolean;
5
+ isDebug?: boolean;
6
+ logLevel?: 0 | 1 | 2 | 3; // 0=DEBUG, 1=INFO, 2=WARN, 3=ERROR
7
+ customerUserId?: string | null;
8
+ }
9
+
10
+ export type LogLevel = 0 | 1 | 2 | 3;
11
+
12
+ export type EventType =
13
+ | "login"
14
+ | "sign_up"
15
+ | "register"
16
+ | "purchase"
17
+ | "subscribe"
18
+ | "start_trial"
19
+ | "add_to_cart"
20
+ | "add_to_wishlist"
21
+ | "initiate_checkout"
22
+ | "view_content"
23
+ | "view_item"
24
+ | "search"
25
+ | "share"
26
+ | "tutorial_complete"
27
+ | "level_start"
28
+ | "level_complete"
29
+ | "custom";
30
+
31
+ export interface EventParams {
32
+ revenue?: number;
33
+ currency?: string;
34
+ [key: string]: unknown;
35
+ }
36
+
37
+ export interface AttributionResult {
38
+ source: "apple_ads" | "fingerprint" | "organic";
39
+ confidence: number;
40
+ campaignName?: string;
41
+ utmSource?: string;
42
+ utmMedium?: string;
43
+ utmCampaign?: string;
44
+ }
45
+
46
+ export interface InstallResponse {
47
+ appsprintId: string;
48
+ attribution: AttributionResult;
49
+ }
50
+
51
+ export interface TestEventResult {
52
+ success: boolean;
53
+ message: string;
54
+ }
55
+
56
+ export interface DeviceInfo {
57
+ deviceModel?: string;
58
+ screenWidth?: number;
59
+ screenHeight?: number;
60
+ locale?: string;
61
+ timezone?: string;
62
+ osVersion?: string;
63
+ idfv?: string;
64
+ idfa?: string;
65
+ adServicesToken?: string;
66
+ }
67
+
68
+ export interface NativeAppSprintModule {
69
+ // Core SDK (delegates to precompiled binary)
70
+ configure(config: Record<string, unknown>): Promise<void>;
71
+ sendEvent(
72
+ eventType: string,
73
+ name: string | null,
74
+ revenue: number | null,
75
+ currency: string | null,
76
+ parameters: Record<string, unknown> | null
77
+ ): Promise<void>;
78
+ sendTestEvent(): Promise<TestEventResult>;
79
+ flush(): Promise<void>;
80
+ clearData(): Promise<void>;
81
+ setCustomerUserId(userId: string): Promise<void>;
82
+ enableAppleAdsAttribution(): Promise<void>;
83
+ getAppSprintId(): Promise<string | null>;
84
+ getAttribution(): Promise<AttributionResult | null>;
85
+ isInitialized(): Promise<boolean>;
86
+ isSdkDisabled(): Promise<boolean>;
87
+ destroy(): Promise<void>;
88
+
89
+ // Utility
90
+ getDeviceInfo(): Promise<DeviceInfo>;
91
+ getAdServicesToken(): Promise<string | null>;
92
+ requestTrackingAuthorization(): Promise<boolean>;
93
+ }