affise-attribution-lib 1.6.35 → 1.6.37

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 (86) hide show
  1. package/README.md +127 -17
  2. package/affise-attribution-native.podspec +1 -1
  3. package/android/build.gradle +1 -1
  4. package/lib/commonjs/Export.js +11 -0
  5. package/lib/commonjs/Export.js.map +1 -1
  6. package/lib/commonjs/debug/AffiseDebug.js +1 -1
  7. package/lib/commonjs/events/base/AffiseEvent.js +9 -9
  8. package/lib/commonjs/events/base/AffiseEvent.js.map +1 -1
  9. package/lib/commonjs/index.js +3 -3
  10. package/lib/commonjs/index.js.map +1 -1
  11. package/lib/commonjs/module/AffiseHasModule.js +14 -0
  12. package/lib/commonjs/module/AffiseHasModule.js.map +1 -0
  13. package/lib/commonjs/module/appsflyer/AffiseAppsFlyer.js +5 -0
  14. package/lib/commonjs/module/appsflyer/AffiseAppsFlyer.js.map +1 -1
  15. package/lib/commonjs/module/appsflyer/AffiseModuleAppsFlyerApi.js +4 -0
  16. package/lib/commonjs/module/link/AffiseLink.js +5 -0
  17. package/lib/commonjs/module/link/AffiseLink.js.map +1 -1
  18. package/lib/commonjs/module/subscription/AffiseSubscription.js +5 -0
  19. package/lib/commonjs/module/subscription/AffiseSubscription.js.map +1 -1
  20. package/lib/commonjs/native/AffiseNative.js +15 -9
  21. package/lib/commonjs/native/AffiseNative.js.map +1 -1
  22. package/lib/commonjs/native/data/DataName.js +2 -0
  23. package/lib/commonjs/native/data/DataName.js.map +1 -1
  24. package/lib/commonjs/settings/PushTokenService.js +13 -0
  25. package/lib/commonjs/settings/PushTokenService.js.map +1 -0
  26. package/lib/module/Export.js +1 -0
  27. package/lib/module/Export.js.map +1 -1
  28. package/lib/module/debug/AffiseDebug.js +1 -1
  29. package/lib/module/events/base/AffiseEvent.js +9 -9
  30. package/lib/module/events/base/AffiseEvent.js.map +1 -1
  31. package/lib/module/index.js +3 -3
  32. package/lib/module/index.js.map +1 -1
  33. package/lib/module/module/AffiseHasModule.js +8 -0
  34. package/lib/module/module/AffiseHasModule.js.map +1 -0
  35. package/lib/module/module/appsflyer/AffiseAppsFlyer.js +5 -0
  36. package/lib/module/module/appsflyer/AffiseAppsFlyer.js.map +1 -1
  37. package/lib/module/module/appsflyer/AffiseModuleAppsFlyerApi.js +1 -1
  38. package/lib/module/module/link/AffiseLink.js +5 -0
  39. package/lib/module/module/link/AffiseLink.js.map +1 -1
  40. package/lib/module/module/subscription/AffiseSubscription.js +5 -0
  41. package/lib/module/module/subscription/AffiseSubscription.js.map +1 -1
  42. package/lib/module/native/AffiseNative.js +15 -9
  43. package/lib/module/native/AffiseNative.js.map +1 -1
  44. package/lib/module/native/data/DataName.js +2 -0
  45. package/lib/module/native/data/DataName.js.map +1 -1
  46. package/lib/module/settings/PushTokenService.js +6 -0
  47. package/lib/module/settings/PushTokenService.js.map +1 -0
  48. package/lib/typescript/Export.d.ts +1 -0
  49. package/lib/typescript/Export.d.ts.map +1 -1
  50. package/lib/typescript/index.d.ts +3 -3
  51. package/lib/typescript/index.d.ts.map +1 -1
  52. package/lib/typescript/module/AffiseHasModule.d.ts +7 -0
  53. package/lib/typescript/module/AffiseHasModule.d.ts.map +1 -0
  54. package/lib/typescript/module/appsflyer/AffiseAppsFlyer.d.ts +1 -0
  55. package/lib/typescript/module/appsflyer/AffiseAppsFlyer.d.ts.map +1 -1
  56. package/lib/typescript/module/appsflyer/AffiseModuleAppsFlyerApi.d.ts +2 -1
  57. package/lib/typescript/module/appsflyer/AffiseModuleAppsFlyerApi.d.ts.map +1 -1
  58. package/lib/typescript/module/link/AffiseLink.d.ts +1 -0
  59. package/lib/typescript/module/link/AffiseLink.d.ts.map +1 -1
  60. package/lib/typescript/module/link/AffiseModuleLinkApi.d.ts +2 -1
  61. package/lib/typescript/module/link/AffiseModuleLinkApi.d.ts.map +1 -1
  62. package/lib/typescript/module/subscription/AffiseModuleSubscriptionApi.d.ts +2 -1
  63. package/lib/typescript/module/subscription/AffiseModuleSubscriptionApi.d.ts.map +1 -1
  64. package/lib/typescript/module/subscription/AffiseSubscription.d.ts +1 -0
  65. package/lib/typescript/module/subscription/AffiseSubscription.d.ts.map +1 -1
  66. package/lib/typescript/native/AffiseNative.d.ts +2 -1
  67. package/lib/typescript/native/AffiseNative.d.ts.map +1 -1
  68. package/lib/typescript/native/data/DataName.d.ts +2 -0
  69. package/lib/typescript/native/data/DataName.d.ts.map +1 -1
  70. package/lib/typescript/settings/PushTokenService.d.ts +5 -0
  71. package/lib/typescript/settings/PushTokenService.d.ts.map +1 -0
  72. package/package.json +1 -1
  73. package/src/Export.ts +1 -0
  74. package/src/debug/AffiseDebug.ts +1 -1
  75. package/src/events/base/AffiseEvent.ts +9 -9
  76. package/src/index.ts +4 -3
  77. package/src/module/AffiseHasModule.ts +17 -0
  78. package/src/module/appsflyer/AffiseAppsFlyer.ts +7 -1
  79. package/src/module/appsflyer/AffiseModuleAppsFlyerApi.ts +3 -1
  80. package/src/module/link/AffiseLink.ts +7 -1
  81. package/src/module/link/AffiseModuleLinkApi.ts +2 -1
  82. package/src/module/subscription/AffiseModuleSubscriptionApi.ts +2 -1
  83. package/src/module/subscription/AffiseSubscription.ts +6 -0
  84. package/src/native/AffiseNative.ts +16 -9
  85. package/src/native/data/DataName.ts +2 -0
  86. package/src/settings/PushTokenService.ts +4 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PushTokenService.d.ts","sourceRoot":"","sources":["../../../src/settings/PushTokenService.ts"],"names":[],"mappings":"AAAA,oBAAY,gBAAgB;IACxB,QAAQ,QAAQ;IAChB,KAAK,SAAS;CACjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "affise-attribution-lib",
