@snowplow/react-native-tracker 0.2.0 → 1.1.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.
@@ -0,0 +1,44 @@
1
+ //
2
+ // RNConfigUtils.h
3
+ //
4
+ // Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved.
5
+ //
6
+ // This program is licensed to you under the Apache License Version 2.0,
7
+ // and you may not use this file except in compliance with the Apache License
8
+ // Version 2.0. You may obtain a copy of the Apache License Version 2.0 at
9
+ // http://www.apache.org/licenses/LICENSE-2.0.
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the Apache License Version 2.0 is distributed on
13
+ // an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14
+ // express or implied. See the Apache License Version 2.0 for the specific
15
+ // language governing permissions and limitations there under.
16
+ //
17
+ // Copyright: Copyright (c) 2022 Snowplow Analytics Ltd
18
+ // License: Apache License Version 2.0
19
+ //
20
+
21
+ #import <Foundation/Foundation.h>
22
+
23
+ #import <SnowplowTracker/SPTrackerConfiguration.h>
24
+ #import <SnowplowTracker/SPSessionConfiguration.h>
25
+ #import <SnowplowTracker/SPEmitterConfiguration.h>
26
+ #import <SnowplowTracker/SPSubjectConfiguration.h>
27
+ #import <SnowplowTracker/SPGDPRConfiguration.h>
28
+ #import <SnowplowTracker/SPGlobalContextsConfiguration.h>
29
+
30
+ @interface RNConfigUtils : NSObject
31
+
32
+ + (SPTrackerConfiguration *) mkTrackerConfig:(NSDictionary *) trackerConfig;
33
+
34
+ + (SPSessionConfiguration *) mkSessionConfig:(NSDictionary *) sessionConfig;
35
+
36
+ + (SPEmitterConfiguration *) mkEmitterConfig:(NSDictionary *) emitterConfig;
37
+
38
+ + (SPSubjectConfiguration *) mkSubjectConfig:(NSDictionary *) subjectConfig;
39
+
40
+ + (SPGDPRConfiguration *) mkGdprConfig:(NSDictionary *) gdprConfig;
41
+
42
+ + (SPGlobalContextsConfiguration *) mkGCConfig:(NSArray *) gcConfig;
43
+
44
+ @end
@@ -0,0 +1,207 @@
1
+ //
2
+ // RNConfigUtils.m
3
+ //
4
+ // Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved.
5
+ //
6
+ // This program is licensed to you under the Apache License Version 2.0,
7
+ // and you may not use this file except in compliance with the Apache License
8
+ // Version 2.0. You may obtain a copy of the Apache License Version 2.0 at
9
+ // http://www.apache.org/licenses/LICENSE-2.0.
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the Apache License Version 2.0 is distributed on
13
+ // an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14
+ // express or implied. See the Apache License Version 2.0 for the specific
15
+ // language governing permissions and limitations there under.
16
+ //
17
+ // Copyright: Copyright (c) 2022 Snowplow Analytics Ltd
18
+ // License: Apache License Version 2.0
19
+ //
20
+
21
+ #import "RNConfigUtils.h"
22
+ #import "RNTrackerVersion.h"
23
+ #import "RNUtilities.h"
24
+
25
+ #import <Foundation/Foundation.h>
26
+
27
+ #import <SnowplowTracker/SPSnowplow.h>
28
+ #import <SnowplowTracker/NSDictionary+SP_TypeMethods.h>
29
+ #import <SnowplowTracker/SPTrackerConfiguration.h>
30
+ #import <SnowplowTracker/SPDevicePlatform.h>
31
+ #import <SnowplowTracker/SPLoggerDelegate.h>
32
+ #import <SnowplowTracker/SPSessionConfiguration.h>
33
+ #import <SnowplowTracker/SPEmitterConfiguration.h>
34
+ #import <SnowplowTracker/SPSubjectConfiguration.h>
35
+ #import <SnowplowTracker/SPGDPRConfiguration.h>
36
+ #import <SnowplowTracker/SPGlobalContextsConfiguration.h>
37
+
38
+ @implementation RNConfigUtils
39
+
40
+ + (SPTrackerConfiguration *) mkTrackerConfig:(NSDictionary *) trackerConfig {
41
+ SPTrackerConfiguration *trackerConfiguration = [SPTrackerConfiguration new];
42
+ trackerConfiguration.trackerVersionSuffix = kRNTrackerVersion;
43
+
44
+ NSString *appId = [trackerConfig sp_stringForKey:@"appId" defaultValue:nil];
45
+ if (appId) {
46
+ trackerConfiguration.appId = appId;
47
+ }
48
+
49
+ NSString *devicePlatform = [trackerConfig sp_stringForKey:@"devicePlatform" defaultValue:nil];
50
+ if (devicePlatform) {
51
+ trackerConfiguration.devicePlatform = SPStringToDevicePlatform(devicePlatform);
52
+ }
53
+
54
+ trackerConfiguration.base64Encoding = [trackerConfig sp_boolForKey:@"base64Encoding" defaultValue:YES];
55
+
56
+ NSString *logLevel = [trackerConfig sp_stringForKey:@"logLevel" defaultValue:nil];
57
+ if (logLevel) {
58
+ NSUInteger index = [@[@"off", @"error", @"debug", @"verbose"] indexOfObject:logLevel];
59
+ trackerConfiguration.logLevel = index != NSNotFound ? index : SPLogLevelOff;
60
+ }
61
+
62
+ trackerConfiguration.sessionContext = [trackerConfig sp_boolForKey:@"sessionContext" defaultValue:YES];
63
+ trackerConfiguration.applicationContext = [trackerConfig sp_boolForKey:@"applicationContext" defaultValue:YES];
64
+ trackerConfiguration.platformContext = [trackerConfig sp_boolForKey:@"platformContext" defaultValue:YES];
65
+ trackerConfiguration.geoLocationContext = [trackerConfig sp_boolForKey:@"geoLocationContext" defaultValue:NO];
66
+ trackerConfiguration.screenContext = [trackerConfig sp_boolForKey:@"screenContext" defaultValue:YES];
67
+ trackerConfiguration.deepLinkContext = [trackerConfig sp_boolForKey:@"deepLinkContext" defaultValue:YES];
68
+ trackerConfiguration.screenViewAutotracking = [trackerConfig sp_boolForKey:@"screenViewAutotracking" defaultValue:YES];
69
+ trackerConfiguration.lifecycleAutotracking = [trackerConfig sp_boolForKey:@"lifecycleAutotracking" defaultValue:NO];
70
+ trackerConfiguration.installAutotracking = [trackerConfig sp_boolForKey:@"installAutotracking" defaultValue:YES];
71
+ trackerConfiguration.exceptionAutotracking = [trackerConfig sp_boolForKey:@"exceptionAutotracking" defaultValue:YES];
72
+ trackerConfiguration.diagnosticAutotracking = [trackerConfig sp_boolForKey:@"diagnosticAutotracking" defaultValue:NO];
73
+
74
+ return trackerConfiguration;
75
+ }
76
+
77
+ + (SPSessionConfiguration *) mkSessionConfig:(NSDictionary *) sessionConfig {
78
+
79
+ NSInteger foreground = [[sessionConfig sp_numberForKey:@"foregroundTimeout" defaultValue:@1800] integerValue];
80
+ NSInteger background = [[sessionConfig sp_numberForKey:@"backgroundTimeout" defaultValue:@1800] integerValue];
81
+ SPSessionConfiguration *sessionConfiguration = [[SPSessionConfiguration alloc] initWithForegroundTimeoutInSeconds:foreground backgroundTimeoutInSeconds:background];
82
+
83
+ return sessionConfiguration;
84
+ }
85
+
86
+ + (SPEmitterConfiguration *) mkEmitterConfig:(NSDictionary *) emitterConfig {
87
+ SPEmitterConfiguration *emitterConfiguration = [[SPEmitterConfiguration alloc] init];
88
+ NSString *bufferOption = [emitterConfig sp_stringForKey:@"bufferOption" defaultValue:@"single"];
89
+ if ([bufferOption isEqualToString:@"default"]) {
90
+ emitterConfiguration.bufferOption = SPBufferOptionDefaultGroup;
91
+ } else if ([bufferOption isEqualToString:@"large"]) {
92
+ emitterConfiguration.bufferOption = SPBufferOptionLargeGroup;
93
+ } else {
94
+ emitterConfiguration.bufferOption = SPBufferOptionSingle;
95
+ }
96
+
97
+ emitterConfiguration.emitRange = [[emitterConfig sp_numberForKey:@"emitRange" defaultValue:@150] integerValue];
98
+ emitterConfiguration.threadPoolSize = [[emitterConfig sp_numberForKey:@"threadPoolSize" defaultValue:@15] integerValue];
99
+ emitterConfiguration.byteLimitGet = [[emitterConfig sp_numberForKey:@"byteLimitGet" defaultValue:@40000] integerValue];
100
+ emitterConfiguration.byteLimitPost = [[emitterConfig sp_numberForKey:@"byteLimitPost" defaultValue:@40000] integerValue];
101
+
102
+ return emitterConfiguration;
103
+ }
104
+
105
+ + (SPSubjectConfiguration *) mkSubjectConfig:(NSDictionary *) subjectConfig {
106
+
107
+ SPSubjectConfiguration *subjectConfiguration = [SPSubjectConfiguration new];
108
+
109
+ NSString *userId = [subjectConfig sp_stringForKey:@"userId" defaultValue:nil];
110
+ if (userId) {
111
+ subjectConfiguration.userId = userId;
112
+ }
113
+
114
+ NSString *networkUserId = [subjectConfig sp_stringForKey:@"networkUserId" defaultValue:nil];
115
+ if (networkUserId) {
116
+ subjectConfiguration.networkUserId = networkUserId;
117
+ }
118
+
119
+ NSString *domainUserId = [subjectConfig sp_stringForKey:@"domainUserId" defaultValue:nil];
120
+ if (domainUserId) {
121
+ subjectConfiguration.domainUserId = domainUserId;
122
+ }
123
+
124
+ NSString *useragent = [subjectConfig sp_stringForKey:@"useragent" defaultValue:nil];
125
+ if (useragent) {
126
+ subjectConfiguration.useragent = useragent;
127
+ }
128
+
129
+ NSString *ipAddress = [subjectConfig sp_stringForKey:@"ipAddress" defaultValue:nil];
130
+ if (ipAddress) {
131
+ subjectConfiguration.ipAddress = ipAddress;
132
+ }
133
+
134
+ NSString *timezone = [subjectConfig sp_stringForKey:@"timezone" defaultValue:nil];
135
+ if (timezone) {
136
+ subjectConfiguration.timezone = timezone;
137
+ }
138
+
139
+ NSString *language = [subjectConfig sp_stringForKey:@"language" defaultValue:nil];
140
+ if (language) {
141
+ subjectConfiguration.language = language;
142
+ }
143
+
144
+ // screenResolution - type checked RN side
145
+ NSArray *screenRSize = [subjectConfig objectForKey:@"screenResolution"];
146
+ if (screenRSize != nil) {
147
+ NSNumber *resWidth = [screenRSize objectAtIndex:0];
148
+ NSNumber *resHeight = [screenRSize objectAtIndex:1];
149
+ SPSize *resSize = [[SPSize alloc] initWithWidth:[resWidth integerValue] height:[resHeight integerValue]];
150
+ subjectConfiguration.screenResolution = resSize;
151
+ }
152
+
153
+ // screenViewport - type checked RN side
154
+ NSArray *screenVPSize = [subjectConfig objectForKey:@"screenViewport"];
155
+ if (screenVPSize != nil) {
156
+ NSNumber *vpWidth = [screenVPSize objectAtIndex:0];
157
+ NSNumber *vpHeight = [screenVPSize objectAtIndex:1];
158
+ SPSize *vpSize = [[SPSize alloc] initWithWidth:[vpWidth integerValue] height:[vpHeight integerValue]];
159
+ subjectConfiguration.screenViewPort = vpSize;
160
+ }
161
+
162
+ // colorDepth
163
+ NSNumber *colorDepth = [subjectConfig sp_numberForKey:@"colorDepth" defaultValue: nil];
164
+ if (colorDepth != nil) {
165
+ subjectConfiguration.colorDepth = colorDepth;
166
+ }
167
+
168
+ return subjectConfiguration;
169
+ }
170
+
171
+ + (SPGDPRConfiguration *) mkGdprConfig:(NSDictionary *) gdprConfig {
172
+ NSString *basis = [gdprConfig objectForKey:@"basisForProcessing"];
173
+ NSString *docId = [gdprConfig objectForKey:@"documentId"];
174
+ NSString *docVer = [gdprConfig objectForKey:@"documentVersion"];
175
+ NSString *docDesc = [gdprConfig objectForKey:@"documentDescription"];
176
+
177
+ SPGDPRConfiguration *gdprConfiguration = [[SPGDPRConfiguration alloc] initWithBasis:[RNUtilities getBasis:basis] documentId:docId documentVersion:docVer documentDescription:docDesc];
178
+
179
+ return gdprConfiguration;
180
+ }
181
+
182
+ + (SPGlobalContextsConfiguration *) mkGCConfig:(NSArray *) gcConfig {
183
+
184
+ SPGlobalContextsConfiguration *gcConfiguration = [[SPGlobalContextsConfiguration alloc] init];
185
+ //NSMutableDictionary *contextGens = [NSMutableDictionary dictionary];
186
+
187
+ for (NSDictionary *gcMap in gcConfig) {
188
+ NSString *itag = [gcMap objectForKey:@"tag"];
189
+ NSArray *globalContexts = [gcMap objectForKey:@"globalContexts"];
190
+
191
+ NSMutableArray *staticContexts = [NSMutableArray array];
192
+ for (NSDictionary *sdj in globalContexts) {
193
+ SPSelfDescribingJson *gContext = [[SPSelfDescribingJson alloc] initWithSchema:(NSString *)[sdj objectForKey:@"schema"]
194
+ andDictionary:(NSDictionary *)[sdj objectForKey:@"data"]];
195
+
196
+ [staticContexts addObject:gContext];
197
+ }
198
+
199
+ SPGlobalContext *gcStatic = [[SPGlobalContext alloc] initWithStaticContexts:(NSArray *)[staticContexts copy]];
200
+
201
+ [gcConfiguration addWithTag:itag contextGenerator:gcStatic];
202
+ }
203
+
204
+ return gcConfiguration;
205
+ }
206
+
207
+ @end
@@ -0,0 +1,27 @@
1
+ //
2
+ // RNTrackerVersion.h
3
+ //
4
+ // Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved.
5
+ //
6
+ // This program is licensed to you under the Apache License Version 2.0,
7
+ // and you may not use this file except in compliance with the Apache License
8
+ // Version 2.0. You may obtain a copy of the Apache License Version 2.0 at
9
+ // http://www.apache.org/licenses/LICENSE-2.0.
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the Apache License Version 2.0 is distributed on
13
+ // an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14
+ // express or implied. See the Apache License Version 2.0 for the specific
15
+ // language governing permissions and limitations there under.
16
+ //
17
+ // Copyright: Copyright (c) 2022 Snowplow Analytics Ltd
18
+ // License: Apache License Version 2.0
19
+ //
20
+
21
+ #import <Foundation/Foundation.h>
22
+
23
+ @interface RNTrackerVersion : NSObject
24
+
25
+ extern NSString * const kRNTrackerVersion;
26
+
27
+ @end
@@ -0,0 +1,27 @@
1
+ //
2
+ // RNTrackerVersion.m
3
+ //
4
+ // Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved.
5
+ //
6
+ // This program is licensed to you under the Apache License Version 2.0,
7
+ // and you may not use this file except in compliance with the Apache License
8
+ // Version 2.0. You may obtain a copy of the Apache License Version 2.0 at
9
+ // http://www.apache.org/licenses/LICENSE-2.0.
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the Apache License Version 2.0 is distributed on
13
+ // an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14
+ // express or implied. See the Apache License Version 2.0 for the specific
15
+ // language governing permissions and limitations there under.
16
+ //
17
+ // Copyright: Copyright (c) 2022 Snowplow Analytics Ltd
18
+ // License: Apache License Version 2.0
19
+ //
20
+
21
+ #import "RNTrackerVersion.h"
22
+
23
+ @implementation RNTrackerVersion
24
+
25
+ NSString * const kRNTrackerVersion = @"rn-1.1.0";
26
+
27
+ @end
@@ -0,0 +1,32 @@
1
+ //
2
+ // RNUtilities.h
3
+ //
4
+ // Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved.
5
+ //
6
+ // This program is licensed to you under the Apache License Version 2.0,
7
+ // and you may not use this file except in compliance with the Apache License
8
+ // Version 2.0. You may obtain a copy of the Apache License Version 2.0 at
9
+ // http://www.apache.org/licenses/LICENSE-2.0.
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the Apache License Version 2.0 is distributed on
13
+ // an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14
+ // express or implied. See the Apache License Version 2.0 for the specific
15
+ // language governing permissions and limitations there under.
16
+ //
17
+ // Copyright: Copyright (c) 2022 Snowplow Analytics Ltd
18
+ // License: Apache License Version 2.0
19
+ //
20
+
21
+ #import <Foundation/Foundation.h>
22
+ #import <SnowplowTracker/SPGDPRConfiguration.h>
23
+
24
+ @interface RNUtilities : NSObject
25
+
26
+ + (NSDictionary *) removeNSNullFromDict:(NSDictionary *)trackerConfig;
27
+
28
+ + (SPGdprProcessingBasis) getBasis:(NSString *)basis;
29
+
30
+ + (NSMutableArray *) mkSDJArray:(NSArray<NSDictionary *> *)sdjArray;
31
+
32
+ @end
@@ -0,0 +1,68 @@
1
+ //
2
+ // RNUtilities.m
3
+ //
4
+ // Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved.
5
+ //
6
+ // This program is licensed to you under the Apache License Version 2.0,
7
+ // and you may not use this file except in compliance with the Apache License
8
+ // Version 2.0. You may obtain a copy of the Apache License Version 2.0 at
9
+ // http://www.apache.org/licenses/LICENSE-2.0.
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the Apache License Version 2.0 is distributed on
13
+ // an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14
+ // express or implied. See the Apache License Version 2.0 for the specific
15
+ // language governing permissions and limitations there under.
16
+ //
17
+ // Copyright: Copyright (c) 2022 Snowplow Analytics Ltd
18
+ // License: Apache License Version 2.0
19
+ //
20
+
21
+ #import "RNUtilities.h"
22
+ #import <Foundation/Foundation.h>
23
+ #import <SnowplowTracker/SPGDPRConfiguration.h>
24
+ #import <SnowplowTracker/SPSelfDescribingJson.h>
25
+
26
+ @implementation RNUtilities
27
+
28
+ + (NSDictionary *) removeNSNullFromDict:(NSDictionary *)dictionary {
29
+ const NSMutableDictionary *newDict = [dictionary mutableCopy];
30
+ const id nullPointer = [NSNull null];
31
+
32
+ for (NSString *key in dictionary) {
33
+ id obj = [dictionary objectForKey:key];
34
+ if (obj == nullPointer) {
35
+ [newDict removeObjectForKey:key];
36
+ }
37
+ }
38
+ return [NSDictionary dictionaryWithDictionary:[newDict copy]];
39
+ }
40
+
41
+ + (SPGdprProcessingBasis) getBasis:(NSString *)basis {
42
+ if ([basis isEqualToString:@"consent"]) {
43
+ return SPGdprProcessingBasisConsent;
44
+ } else if ([basis isEqualToString:@"contract"]) {
45
+ return SPGdprProcessingBasisContract;
46
+ } else if ([basis isEqualToString:@"legal_obligation"]) {
47
+ return SPGdprProcessingBasisLegalObligation;
48
+ } else if ([basis isEqualToString:@"legitimate_interests"]) {
49
+ return SPGdprProcessingBasisLegitimateInterests;
50
+ } else if ([basis isEqualToString:@"public_task"]) {
51
+ return SPGdprProcessingBasisPublicTask;
52
+ } else {
53
+ return SPGdprProcessingBasisVitalInterest;;
54
+ }
55
+ }
56
+
57
+ + (NSMutableArray *) mkSDJArray:(NSArray<NSDictionary *> *)sdjArray {
58
+ NSMutableArray *sdjs = [NSMutableArray array];
59
+ for (NSDictionary* sdj in sdjArray) {
60
+ SPSelfDescribingJson *nativeSdj = [[SPSelfDescribingJson alloc] initWithSchema:(NSString *)[sdj objectForKey:@"schema"]
61
+ andDictionary:(NSDictionary *)[sdj objectForKey:@"data"]];
62
+ [sdjs addObject:nativeSdj];
63
+ }
64
+
65
+ return sdjs;
66
+ }
67
+
68
+ @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowplow/react-native-tracker",
3
- "version": "0.2.0",
3
+ "version": "1.1.0",
4
4
  "description": "A library for tracking Snowplow events in React Native",
