Skip to content

Update master with release 3.0.0 #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 46 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
d0f9309
docs(SDK-4095) - Adds docs for changelog for github issue fixed (#266)
Anush-Shand Oct 21, 2024
81b2392
Updated plugin version to support CT IOS SDK 7.0.3
Dec 2, 2024
3ed87a0
Changed the iOS dependency version to 7.0.2
Dec 2, 2024
4d3807a
task(SDK-4198) - Updates dependencies and versions to support core v7…
Anush-Shand Dec 2, 2024
6b98bc3
Added File Vars Apis and callbacks
Dec 2, 2024
8b936c5
Refactoring File Variables logic
Dec 2, 2024
27e6ac5
Updated the iOS dependency to 7.0.3 and updated the doc
Dec 2, 2024
bad9719
task(SDK-4198) - Adds support for fileVars android
Anush-Shand Dec 2, 2024
4f1feac
Merge branch 'refs/heads/task/SDK-4198/support_corev7.0.3' into task/…
Anush-Shand Dec 2, 2024
60807f7
task(SDK-4198) - Updates version
Anush-Shand Dec 2, 2024
24b93d0
Updated clevertap_plugin file for custom templates
Dec 5, 2024
6ffc4fe
feat(SDK-4200): Adds changes for custom code templates
CTLalit Dec 5, 2024
58ec73e
Add changes for iOS custom templates
Dec 5, 2024
822c4c8
Added inApp UI for custom template present on customTemplatePresent c…
Dec 9, 2024
70c936c
feat(SDK-4200): Reverts map argument changes + revamps app
CTLalit Dec 10, 2024
2586e70
feat(SDK-4200): Uses single instance instead of a list
CTLalit Dec 10, 2024
76d5057
feat(SDK-4217): Introduces clevertap middleware + adds kotlin to project
CTLalit Dec 11, 2024
d377537
feat(SDK-4217): Plugs eventemitter methods + cleanup
CTLalit Dec 12, 2024
52f23f7
fix(GIT-275) - Fixes NPE in mapToBundle
Anush-Shand Dec 13, 2024
dc52e82
feat(SDK-4217): fixes version for core ktx + changes to plugin class
CTLalit Dec 13, 2024
9834f74
feat(SDK-4217): fixes push amp handling + event names
CTLalit Dec 13, 2024
772e3dd
feat(SDK-4217): removes buffering logic from engine attach/detach
CTLalit Dec 13, 2024
fabd497
Add condition to check for map argument
Dec 16, 2024
e256256
Merge pull request #276 from CleverTap/fix/GIT-275/npe_for_mapToBundle
CTLalit Dec 16, 2024
9a314e8
feat(SDK-4217): Flushing logic changed for buffers (#277)
CTLalit Dec 17, 2024
25ea266
Add platform check for new emission method
Dec 17, 2024
a6edf4c
Refactoring the code and code cleaning
Dec 17, 2024
fba1b8d
feat(SDK-4217): fixes pr comments and todos
CTLalit Dec 18, 2024
8f450c6
Rename .java to .kt
CTLalit Dec 18, 2024
2761aac
feat(SDK-4217): moves to kotlin file
CTLalit Dec 18, 2024
a1b4cfb
calling CleverTapPlugin instance before App Launched is called
Dec 18, 2024
15064bb
Merge pull request #272 from CleverTap/feat/SDK-4200
CTLalit Dec 18, 2024
918f099
Merge pull request #271 from CleverTap/Add_Custom_templates
CTLalit Dec 18, 2024
fc9a26e
Merge pull request #269 from CleverTap/task/SDK-4159-Add-File-Vars
CTLalit Dec 18, 2024
0e6d53c
feat(SDK-4217): Avoids posting on main thread if already on it.
CTLalit Dec 18, 2024
3261fb3
Create CustomCodeTemplates.md
kushCT Dec 19, 2024
f305926
Update CustomCodeTemplates.md
kushCT Dec 19, 2024
e5eb22a
Update CustomCodeTemplates.md
kushCT Dec 19, 2024
9dd9945
Updated Changelog
Dec 19, 2024
2245fb5
docs(SDK-4217): Fixes docs
CTLalit Dec 19, 2024
c86625c
Merge pull request #278 from CleverTap/docs/release_3.0.0
CTLalit Dec 19, 2024
1da0c86
docs(SDK-4217): Fixes docs nuances.
CTLalit Dec 19, 2024
21eb5ea
Merge branch 'develop' into task/SDK-4198/support_corev7.0.3
CTLalit Dec 19, 2024
fbd0818
Merge pull request #268 from CleverTap/task/SDK-4198/support_corev7.0.3
CTLalit Dec 19, 2024
bf4f375
docs(SDK-4217): fixes PE docs
CTLalit Dec 19, 2024
e9010f7
Merge pull request #280 from CleverTap/docs/file-vars-changes
CTLalit Dec 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
## CHANGE LOG

Version 3.0.0 *(19 December 2024)*
-------------------------------------------
**What's new**
* **[Android Platform]**
* Supports [CleverTap Android SDK v7.0.3](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md#version-703-november-29-2024).
* Adds support for custom handshake domain configuration in android manifest.

* **[iOS Platform]**
* Supports [CleverTap iOS SDK v7.0.3](https://github.com/CleverTap/clevertap-ios-sdk/blob/master/CHANGELOG.md#version-703-november-29-2024).
* Adds support for custom handshake domains.

* **[Android and iOS Platform]**
* Adds support for File Type Variables in Remote Config. Please refer to the [Remote Config Variables](https://github.com/CleverTap/clevertap-ios-sdk/blob/master/docs/Variables.md) doc to read more on how to integrate this in your app.
* Adds support for Custom Code Templates. Please refer to the [CustomCodeTemplates.md](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CustomCodeTemplates.md) doc to read more on how to integrate this in your app.
* Adds support for custom code in-app templates definitions through a json scheme.

**Bug Fixes**
* **[Android Platform]**
* Fixes [#275](https://github.com/CleverTap/clevertap-flutter/issues/275) - Fixes NPE when casting object to string for PN clicked event.

### Version 2.5.0 *(17th October 2024)*
-------------------------------------------
**What's new**
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ To get started, sign up [here](https://clevertap.com/live-product-demo/).

```yaml
dependencies:
clevertap_plugin: 2.5.0
clevertap_plugin: 3.0.0
```

- Run `flutter packages get` to install the SDK
Expand Down
65 changes: 44 additions & 21 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
plugins {
id "com.android.library"
}
group = 'com.clevertap.clevertap_plugin'
version = '3.0.0'

group 'com.clevertap.clevertap_plugin'
version '2.5.0'
buildscript {
ext.kotlin_version = "1.8.22"
repositories {
google()
mavenCentral()
}

dependencies {
classpath("com.android.tools.build:gradle:8.1.0")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
}
}

rootProject.allprojects {
repositories {
Expand All @@ -15,28 +24,42 @@ rootProject.allprojects {
}
}

allprojects {
repositories {
google()
mavenCentral()
}
}

apply plugin: "com.android.library"
apply plugin: "kotlin-android"

android {
compileSdkVersion 34
if (project.android.hasProperty("namespace")) {
namespace 'com.clevertap.clevertap_plugin'
namespace = "com.clevertap.clevertap_plugin"
}

defaultConfig {
minSdkVersion 19
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
compileSdk = 34

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
lintOptions {
disable 'InvalidPackage'

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8

sourceSets {
main.java.srcDirs += "src/main/kotlin"
test.java.srcDirs += "src/test/kotlin"
}
}

dependencies {
testImplementation 'junit:junit:4.13.2'
api 'com.clevertap.android:clevertap-android-sdk:7.0.1'
compileOnly 'androidx.fragment:fragment:1.3.6'
compileOnly 'androidx.core:core:1.9.0'
dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
testImplementation 'junit:junit:4.13.2'
api 'com.clevertap.android:clevertap-android-sdk:7.0.3'
compileOnly 'androidx.fragment:fragment:1.3.6'
compileOnly 'androidx.core:core:1.9.0'
}
}
11 changes: 0 additions & 11 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
pluginManagement {
repositories {
google()
mavenCentral()
}
}

plugins {
id("com.android.library").version("8.3.0").apply(false)
}

rootProject.name = 'clevertap_plugin'
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class CleverTapApplication extends FlutterApplication implements CTPushNo
@Override
public void onCreate() {
super.onCreate();

CleverTapAPI cleverTapAPI = CleverTapAPI.getDefaultInstance(this);
if (cleverTapAPI != null) {
cleverTapAPI.setCTPushNotificationListener(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.clevertap.clevertap_plugin

enum class CleverTapEvent(
val eventName: String,
val bufferable: Boolean = false
) {

CLEVERTAP_PROFILE_DID_INITIALIZE("CleverTapProfileDidInitialize", bufferable = true),
CLEVERTAP_PROFILE_SYNC("CleverTapProfileSync"),
CLEVERTAP_IN_APP_NOTIFICATION_DISMISSED("CleverTapInAppNotificationDismissed", bufferable = true),
CLEVERTAP_IN_APP_NOTIFICATION_BEFORE_SHOW("CleverTapInAppNotificationBeforeShow", bufferable = true),
CLEVERTAP_IN_APP_NOTIFICATION_SHOWED("CleverTapInAppNotificationShowed", bufferable = true),
CLEVERTAP_INBOX_DID_INITIALIZE("CleverTapInboxDidInitialize", bufferable = true),
CLEVERTAP_INBOX_MESSAGES_DID_UPDATE("CleverTapInboxMessagesDidUpdate"),
CLEVERTAP_ON_INBOX_BUTTON_CLICK("CleverTapInboxMessageButtonTapped"),
CLEVERTAP_ON_INBOX_MESSAGE_CLICK("CleverTapInboxMessageTapped"),
CLEVERTAP_ON_INAPP_BUTTON_CLICK("CleverTapInAppNotificationButtonTapped", bufferable = true),
CLEVERTAP_ON_DISPLAY_UNITS_LOADED("CleverTapDisplayUnitsLoaded", bufferable = true),
CLEVERTAP_FEATURE_FLAGS_DID_UPDATE("CleverTapFeatureFlagsDidUpdate", bufferable = true),
CLEVERTAP_PRODUCT_CONFIG_DID_INITIALIZE("CleverTapProductConfigDidInitialize", bufferable = true),
CLEVERTAP_PRODUCT_CONFIG_DID_FETCH("CleverTapProductConfigDidFetch"),
CLEVERTAP_PRODUCT_CONFIG_DID_ACTIVATE("CleverTapProductConfigDidActivate"),
CLEVERTAP_PUSH_NOTIFICATION_CLICKED("CleverTapPushNotificationClicked", bufferable = true),
CLEVERTAP_ON_PUSH_PERMISSION_RESPONSE("CleverTapPushPermissionResponseReceived"),
CLEVERTAP_ON_PUSH_AMP_PAYLOAD_RECEIVED("CleverTapPushAmpPayloadReceived", bufferable = true),
CLEVERTAP_ON_VARIABLES_CHANGED("CleverTapOnVariablesChanged"),
CLEVERTAP_ON_ONE_TIME_VARIABLES_CHANGED("CleverTapOnOneTimeVariablesChanged"),
CLEVERTAP_ON_VALUE_CHANGED("CleverTapOnValueChanged"),
CLEVERTAP_CUSTOM_TEMPLATE_PRESENT("CleverTapCustomTemplatePresent", bufferable = true),
CLEVERTAP_CUSTOM_FUNCTION_PRESENT("CleverTapCustomFunctionPresent", bufferable = true),
CLEVERTAP_CUSTOM_TEMPLATE_CLOSE("CleverTapCustomTemplateClose"),
CLEVERTAP_ON_FILE_VALUE_CHANGED("CleverTapOnFileValueChanged"),
CLEVERTAP_ON_VARIABLES_CHANGED_AND_NO_DOWNLOADS_PENDING("CleverTapOnVariablesChangedAndNoDownloadsPending"),
CLEVERTAP_ONCE_VARIABLES_CHANGED_AND_NO_DOWNLOADS_PENDING("CleverTapOnceVariablesChangedAndNoDownloadsPending"),
CLEVERTAP_UNKNOWN("CleverTapUnknown");

override fun toString(): String {
return eventName
}

companion object {

@JvmStatic
fun fromName(eventName: String): CleverTapEvent {
return values().find { it.eventName == eventName } ?: CLEVERTAP_UNKNOWN
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
package com.clevertap.clevertap_plugin

import android.util.Log
import com.clevertap.clevertap_plugin.CleverTapPlugin.invokeMethodOnUiThread
import java.util.LinkedList
import java.util.Queue

/**
* CleverTapEventEmitter is responsible for emitting events to the React Native JavaScript layer.
* It manages event buffers and allows events to be queued which is useful when needing to send an
* event while the ReactContext of the application is not yet initialized. Only events specified as
* [CleverTapEvent.bufferable] will be considered for buffering, all other events will be emitted
* immediately.
*/
object CleverTapEventEmitter {
private const val LOG_TAG = "CleverTapEventEmitter"

private var eventsBuffers: Map<CleverTapEvent, Buffer> = createBuffersMap(enableBuffers = true)

/**
* Enable buffering for the specified event. While enabled, all events which should be emitted
* will be added to the buffer. Only buffers for events specified as [CleverTapEvent.bufferable]
* can be enabled.
*
* @see [disableBuffer]
*/
@JvmStatic
fun enableBuffer(event: CleverTapEvent) {
eventsBuffers[event]?.enabled = true
}

/**
* Disable buffering for the specified event. This will only have effect for events specified as
* [CleverTapEvent.bufferable].
*
* @see [enableBuffer]
*/
@JvmStatic
fun disableBuffer(event: CleverTapEvent) {
eventsBuffers[event]?.enabled = false
}

/**
* Clear all the buffered events from all buffers and set whether all buffers should be enabled
* after that.
*
* @param enableBuffers enable/disable all buffers after they are cleared
*/
@JvmStatic
fun resetAllBuffers(enableBuffers: Boolean) {
eventsBuffers = createBuffersMap(enableBuffers)
Log.i(LOG_TAG, "Buffers reset and enabled: $enableBuffers")
}

/**
* Emit all currently buffered events for the specified event name.
*/
@JvmStatic
fun flushBuffer(event: CleverTapEvent) {
val buffer = eventsBuffers[event] ?: return
while (buffer.size() > 0) {
val params = buffer.remove()
sendEvent(event, params)
}
}

@JvmStatic
fun enableAll() {
eventsBuffers.forEach { pair ->
pair.value.enabled = true
}
}

@JvmStatic
fun disableAllAndFlush() {
eventsBuffers.forEach { pair ->
flushBuffer(pair.key)
pair.value.enabled = false
}
}

/**
* Emit an event with specified params. It will be buffered if buffering for the event is enabled or
* it will be send immediately otherwise.
*
* @param event The event to be emitted
* @param params Optional event parameters
*
* @see [enableBuffer]
* @see [disableBuffer]
*/
@JvmStatic
fun emit(event: CleverTapEvent, params: Any?) {
if (eventsBuffers[event]?.enabled == true) {
addToBuffer(event, params)
} else {
sendEvent(event, params)
}
}

/**
* Adds an event to the buffer for future emission.
* Events will remain in the buffer until [flushBuffer] for the same event name is called.
*
* @param event The event to be buffered.
* @param params Optional event parameters to be sent when the event is emitted.
*/
private fun addToBuffer(event: CleverTapEvent, params: Any?) {
val buffer = eventsBuffers[event] ?: return
buffer.add(params)
Log.i(LOG_TAG, "Event $event added to buffer.")
}

private fun sendEvent(
event: CleverTapEvent,
params: Any?
) {
try {
if (event == CleverTapEvent.CLEVERTAP_UNKNOWN) {
Log.i(LOG_TAG, "Not Sending event since its unknown")
return
}
invokeMethodOnUiThread(
EventNameMapper.fromCleverTapEvent(event),
params
)
Log.i(LOG_TAG, "Sending event $event")
} catch (t: Throwable) {
Log.e(LOG_TAG, "Sending event $event failed", t)
}
}

private fun createBuffersMap(enableBuffers: Boolean) =
CleverTapEvent.values().filter { it.bufferable }.associateWith {
Buffer(enabled = enableBuffers)
}
}

private class Buffer(var enabled: Boolean) {
private val items: Queue<Any?> by lazy(LazyThreadSafetyMode.SYNCHRONIZED) { LinkedList() }

fun add(item: Any?) = items.add(item)
fun remove(): Any? = items.remove()
fun size(): Int = items.size
}
Loading