Skip to content

Commit

Permalink
Add changelog entry
Browse files Browse the repository at this point in the history
  • Loading branch information
markmur committed Jan 31, 2024
1 parent d844139 commit d22debe
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 0.2.0 - January 30, 2024

Exposes a new `pixel` event type, which enables you to consume
[Standard](https://shopify.dev/docs/api/web-pixels-api/standard-events) and
[Custom](https://shopify.dev/docs/api/web-pixels-api/emitting-data#publishing-custom-events)
Web Pixels from Checkout and relay them to your third-party analytics providers.

## 0.1.1 - January 15, 2024

Updates the README on the NPM regsitry entry page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ public CustomCheckoutEventProcessor(Context context, ReactContext reactContext)

@Override
public void onCheckoutCompleted() {
sendEvent(this.reactContext, "completed", null);
sendEvent("completed", null);
}

@Override
public void onWebPixelEvent(@NonNull PixelEvent event) {
try {
ObjectMapper mapper = new ObjectMapper();
String data = mapper.writeValueAsString(event);
sendPixelEvent(this.reactContext, data);
sendPixelEvent(data);
} catch (IOException e) {
Log.e("ShopifyCheckoutSheetKit", "Error processing pixel event", e);
e.printStackTrace();
Expand All @@ -67,21 +67,21 @@ public void onCheckoutFailed(CheckoutException checkoutError) {

error.putString("message", checkoutError.getErrorDescription());

sendEvent(this.reactContext, "error", error);
sendEvent("error", error);
}

@Override
public void onCheckoutCanceled() {
sendEvent(this.reactContext, "close", null);
sendEvent("close", null);
}

private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableNativeMap params) {
private void sendEvent(String eventName, @Nullable WritableNativeMap params) {
reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit(eventName, params);
}

private void sendPixelEvent(ReactContext reactContext, String data) {
private void sendPixelEvent(String data) {
reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit("pixel", data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,16 @@ class RCTShopifyCheckoutSheetKit: RCTEventEmitter, CheckoutDelegate {

private func getColorScheme(_ colorScheme: String) -> ShopifyCheckoutSheetKit.Configuration.ColorScheme {
switch colorScheme {
case "web_default":
return ShopifyCheckoutSheetKit.Configuration.ColorScheme.web
case "automatic":
return ShopifyCheckoutSheetKit.Configuration.ColorScheme.automatic
case "light":
return ShopifyCheckoutSheetKit.Configuration.ColorScheme.light
case "dark":
return ShopifyCheckoutSheetKit.Configuration.ColorScheme.dark
default:
return ShopifyCheckoutSheetKit.Configuration.ColorScheme.automatic
case "web_default":
return ShopifyCheckoutSheetKit.Configuration.ColorScheme.web
case "automatic":
return ShopifyCheckoutSheetKit.Configuration.ColorScheme.automatic
case "light":
return ShopifyCheckoutSheetKit.Configuration.ColorScheme.light
case "dark":
return ShopifyCheckoutSheetKit.Configuration.ColorScheme.dark
default:
return ShopifyCheckoutSheetKit.Configuration.ColorScheme.automatic
}
}

Expand All @@ -151,7 +151,7 @@ class RCTShopifyCheckoutSheetKit: RCTEventEmitter, CheckoutDelegate {

if let backgroundColorHex = iosConfig?["backgroundColor"] as? String {
ShopifyCheckoutSheetKit.configuration.backgroundColor = UIColor(hex: backgroundColorHex)
}
}
}

@objc func getConfig(_ resolve: @escaping RCTPromiseResolveBlock, reject _: @escaping RCTPromiseRejectBlock) {
Expand Down Expand Up @@ -192,7 +192,15 @@ class RCTShopifyCheckoutSheetKit: RCTEventEmitter, CheckoutDelegate {
}

private func mapToGenericEvent(standardEvent: ShopifyCheckoutSheetKit.StandardEvent) -> [String: Any] {
return encodeToJSON(from: standardEvent)
let encoded = encodeToJSON(from: standardEvent)
return [
"context": encoded["context"],
"data": encoded["data"],
"id": encoded["id"],
"name": encoded["name"],
"timestamp": encoded["timestamp"],
"type": "STANDARD"
] as [String: Any]
}

private func mapToGenericEvent(customEvent: CustomEvent) -> [String: Any] {
Expand All @@ -211,7 +219,8 @@ class RCTShopifyCheckoutSheetKit: RCTEventEmitter, CheckoutDelegate {
"customData": stringToJSON(from: event.customData),
"id": event.id,
"name": event.name,
"timestamp": event.timestamp
"timestamp": event.timestamp,
"type": "CUSTOM"
] as [String: Any]
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/@shopify/checkout-sheet-kit/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react-native",
"lib": ["esnext", "DOM"],
"lib": ["esnext"],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
Expand Down

0 comments on commit d22debe

Please sign in to comment.