5
5
  "homepage": "https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/react-native-tracker/",
6
6
  "main": "dist/index.js",
@@ -10,13 +10,14 @@
10
10
  "bundle": "rollup --config",
11
11
  "build": "npm run compile && npm run bundle && rimraf dist/tmp",
12
12
  "lint": "eslint . --ext .js,.jsx,.ts,.tsx",
13
- "test": "echo \"Error: no test specified\" && exit 1"
13
+ "test": "jest",
14
+ "bootstrap": "npm run build && cd DemoApp && rimraf node_modules && yarn"
14
15
  },
15
16
  "files": [
16
- "src",
17
17
  "dist",
18
18
  "android",
19
- "ios"
19
+ "ios",
20
+ "RNSnowplowTracker.podspec"
20
21
  ],
21
22
  "keywords": [
22
23
  "react-native",
@@ -28,7 +29,9 @@
28
29
  "Colm O Griobhtha",
29
30
  "James Munro",
30
31
  "Max Bondarenko",
31
- "Paul Boocock"
32
+ "Paul Boocock",
33
+ "Ada Tzereme",
34
+ "Matus Tomlein"
32
35
  ],
33
36
  "license": "Apache-2.0",
34
37
  "repository": {
@@ -40,15 +43,42 @@
40
43
  "react-native": ">=0.59.8"
41
44
  },
