@amplitude/analytics-react-native 0.0.1-dev.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/README.md +0 -0
- package/amplitude-react-native.podspec +21 -0
- package/android/build.gradle +61 -0
- package/android/gradle.properties +3 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/amplitude/reactnative/AmplitudeReactNativeModule.kt +36 -0
- package/android/src/main/java/com/amplitude/reactnative/AmplitudeReactNativePackage.java +28 -0
- package/android/src/main/java/com/amplitude/reactnative/AndroidContextProvider.kt +415 -0
- package/android/src/main/java/com/amplitude/reactnative/AndroidLogger.kt +56 -0
- package/android/src/main/java/com/amplitude/reactnative/Utils.kt +34 -0
- package/ios/AmplitudeReactNative-Bridging-Header.h +5 -0
- package/ios/AmplitudeReactNative.m +7 -0
- package/ios/AmplitudeReactNative.swift +29 -0
- package/ios/AmplitudeReactNative.xcodeproj/project.pbxproj +293 -0
- package/ios/AppleContextProvider.swift +219 -0
- package/lib/commonjs/attribution/campaign-parser.js +74 -0
- package/lib/commonjs/attribution/campaign-parser.js.map +1 -0
- package/lib/commonjs/attribution/campaign-tracker.js +133 -0
- package/lib/commonjs/attribution/campaign-tracker.js.map +1 -0
- package/lib/commonjs/attribution/constants.js +47 -0
- package/lib/commonjs/attribution/constants.js.map +1 -0
- package/lib/commonjs/config.js +257 -0
- package/lib/commonjs/config.js.map +1 -0
- package/lib/commonjs/constants.js +31 -0
- package/lib/commonjs/constants.js.map +1 -0
- package/lib/commonjs/cookie-migration/index.js +74 -0
- package/lib/commonjs/cookie-migration/index.js.map +1 -0
- package/lib/commonjs/index.js +141 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/plugins/context.js +136 -0
- package/lib/commonjs/plugins/context.js.map +1 -0
- package/lib/commonjs/react-native-client.js +362 -0
- package/lib/commonjs/react-native-client.js.map +1 -0
- package/lib/commonjs/session-manager.js +114 -0
- package/lib/commonjs/session-manager.js.map +1 -0
- package/lib/commonjs/storage/cookie.js +124 -0
- package/lib/commonjs/storage/cookie.js.map +1 -0
- package/lib/commonjs/storage/local-storage.js +79 -0
- package/lib/commonjs/storage/local-storage.js.map +1 -0
- package/lib/commonjs/storage/utm-cookie.js +42 -0
- package/lib/commonjs/storage/utm-cookie.js.map +1 -0
- package/lib/commonjs/transports/fetch.js +34 -0
- package/lib/commonjs/transports/fetch.js.map +1 -0
- package/lib/commonjs/transports/send-beacon.js +43 -0
- package/lib/commonjs/transports/send-beacon.js.map +1 -0
- package/lib/commonjs/transports/xhr.js +54 -0
- package/lib/commonjs/transports/xhr.js.map +1 -0
- package/lib/commonjs/typings/browser-snippet.d.js +6 -0
- package/lib/commonjs/typings/browser-snippet.d.js.map +1 -0
- package/lib/commonjs/typings/ua-parser.d.js +2 -0
- package/lib/commonjs/typings/ua-parser.d.js.map +1 -0
- package/lib/commonjs/utils/cookie-name.js +23 -0
- package/lib/commonjs/utils/cookie-name.js.map +1 -0
- package/lib/commonjs/utils/language.js +18 -0
- package/lib/commonjs/utils/language.js.map +1 -0
- package/lib/commonjs/utils/platform.js +21 -0
- package/lib/commonjs/utils/platform.js.map +1 -0
- package/lib/commonjs/utils/query-params.js +36 -0
- package/lib/commonjs/utils/query-params.js.map +1 -0
- package/lib/commonjs/utils/snippet-helper.js +56 -0
- package/lib/commonjs/utils/snippet-helper.js.map +1 -0
- package/lib/commonjs/version.js +9 -0
- package/lib/commonjs/version.js.map +1 -0
- package/lib/module/attribution/campaign-parser.js +62 -0
- package/lib/module/attribution/campaign-parser.js.map +1 -0
- package/lib/module/attribution/campaign-tracker.js +120 -0
- package/lib/module/attribution/campaign-tracker.js.map +1 -0
- package/lib/module/attribution/constants.js +26 -0
- package/lib/module/attribution/constants.js.map +1 -0
- package/lib/module/config.js +217 -0
- package/lib/module/config.js.map +1 -0
- package/lib/module/constants.js +13 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/module/cookie-migration/index.js +56 -0
- package/lib/module/cookie-migration/index.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/plugins/context.js +118 -0
- package/lib/module/plugins/context.js.map +1 -0
- package/lib/module/react-native-client.js +329 -0
- package/lib/module/react-native-client.js.map +1 -0
- package/lib/module/session-manager.js +104 -0
- package/lib/module/session-manager.js.map +1 -0
- package/lib/module/storage/cookie.js +114 -0
- package/lib/module/storage/cookie.js.map +1 -0
- package/lib/module/storage/local-storage.js +67 -0
- package/lib/module/storage/local-storage.js.map +1 -0
- package/lib/module/storage/utm-cookie.js +32 -0
- package/lib/module/storage/utm-cookie.js.map +1 -0
- package/lib/module/transports/fetch.js +24 -0
- package/lib/module/transports/fetch.js.map +1 -0
- package/lib/module/transports/send-beacon.js +33 -0
- package/lib/module/transports/send-beacon.js.map +1 -0
- package/lib/module/transports/xhr.js +44 -0
- package/lib/module/transports/xhr.js.map +1 -0
- package/lib/module/typings/browser-snippet.d.js +2 -0
- package/lib/module/typings/browser-snippet.d.js.map +1 -0
- package/lib/module/typings/ua-parser.d.js +2 -0
- package/lib/module/typings/ua-parser.d.js.map +1 -0
- package/lib/module/utils/cookie-name.js +10 -0
- package/lib/module/utils/cookie-name.js.map +1 -0
- package/lib/module/utils/language.js +9 -0
- package/lib/module/utils/language.js.map +1 -0
- package/lib/module/utils/platform.js +8 -0
- package/lib/module/utils/platform.js.map +1 -0
- package/lib/module/utils/query-params.js +26 -0
- package/lib/module/utils/query-params.js.map +1 -0
- package/lib/module/utils/snippet-helper.js +41 -0
- package/lib/module/utils/snippet-helper.js.map +1 -0
- package/lib/module/version.js +2 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/attribution/campaign-parser.d.ts +10 -0
- package/lib/typescript/attribution/campaign-parser.d.ts.map +1 -0
- package/lib/typescript/attribution/campaign-tracker.d.ts +72 -0
- package/lib/typescript/attribution/campaign-tracker.d.ts.map +1 -0
- package/lib/typescript/attribution/constants.d.ts +17 -0
- package/lib/typescript/attribution/constants.d.ts.map +1 -0
- package/lib/typescript/config.d.ts +90 -0
- package/lib/typescript/config.d.ts.map +1 -0
- package/lib/typescript/constants.d.ts +13 -0
- package/lib/typescript/constants.d.ts.map +1 -0
- package/lib/typescript/cookie-migration/index.d.ts +5 -0
- package/lib/typescript/cookie-migration/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +6 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/plugins/context.d.ts +31 -0
- package/lib/typescript/plugins/context.d.ts.map +1 -0
- package/lib/typescript/react-native-client.d.ts +209 -0
- package/lib/typescript/react-native-client.d.ts.map +1 -0
- package/lib/typescript/session-manager.d.ts +28 -0
- package/lib/typescript/session-manager.d.ts.map +1 -0
- package/lib/typescript/storage/cookie.d.ts +12 -0
- package/lib/typescript/storage/cookie.d.ts.map +1 -0
- package/lib/typescript/storage/local-storage.d.ts +10 -0
- package/lib/typescript/storage/local-storage.d.ts.map +1 -0
- package/lib/typescript/storage/utm-cookie.d.ts +6 -0
- package/lib/typescript/storage/utm-cookie.d.ts.map +1 -0
- package/lib/typescript/transports/fetch.d.ts +6 -0
- package/lib/typescript/transports/fetch.d.ts.map +1 -0
- package/lib/typescript/transports/send-beacon.d.ts +6 -0
- package/lib/typescript/transports/send-beacon.d.ts.map +1 -0
- package/lib/typescript/transports/xhr.d.ts +7 -0
- package/lib/typescript/transports/xhr.d.ts.map +1 -0
- package/lib/typescript/utils/cookie-name.d.ts +3 -0
- package/lib/typescript/utils/cookie-name.d.ts.map +1 -0
- package/lib/typescript/utils/language.d.ts +2 -0
- package/lib/typescript/utils/language.d.ts.map +1 -0
- package/lib/typescript/utils/platform.d.ts +3 -0
- package/lib/typescript/utils/platform.d.ts.map +1 -0
- package/lib/typescript/utils/query-params.d.ts +2 -0
- package/lib/typescript/utils/query-params.d.ts.map +1 -0
- package/lib/typescript/utils/snippet-helper.d.ts +16 -0
- package/lib/typescript/utils/snippet-helper.d.ts.map +1 -0
- package/lib/typescript/version.d.ts +2 -0
- package/lib/typescript/version.d.ts.map +1 -0
- package/package.json +93 -0
- package/src/attribution/campaign-parser.ts +78 -0
- package/src/attribution/campaign-tracker.ts +112 -0
- package/src/attribution/constants.ts +32 -0
- package/src/config.ts +210 -0
- package/src/constants.ts +14 -0
- package/src/cookie-migration/index.ts +54 -0
- package/src/index.ts +23 -0
- package/src/plugins/context.ts +106 -0
- package/src/react-native-client.ts +349 -0
- package/src/session-manager.ts +81 -0
- package/src/storage/cookie.ts +95 -0
- package/src/storage/local-storage.ts +67 -0
- package/src/storage/utm-cookie.ts +27 -0
- package/src/transports/fetch.ts +23 -0
- package/src/transports/send-beacon.ts +34 -0
- package/src/transports/xhr.ts +36 -0
- package/src/typings/browser-snippet.d.ts +7 -0
- package/src/typings/ua-parser.d.ts +4 -0
- package/src/utils/cookie-name.ts +9 -0
- package/src/utils/language.ts +7 -0
- package/src/utils/platform.ts +9 -0
- package/src/utils/query-params.ts +21 -0
- package/src/utils/snippet-helper.ts +35 -0
- package/src/version.ts +1 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc(AmplitudeReactNative)
|
|
4
|
+
class ReactNative: NSObject {
|
|
5
|
+
|
|
6
|
+
private let appleContextProvider = AppleContextProvider()
|
|
7
|
+
|
|
8
|
+
@objc
|
|
9
|
+
static func requiresMainQueueSetup() -> Bool {
|
|
10
|
+
return false
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@objc
|
|
14
|
+
func getApplicationContext(
|
|
15
|
+
_ resolve: RCTPromiseResolveBlock,
|
|
16
|
+
rejecter reject: RCTPromiseRejectBlock
|
|
17
|
+
) -> Void {
|
|
18
|
+
let applicationContext: [String: String?] = [
|
|
19
|
+
"version": appleContextProvider.version,
|
|
20
|
+
"platform": appleContextProvider.platform,
|
|
21
|
+
"language": appleContextProvider.language,
|
|
22
|
+
"os_name": appleContextProvider.osName,
|
|
23
|
+
"os_version": appleContextProvider.osVersion,
|
|
24
|
+
"device_manufacturer": appleContextProvider.deviceManufacturer,
|
|
25
|
+
"device_model": appleContextProvider.deviceModel,
|
|
26
|
+
]
|
|
27
|
+
resolve(applicationContext)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
// !$*UTF8*$!
|
|
2
|
+
{
|
|
3
|
+
archiveVersion = 1;
|
|
4
|
+
classes = {
|
|
5
|
+
};
|
|
6
|
+
objectVersion = 46;
|
|
7
|
+
objects = {
|
|
8
|
+
|
|
9
|
+
/* Begin PBXBuildFile section */
|
|
10
|
+
|
|
11
|
+
5E555C0D2413F4C50049A1A2 /* AmplitudeReactNative.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* AmplitudeReactNative.m */; };
|
|
12
|
+
F4FF95D7245B92E800C19C63 /* AmplitudeReactNative.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF95D6245B92E800C19C63 /* AmplitudeReactNative.swift */; };
|
|
13
|
+
|
|
14
|
+
/* End PBXBuildFile section */
|
|
15
|
+
|
|
16
|
+
/* Begin PBXCopyFilesBuildPhase section */
|
|
17
|
+
58B511D91A9E6C8500147676 /* CopyFiles */ = {
|
|
18
|
+
isa = PBXCopyFilesBuildPhase;
|
|
19
|
+
buildActionMask = 2147483647;
|
|
20
|
+
dstPath = "include/$(PRODUCT_NAME)";
|
|
21
|
+
dstSubfolderSpec = 16;
|
|
22
|
+
files = (
|
|
23
|
+
);
|
|
24
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
25
|
+
};
|
|
26
|
+
/* End PBXCopyFilesBuildPhase section */
|
|
27
|
+
|
|
28
|
+
/* Begin PBXFileReference section */
|
|
29
|
+
134814201AA4EA6300B7C361 /* libAmplitudeReactNative.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAmplitudeReactNative.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
30
|
+
|
|
31
|
+
B3E7B5891CC2AC0600A0062D /* AmplitudeReactNative.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AmplitudeReactNative.m; sourceTree = "<group>"; };
|
|
32
|
+
F4FF95D5245B92E700C19C63 /* AmplitudeReactNative-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AmplitudeReactNative-Bridging-Header.h"; sourceTree = "<group>"; };
|
|
33
|
+
F4FF95D6245B92E800C19C63 /* AmplitudeReactNative.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AmplitudeReactNative.swift; sourceTree = "<group>"; };
|
|
34
|
+
|
|
35
|
+
/* End PBXFileReference section */
|
|
36
|
+
|
|
37
|
+
/* Begin PBXFrameworksBuildPhase section */
|
|
38
|
+
58B511D81A9E6C8500147676 /* Frameworks */ = {
|
|
39
|
+
isa = PBXFrameworksBuildPhase;
|
|
40
|
+
buildActionMask = 2147483647;
|
|
41
|
+
files = (
|
|
42
|
+
);
|
|
43
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
44
|
+
};
|
|
45
|
+
/* End PBXFrameworksBuildPhase section */
|
|
46
|
+
|
|
47
|
+
/* Begin PBXGroup section */
|
|
48
|
+
134814211AA4EA7D00B7C361 /* Products */ = {
|
|
49
|
+
isa = PBXGroup;
|
|
50
|
+
children = (
|
|
51
|
+
134814201AA4EA6300B7C361 /* libAmplitudeReactNative.a */,
|
|
52
|
+
);
|
|
53
|
+
name = Products;
|
|
54
|
+
sourceTree = "<group>";
|
|
55
|
+
};
|
|
56
|
+
58B511D21A9E6C8500147676 = {
|
|
57
|
+
isa = PBXGroup;
|
|
58
|
+
children = (
|
|
59
|
+
|
|
60
|
+
F4FF95D6245B92E800C19C63 /* AmplitudeReactNative.swift */,
|
|
61
|
+
B3E7B5891CC2AC0600A0062D /* AmplitudeReactNative.m */,
|
|
62
|
+
F4FF95D5245B92E700C19C63 /* AmplitudeReactNative-Bridging-Header.h */,
|
|
63
|
+
|
|
64
|
+
134814211AA4EA7D00B7C361 /* Products */,
|
|
65
|
+
);
|
|
66
|
+
sourceTree = "<group>";
|
|
67
|
+
};
|
|
68
|
+
/* End PBXGroup section */
|
|
69
|
+
|
|
70
|
+
/* Begin PBXNativeTarget section */
|
|
71
|
+
58B511DA1A9E6C8500147676 /* ReactNative */ = {
|
|
72
|
+
isa = PBXNativeTarget;
|
|
73
|
+
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "ReactNative" */;
|
|
74
|
+
buildPhases = (
|
|
75
|
+
58B511D71A9E6C8500147676 /* Sources */,
|
|
76
|
+
58B511D81A9E6C8500147676 /* Frameworks */,
|
|
77
|
+
58B511D91A9E6C8500147676 /* CopyFiles */,
|
|
78
|
+
);
|
|
79
|
+
buildRules = (
|
|
80
|
+
);
|
|
81
|
+
dependencies = (
|
|
82
|
+
);
|
|
83
|
+
name = ReactNative;
|
|
84
|
+
productName = RCTDataManager;
|
|
85
|
+
productReference = 134814201AA4EA6300B7C361 /* libAmplitudeReactNative.a */;
|
|
86
|
+
productType = "com.apple.product-type.library.static";
|
|
87
|
+
};
|
|
88
|
+
/* End PBXNativeTarget section */
|
|
89
|
+
|
|
90
|
+
/* Begin PBXProject section */
|
|
91
|
+
58B511D31A9E6C8500147676 /* Project object */ = {
|
|
92
|
+
isa = PBXProject;
|
|
93
|
+
attributes = {
|
|
94
|
+
LastUpgradeCheck = 0920;
|
|
95
|
+
ORGANIZATIONNAME = Facebook;
|
|
96
|
+
TargetAttributes = {
|
|
97
|
+
58B511DA1A9E6C8500147676 = {
|
|
98
|
+
CreatedOnToolsVersion = 6.1.1;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "ReactNative" */;
|
|
103
|
+
compatibilityVersion = "Xcode 3.2";
|
|
104
|
+
developmentRegion = English;
|
|
105
|
+
hasScannedForEncodings = 0;
|
|
106
|
+
knownRegions = (
|
|
107
|
+
English,
|
|
108
|
+
en,
|
|
109
|
+
);
|
|
110
|
+
mainGroup = 58B511D21A9E6C8500147676;
|
|
111
|
+
productRefGroup = 58B511D21A9E6C8500147676;
|
|
112
|
+
projectDirPath = "";
|
|
113
|
+
projectRoot = "";
|
|
114
|
+
targets = (
|
|
115
|
+
58B511DA1A9E6C8500147676 /* ReactNative */,
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
/* End PBXProject section */
|
|
119
|
+
|
|
120
|
+
/* Begin PBXSourcesBuildPhase section */
|
|
121
|
+
58B511D71A9E6C8500147676 /* Sources */ = {
|
|
122
|
+
isa = PBXSourcesBuildPhase;
|
|
123
|
+
buildActionMask = 2147483647;
|
|
124
|
+
files = (
|
|
125
|
+
|
|
126
|
+
F4FF95D7245B92E800C19C63 /* AmplitudeReactNative.swift in Sources */,
|
|
127
|
+
B3E7B58A1CC2AC0600A0062D /* AmplitudeReactNative.m in Sources */,
|
|
128
|
+
|
|
129
|
+
);
|
|
130
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
131
|
+
};
|
|
132
|
+
/* End PBXSourcesBuildPhase section */
|
|
133
|
+
|
|
134
|
+
/* Begin XCBuildConfiguration section */
|
|
135
|
+
58B511ED1A9E6C8500147676 /* Debug */ = {
|
|
136
|
+
isa = XCBuildConfiguration;
|
|
137
|
+
buildSettings = {
|
|
138
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
139
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
|
140
|
+
CLANG_CXX_LIBRARY = "libc++";
|
|
141
|
+
CLANG_ENABLE_MODULES = YES;
|
|
142
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
|
143
|
+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
|
144
|
+
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
145
|
+
CLANG_WARN_COMMA = YES;
|
|
146
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
147
|
+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
148
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
|
149
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
150
|
+
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
151
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
|
152
|
+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
|
153
|
+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
|
154
|
+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
155
|
+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
|
156
|
+
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
|
157
|
+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
158
|
+
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
159
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
160
|
+
COPY_PHASE_STRIP = NO;
|
|
161
|
+
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
162
|
+
ENABLE_TESTABILITY = YES;
|
|
163
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
164
|
+
GCC_DYNAMIC_NO_PIC = NO;
|
|
165
|
+
GCC_NO_COMMON_BLOCKS = YES;
|
|
166
|
+
GCC_OPTIMIZATION_LEVEL = 0;
|
|
167
|
+
GCC_PREPROCESSOR_DEFINITIONS = (
|
|
168
|
+
"DEBUG=1",
|
|
169
|
+
"$(inherited)",
|
|
170
|
+
);
|
|
171
|
+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
|
172
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
173
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
174
|
+
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
175
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
176
|
+
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
177
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
178
|
+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
|
179
|
+
MTL_ENABLE_DEBUG_INFO = YES;
|
|
180
|
+
ONLY_ACTIVE_ARCH = YES;
|
|
181
|
+
SDKROOT = iphoneos;
|
|
182
|
+
};
|
|
183
|
+
name = Debug;
|
|
184
|
+
};
|
|
185
|
+
58B511EE1A9E6C8500147676 /* Release */ = {
|
|
186
|
+
isa = XCBuildConfiguration;
|
|
187
|
+
buildSettings = {
|
|
188
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
189
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
|
190
|
+
CLANG_CXX_LIBRARY = "libc++";
|
|
191
|
+
CLANG_ENABLE_MODULES = YES;
|
|
192
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
|
193
|
+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
|
194
|
+
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
195
|
+
CLANG_WARN_COMMA = YES;
|
|
196
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
197
|
+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
198
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
|
199
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
200
|
+
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
201
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
|
202
|
+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
|
203
|
+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
|
204
|
+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
205
|
+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
|
206
|
+
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
|
207
|
+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
208
|
+
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
209
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
210
|
+
COPY_PHASE_STRIP = YES;
|
|
211
|
+
ENABLE_NS_ASSERTIONS = NO;
|
|
212
|
+
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
213
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
214
|
+
GCC_NO_COMMON_BLOCKS = YES;
|
|
215
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
216
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
217
|
+
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
218
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
219
|
+
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
220
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
221
|
+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
|
222
|
+
MTL_ENABLE_DEBUG_INFO = NO;
|
|
223
|
+
SDKROOT = iphoneos;
|
|
224
|
+
VALIDATE_PRODUCT = YES;
|
|
225
|
+
};
|
|
226
|
+
name = Release;
|
|
227
|
+
};
|
|
228
|
+
58B511F01A9E6C8500147676 /* Debug */ = {
|
|
229
|
+
isa = XCBuildConfiguration;
|
|
230
|
+
buildSettings = {
|
|
231
|
+
HEADER_SEARCH_PATHS = (
|
|
232
|
+
"$(inherited)",
|
|
233
|
+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
|
234
|
+
"$(SRCROOT)/../../../React/**",
|
|
235
|
+
"$(SRCROOT)/../../react-native/React/**",
|
|
236
|
+
);
|
|
237
|
+
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
238
|
+
OTHER_LDFLAGS = "-ObjC";
|
|
239
|
+
PRODUCT_NAME = ReactNative;
|
|
240
|
+
SKIP_INSTALL = YES;
|
|
241
|
+
|
|
242
|
+
SWIFT_OBJC_BRIDGING_HEADER = "AmplitudeReactNative-Bridging-Header.h";
|
|
243
|
+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
|
244
|
+
SWIFT_VERSION = 5.0;
|
|
245
|
+
|
|
246
|
+
};
|
|
247
|
+
name = Debug;
|
|
248
|
+
};
|
|
249
|
+
58B511F11A9E6C8500147676 /* Release */ = {
|
|
250
|
+
isa = XCBuildConfiguration;
|
|
251
|
+
buildSettings = {
|
|
252
|
+
HEADER_SEARCH_PATHS = (
|
|
253
|
+
"$(inherited)",
|
|
254
|
+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
|
255
|
+
"$(SRCROOT)/../../../React/**",
|
|
256
|
+
"$(SRCROOT)/../../react-native/React/**",
|
|
257
|
+
);
|
|
258
|
+
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
259
|
+
OTHER_LDFLAGS = "-ObjC";
|
|
260
|
+
PRODUCT_NAME = ReactNative;
|
|
261
|
+
SKIP_INSTALL = YES;
|
|
262
|
+
|
|
263
|
+
SWIFT_OBJC_BRIDGING_HEADER = "AmplitudeReactNative-Bridging-Header.h";
|
|
264
|
+
SWIFT_VERSION = 5.0;
|
|
265
|
+
|
|
266
|
+
};
|
|
267
|
+
name = Release;
|
|
268
|
+
};
|
|
269
|
+
/* End XCBuildConfiguration section */
|
|
270
|
+
|
|
271
|
+
/* Begin XCConfigurationList section */
|
|
272
|
+
58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "ReactNative" */ = {
|
|
273
|
+
isa = XCConfigurationList;
|
|
274
|
+
buildConfigurations = (
|
|
275
|
+
58B511ED1A9E6C8500147676 /* Debug */,
|
|
276
|
+
58B511EE1A9E6C8500147676 /* Release */,
|
|
277
|
+
);
|
|
278
|
+
defaultConfigurationIsVisible = 0;
|
|
279
|
+
defaultConfigurationName = Release;
|
|
280
|
+
};
|
|
281
|
+
58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "ReactNative" */ = {
|
|
282
|
+
isa = XCConfigurationList;
|
|
283
|
+
buildConfigurations = (
|
|
284
|
+
58B511F01A9E6C8500147676 /* Debug */,
|
|
285
|
+
58B511F11A9E6C8500147676 /* Release */,
|
|
286
|
+
);
|
|
287
|
+
defaultConfigurationIsVisible = 0;
|
|
288
|
+
defaultConfigurationName = Release;
|
|
289
|
+
};
|
|
290
|
+
/* End XCConfigurationList section */
|
|
291
|
+
};
|
|
292
|
+
rootObject = 58B511D31A9E6C8500147676 /* Project object */;
|
|
293
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class AppleContextProvider : NSObject {
|
|
4
|
+
|
|
5
|
+
public let version: String? = AppleContextProvider.getVersion()
|
|
6
|
+
public let language: String? = AppleContextProvider.getLanguage()
|
|
7
|
+
public let platform: String = AppleContextProvider.getPlatform()
|
|
8
|
+
public let osName: String = AppleContextProvider.getOsName()
|
|
9
|
+
public let osVersion: String = AppleContextProvider.getOsVersion()
|
|
10
|
+
public let deviceManufacturer: String = AppleContextProvider.getDeviceManufacturer()
|
|
11
|
+
public let deviceModel: String = AppleContextProvider.getDeviceModel()
|
|
12
|
+
|
|
13
|
+
private static func getVersion() -> String? {
|
|
14
|
+
return Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
private static func getLanguage() -> String? {
|
|
18
|
+
return Locale(identifier: "en_US").localizedString(forLanguageCode: Locale.preferredLanguages[0])
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private static func getPlatform() -> String {
|
|
22
|
+
return "iOS"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private static func getOsName() -> String {
|
|
26
|
+
return "ios"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private static func getOsVersion() -> String {
|
|
30
|
+
let systemVersion = ProcessInfo.processInfo.operatingSystemVersion
|
|
31
|
+
return "\(systemVersion.majorVersion).\(systemVersion.minorVersion).\(systemVersion.patchVersion)."
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private static func getDeviceManufacturer() -> String {
|
|
35
|
+
return "Apple"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private static func getPlatformString() -> String {
|
|
39
|
+
var sysinfo = utsname()
|
|
40
|
+
uname(&sysinfo) // ignore return value
|
|
41
|
+
return String(bytes: Data(bytes: &sysinfo.machine, count: Int(_SYS_NAMELEN)), encoding: .ascii)!.trimmingCharacters(in: .controlCharacters)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private static func getDeviceModel() -> String {
|
|
45
|
+
let platform = getPlatformString()
|
|
46
|
+
// == iPhone ==
|
|
47
|
+
// iPhone 1
|
|
48
|
+
if (platform == "iPhone1,1") { return "iPhone 1" }
|
|
49
|
+
// iPhone 3
|
|
50
|
+
if (platform == "iPhone1,2") { return "iPhone 3G" }
|
|
51
|
+
if (platform == "iPhone2,1") { return "iPhone 3GS" }
|
|
52
|
+
// iPhone 4
|
|
53
|
+
if (platform == "iPhone3,1") { return "iPhone 4" }
|
|
54
|
+
if (platform == "iPhone3,2") { return "iPhone 4" }
|
|
55
|
+
if (platform == "iPhone3,3") { return "iPhone 4" }
|
|
56
|
+
if (platform == "iPhone4,1") { return "iPhone 4S" }
|
|
57
|
+
// iPhone 5
|
|
58
|
+
if (platform == "iPhone5,1") { return "iPhone 5" }
|
|
59
|
+
if (platform == "iPhone5,2") { return "iPhone 5" }
|
|
60
|
+
if (platform == "iPhone5,3") { return "iPhone 5c" }
|
|
61
|
+
if (platform == "iPhone5,4") { return "iPhone 5c" }
|
|
62
|
+
if (platform == "iPhone6,1") { return "iPhone 5s" }
|
|
63
|
+
if (platform == "iPhone6,2") { return "iPhone 5s" }
|
|
64
|
+
// iPhone 6
|
|
65
|
+
if (platform == "iPhone7,1") { return "iPhone 6 Plus" }
|
|
66
|
+
if (platform == "iPhone7,2") { return "iPhone 6" }
|
|
67
|
+
if (platform == "iPhone8,1") { return "iPhone 6s" }
|
|
68
|
+
if (platform == "iPhone8,2") { return "iPhone 6s Plus" }
|
|
69
|
+
|
|
70
|
+
// iPhone 7
|
|
71
|
+
if (platform == "iPhone9,1") { return "iPhone 7" }
|
|
72
|
+
if (platform == "iPhone9,2") { return "iPhone 7 Plus" }
|
|
73
|
+
if (platform == "iPhone9,3") { return "iPhone 7" }
|
|
74
|
+
if (platform == "iPhone9,4") { return "iPhone 7 Plus" }
|
|
75
|
+
// iPhone 8
|
|
76
|
+
if (platform == "iPhone10,1") { return "iPhone 8" }
|
|
77
|
+
if (platform == "iPhone10,4") { return "iPhone 8" }
|
|
78
|
+
if (platform == "iPhone10,2") { return "iPhone 8 Plus" }
|
|
79
|
+
if (platform == "iPhone10,5") { return "iPhone 8 Plus" }
|
|
80
|
+
|
|
81
|
+
// iPhone X
|
|
82
|
+
if (platform == "iPhone10,3") { return "iPhone X" }
|
|
83
|
+
if (platform == "iPhone10,6") { return "iPhone X" }
|
|
84
|
+
|
|
85
|
+
// iPhone XS
|
|
86
|
+
if (platform == "iPhone11,2") { return "iPhone XS" }
|
|
87
|
+
if (platform == "iPhone11,6") { return "iPhone XS Max" }
|
|
88
|
+
|
|
89
|
+
// iPhone XR
|
|
90
|
+
if (platform == "iPhone11,8") { return "iPhone XR" }
|
|
91
|
+
|
|
92
|
+
// iPhone 11
|
|
93
|
+
if (platform == "iPhone12,1") { return "iPhone 11" }
|
|
94
|
+
if (platform == "iPhone12,3") { return "iPhone 11 Pro" }
|
|
95
|
+
if (platform == "iPhone12,5") { return "iPhone 11 Pro Max" }
|
|
96
|
+
|
|
97
|
+
// iPhone SE
|
|
98
|
+
if (platform == "iPhone8,4") { return "iPhone SE" }
|
|
99
|
+
if (platform == "iPhone12,8") { return "iPhone SE 2" }
|
|
100
|
+
|
|
101
|
+
// == iPod ==
|
|
102
|
+
if (platform == "iPod1,1") { return "iPod Touch 1G" }
|
|
103
|
+
if (platform == "iPod2,1") { return "iPod Touch 2G" }
|
|
104
|
+
if (platform == "iPod3,1") { return "iPod Touch 3G" }
|
|
105
|
+
if (platform == "iPod4,1") { return "iPod Touch 4G" }
|
|
106
|
+
if (platform == "iPod5,1") { return "iPod Touch 5G" }
|
|
107
|
+
if (platform == "iPod7,1") { return "iPod Touch 6G" }
|
|
108
|
+
if (platform == "iPod9,1") { return "iPod Touch 7G" }
|
|
109
|
+
|
|
110
|
+
// == iPad ==
|
|
111
|
+
// iPad 1
|
|
112
|
+
if (platform == "iPad1,1") { return "iPad 1" }
|
|
113
|
+
// iPad 2
|
|
114
|
+
if (platform == "iPad2,1") { return "iPad 2" }
|
|
115
|
+
if (platform == "iPad2,2") { return "iPad 2" }
|
|
116
|
+
if (platform == "iPad2,3") { return "iPad 2" }
|
|
117
|
+
if (platform == "iPad2,4") { return "iPad 2" }
|
|
118
|
+
// iPad 3
|
|
119
|
+
if (platform == "iPad3,1") { return "iPad 3" }
|
|
120
|
+
if (platform == "iPad3,2") { return "iPad 3" }
|
|
121
|
+
if (platform == "iPad3,3") { return "iPad 3" }
|
|
122
|
+
// iPad 4
|
|
123
|
+
if (platform == "iPad3,4") { return "iPad 4" }
|
|
124
|
+
if (platform == "iPad3,5") { return "iPad 4" }
|
|
125
|
+
if (platform == "iPad3,6") { return "iPad 4" }
|
|
126
|
+
// iPad Air
|
|
127
|
+
if (platform == "iPad4,1") { return "iPad Air" }
|
|
128
|
+
if (platform == "iPad4,2") { return "iPad Air" }
|
|
129
|
+
if (platform == "iPad4,3") { return "iPad Air" }
|
|
130
|
+
// iPad Air 2
|
|
131
|
+
if (platform == "iPad5,3") { return "iPad Air 2" }
|
|
132
|
+
if (platform == "iPad5,4") { return "iPad Air 2" }
|
|
133
|
+
// iPad 5
|
|
134
|
+
if (platform == "iPad6,11") { return "iPad 5" }
|
|
135
|
+
if (platform == "iPad6,12") { return "iPad 5" }
|
|
136
|
+
// iPad 6
|
|
137
|
+
if (platform == "iPad7,5") { return "iPad 6" }
|
|
138
|
+
if (platform == "iPad7,6") { return "iPad 6" }
|
|
139
|
+
// iPad Air 3
|
|
140
|
+
if (platform == "iPad11,3") { return "iPad Air 3" }
|
|
141
|
+
if (platform == "iPad11,4") { return "iPad Air 3" }
|
|
142
|
+
// iPad 7
|
|
143
|
+
if (platform == "iPad7,11") { return "iPad 6" }
|
|
144
|
+
if (platform == "iPad7,12") { return "iPad 6" }
|
|
145
|
+
|
|
146
|
+
// iPad Pro
|
|
147
|
+
if (platform == "iPad6,7") { return "iPad Pro" }
|
|
148
|
+
if (platform == "iPad6,8") { return "iPad Pro" }
|
|
149
|
+
if (platform == "iPad6,3") { return "iPad Pro" }
|
|
150
|
+
if (platform == "iPad6,4") { return "iPad Pro" }
|
|
151
|
+
if (platform == "iPad7,1") { return "iPad Pro" }
|
|
152
|
+
if (platform == "iPad7,2") { return "iPad Pro" }
|
|
153
|
+
if (platform == "iPad7,3") { return "iPad Pro" }
|
|
154
|
+
if (platform == "iPad7,4") { return "iPad Pro" }
|
|
155
|
+
if (platform == "iPad8,1") { return "iPad Pro" }
|
|
156
|
+
if (platform == "iPad8,2") { return "iPad Pro" }
|
|
157
|
+
if (platform == "iPad8,3") { return "iPad Pro" }
|
|
158
|
+
if (platform == "iPad8,4") { return "iPad Pro" }
|
|
159
|
+
if (platform == "iPad8,5") { return "iPad Pro" }
|
|
160
|
+
if (platform == "iPad8,6") { return "iPad Pro" }
|
|
161
|
+
if (platform == "iPad8,7") { return "iPad Pro" }
|
|
162
|
+
if (platform == "iPad8,8") { return "iPad Pro" }
|
|
163
|
+
|
|
164
|
+
// iPad Mini
|
|
165
|
+
if (platform == "iPad2,5") { return "iPad Mini" }
|
|
166
|
+
if (platform == "iPad2,6") { return "iPad Mini" }
|
|
167
|
+
if (platform == "iPad2,7") { return "iPad Mini" }
|
|
168
|
+
// iPad Mini 2
|
|
169
|
+
if (platform == "iPad4,4") { return "iPad Mini 2" }
|
|
170
|
+
if (platform == "iPad4,5") { return "iPad Mini 2" }
|
|
171
|
+
if (platform == "iPad4,6") { return "iPad Mini 2" }
|
|
172
|
+
// iPad Mini 3
|
|
173
|
+
if (platform == "iPad4,7") { return "iPad Mini 3" }
|
|
174
|
+
if (platform == "iPad4,8") { return "iPad Mini 3" }
|
|
175
|
+
if (platform == "iPad4,9") { return "iPad Mini 3" }
|
|
176
|
+
// iPad Mini 4
|
|
177
|
+
if (platform == "iPad5,1") { return "iPad Mini 4" }
|
|
178
|
+
if (platform == "iPad5,2") { return "iPad Mini 4" }
|
|
179
|
+
// iPad Mini 5
|
|
180
|
+
if (platform == "iPad11,1") { return "iPad Mini 5" }
|
|
181
|
+
if (platform == "iPad11,2") { return "iPad Mini 5" }
|
|
182
|
+
|
|
183
|
+
// == Apple Watch ==
|
|
184
|
+
if (platform == "Watch1,1") { return "Apple Watch 38mm" }
|
|
185
|
+
if (platform == "Watch1,2") { return "Apple Watch 42mm" }
|
|
186
|
+
if (platform == "Watch2,3") { return "Apple Watch Series 2 38mm" }
|
|
187
|
+
if (platform == "Watch2,4") { return "Apple Watch Series 2 42mm" }
|
|
188
|
+
if (platform == "Watch2,6") { return "Apple Watch Series 1 38mm" }
|
|
189
|
+
if (platform == "Watch2,7") { return "Apple Watch Series 1 42mm" }
|
|
190
|
+
if (platform == "Watch3,1") { return "Apple Watch Series 3 38mm Cellular" }
|
|
191
|
+
if (platform == "Watch3,2") { return "Apple Watch Series 3 42mm Cellular" }
|
|
192
|
+
if (platform == "Watch3,3") { return "Apple Watch Series 3 38mm" }
|
|
193
|
+
if (platform == "Watch3,4") { return "Apple Watch Series 3 42mm" }
|
|
194
|
+
if (platform == "Watch4,1") { return "Apple Watch Series 4 40mm" }
|
|
195
|
+
if (platform == "Watch4,2") { return "Apple Watch Series 4 44mm" }
|
|
196
|
+
if (platform == "Watch4,3") { return "Apple Watch Series 4 40mm Cellular" }
|
|
197
|
+
if (platform == "Watch4,4") { return "Apple Watch Series 4 44mm Cellular" }
|
|
198
|
+
if (platform == "Watch5,1") { return "Apple Watch Series 5 40mm" }
|
|
199
|
+
if (platform == "Watch5,2") { return "Apple Watch Series 5 44mm" }
|
|
200
|
+
if (platform == "Watch5,3") { return "Apple Watch Series 5 40mm Cellular" }
|
|
201
|
+
if (platform == "Watch5,4") { return "Apple Watch Series 5 44mm Cellular" }
|
|
202
|
+
if (platform == "Watch6,1") { return "Apple Watch Series 6 40mm" }
|
|
203
|
+
if (platform == "Watch6,2") { return "Apple Watch Series 6 44mm" }
|
|
204
|
+
if (platform == "Watch6,3") { return "Apple Watch Series 6 40mm Cellular" }
|
|
205
|
+
if (platform == "Watch6,4") { return "Apple Watch Series 6 44mm Cellular" }
|
|
206
|
+
|
|
207
|
+
// == Others ==
|
|
208
|
+
if (platform == "i386") { return "Simulator" }
|
|
209
|
+
if (platform == "x86_64") { return "Simulator" }
|
|
210
|
+
if (platform.hasPrefix("MacBookAir")) { return "MacBook Air" }
|
|
211
|
+
if (platform.hasPrefix("MacBookPro")) { return "MacBook Pro" }
|
|
212
|
+
if (platform.hasPrefix("MacBook")) { return "MacBook" }
|
|
213
|
+
if (platform.hasPrefix("MacPro")) { return "Mac Pro" }
|
|
214
|
+
if (platform.hasPrefix("Macmini")) { return "Mac Mini" }
|
|
215
|
+
if (platform.hasPrefix("iMac")) { return "iMac" }
|
|
216
|
+
if (platform.hasPrefix("Xserve")) { return "Xserve" }
|
|
217
|
+
return platform
|
|
218
|
+
}
|
|
219
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CampaignParser = void 0;
|
|
7
|
+
|
|
8
|
+
var _utmCookie = require("../storage/utm-cookie");
|
|
9
|
+
|
|
10
|
+
var _queryParams = require("../utils/query-params");
|
|
11
|
+
|
|
12
|
+
var _constants = require("./constants");
|
|
13
|
+
|
|
14
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
|
|
16
|
+
class CampaignParser {
|
|
17
|
+
constructor() {
|
|
18
|
+
_defineProperty(this, "utmCookieStorage", new _utmCookie.UTMCookie());
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async parse() {
|
|
22
|
+
return { ..._constants.BASE_CAMPAIGN,
|
|
23
|
+
...(await this.getUtmParam()),
|
|
24
|
+
...this.getReferrer(),
|
|
25
|
+
...this.getClickIds()
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async getUtmParam() {
|
|
30
|
+
const params = (0, _queryParams.getQueryParams)();
|
|
31
|
+
const cookies = (await this.utmCookieStorage.isEnabled()) && (await this.utmCookieStorage.get('__utmz')) || {};
|
|
32
|
+
const utmSource = params[_constants.UTM_SOURCE] || cookies[_constants.UTMZ_SOURCE];
|
|
33
|
+
const utmMedium = params[_constants.UTM_MEDIUM] || cookies[_constants.UTMZ_MEDIUM];
|
|
34
|
+
const utmCampaign = params[_constants.UTM_CAMPAIGN] || cookies[_constants.UTMZ_CAMPAIGN];
|
|
35
|
+
const utmTerm = params[_constants.UTM_TERM] || cookies[_constants.UTMZ_TERM];
|
|
36
|
+
const utmContent = params[_constants.UTM_CONTENT] || cookies[_constants.UTMZ_CONTENT];
|
|
37
|
+
return {
|
|
38
|
+
utm_source: utmSource,
|
|
39
|
+
utm_medium: utmMedium,
|
|
40
|
+
utm_campaign: utmCampaign,
|
|
41
|
+
utm_term: utmTerm,
|
|
42
|
+
utm_content: utmContent
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
getReferrer() {
|
|
47
|
+
const data = {
|
|
48
|
+
referrer: undefined,
|
|
49
|
+
referring_domain: undefined
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
var _data$referrer$split$, _data$referrer;
|
|
54
|
+
|
|
55
|
+
data.referrer = document.referrer || undefined;
|
|
56
|
+
data.referring_domain = (_data$referrer$split$ = (_data$referrer = data.referrer) === null || _data$referrer === void 0 ? void 0 : _data$referrer.split('/')[2]) !== null && _data$referrer$split$ !== void 0 ? _data$referrer$split$ : undefined;
|
|
57
|
+
} catch {// nothing to track
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return data;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getClickIds() {
|
|
64
|
+
const params = (0, _queryParams.getQueryParams)();
|
|
65
|
+
return {
|
|
66
|
+
[_constants.GCLID]: params[_constants.GCLID],
|
|
67
|
+
[_constants.FBCLID]: params[_constants.FBCLID]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
exports.CampaignParser = CampaignParser;
|
|
74
|
+
//# sourceMappingURL=campaign-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CampaignParser","UTMCookie","parse","BASE_CAMPAIGN","getUtmParam","getReferrer","getClickIds","params","getQueryParams","cookies","utmCookieStorage","isEnabled","get","utmSource","UTM_SOURCE","UTMZ_SOURCE","utmMedium","UTM_MEDIUM","UTMZ_MEDIUM","utmCampaign","UTM_CAMPAIGN","UTMZ_CAMPAIGN","utmTerm","UTM_TERM","UTMZ_TERM","utmContent","UTM_CONTENT","UTMZ_CONTENT","utm_source","utm_medium","utm_campaign","utm_term","utm_content","data","referrer","undefined","referring_domain","document","split","GCLID","FBCLID"],"sources":["campaign-parser.ts"],"sourcesContent":["import { UTMCookie } from '../storage/utm-cookie';\nimport { getQueryParams } from '../utils/query-params';\nimport {\n UTM_CAMPAIGN,\n UTM_CONTENT,\n UTM_MEDIUM,\n UTM_SOURCE,\n UTM_TERM,\n UTMZ_SOURCE,\n UTMZ_MEDIUM,\n UTMZ_CAMPAIGN,\n UTMZ_TERM,\n UTMZ_CONTENT,\n GCLID,\n FBCLID,\n BASE_CAMPAIGN,\n} from './constants';\nimport {\n Campaign,\n CampaignParser as ICampaignParser,\n ClickIdParameters,\n ReferrerParameters,\n UTMParameters,\n} from '@amplitude/analytics-types';\n\nexport class CampaignParser implements ICampaignParser {\n utmCookieStorage = new UTMCookie();\n\n async parse(): Promise<Campaign> {\n return {\n ...BASE_CAMPAIGN,\n ...(await this.getUtmParam()),\n ...this.getReferrer(),\n ...this.getClickIds(),\n } as Campaign;\n }\n\n async getUtmParam(): Promise<UTMParameters> {\n const params = getQueryParams();\n const cookies = ((await this.utmCookieStorage.isEnabled()) && (await this.utmCookieStorage.get('__utmz'))) || {};\n\n const utmSource = params[UTM_SOURCE] || cookies[UTMZ_SOURCE];\n const utmMedium = params[UTM_MEDIUM] || cookies[UTMZ_MEDIUM];\n const utmCampaign = params[UTM_CAMPAIGN] || cookies[UTMZ_CAMPAIGN];\n const utmTerm = params[UTM_TERM] || cookies[UTMZ_TERM];\n const utmContent = params[UTM_CONTENT] || cookies[UTMZ_CONTENT];\n\n return {\n utm_source: utmSource,\n utm_medium: utmMedium,\n utm_campaign: utmCampaign,\n utm_term: utmTerm,\n utm_content: utmContent,\n };\n }\n\n getReferrer(): ReferrerParameters {\n const data: ReferrerParameters = {\n referrer: undefined,\n referring_domain: undefined,\n };\n try {\n data.referrer = document.referrer || undefined;\n data.referring_domain = data.referrer?.split('/')[2] ?? undefined;\n } catch {\n // nothing to track\n }\n return data;\n }\n\n getClickIds(): ClickIdParameters {\n const params = getQueryParams();\n return {\n [GCLID]: params[GCLID],\n [FBCLID]: params[FBCLID],\n };\n }\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAuBO,MAAMA,cAAN,CAAgD;EAAA;IAAA,0CAClC,IAAIC,oBAAJ,EADkC;EAAA;;EAG1C,MAALC,KAAK,GAAsB;IAC/B,OAAO,EACL,GAAGC,wBADE;MAEL,IAAI,MAAM,KAAKC,WAAL,EAAV,CAFK;MAGL,GAAG,KAAKC,WAAL,EAHE;MAIL,GAAG,KAAKC,WAAL;IAJE,CAAP;EAMD;;EAEgB,MAAXF,WAAW,GAA2B;IAC1C,MAAMG,MAAM,GAAG,IAAAC,2BAAA,GAAf;IACA,MAAMC,OAAO,GAAI,CAAC,MAAM,KAAKC,gBAAL,CAAsBC,SAAtB,EAAP,MAA8C,MAAM,KAAKD,gBAAL,CAAsBE,GAAtB,CAA0B,QAA1B,CAApD,CAAD,IAA8F,EAA9G;IAEA,MAAMC,SAAS,GAAGN,MAAM,CAACO,qBAAD,CAAN,IAAsBL,OAAO,CAACM,sBAAD,CAA/C;IACA,MAAMC,SAAS,GAAGT,MAAM,CAACU,qBAAD,CAAN,IAAsBR,OAAO,CAACS,sBAAD,CAA/C;IACA,MAAMC,WAAW,GAAGZ,MAAM,CAACa,uBAAD,CAAN,IAAwBX,OAAO,CAACY,wBAAD,CAAnD;IACA,MAAMC,OAAO,GAAGf,MAAM,CAACgB,mBAAD,CAAN,IAAoBd,OAAO,CAACe,oBAAD,CAA3C;IACA,MAAMC,UAAU,GAAGlB,MAAM,CAACmB,sBAAD,CAAN,IAAuBjB,OAAO,CAACkB,uBAAD,CAAjD;IAEA,OAAO;MACLC,UAAU,EAAEf,SADP;MAELgB,UAAU,EAAEb,SAFP;MAGLc,YAAY,EAAEX,WAHT;MAILY,QAAQ,EAAET,OAJL;MAKLU,WAAW,EAAEP;IALR,CAAP;EAOD;;EAEDpB,WAAW,GAAuB;IAChC,MAAM4B,IAAwB,GAAG;MAC/BC,QAAQ,EAAEC,SADqB;MAE/BC,gBAAgB,EAAED;IAFa,CAAjC;;IAIA,IAAI;MAAA;;MACFF,IAAI,CAACC,QAAL,GAAgBG,QAAQ,CAACH,QAAT,IAAqBC,SAArC;MACAF,IAAI,CAACG,gBAAL,8CAAwBH,IAAI,CAACC,QAA7B,mDAAwB,eAAeI,KAAf,CAAqB,GAArB,EAA0B,CAA1B,CAAxB,yEAAwDH,SAAxD;IACD,CAHD,CAGE,MAAM,CACN;IACD;;IACD,OAAOF,IAAP;EACD;;EAED3B,WAAW,GAAsB;IAC/B,MAAMC,MAAM,GAAG,IAAAC,2BAAA,GAAf;IACA,OAAO;MACL,CAAC+B,gBAAD,GAAShC,MAAM,CAACgC,gBAAD,CADV;MAEL,CAACC,iBAAD,GAAUjC,MAAM,CAACiC,iBAAD;IAFX,CAAP;EAID;;AAnDoD"}
|