Skip to content

Commit fcf3933

Browse files
authored
feat: add clevertap plugin (#759)
* feat: add clevertap plugin * chore: fix readme * chore: refactor, add birthday date check * chore: cleanup example * chore: add clevertap to readme * chore: refactor birthday check --------- Co-authored-by: Alan Charles <[email protected]>
1 parent 9808b08 commit fcf3933

File tree

20 files changed

+535
-7
lines changed

20 files changed

+535
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ Refer to the following table for Plugins you can use to meet your tracking needs
524524
| [AppsFlyer](https://github.com/segmentio/analytics-react-native/tree/master/packages/plugins/plugin-appsflyer) | `@segment/analytics-react-native-plugin-appsflyer`|
525525
| [Braze](https://github.com/segmentio/analytics-react-native/tree/master/packages/plugins/plugin-braze) | `@segment/analytics-react-native-plugin-braze`|
526526
| [Braze Middleware (Cloud Mode)](https://github.com/segmentio/analytics-react-native/tree/master/packages/plugins/plugin-braze) | `@segment/analytics-react-native-plugin-braze-middleware`|
527+
| [CleverTap](https://github.com/segmentio/analytics-react-native/tree/master/packages/plugins/plugin-clevertap) | `@segment/analytics-react-native-plugin-clevertap`|
527528
| [Facebook App Events](https://github.com/segmentio/analytics-react-native/tree/master/packages/plugins/plugin-facebook-app-events) | `@segment/analytics-react-native-plugin-facebook-app-events` |
528529
| [Firebase](https://github.com/segmentio/analytics-react-native/tree/master/packages/plugins/plugin-firebase) | `@segment/analytics-react-native-plugin-firebase`|
529530
| [FullStory](https://github.com/fullstorydev/segment-react-native-plugin-fullstory) | `@fullstory/segment-react-native-plugin-fullstory`|

example/ios/AnalyticsReactNativeExample/AppDelegate.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#import <React/RCTAppSetupUtils.h>
66
#import <segment_analytics_react_native-Swift.h>
77
// #import <Firebase.h>
8+
// #import <CleverTap-iOS-SDK/CleverTap.h>
9+
// #import <clevertap-react-native/CleverTapReactManager.h>
810
#if RCT_NEW_ARCH_ENABLED
911
#import <React/CoreModulesPlugins.h>
1012
#import <React/RCTCxxBridgeDelegate.h>
@@ -49,6 +51,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
4951
[self.window makeKeyAndVisible];
5052
// enable for firebase plugin
5153
// [FIRApp configure];
54+
55+
// integrate CleverTap SDK using the autoIntegrate option
56+
// [CleverTap autoIntegrate];
57+
// [[CleverTapReactManager sharedInstance] applicationDidLaunchWithOptions:launchOptions];
5258
return YES;
5359
}
5460

example/ios/AnalyticsReactNativeExample/Info.plist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>CleverTapAccountID</key>
6+
<string>UserCleverTapAccountID</string>
7+
<key>CleverTapToken</key>
8+
<string>USERCleverTapToken</string>
59
<key>CFBundleDevelopmentRegion</key>
610
<string>en</string>
711
<key>CFBundleDisplayName</key>

example/ios/Podfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ flags = get_default_flags()
3939
# Pods for Plugins
4040
pod 'segment-analytics-react-native-plugin-idfa', :path => '../../packages/plugins/plugin-idfa'
4141

42-
4342
post_install do |installer|
4443
installer.aggregate_targets.each do |aggregate_target|
4544
aggregate_target.user_project.native_targets.each do |target|

example/ios/Podfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ PODS:
298298
- React
299299
- RNGestureHandler (2.6.0):
300300
- React-Core
301-
- segment-analytics-react-native (2.11.0):
301+
- segment-analytics-react-native (2.12.0):
302302
- React-Core
303303
- sovran-react-native
304304
- segment-analytics-react-native-plugin-idfa (0.6.0):
@@ -478,11 +478,11 @@ SPEC CHECKSUMS:
478478
RNCAsyncStorage: 0c357f3156fcb16c8589ede67cc036330b6698ca
479479
RNCMaskedView: 0e1bc4bfa8365eba5fbbb71e07fbdc0555249489
480480
RNGestureHandler: 920eb17f5b1e15dae6e5ed1904045f8f90e0b11e
481-
segment-analytics-react-native: 2ba71e946824d44bea9a9001a911c3fcf84f0b16
481+
segment-analytics-react-native: f28f404167ef4e2b4f5d5decf9526180393512f4
482482
segment-analytics-react-native-plugin-idfa: c9335ec0327b8f5f35c78bbf0bf7821e9137537e
483483
sovran-react-native: fd3dc8f1a4b14acdc4ad25fc6b4ac4f52a2a2a15
484484
Yoga: 0b84a956f7393ef1f37f3bb213c516184e4a689d
485485

486-
PODFILE CHECKSUM: 5df1bd43a50322f0e6eb5d11d6ae1922ebfec385
486+
PODFILE CHECKSUM: 2ecd5be7772aafe05298cc4aa625fde6b4fcae1d
487487

488488
COCOAPODS: 1.11.3

example/src/App.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ import { AmplitudeSessionPlugin } from '@segment/analytics-react-native-plugin-a
3636
//@ts-ignore
3737
// import { AdvertisingIdPlugin } from '@segment/analytics-react-native-plugin-advertising-id';
3838

39+
//@ts-ignore
40+
// import { ClevertapPlugin } from '@segment/analytics-react-native-plugin-clevertap';
41+
3942
const segmentClient = createClient({
4043
writeKey: 'WRITE_KEY',
4144
trackAppLifecycleEvents: true,
@@ -63,6 +66,8 @@ segmentClient.add({ plugin: LoggerPlugin });
6366

6467
segmentClient.add({ plugin: new AmplitudeSessionPlugin() });
6568

69+
// segmentClient.add({ plugin: new ClevertapPlugin() });
70+
6671
// segmentClient.add({
6772
// plugin: new AdvertisingIdPlugin(),
6873
// });

packages/core/src/info.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export const libraryInfo = {
22
name: '@segment/analytics-react-native',
3-
version: '2.11.0',
3+
version: '2.12.0',
44
};

packages/plugins/plugin-clevertap/CHANGELOG.md

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Segment
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# @segment/analytics-react-native-plugin-clevertap
2+
3+
`DestinationPlugin` for [CleverTap](https://https://clevertap.com/). Wraps [`clevertap-react-native`](https://github.com/CleverTap/clevertap-react-native).
4+
5+
## Installation
6+
7+
You need to install the `@segment/analytics-react-native-plugin-clevertap` and the `clevertap-react-native` dependency.
8+
9+
Using NPM:
10+
```bash
11+
npm install --save @segment/analytics-react-native-plugin-clevertap clevertap-react-native
12+
```
13+
14+
Using Yarn:
15+
```bash
16+
yarn add @segment/analytics-react-native-plugin-clevertap clevertap-react-native
17+
```
18+
19+
Run `pod install` after the installation to autolink the Clevertap SDK.
20+
21+
See [CleverTap React Native SDK](https://github.com/CleverTap/clevertap-react-native/blob/master/docs/install.md) for more details of this dependency.
22+
## Usage
23+
24+
Follow the [instructions for adding plugins](https://github.com/segmentio/analytics-react-native#adding-plugins) on the main Analytics client:
25+
26+
In your code where you initialize the analytics client call the `.add(plugin)` method with an `ClevertapPlugin` instance:
27+
28+
```ts
29+
import { createClient } from '@segment/analytics-react-native';
30+
31+
import { ClevertapPlugin } from '@segment/analytics-react-native-plugin-clevertap';
32+
33+
const segmentClient = createClient({
34+
writeKey: 'SEGMENT_KEY'
35+
});
36+
37+
segmentClient.add({ plugin: new ClevertapPlugin() });
38+
```
39+
40+
## Support
41+
42+
Please use Github issues, Pull Requests, or feel free to reach out to our [support team](https://segment.com/help/).
43+
44+
## Integrating with Segment
45+
46+
Interested in integrating your service with us? Check out our [Partners page](https://segment.com/partners/) for more details.
47+
48+
## License
49+
```
50+
MIT License
51+
52+
Copyright (c) 2021 Segment
53+
54+
Permission is hereby granted, free of charge, to any person obtaining a copy
55+
of this software and associated documentation files (the "Software"), to deal
56+
in the Software without restriction, including without limitation the rights
57+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
58+
copies of the Software, and to permit persons to whom the Software is
59+
furnished to do so, subject to the following conditions:
60+
61+
The above copyright notice and this permission notice shall be included in all
62+
copies or substantial portions of the Software.
63+
64+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
65+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
66+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
67+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
68+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
69+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
70+
SOFTWARE.
71+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: ['module:metro-react-native-babel-preset'],
3+
};
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"name": "@segment/analytics-react-native-plugin-clevertap",
3+
"version": "0.1.0",
4+
"description": "The hassle-free way to add Segment analytics to your React-Native app.",
5+
"main": "lib/commonjs/index",
6+
"scripts": {
7+
"build": "bob build",
8+
"test": "jest",
9+
"typescript": "tsc --noEmit",
10+
"clean": "rimraf lib node_modules",
11+
"release": "semantic-release"
12+
},
13+
"keywords": [
14+
"segment",
15+
"react-native",
16+
"ios",
17+
"android"
18+
],
19+
"module": "lib/module/index",
20+
"types": "lib/typescript/src/index.d.ts",
21+
"react-native": "src/index",
22+
"source": "src/index",
23+
"files": [
24+
"src",
25+
"lib",
26+
"android",
27+
"ios",
28+
"cpp",
29+
"segment-analytics-react-native.podspec",
30+
"package.json",
31+
"!src/**/*.e2e.mock.js",
32+
"!**/__tests__",
33+
"!**/__fixtures__",
34+
"!**/__mocks__"
35+
],
36+
"repository": {
37+
"type": "git",
38+
"url": "https://github.com/segmentio/analytics-react-native.git",
39+
"directory": "packages/core"
40+
},
41+
"author": "Segment <[email protected]> (https://segment.com/)",
42+
"license": "MIT",
43+
"bugs": {
44+
"url": "https://github.com/segmentio/analytics-react-native/issues"
45+
},
46+
"homepage": "https://github.com/segmentio/analytics-react-native#readme",
47+
"peerDependencies": {
48+
"@segment/analytics-react-native": "*"
49+
},
50+
"dependencies": {
51+
"clevertap-react-native": "^1.0.0"
52+
},
53+
"devDependencies": {
54+
"@semantic-release/changelog": "^6.0.1",
55+
"@semantic-release/commit-analyzer": "^9.0.2",
56+
"@semantic-release/git": "^10.0.1",
57+
"@semantic-release/github": "^8.0.4",
58+
"@semantic-release/npm": "^9.0.1",
59+
"@semantic-release/release-notes-generator": "^10.0.3",
60+
"@types/jest": "^27.0.3",
61+
"conventional-changelog-conventionalcommits": "^5.0.0",
62+
"rimraf": "^3.0.2",
63+
"semantic-release": "^19.0.3",
64+
"semantic-release-monorepo": "^7.0.5",
65+
"ts-jest": "^27.0.7",
66+
"typescript": "^4.4.4"
67+
},
68+
"jest": {
69+
"setupFiles": [
70+
"<rootDir>/src/methods/__tests__/jest_setup.ts"
71+
]
72+
},
73+
"react-native-builder-bob": {
74+
"source": "src",
75+
"output": "lib",
76+
"targets": [
77+
"commonjs",
78+
"module",
79+
"typescript"
80+
]
81+
},
82+
"engines": {
83+
"node": ">=12"
84+
}
85+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['../../../release.config.js', 'semantic-release-monorepo'],
3+
};

0 commit comments

Comments
 (0)