42
45
  "devDependencies": {
43
- "@types/react": "^17.0.11",
44
- "@types/react-native": "^0.64.10",
45
- "@typescript-eslint/eslint-plugin": "^4.27.0",
46
- "@typescript-eslint/parser": "^4.27.0",
47
- "eslint": "^7.28.0",
48
- "eslint-plugin-promise": "^5.1.0",
46
+ "@types/jest": "^27.4.0",
47
+ "@types/react": "^17.0.39",
48
+ "@types/react-native": "^0.66.15",
49
+ "@typescript-eslint/eslint-plugin": "^5.10.2",
50
+ "@typescript-eslint/parser": "^5.10.2",
51
+ "eslint": "^8.8.0",
52
+ "eslint-plugin-jest": "^26.1.0",
53
+ "eslint-plugin-promise": "^6.0.0",
54
+ "jest": "^27.5.0",
49
55
  "rimraf": "^3.0.2",
50
- "rollup": "^2.52.1",
51
- "rollup-plugin-dts": "^3.0.2",
52
- "typescript": "^4.3.2"
56
+ "rollup": "^2.67.1",
57
+ "rollup-plugin-dts": "^4.1.0",
58
+ "rollup-plugin-sourcemaps": "^0.6.3",
59
+ "ts-jest": "^27.1.3",
60
+ "typescript": "^4.5.5"
61
+ },
62
+ "jest": {
63
+ "testEnvironment": "node",
64
+ "testMatch": [
65
+ "<rootDir>/tests/**/*test.ts"
66
+ ],
67
+ "testPathIgnorePatterns": [
68
+ "<rootDir>/node_modules/",
69
+ "<rootDir>/DemoApp/"
70
+ ],
71
+ "transform": {
72
+ "^.+\\.(ts|tsx)$": "ts-jest"
73
+ },
74
+ "roots": [
75
+ "<rootDir>/src/",
76
+ "<rootDir>/tests/"
77
+ ],
78
+ "globals": {
79
+ "ts-jest": {
80
+ "tsconfig": "<rootDir>/tests/tsconfig.json"
81
+ }
82
+ }
53
83
  }
