Skip to content

Commit

Permalink
Release version 2.0.0 - Merge pull request #114 from klaviyo/rel/2.0.0
Browse files Browse the repository at this point in the history
Release version 2.0.0
  • Loading branch information
evan-masseau authored Jan 24, 2024
2 parents e01d661 + e8ed86f commit 0ccc9e2
Show file tree
Hide file tree
Showing 31 changed files with 467 additions and 362 deletions.
35 changes: 18 additions & 17 deletions .github/workflows/android-feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,26 @@ jobs:
# A job for running our tests
test:
name: Run Unit Tests

# The type of runner that the job will run on
runs-on: ubuntu-22.04

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so the job can access it

- uses: actions/checkout@v4
# Sets up a JDK on the job so that we can run Java code
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
java-package: jdk

# Call Gradle to run the unit tests
- name: Unit Tests
run: ./gradlew test --stacktrace --no-daemon
# Checks-out your repository under $GITHUB_WORKSPACE, so the job can access it
- uses: actions/checkout@v4

# Sets up a JDK on the job so that we can run Java code
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
java-package: jdk

# Call Gradle to run the unit tests
- name: Unit Tests
run: ./gradlew test --stacktrace --no-daemon

# Another job for asserting our linting rules
ktlint:
name: Run ktlintCheck
Expand All @@ -41,11 +42,11 @@ jobs:
- uses: actions/checkout@v4

# Sets up a JDK on the job so that we can run Java code
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'
java-package: jdk

# Call Gradle to run ktlint check
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/android-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
- uses: actions/checkout@v4

# Sets up a JDK on the job so that we can run Java code
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'
java-package: jdk

# Call Gradle to run the unit tests
Expand All @@ -43,11 +43,11 @@ jobs:
- uses: actions/checkout@v4

# Sets up a JDK on the job so that we can run Java code
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'
java-package: jdk

# Call Gradle to run ktlint check
Expand All @@ -64,11 +64,11 @@ jobs:
- uses: actions/checkout@v4

# Sets up a JDK on the job so that we can run Java code
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'
java-package: jdk

# Call Gradle to build our debug AAR
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name: Mark stale issues and pull requests

on:
schedule:
- cron: '30 1 * * *'
- cron: '0 16 * * *'

jobs:
stale:
Expand Down
34 changes: 32 additions & 2 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,39 @@
This document provides guidance on how to migrate from the old version of the SDK to a newer version.
It will be updated as new versions are released including deprecations or breaking changes.

## 1.4.0 Deprecations
*`EventType` is deprecated in favor of `EventMetric`.* `EventType` will be removed in the next major release.
## 2.0.0 Breaking Changes
#### Removed `EventType` in favor of `EventMetric`.
The reasoning is explained below, see [1.4.0 Deprecations](#140-deprecations) for details and code samples.
Additionally, for consistent naming conventions `Event.type` has been renamed to `Event.metric`,
including all argument labels in `Event` constructors. For example:

```kotlin
//Old code: Will no longer compile
val event = Event(type="Custom Event")

//New code: Corrected argument label
val event = Event(metric="Custom Event")
```

#### Corrected `Event.value` from `String` to `Double`
In version 1.x, `Event.value` was incorrectly typed as `String`. Klaviyo's API expects `value` to be numeric, and
while the backend will implicitly convert a numeric string to a number, it is better to be explicit about the type.
```kotlin
// Old code: accepted strings (though still would be converted to a number on the server)
val event = Event("Test").setValue("1.0")
// Or
val event = Event("Test")
event.value = "1.0"

//New code: type has been corrected to Double
val event = Event("Test").setValue(1.0)
// Or
val event = Event("Test")
event.value = 1.0
```

## 1.4.0 Deprecations
#### Deprecated `EventType` in favor of `EventMetric`
It was recently discovered that the Android SDK was using legacy event names for some common events,
like "Viewed Product" and some events that are associated with server actions, like "Ordered Product."
As a result, if your account used these standard events, they were being logged with names like "$viewed_product"
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ send them timely push notifications via FCM.
```kotlin
// build.gradle.kts
dependencies {
implementation("com.github.klaviyo.klaviyo-android-sdk:analytics:1.4.1")
implementation("com.github.klaviyo.klaviyo-android-sdk:push-fcm:1.4.1")
implementation("com.github.klaviyo.klaviyo-android-sdk:analytics:2.0.0")
implementation("com.github.klaviyo.klaviyo-android-sdk:push-fcm:2.0.0")
}
```
```groovy
// build.gradle
dependencies {
implementation "com.github.klaviyo.klaviyo-android-sdk:analytics:1.4.1"
implementation "com.github.klaviyo.klaviyo-android-sdk:push-fcm:1.4.1"
implementation "com.github.klaviyo.klaviyo-android-sdk:analytics:2.0.0"
implementation "com.github.klaviyo.klaviyo-android-sdk:push-fcm:2.0.0"
}
```

Expand Down Expand Up @@ -141,8 +141,8 @@ Additional event properties can be specified as part of `EventModel`

```kotlin
val event = Event(EventMetric.VIEWED_PRODUCT)
.setProperty(EventKey.VALUE, "10")
.setProperty(EventKey.CUSTOM("custom_key"), "value")
.setProperty(EventKey.CUSTOM("Product"), "Coffee Mug")
.setValue(10.0)
Klaviyo.createEvent(event)
```

Expand Down
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ buildscript {
// NOTE: These are dependencies for the build script itself
// Do not place your application dependencies here;
// they belong in the individual module build.gradle files
classpath "com.android.tools.build:gradle:${gradleBuildToolsVersion}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${gradleKotlinVersion}"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:${dokkaVersion}"
classpath "org.jlleitschuh.gradle:ktlint-gradle:${gradleKtlintVersion}"
classpath Android.tools.build.gradlePlugin
classpath Kotlin.gradlePlugin
classpath "org.jetbrains.dokka:dokka-gradle-plugin:_"
classpath "org.jlleitschuh.gradle:ktlint-gradle:_"
}
}

Expand All @@ -38,11 +38,11 @@ allprojects {
}
}

task clean(type: Delete) {
delete rootProject.buildDir
tasks.register('clean', Delete) {
delete rootProject.layout.buildDirectory
}

dokkaHtmlMultiModule {
outputDirectory = file("${buildDir}/../docs")
outputDirectory = file("${layout.buildDirectory}/../docs")
includes.from("README.md")
}
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<!-- Redirect to latest version -->
<meta HTTP-EQUIV="REFRESH" content="0; url=./1.4.1/index.html">
<meta HTTP-EQUIV="REFRESH" content="0; url=./2.0.0/index.html">
4 changes: 0 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

# Opt-in to upcoming AGP feature to prevent building components for all variants automatically
# Instead, we'll explicitly specify which variants to build components for
android.disableAutomaticComponentCreation=true

# URL to Klaviyo server
klaviyoServerUrl=https://a.klaviyo.com

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 4 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Thu Nov 10 17:20:37 EST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 0ccc9e2

Please sign in to comment.