Skip to content

Commit a57c67d

Browse files
author
Erin Peach
authored
Merge pull request code-dot-org#26740 from code-dot-org/log-delete-assets
Logging Asset Deletes
2 parents ce6a9bc + 3bb2d05 commit a57c67d

File tree

8 files changed

+53
-10
lines changed

8 files changed

+53
-10
lines changed

apps/src/applab/designElements/ImagePickerPropertyRow.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default class ImagePickerPropertyRow extends React.Component {
1717
initialValue: PropTypes.string.isRequired,
1818
handleChange: PropTypes.func,
1919
desc: PropTypes.node,
20+
elementId: PropTypes.string
2021
};
2122

2223
componentDidMount() {
@@ -61,7 +62,8 @@ export default class ImagePickerPropertyRow extends React.Component {
6162
// However today the `createModalDialog` function and `Dialog` component
6263
// are intertwined with `StudioApp` which is why we have this direct call.
6364
dashboard.assets.showAssetManager(this.changeImage, 'image', null, {
64-
showUnderageWarning: !getStore().getState().pageConstants.is13Plus
65+
showUnderageWarning: !getStore().getState().pageConstants.is13Plus,
66+
elementId: this.props.elementId
6567
});
6668
};
6769

apps/src/applab/designElements/button.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class ButtonProperties extends React.Component {
103103
desc={'image'}
104104
initialValue={element.getAttribute('data-canonical-image-url') || ''}
105105
handleChange={this.props.handleChange.bind(this, 'image')}
106+
elementId={elementUtils.getId(element)}
106107
/>
107108
{iconColorPicker}
108109
<BooleanPropertyRow

apps/src/applab/designElements/image.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class ImageProperties extends React.Component {
7676
desc={'image'}
7777
initialValue={element.getAttribute('data-canonical-image-url') || ''}
7878
handleChange={this.props.handleChange.bind(this, 'picture')}
79+
elementId={elementUtils.getId(element)}
7980
/>
8081
{iconColorPicker}
8182
<EnumPropertyRow

apps/src/applab/designElements/screen.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class ScreenProperties extends React.Component {
5252
desc={'image'}
5353
initialValue={element.getAttribute('data-canonical-image-url') || ''}
5454
handleChange={this.props.handleChange.bind(this, 'screen-image')}
55+
elementId={elementUtils.getId(element)}
5556
/>
5657
{iconColorPicker}
5758
<DefaultScreenButtonPropertyRow

apps/src/code-studio/assets/show.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var Dialog = require('../LegacyDialog');
1818
* @param [options.showUnderageWarning] {boolean} Warn if underage.
1919
* @param [options.useFilesApi] {boolean} Use files API instead of assets API.
2020
* @param [options.disableAudioRecording] {boolean} Do not display option to record and upload audio files
21+
* @param [options.elementId] {string} Logging Purposes: which element is the image chosen for
2122
*/
2223
module.exports = function showAssetManager(assetChosen, typeFilter, onClose, options) {
2324
options = options || {};
@@ -48,7 +49,8 @@ module.exports = function showAssetManager(assetChosen, typeFilter, onClose, opt
4849
showUnderageWarning: !!options.showUnderageWarning,
4950
projectId: dashboard.project.getCurrentId(),
5051
soundPlayer: sounds,
51-
disableAudioRecording: options.disableAudioRecording
52+
disableAudioRecording: options.disableAudioRecording,
53+
elementId: options.elementId
5254
}), codeDiv);
5355

5456
dialog.show();

apps/src/code-studio/components/AssetManager.jsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ export default class AssetManager extends React.Component {
4848
allowedExtensions: PropTypes.string,
4949
uploadsEnabled: PropTypes.bool.isRequired,
5050
useFilesApi: PropTypes.bool,
51-
//For logging upload failures
52-
projectId: PropTypes.string,
5351
soundPlayer: PropTypes.object,
5452
disableAudioRecording: PropTypes.bool,
55-
//Temp prop for logging - identifies if displayed by 'Manage Assets' flow
56-
imagePicker: PropTypes.bool
53+
54+
// For logging purposes
55+
imagePicker: PropTypes.bool, // identifies if displayed by 'Manage Assets' flow
56+
projectId: PropTypes.string,
57+
elementId: PropTypes.string
5758
};
5859

5960
constructor(props) {
@@ -143,6 +144,21 @@ export default class AssetManager extends React.Component {
143144
if (this.props.assetsChanged) {
144145
this.props.assetsChanged();
145146
}
147+
firehoseClient.putRecord(
148+
{
149+
study: 'delete-asset',
150+
study_group: this.props.assetChosen && typeof this.props.assetChosen === 'function' ? 'choose-assets' : 'manage-assets',
151+
event: 'confirm',
152+
project_id: this.props.projectId,
153+
data_json: JSON.stringify(
154+
{
155+
assetName: name,
156+
elementId: this.props.elementId
157+
}
158+
)
159+
}
160+
);
161+
146162
this.setState({
147163
assets: assetListStore.list(this.props.allowedExtensions),
148164
statusMessage: 'File "' + name + '" successfully deleted!'
@@ -223,6 +239,8 @@ export default class AssetManager extends React.Component {
223239
onDelete={this.deleteAssetRow.bind(this, asset.filename)}
224240
soundPlayer={this.props.soundPlayer}
225241
imagePicker={this.props.imagePicker}
242+
projectId={this.props.projectId}
243+
elementId={this.props.elementId}
226244
/>
227245
);
228246
}.bind(this));

apps/src/code-studio/components/AssetRow.jsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ export default class AssetRow extends React.Component {
1717
onChoose: PropTypes.func,
1818
onDelete: PropTypes.func.isRequired,
1919
soundPlayer: PropTypes.object,
20+
projectId: PropTypes.string,
2021

21-
//temporary prop to differentiate choosing images and sounds
22-
imagePicker: PropTypes.bool
22+
// For logging purposes
23+
imagePicker: PropTypes.bool, // identifies if displayed by 'Manage Assets' flow
24+
elementId: PropTypes.string
2325
};
2426

2527
state = {
@@ -32,6 +34,20 @@ export default class AssetRow extends React.Component {
3234
*/
3335
confirmDelete = () => {
3436
this.setState({action: 'confirming delete', actionText: ''});
37+
firehoseClient.putRecord(
38+
{
39+
study: 'delete-asset',
40+
study_group: this.props.onChoose && typeof this.props.onChoose === 'function' ? 'choose-assets' : 'manage-assets',
41+
event: 'initiate',
42+
project_id: this.props.projectId,
43+
data_json: JSON.stringify(
44+
{
45+
assetName: this.props.name,
46+
elementId: this.props.elementId
47+
}
48+
)
49+
}
50+
);
3551
};
3652

3753
/**

apps/src/code-studio/components/ImagePicker.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ export default class ImagePicker extends React.Component {
2323
useFilesApi: PropTypes.bool,
2424
soundPlayer: PropTypes.object,
2525
disableAudioRecording: PropTypes.bool,
26-
//For logging upload failures
27-
projectId: PropTypes.string
26+
//For logging purposes
27+
projectId: PropTypes.string,
28+
elementId: PropTypes.string
2829
};
2930

3031
state = {mode: 'files'};
@@ -93,6 +94,7 @@ export default class ImagePicker extends React.Component {
9394
soundPlayer={this.props.soundPlayer}
9495
disableAudioRecording={this.props.disableAudioRecording}
9596
imagePicker={true}
97+
elementId={this.props.elementId}
9698
/> :
9799
<IconLibrary assetChosen={this.getAssetNameWithPrefix}/>;
98100

0 commit comments

Comments
 (0)