@capgo/capacitor-rudderstack 8.1.2
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/CapgoCapacitorRudderStack.podspec +19 -0
- package/LICENSE +373 -0
- package/Package.swift +30 -0
- package/README.md +390 -0
- package/android/build.gradle +182 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/app/capgo/rudderstack/RudderStackBridge.java +256 -0
- package/android/src/main/java/app/capgo/rudderstack/RudderStackPlugin.java +205 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +525 -0
- package/dist/esm/definitions.d.ts +154 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +9 -0
- package/dist/esm/index.js +211 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +63 -0
- package/dist/esm/web.js +69 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +283 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +286 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/RudderStackPlugin/RudderStackBridge.swift +244 -0
- package/ios/Sources/RudderStackPlugin/RudderStackPlugin.swift +210 -0
- package/ios/Tests/RudderStackPluginTests/RudderStackPluginTests.swift +8 -0
- package/package.json +94 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc(RudderStackPlugin)
|
|
5
|
+
public class RudderStackPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
6
|
+
public let identifier = "RudderStackPlugin"
|
|
7
|
+
public let jsName = "RudderStack"
|
|
8
|
+
public let pluginMethods: [CAPPluginMethod] = [
|
|
9
|
+
CAPPluginMethod(name: "initialize", returnType: CAPPluginReturnPromise),
|
|
10
|
+
CAPPluginMethod(name: "identify", returnType: CAPPluginReturnPromise),
|
|
11
|
+
CAPPluginMethod(name: "group", returnType: CAPPluginReturnPromise),
|
|
12
|
+
CAPPluginMethod(name: "track", returnType: CAPPluginReturnPromise),
|
|
13
|
+
CAPPluginMethod(name: "screen", returnType: CAPPluginReturnPromise),
|
|
14
|
+
CAPPluginMethod(name: "alias", returnType: CAPPluginReturnPromise),
|
|
15
|
+
CAPPluginMethod(name: "reset", returnType: CAPPluginReturnPromise),
|
|
16
|
+
CAPPluginMethod(name: "flush", returnType: CAPPluginReturnPromise),
|
|
17
|
+
CAPPluginMethod(name: "putDeviceToken", returnType: CAPPluginReturnPromise),
|
|
18
|
+
CAPPluginMethod(name: "setAdvertisingId", returnType: CAPPluginReturnPromise),
|
|
19
|
+
CAPPluginMethod(name: "putAdvertisingId", returnType: CAPPluginReturnPromise),
|
|
20
|
+
CAPPluginMethod(name: "setAnonymousId", returnType: CAPPluginReturnPromise),
|
|
21
|
+
CAPPluginMethod(name: "putAnonymousId", returnType: CAPPluginReturnPromise),
|
|
22
|
+
CAPPluginMethod(name: "optOut", returnType: CAPPluginReturnPromise),
|
|
23
|
+
CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise)
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
private let implementation = RudderStackBridge()
|
|
27
|
+
|
|
28
|
+
@objc func initialize(_ call: CAPPluginCall) {
|
|
29
|
+
guard let writeKey = call.getString("writeKey"), !writeKey.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
|
|
30
|
+
call.reject("writeKey is required")
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
do {
|
|
35
|
+
try implementation.initialize(
|
|
36
|
+
writeKey: writeKey,
|
|
37
|
+
config: call.getObject("config"),
|
|
38
|
+
options: call.getObject("options")
|
|
39
|
+
)
|
|
40
|
+
call.resolve()
|
|
41
|
+
} catch {
|
|
42
|
+
call.reject(error.localizedDescription)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@objc func identify(_ call: CAPPluginCall) {
|
|
47
|
+
guard let userId = call.getString("userId"), !userId.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
|
|
48
|
+
call.reject("userId is required")
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
do {
|
|
53
|
+
try implementation.identify(
|
|
54
|
+
userId: userId,
|
|
55
|
+
traits: call.getObject("traits"),
|
|
56
|
+
options: call.getObject("options")
|
|
57
|
+
)
|
|
58
|
+
call.resolve()
|
|
59
|
+
} catch {
|
|
60
|
+
call.reject(error.localizedDescription)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@objc func group(_ call: CAPPluginCall) {
|
|
65
|
+
guard let groupId = call.getString("groupId"), !groupId.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
|
|
66
|
+
call.reject("groupId is required")
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
do {
|
|
71
|
+
try implementation.group(
|
|
72
|
+
groupId: groupId,
|
|
73
|
+
groupTraits: call.getObject("groupTraits"),
|
|
74
|
+
options: call.getObject("options")
|
|
75
|
+
)
|
|
76
|
+
call.resolve()
|
|
77
|
+
} catch {
|
|
78
|
+
call.reject(error.localizedDescription)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@objc func track(_ call: CAPPluginCall) {
|
|
83
|
+
guard let eventName = call.getString("eventName"), !eventName.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
|
|
84
|
+
call.reject("eventName is required")
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
do {
|
|
89
|
+
try implementation.track(
|
|
90
|
+
eventName: eventName,
|
|
91
|
+
properties: call.getObject("properties"),
|
|
92
|
+
options: call.getObject("options")
|
|
93
|
+
)
|
|
94
|
+
call.resolve()
|
|
95
|
+
} catch {
|
|
96
|
+
call.reject(error.localizedDescription)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@objc func screen(_ call: CAPPluginCall) {
|
|
101
|
+
guard let screenName = call.getString("screenName"), !screenName.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
|
|
102
|
+
call.reject("screenName is required")
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
do {
|
|
107
|
+
try implementation.screen(
|
|
108
|
+
screenName: screenName,
|
|
109
|
+
properties: call.getObject("properties"),
|
|
110
|
+
options: call.getObject("options")
|
|
111
|
+
)
|
|
112
|
+
call.resolve()
|
|
113
|
+
} catch {
|
|
114
|
+
call.reject(error.localizedDescription)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@objc func alias(_ call: CAPPluginCall) {
|
|
119
|
+
guard let newId = call.getString("newId"), !newId.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
|
|
120
|
+
call.reject("newId is required")
|
|
121
|
+
return
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
do {
|
|
125
|
+
try implementation.alias(
|
|
126
|
+
newId: newId,
|
|
127
|
+
options: call.getObject("options")
|
|
128
|
+
)
|
|
129
|
+
call.resolve()
|
|
130
|
+
} catch {
|
|
131
|
+
call.reject(error.localizedDescription)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@objc func reset(_ call: CAPPluginCall) {
|
|
136
|
+
do {
|
|
137
|
+
try implementation.reset()
|
|
138
|
+
call.resolve()
|
|
139
|
+
} catch {
|
|
140
|
+
call.reject(error.localizedDescription)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@objc func flush(_ call: CAPPluginCall) {
|
|
145
|
+
do {
|
|
146
|
+
try implementation.flush()
|
|
147
|
+
call.resolve()
|
|
148
|
+
} catch {
|
|
149
|
+
call.reject(error.localizedDescription)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@objc func putDeviceToken(_ call: CAPPluginCall) {
|
|
154
|
+
guard let deviceToken = call.getString("deviceToken"), !deviceToken.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
|
|
155
|
+
call.reject("deviceToken is required")
|
|
156
|
+
return
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
implementation.putDeviceToken(deviceToken)
|
|
160
|
+
call.resolve()
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@objc func setAdvertisingId(_ call: CAPPluginCall) {
|
|
164
|
+
putAdvertisingId(call)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@objc func putAdvertisingId(_ call: CAPPluginCall) {
|
|
168
|
+
guard let advertisingId = call.getString("advertisingId"), !advertisingId.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
|
|
169
|
+
call.reject("advertisingId is required")
|
|
170
|
+
return
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
implementation.putAdvertisingId(advertisingId)
|
|
174
|
+
call.resolve()
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@objc func setAnonymousId(_ call: CAPPluginCall) {
|
|
178
|
+
putAnonymousId(call)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
@objc func putAnonymousId(_ call: CAPPluginCall) {
|
|
182
|
+
guard let anonymousId = call.getString("anonymousId"), !anonymousId.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
|
|
183
|
+
call.reject("anonymousId is required")
|
|
184
|
+
return
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
implementation.putAnonymousId(anonymousId)
|
|
188
|
+
call.resolve()
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@objc func optOut(_ call: CAPPluginCall) {
|
|
192
|
+
guard let optOut = call.getBool("optOut") else {
|
|
193
|
+
call.reject("optOut is required")
|
|
194
|
+
return
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
do {
|
|
198
|
+
try implementation.optOut(optOut)
|
|
199
|
+
call.resolve()
|
|
200
|
+
} catch {
|
|
201
|
+
call.reject(error.localizedDescription)
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
@objc func getPluginVersion(_ call: CAPPluginCall) {
|
|
206
|
+
call.resolve([
|
|
207
|
+
"version": implementation.version
|
|
208
|
+
])
|
|
209
|
+
}
|
|
210
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@capgo/capacitor-rudderstack",
|
|
3
|
+
"version": "8.1.2",
|
|
4
|
+
"iosSdkVersion": "2.6.0",
|
|
5
|
+
"androidSdkVersion": "1.27.2",
|
|
6
|
+
"buildNumber": "1",
|
|
7
|
+
"description": "Capacitor plugin for RudderStack analytics, identity, and event tracking.",
|
|
8
|
+
"main": "dist/plugin.cjs.js",
|
|
9
|
+
"module": "dist/esm/index.js",
|
|
10
|
+
"types": "dist/esm/index.d.ts",
|
|
11
|
+
"unpkg": "dist/plugin.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"android/src/main/",
|
|
14
|
+
"android/build.gradle",
|
|
15
|
+
"dist/",
|
|
16
|
+
"ios/Sources",
|
|
17
|
+
"ios/Tests",
|
|
18
|
+
"Package.swift",
|
|
19
|
+
"CapgoCapacitorRudderStack.podspec"
|
|
20
|
+
],
|
|
21
|
+
"author": "Martin Donadieu <martin@capgo.app>",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/Cap-go/capacitor-rudderstack.git"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/Cap-go/capacitor-rudderstack/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://capgo.app/docs/plugins/rudderstack/",
|
|
31
|
+
"keywords": [
|
|
32
|
+
"capacitor",
|
|
33
|
+
"plugin",
|
|
34
|
+
"rudderstack",
|
|
35
|
+
"analytics",
|
|
36
|
+
"tracking",
|
|
37
|
+
"identity",
|
|
38
|
+
"attribution"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"verify": "bun run verify:ios && bun run verify:android && bun run verify:web",
|
|
42
|
+
"verify:ios": "xcodebuild -scheme CapgoCapacitorRudderStack -destination generic/platform=iOS",
|
|
43
|
+
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
44
|
+
"verify:web": "bun run build",
|
|
45
|
+
"lint": "bun run eslint && bun run prettier -- --check && bun run swiftlint -- lint",
|
|
46
|
+
"fmt": "bun run eslint -- --fix && bun run prettier -- --write && bun run swiftlint -- --fix --format",
|
|
47
|
+
"eslint": "eslint . --ext .ts",
|
|
48
|
+
"prettier": "prettier-pretty-check \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
|
|
49
|
+
"swiftlint": "node-swiftlint",
|
|
50
|
+
"docgen": "docgen --api RudderStackPlugin --output-readme README.md --output-json dist/docs.json",
|
|
51
|
+
"build": "bun run clean && bun run docgen && tsc && rollup -c rollup.config.mjs",
|
|
52
|
+
"clean": "rimraf ./dist",
|
|
53
|
+
"watch": "tsc --watch",
|
|
54
|
+
"prepublishOnly": "bun run build",
|
|
55
|
+
"check:wiring": "node scripts/check-capacitor-plugin-wiring.mjs"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@capacitor/android": "^8.0.0",
|
|
59
|
+
"@capacitor/cli": "^8.0.0",
|
|
60
|
+
"@capacitor/core": "^8.0.0",
|
|
61
|
+
"@capacitor/docgen": "^0.3.1",
|
|
62
|
+
"@capacitor/ios": "^8.0.0",
|
|
63
|
+
"@ionic/eslint-config": "^0.4.0",
|
|
64
|
+
"@ionic/prettier-config": "^4.0.0",
|
|
65
|
+
"@ionic/swiftlint-config": "^2.0.0",
|
|
66
|
+
"@types/node": "^24.10.1",
|
|
67
|
+
"eslint": "^8.57.1",
|
|
68
|
+
"eslint-plugin-import": "^2.31.0",
|
|
69
|
+
"husky": "^9.1.7",
|
|
70
|
+
"prettier": "^3.6.2",
|
|
71
|
+
"prettier-pretty-check": "^0.2.0",
|
|
72
|
+
"prettier-plugin-java": "^2.7.7",
|
|
73
|
+
"rimraf": "^6.1.0",
|
|
74
|
+
"rollup": "^4.53.2",
|
|
75
|
+
"swiftlint": "^2.0.0",
|
|
76
|
+
"typescript": "^5.9.3"
|
|
77
|
+
},
|
|
78
|
+
"peerDependencies": {
|
|
79
|
+
"@capacitor/core": ">=8.0.0"
|
|
80
|
+
},
|
|
81
|
+
"prettier": "@ionic/prettier-config",
|
|
82
|
+
"swiftlint": "@ionic/swiftlint-config",
|
|
83
|
+
"eslintConfig": {
|
|
84
|
+
"extends": "@ionic/eslint-config/recommended"
|
|
85
|
+
},
|
|
86
|
+
"capacitor": {
|
|
87
|
+
"ios": {
|
|
88
|
+
"src": "ios"
|
|
89
|
+
},
|
|
90
|
+
"android": {
|
|
91
|
+
"src": "android"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|