3
- "version": "1.6.35",
3
+ "version": "1.6.37",
4
4
  "description": "Affise Attribution Library",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
package/src/Export.ts CHANGED
@@ -22,6 +22,7 @@ export * from './settings/AffiseSettingsApi';
22
22
  export * from './settings/AffiseConfig';
23
23
  export * from './settings/OnInitErrorHandler';
24
24
  export * from './settings/OnInitSuccessHandler';
25
+ export * from './settings/PushTokenService';
25
26
 
26
27
  export * from './skad/SKAdNetwork';
27
28
  export * from './skad/CoarseValue';
@@ -33,7 +33,7 @@ export class AffiseDebug implements AffiseDebugApi {
33
33
  * Debug get version of flutter library
34
34
  */
35
35
  version(): string {
36
- return "1.6.35";
36
+ return "1.6.37";
37
37
  }
38
38
 
39
39
  /**
@@ -142,14 +142,14 @@ export class AffiseEvent implements PredefinedParameter {
142
142
  }
143
143
 
144
144
  toRecord(): Record<string, any> {
145
- const result :Record<string, any> = {};
146
- result[Parameters.AFFISE_EVENT_NAME] = this.name;
147
- result[Parameters.AFFISE_EVENT_CATEGORY] = this.category;
148
- result[Parameters.AFFISE_EVENT_TIMESTAMP] = timestamp();
149
- result[Parameters.AFFISE_EVENT_FIRST_FOR_USER] = this.firstForUser;
150
- result[Parameters.AFFISE_EVENT_USER_DATA] = this.userData;
151
- result[Parameters.AFFISE_EVENT_DATA] = this.serialize;
152
- result[Parameters.AFFISE_PARAMETERS] = this.getPredefinedParameters();
153
- return result;
145
+ return {
146
+ [Parameters.AFFISE_EVENT_NAME]: this.name,
147
+ [Parameters.AFFISE_EVENT_CATEGORY]: this.category,
148
+ [Parameters.AFFISE_EVENT_TIMESTAMP]: timestamp(),
149
+ [Parameters.AFFISE_EVENT_FIRST_FOR_USER]: this.firstForUser,
150
+ [Parameters.AFFISE_EVENT_USER_DATA]: this.userData,
151
+ [Parameters.AFFISE_EVENT_DATA]: this.serialize,
152
+ [Parameters.AFFISE_PARAMETERS]: this.getPredefinedParameters(),
153
+ };
154
154
  }
155
155
  }
package/src/index.ts CHANGED
@@ -10,6 +10,7 @@ import type {
10
10
  OnDeeplinkCallback,
11
11
  OnSendSuccessCallback,
12
12
  OnSendFailedCallback,
13
+ PushTokenService,
13
14
  } from "./Export";
14
15
  import { AffiseNative } from "./native/AffiseNative";
15
16
  import { AffiseSettings } from "./settings/AffiseSettings";
@@ -80,10 +81,10 @@ export class Affise {
80
81
  }
81
82
 
82
83
  /**
83
- * Add [pushToken]
84
+ * Add [pushToken] from [service]
84
85
  */
85
- static addPushToken(pushToken: string) {
86
- this.native.addPushToken(pushToken);
86
+ static addPushToken(pushToken: string, service: PushTokenService) {
87
+ this.native.addPushToken(pushToken, service);
87
88
  }
88
89
 
89
90
  /**
@@ -0,0 +1,17 @@
1
+ import type { AffiseNative } from "../native/AffiseNative"
2
+ import { AffiseModules } from "./AffiseModules"
3
+
4
+ export interface AffiseHasModule {
5
+ hasModule(): Promise<boolean>;
6
+ }
7
+
8
+ export function isModuleInit(native: AffiseNative, module: AffiseModules): Promise<boolean> {
9
+ return new Promise((resolve, reject) => {
10
+ native
11
+ .getModulesInstalled()
12
+ .then((modules) => {
13
+ resolve(modules.includes(module))
14
+ })
15
+ .catch(reject);
16
+ })
17
+ }
@@ -1,4 +1,6 @@
1
1
  import type { AffiseNative } from "../../native/AffiseNative";
2
+ import { isModuleInit } from "../AffiseHasModule";
3
+ import { AffiseModules } from "../AffiseModules";
2
4
  import type { AffiseModuleAppsFlyerApi } from "./AffiseModuleAppsFlyerApi";
3
5
 
4
6
  export class AffiseAppsFlyer implements AffiseModuleAppsFlyerApi {
@@ -14,6 +16,10 @@ export class AffiseAppsFlyer implements AffiseModuleAppsFlyerApi {
14
16
  * @param eventValues event data
15
17
  */
16
18
  logEvent(eventName: string, eventValues: Record<string, any>) {
17
- this.native.logEvent(eventName, eventValues);
19
+ this.native.logEvent(eventName, eventValues)
20
+ }
21
+
22
+ hasModule(): Promise<boolean> {
23
+ return isModuleInit(this.native, AffiseModules.APPSFLYER)
18
24
  }
19
25
  }
@@ -1,4 +1,6 @@
1
- export interface AffiseModuleAppsFlyerApi {
1
+ import type { AffiseHasModule } from "../AffiseHasModule";
2
+
3
+ export interface AffiseModuleAppsFlyerApi extends AffiseHasModule {
2
4
  /**
3
5
  * Send Appflyer event data to affise
4
6
  * @param eventName event name
@@ -1,6 +1,8 @@
1
1
  import type { AffiseNative } from "../../native/AffiseNative";
2
2
  import type { AffiseLinkCallback } from "./AffiseLinkCallback";
3
3
  import type { AffiseModuleLinkApi } from "./AffiseModuleLinkApi";
4
+ import { isModuleInit } from "../AffiseHasModule";
5
+ import { AffiseModules } from "../AffiseModules";
4
6
 
5
7
  export class AffiseLink implements AffiseModuleLinkApi {
6
8
  private native: AffiseNative
@@ -17,4 +19,8 @@ export class AffiseLink implements AffiseModuleLinkApi {
17
19
  resolve(url: string, callback: AffiseLinkCallback): void {
18
20
  this.native.linkResolve(url, callback);
19
21
  }
20
- }
22
+
23
+ hasModule(): Promise<boolean> {
24
+ return isModuleInit(this.native, AffiseModules.LINK)
25
+ }
26
+ }
@@ -1,6 +1,7 @@
1
1
  import type { AffiseLinkCallback } from "./AffiseLinkCallback";
2
+ import type { AffiseHasModule } from "../AffiseHasModule";
2
3
 
3
- export interface AffiseModuleLinkApi {
4
+ export interface AffiseModuleLinkApi extends AffiseHasModule {
4
5
  /**
5
6
  * Module Link url Resolve
6
7
  * @param url url
@@ -3,8 +3,9 @@ import type { AffiseProductType } from "./AffiseProductType";
3
3
  import type { AffisePurchasedInfo } from "./AffisePurchasedInfo";
4
4
  import type { AffiseProductsResult } from "./AffiseProductsResult";
5
5
  import type { AffiseResultCallback } from "./AffiseResultCallback";
6
+ import type { AffiseHasModule } from "../AffiseHasModule";
6
7
 
7
- export interface AffiseModuleSubscriptionApi {
8
+ export interface AffiseModuleSubscriptionApi extends AffiseHasModule {
8
9
  /**
9
10
  * Module subscription fetchProducts
10
11
  * @param ids list of product ids
@@ -5,6 +5,8 @@ import type { AffiseProductType } from "./AffiseProductType";
5
5
  import type { AffisePurchasedInfo } from "./AffisePurchasedInfo";
6
6
  import type { AffiseProductsResult } from "./AffiseProductsResult";
7
7
  import type { AffiseResultCallback } from "./AffiseResultCallback";
8
+ import { isModuleInit } from "../AffiseHasModule";
9
+ import { AffiseModules } from "../AffiseModules";
8
10
 
9
11
  export class AffiseSubscription implements AffiseModuleSubscriptionApi {
10
12
  private native: AffiseNative
@@ -31,4 +33,8 @@ export class AffiseSubscription implements AffiseModuleSubscriptionApi {
31
33
  purchase(product: AffiseProduct, type: AffiseProductType, callback: AffiseResultCallback<AffisePurchasedInfo>) {
32
34
  this.native.purchase(product, type, callback);
33
35
  }
36
+
37
+ hasModule(): Promise<boolean> {
38
+ return isModuleInit(this.native, AffiseModules.SUBSCRIPTION)
39
+ }
34
40
  }
@@ -27,6 +27,7 @@ import type {AffisePurchasedInfo} from "../module/subscription/AffisePurchasedIn
27
27
  import {DataName} from "./data/DataName";
28
28
  import type { OnInitSuccessHandler } from "../settings/OnInitSuccessHandler";
29
29
  import type { OnInitErrorHandler } from "../settings/OnInitErrorHandler";
30
+ import type { PushTokenService } from "../settings/PushTokenService";
30
31
 
31
32
 
32
33
  export class AffiseNative extends NativeBase {
@@ -71,8 +72,12 @@ export class AffiseNative extends NativeBase {
71
72
  );
72
73
  }
73
74
 
74
- addPushToken(pushToken: string) {
75
- this.native(AffiseApiMethod.ADD_PUSH_TOKEN, pushToken);
75
+ addPushToken(pushToken: string, service: PushTokenService) {
76
+ const data: Record<string, any> = {
77
+ [DataName.PUSH_TOKEN]: pushToken,
78
+ [DataName.PUSH_TOKEN_SERVICE]: service,
79
+ };
80
+ this.native(AffiseApiMethod.ADD_PUSH_TOKEN, data);
76
81
  }
77
82
 
78
83
  registerDeeplinkCallback(callback: OnDeeplinkCallback) {
@@ -161,10 +166,11 @@ export class AffiseNative extends NativeBase {
161
166
  }
162
167
 
163
168
  updatePostbackConversionValue(fineValue: bigint, coarseValue: CoarseValue, completionHandler: ErrorCallback) {
164
- const value: Record<string, any> = {};
165
- value[DataName.FINE_VALUE] = Number(fineValue);
166
- value[DataName.COARSE_VALUE] = coarseValue.value;
167
- this.nativeCallbackOnce(AffiseApiMethod.SKAD_POSTBACK_ERROR_CALLBACK, completionHandler, value);
169
+ const data: Record<string, any> = {
170
+ [DataName.FINE_VALUE]: Number(fineValue),
171
+ [DataName.COARSE_VALUE]: coarseValue.value,
172
+ };
173
+ this.nativeCallbackOnce(AffiseApiMethod.SKAD_POSTBACK_ERROR_CALLBACK, completionHandler, data);
168
174
  }
169
175
 
170
176
  ////////////////////////////////////////
@@ -217,9 +223,10 @@ export class AffiseNative extends NativeBase {
217
223
 
218
224
  // Subscription Module
219
225
  purchase(product: AffiseProduct, type: AffiseProductType, callback: AffiseResultCallback<AffisePurchasedInfo>) {
220
- const data: Record<string, any> = {};
221
- data[DataName.PRODUCT] = DataMapper.fromProduct(product);
222
- data[DataName.TYPE] = type;
226
+ const data: Record<string, any> = {
227
+ [DataName.PRODUCT]: DataMapper.fromProduct(product),
228
+ [DataName.TYPE]: type,
229
+ };
223
230
 
224
231
  this.nativeCallbackOnce(
225
232
  AffiseApiMethod.MODULE_SUBS_PURCHASE_CALLBACK,
@@ -46,4 +46,6 @@ export class DataName {
46
46
 
47
47
  static EVENT_NAME = "eventName";
48
48
  static EVENT_VALUES = "eventValues";
49
+ static PUSH_TOKEN = "push_token";
50
+ static PUSH_TOKEN_SERVICE = "push_token_service";
49
51
  }
@@ -0,0 +1,4 @@
1
+ export enum PushTokenService {
2
+ FIREBASE = "fms",
3
+ APPLE = "apns",
4
+ }