Skip to content
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

[Draft] Best Practices Guide: Sending Data to External Destinations #694

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
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
103 changes: 103 additions & 0 deletions docs/best-practices/send-dvc-data-external-destinations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
title: Sending DevCycle Data to External Destinations
sidebar_label: Sending Data to External Destinations
sidebar_position: 11
description: How to send DevCycle Feature data to external destinations such as CDPs, analytics providers, etc.
sidebar_custom_props: { icon: carbon:data-vis-1 }
---

# Sending DevCycle Data to External Destinations

This topic explains how to send Feature and/or experimentation data to external destinations.

Some of our users prefer to use their own data warehouse and tools to analyze Feature and experiment data. Given this need, DevCycle provides ways to pipe data to any location of your choice.

In this guide, we provide code examples for the Node.js, Javascript, Android, and iOS SDKs on how to pull Experiment and Variation information from the DevCycle SDK for a given user and pass it to an example data analytics platform, such as Adobe.

While the specifics differ slightly between SDKs, the concept is largely the same. DevCycle has a method called `getAllFeatures` which provides a JSON map of the Features (Experiments) and Variations that a user received. This map can then be passed to an analytics provider in whatever format or context is desired. While the details below provide code specific to each SDK, the general documentation for the `getAllFeatures` method can be found [here](/sdk/features#getting-all-features).

The format of the `getAllFeatures` response looks like this:

```json
{
"your-cool-feature": {
"_id": "123456",
"key": "your-cool-feature",
"type": "release",
"_variation": "333345",
"variationName": "Some Variation",
"variationKey": "some-variation"
},
"an-experiment": {
"_id": "234567",
"key": "an-experiment",
"type": "experiment",
"_variation": "444123",
"variationName": "Treatment",
"variationKey": "treatment"
}
}
```
Given DevCycle may be used for experimentation, feature flagging and remote configuration, the “type” field in the response can be used to either filter or augment the data that is being sent to your chosen destination.

**Note**: The details specific to your analytics destination should be reviewed and verified by your team to ensure the accuracy and desired format of the data.


## Code Examples for Adobe


### DevCycle Code for Node.js

```javascript
const user = { user_id: '123' }
const features = devcycleClient.allFeatures(user);
const variations = {};
Object.values(features).forEach((feature) => {
variations[feature.key] = feature.variationName;
})
Analytics.trackAction("DVC_Features", variations);
```

Link to [Node.js Documentation](/sdk/server-side-sdks/node/node-usage#getting-all-features)

### DevCycle Code for Javascript

```javascript
const features = devcycleClient.allFeatures();
let variations = [];
Object.values(features).forEach((feature) => {
variations.push(`${feature.key}:${feature.variationName}`);
})
omtr.eVarNumber = variations.join(',');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats omtr?

```
Link to [Javascript Documentation](/sdk/client-side-sdks/javascript/javascript-usage#get-all-features)

### DevCycle Code for Android (Java)

```java
import com.devcycle.sdk.android.model.Feature;

HashMap<String, String> variations = new HashMap<>();
Map<String, Feature> features = devcycleClient.allFeatures();
for (Feature feature : features.values()) {
variations.put(feature.getKey(), feature.getVariationName());
}

Analytics.trackAction("DVC_Features", variations);
```
Link to [Android Documentation](/sdk/client-side-sdks/android/android-usage#java-example-3)

### DevCycle Code for iOS (Swift)

```swift
var variations: [String: String] = [:]
let features: [String: Feature] = self.devcycleClient!.allFeatures()
for featurekey in features.keys {
let variation = features[featurekey]?.variationName
variations[featurekey] = variation
}

MobileCore.track(action: "DVC_Features", data: variations)
```
Link to [iOS Documentation](/sdk/client-side-sdks/ios/ios-usage#get-all-features)

Loading