@metrixorg/cordova-plugin 1.4.0 → 1.5.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.
- package/package.json +1 -1
- package/plugin.xml +26 -5
- package/src/android/MetrixCordova.java +5 -1
- package/src/android/MetrixCordovaUtils.java +6 -0
- package/src/ios/MetrixCordova.m +303 -0
- package/www/metrix.js +56 -25
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
2
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
3
3
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
|
-
id="ir.metrix.cordova" version="1.
|
|
4
|
+
id="ir.metrix.cordova" version="1.5.0" >
|
|
5
5
|
<name>Metrix</name>
|
|
6
6
|
<description>Metrix SDK plugin for Cordova</description>
|
|
7
7
|
<author>Metrix</author>
|
|
8
8
|
<license>Apache 2.0 License</license>
|
|
9
9
|
<engines>
|
|
10
10
|
<engine name="cordova-android" version=">=4.0.0" />
|
|
11
|
-
|
|
11
|
+
<engine name="cordova-ios" version=">=3.0.0" />
|
|
12
12
|
</engines>
|
|
13
13
|
<keywords>cordova, android, metrix, attribution, analytics</keywords>
|
|
14
|
-
|
|
15
|
-
<issue></issue>
|
|
16
|
-
|
|
14
|
+
|
|
17
15
|
<js-module src="www/metrix.js" name="Metrix">
|
|
18
16
|
<clobbers target="Metrix" />
|
|
19
17
|
</js-module>
|
|
20
18
|
|
|
19
|
+
<!-- android -->
|
|
21
20
|
<platform name="android">
|
|
22
21
|
<config-file target="res/xml/config.xml" parent="/*">
|
|
23
22
|
<feature name="Metrix">
|
|
@@ -31,4 +30,26 @@
|
|
|
31
30
|
|
|
32
31
|
<framework src="src/android/metrix.gradle" custom="true" type="gradleReference"/>
|
|
33
32
|
</platform>
|
|
33
|
+
|
|
34
|
+
<!-- iOS -->
|
|
35
|
+
<platform name="ios">
|
|
36
|
+
<config-file target="config.xml" parent="/*">
|
|
37
|
+
<feature name="Metrix">
|
|
38
|
+
<param name="ios-package" value="MetrixCordova"/>
|
|
39
|
+
<param name="onload" value="true" />
|
|
40
|
+
</feature>
|
|
41
|
+
</config-file>
|
|
42
|
+
|
|
43
|
+
<source-file src="src/ios/MetrixCordova.m" />
|
|
44
|
+
|
|
45
|
+
<podspec>
|
|
46
|
+
<config>
|
|
47
|
+
<source url="https://cdn.cocoapods.org/"/>
|
|
48
|
+
</config>
|
|
49
|
+
<pods>
|
|
50
|
+
<pod name="Metrix/cordova" spec="2.0.3" />
|
|
51
|
+
</pods>
|
|
52
|
+
</podspec>
|
|
53
|
+
|
|
54
|
+
</platform>
|
|
34
55
|
</plugin>
|
|
@@ -27,7 +27,11 @@ public class MetrixCordova extends CordovaPlugin {
|
|
|
27
27
|
|
|
28
28
|
@Override
|
|
29
29
|
public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
|
|
30
|
-
if (action.equals(
|
|
30
|
+
if (action.equals(COMMAND_INITIALIZE) ||
|
|
31
|
+
action.equals(COMMAND_SET_STORE) ||
|
|
32
|
+
action.equals(COMMAND_SET_APP_SECRET) ||
|
|
33
|
+
action.equals(COMMAND_SET_DEFAULT_TRACKER)) {
|
|
34
|
+
} else if (action.equals(COMMAND_SET_ATTRIBUTION_CHANGE_LISTENER)) {
|
|
31
35
|
attributionCallbackContext = callbackContext;
|
|
32
36
|
setAttributionListener();
|
|
33
37
|
} else if (action.equals(COMMAND_SET_PUSH_TOKEN)) {
|
|
@@ -9,6 +9,12 @@ import org.json.JSONException;
|
|
|
9
9
|
import ir.metrix.AttributionData;
|
|
10
10
|
|
|
11
11
|
public class MetrixCordovaUtils {
|
|
12
|
+
// iOS only
|
|
13
|
+
public static final String COMMAND_INITIALIZE = "initialize";
|
|
14
|
+
public static final String COMMAND_SET_STORE = "seStore";
|
|
15
|
+
public static final String COMMAND_SET_APP_SECRET = "setAppSecret";
|
|
16
|
+
public static final String COMMAND_SET_DEFAULT_TRACKER = "setDefaultTracker";
|
|
17
|
+
|
|
12
18
|
public static final String COMMAND_SET_PUSH_TOKEN = "setPushToken";
|
|
13
19
|
public static final String COMMAND_SET_ATTRIBUTION_CHANGE_LISTENER = "setAttributionChangeListener";
|
|
14
20
|
public static final String COMMAND_GET_SESSION_NUMBER = "setSessionNumberListener";
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
//
|
|
2
|
+
// MetrixCordova.h
|
|
3
|
+
// Metrix SDK
|
|
4
|
+
//
|
|
5
|
+
// Created by Matin on 21th June 2022.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <Cordova/CDV.h>
|
|
9
|
+
|
|
10
|
+
@interface MetrixCordova : CDVPlugin
|
|
11
|
+
|
|
12
|
+
- (void)initialize:(CDVInvokedUrlCommand *)command;
|
|
13
|
+
- (void)setStore:(CDVInvokedUrlCommand *)command;
|
|
14
|
+
- (void)setDefaultTracker:(CDVInvokedUrlCommand *)command;
|
|
15
|
+
- (void)setAppSecret:(CDVInvokedUrlCommand *)command;
|
|
16
|
+
|
|
17
|
+
- (void)trackSimpleEvent:(CDVInvokedUrlCommand *)command;
|
|
18
|
+
- (void)trackCustomEvent:(CDVInvokedUrlCommand *)command;
|
|
19
|
+
- (void)trackSimpleRevenue:(CDVInvokedUrlCommand *)command;
|
|
20
|
+
- (void)setAttributionChangeListener:(CDVInvokedUrlCommand *)command;
|
|
21
|
+
- (void)setSessionNumberListener:(CDVInvokedUrlCommand *)command;
|
|
22
|
+
- (void)setSessionIdListener:(CDVInvokedUrlCommand *)command;
|
|
23
|
+
- (void)setUserIdListener:(CDVInvokedUrlCommand *)command;
|
|
24
|
+
|
|
25
|
+
- (void)setPushToken:(CDVInvokedUrlCommand *)command;
|
|
26
|
+
- (void)setShouldLaunchDeeplink:(CDVInvokedUrlCommand *)command;
|
|
27
|
+
- (void)setDeeplinkResponseListener:(CDVInvokedUrlCommand *)command;
|
|
28
|
+
|
|
29
|
+
@end
|
|
30
|
+
|
|
31
|
+
@import Metrix;
|
|
32
|
+
|
|
33
|
+
@implementation MetrixCordova
|
|
34
|
+
|
|
35
|
+
NSString* attributionCallbackId;
|
|
36
|
+
NSString* sessionIdCallbackId;
|
|
37
|
+
NSString* sessionNumberCallbackId;
|
|
38
|
+
NSString* userIdCallbackId;
|
|
39
|
+
|
|
40
|
+
- (void)initialize:(CDVInvokedUrlCommand*)command
|
|
41
|
+
{
|
|
42
|
+
CDVPluginResult* pluginResult = nil;
|
|
43
|
+
NSString* appId = [command.arguments objectAtIndex:0];
|
|
44
|
+
|
|
45
|
+
if (appId != nil) {
|
|
46
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
47
|
+
[MetrixClient initializeWithMetrixAppId:appId];
|
|
48
|
+
} else {
|
|
49
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"AppId was null"];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
- (void)setStore:(CDVInvokedUrlCommand*)command
|
|
56
|
+
{
|
|
57
|
+
CDVPluginResult* pluginResult = nil;
|
|
58
|
+
NSString* store = [command.arguments objectAtIndex:0];
|
|
59
|
+
|
|
60
|
+
if (store != nil) {
|
|
61
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
62
|
+
[MetrixClient setStoreWithStoreName:store];
|
|
63
|
+
} else {
|
|
64
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Store was null"];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
- (void)setDefaultTracker:(CDVInvokedUrlCommand*)command
|
|
71
|
+
{
|
|
72
|
+
CDVPluginResult* pluginResult = nil;
|
|
73
|
+
NSString* token = [command.arguments objectAtIndex:0];
|
|
74
|
+
|
|
75
|
+
if (token != nil) {
|
|
76
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
77
|
+
[MetrixClient setDefaultTrackerWithTrackerToken:token];
|
|
78
|
+
} else {
|
|
79
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Tracker token was null"];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
- (void)setAppSecret:(CDVInvokedUrlCommand*)command
|
|
86
|
+
{
|
|
87
|
+
CDVPluginResult* pluginResult = nil;
|
|
88
|
+
NSNumber* secretId = [command.arguments objectAtIndex:0];
|
|
89
|
+
NSNumber* info1 = [command.arguments objectAtIndex:1];
|
|
90
|
+
NSNumber* info2 = [command.arguments objectAtIndex:2];
|
|
91
|
+
NSNumber* info3 = [command.arguments objectAtIndex:3];
|
|
92
|
+
NSNumber* info4 = [command.arguments objectAtIndex:4];
|
|
93
|
+
|
|
94
|
+
if (secretId != nil && info1 != nil && info2 != nil && info3 != nil && info4 != nil) {
|
|
95
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
96
|
+
[MetrixClient setAppSecretWithSecretId:[secretId integerValue] info1:[info1 integerValue] info2:[info2 integerValue] info3:[info3 integerValue] info4:[info4 integerValue]];
|
|
97
|
+
} else {
|
|
98
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Null app secret info was received"];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
- (void)trackSimpleEvent:(CDVInvokedUrlCommand*)command
|
|
105
|
+
{
|
|
106
|
+
CDVPluginResult* pluginResult = nil;
|
|
107
|
+
NSString* slug = [command.arguments objectAtIndex:0];
|
|
108
|
+
|
|
109
|
+
if (slug != nil) {
|
|
110
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
111
|
+
[MetrixClient newEventWithSlug:slug];
|
|
112
|
+
} else {
|
|
113
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"slug was null"];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
- (void)trackCustomEvent:(CDVInvokedUrlCommand*)command
|
|
120
|
+
{
|
|
121
|
+
CDVPluginResult* pluginResult = nil;
|
|
122
|
+
NSString* slug = [command.arguments objectAtIndex:0];
|
|
123
|
+
NSDictionary * attributes = [command.arguments objectAtIndex:1];
|
|
124
|
+
|
|
125
|
+
if (slug != nil && attributes != nil) {
|
|
126
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
127
|
+
[MetrixClient newEventWithSlug:slug attributes:attributes];
|
|
128
|
+
} else {
|
|
129
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"slug was null"];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
- (void)addUserDefaultAttributes:(CDVInvokedUrlCommand*)command
|
|
136
|
+
{
|
|
137
|
+
CDVPluginResult* pluginResult = nil;
|
|
138
|
+
NSDictionary * attributes = [command.arguments objectAtIndex:0];
|
|
139
|
+
|
|
140
|
+
if (attributes != nil) {
|
|
141
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
142
|
+
[MetrixClient addUserAttributesWithUserAttrs:attributes];
|
|
143
|
+
} else {
|
|
144
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"slug was null"];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
- (void)trackSimpleRevenue:(CDVInvokedUrlCommand*)command
|
|
151
|
+
{
|
|
152
|
+
CDVPluginResult* pluginResult = nil;
|
|
153
|
+
NSString* slug = [command.arguments objectAtIndex:0];
|
|
154
|
+
NSNumber* amount = [command.arguments objectAtIndex:1];
|
|
155
|
+
NSString* currency = [command.arguments objectAtIndex:2];
|
|
156
|
+
|
|
157
|
+
int cr = RevenueCurrencyIRR;
|
|
158
|
+
if ([currency isEqual: @"USD"]) {
|
|
159
|
+
cr = RevenueCurrencyUSD;
|
|
160
|
+
} else if ([currency isEqual: @"EUR"]) {
|
|
161
|
+
cr = RevenueCurrencyEUR;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (slug != nil && amount != nil && currency != nil) {
|
|
165
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
166
|
+
[MetrixClient newRevenueWithSlug:slug revenue:[amount doubleValue] currency:cr];
|
|
167
|
+
} else {
|
|
168
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Null parameter was recieved"];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
- (void)trackFullRevenue:(CDVInvokedUrlCommand*)command
|
|
175
|
+
{
|
|
176
|
+
CDVPluginResult* pluginResult = nil;
|
|
177
|
+
NSString* slug = [command.arguments objectAtIndex:0];
|
|
178
|
+
NSNumber* amount = [command.arguments objectAtIndex:1];
|
|
179
|
+
NSString* currency = [command.arguments objectAtIndex:2];
|
|
180
|
+
NSString* orderId = [command.arguments objectAtIndex:3];
|
|
181
|
+
|
|
182
|
+
int cr = RevenueCurrencyIRR;
|
|
183
|
+
if ([currency isEqual: @"USD"]) {
|
|
184
|
+
cr = RevenueCurrencyUSD;
|
|
185
|
+
} else if ([currency isEqual: @"EUR"]) {
|
|
186
|
+
cr = RevenueCurrencyEUR;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (slug != nil && amount != nil && currency != nil && orderId != nil) {
|
|
190
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
191
|
+
[MetrixClient newRevenueWithSlug:slug revenue:[amount doubleValue] currency:cr orderId:orderId];
|
|
192
|
+
} else {
|
|
193
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Null parameter was recieved"];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
- (void)setAttributionChangeListener:(CDVInvokedUrlCommand*)command
|
|
200
|
+
{
|
|
201
|
+
attributionCallbackId = command.callbackId;
|
|
202
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT];
|
|
203
|
+
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
|
|
204
|
+
|
|
205
|
+
[MetrixClient setOnAttributionChangedListener:^(AttributionData *data) {
|
|
206
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self getAttributionInfoObject:data]];
|
|
207
|
+
if ([data.attributionStatusRaw isEqual: @"NOT_ATTRIBUTED_YET"]) {
|
|
208
|
+
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
|
|
209
|
+
} else {
|
|
210
|
+
[pluginResult setKeepCallback:[NSNumber numberWithBool:NO]];
|
|
211
|
+
}
|
|
212
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:attributionCallbackId];
|
|
213
|
+
}];
|
|
214
|
+
|
|
215
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
- (void)setSessionNumberListener:(CDVInvokedUrlCommand*)command
|
|
219
|
+
{
|
|
220
|
+
sessionNumberCallbackId = command.callbackId;
|
|
221
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT];
|
|
222
|
+
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
|
|
223
|
+
|
|
224
|
+
[MetrixClient setSessionNumberListener:^(NSInteger num) {
|
|
225
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(int)num];
|
|
226
|
+
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
|
|
227
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:sessionNumberCallbackId];
|
|
228
|
+
}];
|
|
229
|
+
|
|
230
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
- (void)setSessionIdListener:(CDVInvokedUrlCommand*)command
|
|
234
|
+
{
|
|
235
|
+
sessionIdCallbackId = command.callbackId;
|
|
236
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT];
|
|
237
|
+
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
|
|
238
|
+
|
|
239
|
+
[MetrixClient setSessionIdListener:^(NSString* sessionId) {
|
|
240
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:sessionId];
|
|
241
|
+
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
|
|
242
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:sessionIdCallbackId];
|
|
243
|
+
}];
|
|
244
|
+
|
|
245
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
- (void)setUserIdListener:(CDVInvokedUrlCommand*)command
|
|
249
|
+
{
|
|
250
|
+
userIdCallbackId = command.callbackId;
|
|
251
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT];
|
|
252
|
+
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
|
|
253
|
+
|
|
254
|
+
[MetrixClient setUserIdListener:^(NSString* userId) {
|
|
255
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:userId];
|
|
256
|
+
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
|
|
257
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:userIdCallbackId];
|
|
258
|
+
}];
|
|
259
|
+
|
|
260
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
- (NSDictionary *)getAttributionInfoObject:(AttributionData *)data {
|
|
264
|
+
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
|
265
|
+
[self addValueOrEmpty:dictionary key:@"trackerToken" value:data.trackerToken];
|
|
266
|
+
[self addValueOrEmpty:dictionary key:@"acquisitionAd" value:data.acquisitionAd];
|
|
267
|
+
[self addValueOrEmpty:dictionary key:@"acquisitionAdSet" value:data.acquisitionAdSet];
|
|
268
|
+
[self addValueOrEmpty:dictionary key:@"acquisitionCampaign" value:data.acquisitionCampaign];
|
|
269
|
+
[self addValueOrEmpty:dictionary key:@"acquisitionSource" value:data.acquisitionSource];
|
|
270
|
+
[self addValueOrEmpty:dictionary key:@"attributionStatus" value:data.attributionStatusRaw];
|
|
271
|
+
|
|
272
|
+
return dictionary;;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
- (void)addValueOrEmpty:(NSMutableDictionary *)dictionary
|
|
276
|
+
key:(NSString *)key
|
|
277
|
+
value:(NSObject *)value {
|
|
278
|
+
if (nil != value) {
|
|
279
|
+
[dictionary setObject:[NSString stringWithFormat:@"%@", value] forKey:key];
|
|
280
|
+
} else {
|
|
281
|
+
[dictionary setObject:@"" forKey:key];
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// Android specific methods (ignored)
|
|
286
|
+
- (void)setPushToken:(CDVInvokedUrlCommand*)command {
|
|
287
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
288
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// Android specific methods (ignored)
|
|
292
|
+
- (void)setShouldLaunchDeeplink:(CDVInvokedUrlCommand*)command {
|
|
293
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
294
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Android specific methods (ignored)
|
|
298
|
+
- (void)setDeeplinkResponseListener:(CDVInvokedUrlCommand*)command {
|
|
299
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
300
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
@end
|
package/www/metrix.js
CHANGED
|
@@ -22,10 +22,34 @@ function callCordovaCallback(action, callback) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
var Metrix = {
|
|
25
|
-
|
|
26
|
-
if
|
|
27
|
-
callCordova('
|
|
25
|
+
newEvent: function(slug, attributes) {
|
|
26
|
+
if(attributes) {
|
|
27
|
+
callCordova('trackCustomEvent', slug, attributes);
|
|
28
|
+
} else {
|
|
29
|
+
callCordova('trackSimpleEvent', slug);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
addUserAttributes: function(attributes) {
|
|
34
|
+
callCordova('addUserDefaultAttributes', attributes);
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
newRevenue: function(slug, amount, currency, orderId) {
|
|
38
|
+
var cr = null;
|
|
39
|
+
if (currency === 0) {
|
|
40
|
+
cr = "IRR";
|
|
41
|
+
} else if (currency === 1) {
|
|
42
|
+
cr = "USD";
|
|
43
|
+
} else if (currency === 2) {
|
|
44
|
+
cr = "EUR";
|
|
45
|
+
} else {
|
|
46
|
+
cr = "IRR";
|
|
28
47
|
}
|
|
48
|
+
if (orderId) {
|
|
49
|
+
callCordova('trackFullRevenue', slug, amount, cr, orderId);
|
|
50
|
+
} else {
|
|
51
|
+
callCordova('trackSimpleRevenue', slug, amount, cr);
|
|
52
|
+
}
|
|
29
53
|
},
|
|
30
54
|
|
|
31
55
|
setOnAttributionChangedListener: function(callback) {
|
|
@@ -52,44 +76,51 @@ var Metrix = {
|
|
|
52
76
|
}
|
|
53
77
|
},
|
|
54
78
|
|
|
79
|
+
// android only
|
|
80
|
+
setPushToken: function(token) {
|
|
81
|
+
if (token) {
|
|
82
|
+
callCordova('setPushToken', token);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
// android only
|
|
55
87
|
setShouldLaunchDeeplink: function(launch) {
|
|
56
88
|
callCordova('setShouldLaunchDeeplink', launch);
|
|
57
89
|
},
|
|
58
90
|
|
|
91
|
+
// android only
|
|
59
92
|
setOnDeeplinkResponseListener: function(callback) {
|
|
60
93
|
if (callback != null) {
|
|
61
94
|
callCordovaCallback('setDeeplinkResponseListener', callback, this.shouldLaunchDeeplink);
|
|
62
95
|
}
|
|
63
96
|
},
|
|
64
97
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
callCordova('trackSimpleEvent', slug);
|
|
98
|
+
// iOS only
|
|
99
|
+
initialize: function(appId) {
|
|
100
|
+
if (appId) {
|
|
101
|
+
callCordova('initialize', appId);
|
|
70
102
|
}
|
|
71
103
|
},
|
|
72
104
|
|
|
73
|
-
|
|
74
|
-
|
|
105
|
+
// iOS only
|
|
106
|
+
setDefaultTracker: function(token) {
|
|
107
|
+
if (token) {
|
|
108
|
+
callCordova('setDefaultTracker', token);
|
|
109
|
+
}
|
|
75
110
|
},
|
|
76
111
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
112
|
+
// iOS only
|
|
113
|
+
setStore: function(store) {
|
|
114
|
+
if (store) {
|
|
115
|
+
callCordova('setStore', store);
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
// iOS only
|
|
120
|
+
setAppSecret: function(id, info1, info2, info3, info4) {
|
|
121
|
+
if (id && info1 && info2 && info3 && info4) {
|
|
122
|
+
callCordova('setAppSecret', id, info1, info2, info3, info4);
|
|
87
123
|
}
|
|
88
|
-
if (orderId) {
|
|
89
|
-
callCordova('trackFullRevenue', slug, amount, cr, orderId);
|
|
90
|
-
} else {
|
|
91
|
-
callCordova('trackSimpleRevenue', slug, amount, cr);
|
|
92
|
-
}
|
|
93
124
|
},
|
|
94
125
|
};
|
|
95
126
|
|