54
84
  }
package/ios/Podfile DELETED
@@ -1,22 +0,0 @@
1
- # Uncomment the next line to define a global platform for your project
2
- platform :ios, '9.0'
3
- use_modular_headers!
4
-
5
- target 'RNSnowplowTracker' do
6
- # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
7
- # use_frameworks!
8
-
9
- # Pods for RNSnowplowTracker
10
- pod 'yoga', path: '../node_modules/react-native/ReactCommon/yoga'
11
- pod 'React', path: '../node_modules/react-native'
12
- pod 'SnowplowTracker', '~> 1.7.0'
13
-
14
- post_install do |installer|
15
- installer.pods_project.targets.each do |target|
16
- if target.name == "React"
17
- target.remove_from_project
18
- end
19
- end
20
- end
21
-
22
- end
package/ios/Podfile.lock DELETED
@@ -1,37 +0,0 @@
1
- PODS:
2
- - FMDB (2.7.5):
3
- - FMDB/standard (= 2.7.5)
4
- - FMDB/standard (2.7.5)
5
- - React (0.59.10):
6
- - React/Core (= 0.59.10)
7
- - React/Core (0.59.10):
8
- - yoga (= 0.59.10.React)
9
- - SnowplowTracker (1.7.0):
10
- - FMDB (~> 2.6)
11
- - yoga (0.59.10.React)
12
-
13
- DEPENDENCIES:
14
- - React (from `../node_modules/react-native`)
15
- - SnowplowTracker (~> 1.7.0)
16
- - yoga (from `../node_modules/react-native/ReactCommon/yoga`)
17
-
18
- SPEC REPOS:
19
- trunk:
20
- - FMDB
21
- - SnowplowTracker
22
-
23
- EXTERNAL SOURCES:
24
- React:
25
- :path: "../node_modules/react-native"
26
- yoga:
27
- :path: "../node_modules/react-native/ReactCommon/yoga"
28
-
29
- SPEC CHECKSUMS:
30
- FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
31
- React: 36d0768f9e93be2473b37e7fa64f92c1d5341eef
32
- SnowplowTracker: af57230e44ca85007d36eab7ae1a199af5d31192
33
- yoga: 684513b14b03201579ba3cee20218c9d1298b0cc
34
-
35
- PODFILE CHECKSUM: a26d715479a0ed9008e1b647c3385b566fac22b1
36
-
37
- COCOAPODS: 1.10.1
@@ -1,17 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
- #import <React/RCTConvert.h>
3
-
4
- @class SPSelfDescribingJson;
5
- @class SPSelfDescribingJsonArray;
6
- @class SPUnstructured;
7
- @class SPUnstructuredArray;
8
-
9
- @interface RCTConvert (Snowplow)
10
-
11
- + (SPSelfDescribingJson *)SPSelfDescribingJson:(id)json;
12
- + (NSArray<SPSelfDescribingJson *> *)SPSelfDescribingJsonArray:(id)json;
13
-
14
- + (SPUnstructured *)SPUnstructured:(id)json;
15
- + (NSArray<SPUnstructured *> *)SPUnstructuredArray:(id)json;
16
-
17
- @end
@@ -1,57 +0,0 @@
1
- #import "RCTConvert+Snowplow.h"
2
- #import <SnowplowTracker/SPSelfDescribingJson.h>
3
- #import <SnowplowTracker/SPEvent.h>
4
-
5
- @implementation RCTConvert (Snowplow)
6
-
7
- + (SPSelfDescribingJson *)SPSelfDescribingJson:(id)json {
8
- if (!json) {
9
- return nil;
10
- }
11
-
12
- if ([json isKindOfClass:[NSDictionary class]]) {
13
- NSString * schema = [json objectForKey:@"schema"];
14
- NSDictionary * data = [json objectForKey:@"data"];
15
- if (schema == nil || data == nil) {
16
- return nil;
17
- }
18
- SPSelfDescribingJson *sdj = [[SPSelfDescribingJson alloc] initWithSchema:schema andData:data];
19
- return sdj;
20
- }
21
- return nil;
22
- }
23
-
24
- RCT_ARRAY_CONVERTER(SPSelfDescribingJson)
25
-
26
- + (SPUnstructured *)SPUnstructured:(id)json {
27
- if (!json) {
28
- return nil;
29
- }
30
-
31
- if (![json isKindOfClass:[NSDictionary class]]) {
32
- RCTLogConvertError(json, @"Self-describing JSON to be an NSDictionary with at least schema and some data type");
33
- return nil;
34
- }
35
-
36
- SPSelfDescribingJson * data = [self SPSelfDescribingJson:json[@"event"]];
37
- NSNumber * timestamp = [self NSNumber:json[@"timestamp"]];
38
- NSArray * contexts = [self SPSelfDescribingJsonArray:json[@"contexts"]];
39
- NSString * eventId = [self NSString:json[@"eventId"]];
40
- SPUnstructured * unstructEvent = [SPUnstructured build:^(id<SPUnstructuredBuilder> builder) {
41
- [builder setEventData:data];
42
- if (timestamp != nil) {
43
- [builder setTimestamp:timestamp];
44
- }
45
- if (eventId != nil) {
46
- [builder setEventId:eventId];
47
- }
48
- if (contexts != nil) {
49
- [builder setContexts:[[NSMutableArray alloc] initWithArray:contexts]];
50
- }
51
- }];
52
- return unstructEvent;
53
- }
54
-
55
- RCT_ARRAY_CONVERTER(SPUnstructured)
56
-
57
- @end
@@ -1,22 +0,0 @@
1
-
2
- Pod::Spec.new do |s|
3
- s.name = "RNSnowplowTracker"
4
- s.version = "1.0.0"
5
- s.summary = "RNSnowplowTracker"
6
- s.description = <<-DESC
7
- RNSnowplowTracker
8
- DESC
9
- s.homepage = "github.com/snowplow/snowplow-react-native-tracker"
10
- s.license = "Apache-2.0"
11
- s.author = { "author" => "author@domain.cn" }
12
- s.platform = :ios, "7.0"
13
- s.source = { :git => "https://github.com/author/RNSnowplowTracker.git", :tag => "master" }
14
- s.source_files = "*.{h,m}"
15
- s.requires_arc = true
16
-
17
-
18
- s.dependency "React-Core"
19
- s.dependency "SnowplowTracker", "~> 1.7.0"
20
- #s.dependency "others"
21
-
22
- end